Commit 835ea7bb authored by JiangWanZhi's avatar JiangWanZhi

更新点击组的表现

parent a23aca39
...@@ -421,4 +421,4 @@ MonoBehaviour: ...@@ -421,4 +421,4 @@ MonoBehaviour:
idName: 12 idName: 12
useColor: {r: 0.9612525, g: 0.9811321, b: 0, a: 1} useColor: {r: 0.9612525, g: 0.9811321, b: 0, a: 1}
index: 0 index: 0
selectLang: 0.25 selectLang: 0.05
...@@ -2971,11 +2971,11 @@ MonoBehaviour: ...@@ -2971,11 +2971,11 @@ MonoBehaviour:
m_Bottom: 0 m_Bottom: 0
m_ChildAlignment: 0 m_ChildAlignment: 0
m_StartCorner: 0 m_StartCorner: 0
m_StartAxis: 0 m_StartAxis: 1
m_CellSize: {x: 120, y: 120} m_CellSize: {x: 120, y: 120}
m_Spacing: {x: 0, y: 0} m_Spacing: {x: 0, y: 0}
m_Constraint: 0 m_Constraint: 2
m_ConstraintCount: 2 m_ConstraintCount: 1
--- !u!1 &6769909122946713645 --- !u!1 &6769909122946713645
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
......
...@@ -11,6 +11,7 @@ using UnityEngine.Networking; ...@@ -11,6 +11,7 @@ using UnityEngine.Networking;
using UnityEngine.SceneManagement; using UnityEngine.SceneManagement;
using UnityEngine.UI; using UnityEngine.UI;
using static gameSceneLogic; using static gameSceneLogic;
using System.Linq;
class DebugNetHotData class DebugNetHotData
{ {
...@@ -37,6 +38,8 @@ public class gameSceneLogic : MonoBehaviour, IEventHandler ...@@ -37,6 +38,8 @@ public class gameSceneLogic : MonoBehaviour, IEventHandler
public float tempValue1 = 130f; public float tempValue1 = 130f;
public float tempValue2 = 130f; public float tempValue2 = 130f;
private float tempValue3 = 5f; private float tempValue3 = 5f;
private int DestoryIndex = -1;
Dictionary<string, EventChildItemBack> childEventHandlers = new Dictionary<string, EventChildItemBack>(); Dictionary<string, EventChildItemBack> childEventHandlers = new Dictionary<string, EventChildItemBack>();
void onEvent(string name, EventChildItemBack func) void onEvent(string name, EventChildItemBack func)
{ {
...@@ -65,7 +68,7 @@ public class gameSceneLogic : MonoBehaviour, IEventHandler ...@@ -65,7 +68,7 @@ public class gameSceneLogic : MonoBehaviour, IEventHandler
onEvent("gameViewOnInitEnd",this.onEvent_gameViewOnInitEnd_Handler); //游戏图片初始化完成 onEvent("gameViewOnInitEnd",this.onEvent_gameViewOnInitEnd_Handler); //游戏图片初始化完成
onEvent("gameClickPos",this.onEvent_gameClickPos_Handler); //灰色的点击回掉 onEvent("gameClickPos",this.onEvent_gameClickPos_Handler); //灰色的点击回掉
onEvent("inGameLoadingBarEnd",this.onEvent_inGameLoadingBarEnd_Handler); //进入游戏的进度条加载完成 onEvent("inGameLoadingBarEnd",this.onEvent_inGameLoadingBarEnd_Handler); //进入游戏的进度条加载完成
onEvent("showAreaEventOk", onSelectAreaEvent); //当前组的都涂完了 onEvent("showAreaEventOk", onSelectAreaEvent); //当前组的涂了一个
onEvent("initViewShowData", onInitViewShowDataEvent); //初始化数据完成 onEvent("initViewShowData", onInitViewShowDataEvent); //初始化数据完成
onEvent("changeGameUserProgress", onChangeGameUserProgressEvent); //整体进度改变 onEvent("changeGameUserProgress", onChangeGameUserProgressEvent); //整体进度改变
onEvent("tipShowPosMaxScale", onTipShowPosMaxScaleEvent); // 点提示,当前组随机一个没涂的位置放大 onEvent("tipShowPosMaxScale", onTipShowPosMaxScaleEvent); // 点提示,当前组随机一个没涂的位置放大
...@@ -142,6 +145,10 @@ public class gameSceneLogic : MonoBehaviour, IEventHandler ...@@ -142,6 +145,10 @@ public class gameSceneLogic : MonoBehaviour, IEventHandler
void Update() void Update()
{ {
ActionManages.update(); ActionManages.update();
if (Input.GetKeyDown(KeyCode.A))
{
SubAGorpItem(1);
}
} }
//创建列表item的时候回调并设置、初始化和刷新 //创建列表item的时候回调并设置、初始化和刷新
...@@ -155,6 +162,7 @@ public class gameSceneLogic : MonoBehaviour, IEventHandler ...@@ -155,6 +162,7 @@ public class gameSceneLogic : MonoBehaviour, IEventHandler
item.IsSelect = isSelect; item.IsSelect = isSelect;
item.index = idx; item.index = idx;
item.IdName = (group.gid).ToString(); item.IdName = (group.gid).ToString();
item.GID = group.gid;
item.UseColor = group.rgb; item.UseColor = group.rgb;
item.NowProgress = group.Jindu; item.NowProgress = group.Jindu;
...@@ -187,30 +195,49 @@ public class gameSceneLogic : MonoBehaviour, IEventHandler ...@@ -187,30 +195,49 @@ public class gameSceneLogic : MonoBehaviour, IEventHandler
//切换组的id //切换组的id
private void onEvent_switchGameAreaGroupId_Handler(List<UnityEngine.Object> uobjects, List<System.Object> objects) private void onEvent_switchGameAreaGroupId_Handler(List<UnityEngine.Object> uobjects, List<System.Object> objects)
{ {
Vector3 vector3;
Quaternion quaternion;
var gridViewList = areaGroupList.GetComponent<gameSceneAreaGroupHandler>(); var gridViewList = areaGroupList.GetComponent<gameSceneAreaGroupHandler>();
colorItem item = null; colorItem item = null;
var maingameView = gameShowView.GetComponent<mainGameView>();
if (DestoryIndex != -1)
{
oldindex = 0;
if (DestoryIndex == groupInfos.Count)
{
nowidx = DestoryIndex - 1;
}
else
{
nowidx = (int)objects[0] - 1;
}
DestoryIndex = -1;
var ite = groupInfos[nowidx].gid;
item = gridViewList.GetObjByGID(ite).GetComponent<colorItem>();
item.IsSelect = true;
item.switchPlayAnimation();
maingameView.switchShowAreaGroup((short)ite, (int id, bool isOk) => {
if (isOk)
{
transform.Find("areaGroupList/tipSelectGroup").gameObject.SetActive(false);
}
});
return;
}
if (nowidx >= 0) if (nowidx >= 0)
{ {
item = gridViewList.getObjectById(nowidx).GetComponent<colorItem>(); item = gridViewList.getObjectById(nowidx).GetComponent<colorItem>();
item.IsSelect = false; item.IsSelect = false;
item.transform.GetLocalPositionAndRotation(out vector3, out quaternion);
//vector3.y = vector3.y - 14;
item.transform.SetLocalPositionAndRotation(vector3, quaternion);
item.updateOneUI(); item.updateOneUI();
item.switchPlayAnimation(); item.switchPlayAnimation();
} }
var maingameView = gameShowView.GetComponent<mainGameView>();
int idx = (int)objects[0]; int idx = (int)objects[0];
oldindex = nowidx; oldindex = nowidx;
nowidx = idx; nowidx = idx;
var nowSelectGroupId = groupInfos[idx].gid; var nowSelectGroupId = groupInfos[idx].gid;
item = gridViewList.getObjectById(idx).GetComponent<colorItem>(); item = gridViewList.getObjectById(idx).GetComponent<colorItem>();
item.IsSelect = true; item.IsSelect = true;
item.transform.GetLocalPositionAndRotation(out vector3, out quaternion);
//vector3.y = vector3.y + 14;
item.transform.SetLocalPositionAndRotation(vector3, quaternion);
item.switchPlayAnimation(); item.switchPlayAnimation();
maingameView.switchShowAreaGroup((short)nowSelectGroupId, (int id, bool isOk) => { maingameView.switchShowAreaGroup((short)nowSelectGroupId, (int id, bool isOk) => {
if (isOk) if (isOk)
...@@ -262,18 +289,6 @@ public class gameSceneLogic : MonoBehaviour, IEventHandler ...@@ -262,18 +289,6 @@ public class gameSceneLogic : MonoBehaviour, IEventHandler
} }
IEnumerator DelayToRefreshGrid()
{
yield return new WaitForSeconds(0.6f);
if (areaGroupList.transform.GetComponent<ScrollRect>().content.GetComponent<GridLayoutGroup>().enabled)
{
LayoutRebuilder.ForceRebuildLayoutImmediate(areaGroupList.transform.GetComponent<ScrollRect>().content.GetComponent<RectTransform>());
}
else
{
areaGroupList.transform.GetComponent<ScrollRect>().content.GetComponent<GridLayoutGroup>().enabled = true;
}
}
//游戏图片初始化完成 //游戏图片初始化完成
private void onEvent_gameViewOnInitEnd_Handler(List<UnityEngine.Object> uobjects, List<System.Object> objects) private void onEvent_gameViewOnInitEnd_Handler(List<UnityEngine.Object> uobjects, List<System.Object> objects)
{ {
...@@ -639,7 +654,7 @@ public class gameSceneLogic : MonoBehaviour, IEventHandler ...@@ -639,7 +654,7 @@ public class gameSceneLogic : MonoBehaviour, IEventHandler
// }, 10); // }, 10);
} }
//当前组的都涂完了 //当前组的色块涂一个就会回调过来
void onSelectAreaEvent(List<UnityEngine.Object> uobjects, List<System.Object> objects) void onSelectAreaEvent(List<UnityEngine.Object> uobjects, List<System.Object> objects)
{ {
gameAreaItem gameArea = (gameAreaItem)objects[0]; gameAreaItem gameArea = (gameAreaItem)objects[0];
...@@ -647,44 +662,52 @@ public class gameSceneLogic : MonoBehaviour, IEventHandler ...@@ -647,44 +662,52 @@ public class gameSceneLogic : MonoBehaviour, IEventHandler
short y = (short)objects[2]; short y = (short)objects[2];
short nowAidByGid = gameArea.gid; short nowAidByGid = gameArea.gid;
if (groupInfos.Count.Equals(0) || nowidx < 0) return; if (groupInfos.Count.Equals(0) || nowidx < 0) return;
if (groupInfos[nowidx].gid.Equals(nowAidByGid) == false) return;
var groupdinfo = groupInfos.FirstOrDefault(a => a.gid == nowAidByGid);
if (groupdinfo == null)
return;
if (groupInfos != null) if (groupInfos != null)
{ {
int operId = -1;
for (int i = 0; i < groupInfos.Count; i++) {
if (groupInfos[i].gid.Equals(nowAidByGid))
{
operId = i;
break;
}
}
if (operId.Equals(-1)) return;
var gridViewList = areaGroupList.GetComponent<gameSceneAreaGroupHandler>(); var gridViewList = areaGroupList.GetComponent<gameSceneAreaGroupHandler>();
colorItem item = null; colorItem item = null;
groupInfos[operId].show++; groupdinfo.show++;
if (groupInfos[operId].show.Equals(groupInfos[operId].size))//直接移除 if (groupdinfo.show.Equals(groupdinfo.size))//直接移除,这里涂了的区域和总的区域一样了
{ {
if(operId == groupInfos.Count - 1) if (groupdinfo.gid == nowAidByGid)
{ {
groupInfos.RemoveAt(operId); groupInfos.Remove(groupdinfo);
operId--; }
}else
groupInfos.RemoveAt(operId);
//切换组 //切换组
if (autoSwitchGroup == false) nowidx = -1; //if (autoSwitchGroup == false) nowidx = -1;
Vector2 size = gridViewList.getCellSize(); //Vector2 size = gridViewList.getCellSize();
gradViewBack gradView = (GameObject gobject, int idx, ListViewBackTypeEnum lvbType) => { //gradViewBack gradView = (GameObject gobject, int idx, ListViewBackTypeEnum lvbType) =>
if(lvbType == ListViewBackTypeEnum.create) //{
{ // if (lvbType == ListViewBackTypeEnum.create)
var gagi = gobject.GetComponent<colorItem>(); // {
if (gagi == null) { // var gagi = gobject.GetComponent<colorItem>();
Debug.Log("gagi == null"); // if (gagi == null)
} // {
gagi.resetSize(size.x, size.y); // Debug.Log("gagi == null");
} // }
this.onUpdateGroupGridHandler(gobject, idx, lvbType, groupInfos[idx],false); // gagi.resetSize(size.x, size.y);
}; // }
gridViewList.setDataNoGrid(groupInfos.Count, tempValue1, tempValue2, tempValue3, gradView,false); // this.onUpdateGroupGridHandler(gobject, idx, lvbType, groupInfos[idx], false);
//};
//gridViewList.setDataNoGrid(groupInfos.Count, tempValue1, tempValue2, tempValue3, gradView, false);
if (groupInfos.Count <= 1)
{
Debug.LogError($"没有组了,涂完了");
}
else
{
SubAGorpItem(nowidx);
}
//gridViewList.setData(groupInfos.Count, gradView,false); //gridViewList.setData(groupInfos.Count, gradView,false);
//震动 //震动
if (vibration) if (vibration)
...@@ -704,11 +727,64 @@ public class gameSceneLogic : MonoBehaviour, IEventHandler ...@@ -704,11 +727,64 @@ public class gameSceneLogic : MonoBehaviour, IEventHandler
} }
else else
{ {
item = gridViewList.getObjectById(nowidx).GetComponent<colorItem>(); //item = gridViewList.getObjectById(nowidx).GetComponent<colorItem>();
item.NowProgress = groupInfos[nowidx].Jindu; item = gridViewList.GetObjByGID(nowAidByGid).GetComponent<colorItem>();
var gdata = groupInfos.FirstOrDefault(a => a.gid == nowAidByGid);
item.NowProgress = gdata.Jindu;
}
}
}
private void SubAGorpItem(int index) //去掉一个组的item的动画效果
{
ScrollRect Rect = areaGroupList.transform.GetComponent<ScrollRect>();
Transform item = Rect.content.GetChild(index);
DestoryIndex = index;
item.DOScale(Vector3.zero, 0.5f).onComplete = () =>
{
Destroy(item.gameObject);
if (Rect.content.childCount - 1 > index)
{
Rect.content.sizeDelta = new Vector2(Rect.content.sizeDelta.x - 120, Rect.content.sizeDelta.y);
}
for (int i = 0; i < Rect.content.childCount; i++)
{
if (i > index)
{
Rect.content.GetChild(i).GetComponent<colorItem>().index = i - 1;
Rect.content.GetChild(i).name = Rect.content.GetChild(i).name.Replace($"{i}", $"{i - 1}");
}
} }
};
if (Rect.content.childCount - 1 == index && Rect.content.localPosition.x < -120) //最右边的那个
{
Rect.content.DOLocalMoveX(Rect.content.localPosition.x + 120, 0.5f).onComplete = () => { Rect.content.sizeDelta = new Vector2(Rect.content.sizeDelta.x - 120, Rect.content.sizeDelta.y); };
}
//else if (-Rect.content.localPosition.x > Rect.content.sizeDelta.x - 120)
//{
// Rect.content.DOLocalMoveX(Rect.content.localPosition.x - 120, 0.5f);
//}
else
{
for (int i = 0; i < Rect.content.childCount; i++)
{
if (i > index)
{
Rect.content.GetChild(i).DOLocalMoveX(Rect.content.GetChild(i).localPosition.x - 120, 0.6f);
}
}
}
if (index < Rect.content.childCount - 1)
Rect.content.GetChild(index + 1).GetComponent<colorItem>().onClickAreaGroup();
else if (index > 0)
{
Rect.content.GetChild(index - 1).GetComponent<colorItem>().onClickAreaGroup();
} }
} }
public void onRemoveGroupByGidEvent(List<UnityEngine.Object> uobjects, List<System.Object> objects) public void onRemoveGroupByGidEvent(List<UnityEngine.Object> uobjects, List<System.Object> objects)
{ {
short gid = (short)objects[0]; short gid = (short)objects[0];
......
using ICSharpCode.SharpZipLib;
using System; using System;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using Unity.VisualScripting; using Unity.VisualScripting;
using UnityEngine; using UnityEngine;
using UnityEngine.UI; using UnityEngine.UI;
using static UnityEngine.Rendering.DebugUI.Table; using static UnityEngine.Rendering.DebugUI.Table;
using Debug = UnityEngine.Debug;
public class gridView : MonoBehaviour public class gridView : MonoBehaviour
{ {
...@@ -70,6 +73,19 @@ public class gridView : MonoBehaviour ...@@ -70,6 +73,19 @@ public class gridView : MonoBehaviour
} }
return transfromitem.gameObject; return transfromitem.gameObject;
} }
//根据组的ID获取列表对应的物体
public Transform GetObjByGID(int Gid)
{
Transform parent = transform.GetComponent<ScrollRect>().content;
for (int i = 0; i < parent.childCount; i++)
{
var item = parent.GetChild(i).GetComponent<colorItem>();
if (item.GID == Gid)
return item.transform;
}
return null;
}
virtual public Vector2 getOffset() virtual public Vector2 getOffset()
{ {
var gameObjectContext = GetComponent<ScrollRect>(); var gameObjectContext = GetComponent<ScrollRect>();
...@@ -170,9 +186,8 @@ public class gridView : MonoBehaviour ...@@ -170,9 +186,8 @@ public class gridView : MonoBehaviour
{ {
w = width - w; w = width - w;
} }
rectTransform.sizeDelta = new Vector2(w,rectTransform.sizeDelta.y); rectTransform.sizeDelta = new Vector2(w, rectTransform.sizeDelta.y);
} }
Vector3 vector3 = new Vector3();
utilsTools.setGDataByKey("listViewTempCellSize", new Vector2(gridLayout.cellSize.x, gridLayout.cellSize.y)); utilsTools.setGDataByKey("listViewTempCellSize", new Vector2(gridLayout.cellSize.x, gridLayout.cellSize.y));
for (int i = 0; i < size; i++) for (int i = 0; i < size; i++)
{ {
...@@ -285,7 +300,7 @@ public class gridView : MonoBehaviour ...@@ -285,7 +300,7 @@ public class gridView : MonoBehaviour
startY = 0 - h / 2 + heightItem / 2 - (heightItem / 2 + interval / 2); startY = 0 - h / 2 + heightItem / 2 - (heightItem / 2 + interval / 2);
vector3.x = 0 - rectTransform.sizeDelta.x / 2 - offset1; vector3.x = 0 - rectTransform.sizeDelta.x / 2 - offset1;
float spacingLen =interval * (size - 1); float spacingLen =interval * (size - 1);
float height = spacingLen + coutPixel; float height = coutPixel;
if (height > h) if (height > h)
{ {
h = height; h = height;
...@@ -298,7 +313,7 @@ public class gridView : MonoBehaviour ...@@ -298,7 +313,7 @@ public class gridView : MonoBehaviour
vector3.y = 0 - rectTransform.sizeDelta.y / 2 - offset1;//0 - rectTransform.sizeDelta.y / 2 - offset1; vector3.y = 0 - rectTransform.sizeDelta.y / 2 - offset1;//0 - rectTransform.sizeDelta.y / 2 - offset1;
startX = 0 - w / 2 + widthItem / 2 - (widthItem / 2 + interval / 2); startX = 0 - w / 2 + widthItem / 2 - (widthItem / 2 + interval / 2);
float spacingLen = interval * (size - 1); float spacingLen = interval * (size - 1);
float width = spacingLen + coutPixel; float width = coutPixel;
if (width > w) if (width > w)
{ {
w = width - w; w = width - w;
......
...@@ -19,25 +19,33 @@ public class colorItem : MonoBehaviour ...@@ -19,25 +19,33 @@ public class colorItem : MonoBehaviour
private Color useColor = new Color(); private Color useColor = new Color();
public int index = 0; public int index = 0;
public float selectLang = 0.05f; public float selectLang = 0.05f;
private int gID;
public int GID //组ID
{
get { return gID; }
set { gID = value; }
}
private gameGroupEffect effectImg = null; private gameGroupEffect effectImg = null;
private Vector3 normalScale = Vector3.one; private Vector3 normalScale = Vector3.one;
private List<Vector2> initScaleSize = new List<Vector2>(); private List<Vector2> initScaleSize = new List<Vector2>();
private float offset = 0; private float offset = 0;
private Vector3 LocalPos_Root;//记录实例化出来后在本地的原始坐标 private Vector3 LocalPos_Root;//记录实例化出来后在本地的原始坐标
void initMember() void initMember()
{ {
if(effectImg == null) if (effectImg == null)
{ {
Vector2 listViewTempCellSize = utilsTools.getGDataByKey<Vector2>("listViewTempCellSize", Vector2.zero); Vector2 listViewTempCellSize = utilsTools.getGDataByKey<Vector2>("listViewTempCellSize", Vector2.zero);
Vector2 listViewContextCellSize = utilsTools.getGDataByKey<Vector2>("listViewContextCellSize", Vector2.zero); Vector2 listViewContextCellSize = utilsTools.getGDataByKey<Vector2>("listViewContextCellSize", Vector2.zero);
offset = (listViewContextCellSize.y - listViewTempCellSize.y)/2f; offset = (listViewContextCellSize.y - listViewTempCellSize.y) / 2f;
effectImg = transform.Find("circle").GetComponent<gameGroupEffect>(); effectImg = transform.Find("circle").GetComponent<gameGroupEffect>();
normalScale = transform.localScale * 0.85f; normalScale = transform.localScale * 0.85f;
transform.localScale = normalScale; transform.localScale = normalScale;
} }
transform.localScale = Vector3.one * 0.8f;
} }
public bool IsSelect public bool IsSelect
{ {
...@@ -149,7 +157,8 @@ public class colorItem : MonoBehaviour ...@@ -149,7 +157,8 @@ public class colorItem : MonoBehaviour
} }
nowProgress = value; nowProgress = value;
bool isend = this.isFinish(); bool isend = this.isFinish();
effectImg.Height = 1.0f - nowProgress; //effectImg.Height = 1.0f - nowProgress;
effectImg.Height = nowProgress;
transform.Find("idname").gameObject.SetActive(!isend); transform.Find("idname").gameObject.SetActive(!isend);
if (isend) if (isend)
{ {
......
...@@ -784,7 +784,7 @@ PlayerSettings: ...@@ -784,7 +784,7 @@ PlayerSettings:
embeddedLinuxEnableGamepadInput: 1 embeddedLinuxEnableGamepadInput: 1
hmiLogStartupTiming: 0 hmiLogStartupTiming: 0
hmiCpuConfiguration: hmiCpuConfiguration:
apiCompatibilityLevel: 6 apiCompatibilityLevel: 3
activeInputHandler: 0 activeInputHandler: 0
windowsGamepadBackendHint: 0 windowsGamepadBackendHint: 0
cloudProjectId: cloudProjectId:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment