Commit 009ec99f authored by JiangWanZhi's avatar JiangWanZhi

一些UI的适配和组的列表调整

parent f7558b48
......@@ -36,7 +36,7 @@ RectTransform:
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 120, y: 120}
m_SizeDelta: {x: 125, y: 125}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &637148015308226340
CanvasRenderer:
......
This diff is collapsed.
......@@ -27,8 +27,19 @@ public class gameSceneAreaGroupHandler : gridView
{
RectTransform rectTransform = transform.parent.Find("bg").GetComponent<RectTransform>();
utilsTools.DisplaySize = new Vector2(rectTransform.rect.width,rectTransform.rect.height);
}
public void SetChild_ListPosData()
{
var content = transform.GetComponent<ScrollRect>().content;
content.GetComponent<GridLayoutGroup>().enabled = false;
for (int i = 0; i < content.childCount; i++)
{
content.GetChild(i).GetComponent<colorItem>().SetLocalRootPos();
}
}
// Update is called once per frame
void Update(){
}
......
......@@ -70,16 +70,17 @@ public class gameSceneLogic : MonoBehaviour, IEventHandler
onEvent("gamePlayerEndHandler", onGamePlayerEndHandlerEvent); //整个大图都涂完了
onEvent("closeGameScene", onCloseGameSceneEvent); //关游戏
onEvent("removeGroupByGid", onRemoveGroupByGidEvent); //自动涂gid不一致会调过来
onEvent("GroupIsLoadOver", onGroupIsLoadOver); //组的成员加载完成
transform.Find("ingameLoad/loadImg").gameObject.SetActive(false);
//gameScenUser
var gridViewList = areaGroupList.GetComponent<gameSceneAreaGroupHandler>();
gridViewList.gameObject.SetActive(false);
transform.Find("groupListBg").gameObject.SetActive(false);
transform.Find("gameProgressText").gameObject.SetActive(false);
transform.Find("gameProgress/gameProgressText").gameObject.SetActive(false);
transform.Find("gameProgress").gameObject.SetActive(false);
transform.Find("gameEndOperBase").gameObject.SetActive(false);
transform.Find("gameEndOperBase").GetComponent<gameEndLogic>().initMember();
transform.Find("tipSelectGroup").gameObject.SetActive(false);
transform.Find("areaGroupList/tipSelectGroup").gameObject.SetActive(false);
transform.Find("top").gameObject.SetActive(false);
utilsTools.setGDataByKey("PhoneOffsetValue", 50);
utilsTools.addTimer_Sec(gameObject, "loopGetHot", (String name) =>
......@@ -91,11 +92,21 @@ public class gameSceneLogic : MonoBehaviour, IEventHandler
addHotParams<int>("TUSE_PhoneOffsetValue", "PhoneOffsetValue", int.TryParse);
return true;
}, 3, 0);
utilsTools.resetGameObjectTreeSize(gameObject, (String path) =>
//utilsTools.resetGameObjectTreeSize(gameObject, (String path) =>
//{
// if (path.IndexOf("/top/") > 0) return 1;
// return 0;
//});
}
private void onGroupIsLoadOver(List<UnityEngine.Object> uobjects, List<object> objects)
{
if (path.IndexOf("/top/") > 0) return 1;
return 0;
});
StartCoroutine(TestDelay());
}
IEnumerator TestDelay()
{
yield return new WaitForSeconds(0.5f);
areaGroupList.GetComponent<gameSceneAreaGroupHandler>().SetChild_ListPosData();
}
void addHotParams<T>(string netKey,string localKey, StringOutTValue<T> back, NotifyBoolParam notifyBoolParam = null)
......@@ -183,7 +194,7 @@ public class gameSceneLogic : MonoBehaviour, IEventHandler
item = gridViewList.getObjectById(nowidx).GetComponent<colorItem>();
item.IsSelect = false;
item.transform.GetLocalPositionAndRotation(out vector3, out quaternion);
vector3.y = vector3.y - 14;
//vector3.y = vector3.y - 14;
item.transform.SetLocalPositionAndRotation(vector3, quaternion);
item.updateOneUI();
item.switchPlayAnimation();
......@@ -195,15 +206,27 @@ public class gameSceneLogic : MonoBehaviour, IEventHandler
item = gridViewList.getObjectById(idx).GetComponent<colorItem>();
item.IsSelect = true;
item.transform.GetLocalPositionAndRotation(out vector3, out quaternion);
vector3.y = vector3.y + 14;
//vector3.y = vector3.y + 14;
item.transform.SetLocalPositionAndRotation(vector3, quaternion);
item.switchPlayAnimation();
maingameView.switchShowAreaGroup((short)nowSelectGroupId, (int id, bool isOk) => {
if (isOk)
{
transform.Find("tipSelectGroup").gameObject.SetActive(false);
transform.Find("areaGroupList/tipSelectGroup").gameObject.SetActive(false);
}
});
Transform item_obj;
for (int i = 0; i < areaGroupList.transform.GetComponent<ScrollRect>().content.childCount; i++)
{
if (i == nowidx)
continue;
item_obj = areaGroupList.transform.GetComponent<ScrollRect>().content.GetChild(i);
item_obj.GetComponent<colorItem>().ChangeLocalPos_Select(i < nowidx, nowidx, item.transform.localPosition.x);
}
}
//游戏图片初始化完成
private void onEvent_gameViewOnInitEnd_Handler(List<UnityEngine.Object> uobjects, List<System.Object> objects)
......@@ -249,13 +272,15 @@ public class gameSceneLogic : MonoBehaviour, IEventHandler
});
}
//RectTransform rectTransform1 = gridViewList.GetComponent<RectTransform>();
RectTransform rectTransform2 = transform.Find("tipSelectGroup").GetComponent<RectTransform>();
RectTransform rectTransform2 = transform.Find("areaGroupList/tipSelectGroup").GetComponent<RectTransform>();
if (autoSwitchGroup == false)
{
rectTransform2.gameObject.SetActive(true);
maingameView.GetComponent<mainGameScaleMove>().setCheckInput();
utilsTools.sendEventObjectParams("inGameLoadingValue", 100f, true);
}
}
private bool phoneClickByPos(ref mainGameView mainview, short x, short y, short faulTolerant, bool isFirst)
{
......@@ -335,7 +360,7 @@ public class gameSceneLogic : MonoBehaviour, IEventHandler
short y = (short)objects[1];
if(nowidx < 0)
{
transform.Find("tipSelectGroup").gameObject.SetActive(true);
transform.Find("areaGroupList/tipSelectGroup").gameObject.SetActive(true);
return;
}
var maingameView = gameShowView.GetComponent<mainGameView>();
......@@ -357,7 +382,7 @@ public class gameSceneLogic : MonoBehaviour, IEventHandler
transform.Find("ingameLoad").gameObject.SetActive(false);
transform.Find("top").gameObject.SetActive(true);
utilsTools.setGDataByKey("loadingEnd", utilsTools.getTotalMillisecond());
RectTransform transform1 = transform.Find("gameProgressText").GetComponent<RectTransform>();
RectTransform transform1 = transform.Find("gameProgress/gameProgressText").GetComponent<RectTransform>();
transform1.gameObject.SetActive(true);
transform1 = transform.Find("gameProgress").GetComponent<RectTransform>();
transform1.gameObject.SetActive(true);
......@@ -418,7 +443,7 @@ public class gameSceneLogic : MonoBehaviour, IEventHandler
Sprite sprite = Sprite.Create(texture2d, new Rect(0, 0, texture2d.width, texture2d.height), new Vector2(0.5f, 0.5f));
image.sprite = sprite;
image.color = new Color(1,1,1,1);
autoSwitchGroup = Boolean.Parse(utilsTools.getGDataByKey<string>("auto_switch", autoSwitchGroup.ToString()));
autoSwitchGroup = true;//Boolean.Parse(utilsTools.getGDataByKey<string>("auto_switch", autoSwitchGroup.ToString()));
if (autoSwitchGroup == false) nowidx = -1;
vibration = Boolean.Parse(utilsTools.getGDataByKey<string>("vibration", vibration.ToString()));
this.handlerLoadingPosition(image);
......@@ -533,7 +558,7 @@ public class gameSceneLogic : MonoBehaviour, IEventHandler
void onChangeGameUserProgressEvent(List<UnityEngine.Object> uobjects,List<System.Object> objects) {
int pro = (int)objects[0];
transform.Find("ingameLoad").gameObject.SetActive(false);
TextMeshProUGUI textMeshPro = transform.Find("gameProgressText").GetComponent<TextMeshProUGUI>();
TextMeshProUGUI textMeshPro = transform.Find("gameProgress/gameProgressText").GetComponent<TextMeshProUGUI>();
textMeshPro.text = pro.ToString() + "%";
UnityEngine.UI.Slider slider = transform.Find("gameProgress").GetComponent<UnityEngine.UI.Slider>();
slider.value = pro;
......@@ -575,7 +600,8 @@ public class gameSceneLogic : MonoBehaviour, IEventHandler
short x = (short)objects[1];
short y = (short)objects[2];
short nowAidByGid = gameArea.gid;
if (nowAidByGid != nowidx) return;
if (groupInfos.Count.Equals(0) || nowidx < 0) return;
if (groupInfos[nowidx].gid.Equals(nowAidByGid) == false) return;
if (groupInfos != null)
{
int operId = -1;
......@@ -691,6 +717,8 @@ public class gameSceneLogic : MonoBehaviour, IEventHandler
Debug.Log(tempJsondata);
}
gameShowView.GetComponent<mainGameView>().onClear();
int index = utilsTools.getGDataByKey<int>("testIdx", 0);
utilsTools.setGDataByKey("testIdx", ++index);
SceneManager.LoadScene("Scenes/MainGame");
return false;
}, 40);
......
This diff is collapsed.
......@@ -5,6 +5,7 @@ using System.Runtime.CompilerServices;
using Unity.VisualScripting;
using UnityEngine;
using UnityEngine.UI;
using static UnityEngine.Rendering.DebugUI.Table;
public class gridView : MonoBehaviour
{
......@@ -213,19 +214,35 @@ public class gridView : MonoBehaviour
childTransform.SetParent(null);
GameObject.Destroy(childTransform.gameObject);
}
//if (transform.name== "areaGroupList")
//{
// StartCoroutine(TestDelay());
//}
}
IEnumerator TestDelay()
{
yield return new WaitForSeconds(0.5f);
var content = transform.GetComponent<ScrollRect>().content;
content.GetComponent<GridLayoutGroup>().gameObject.SetActive(false);
for (int i = 0; i < content.childCount; i++)
{
content.GetChild(i).GetComponent<colorItem>().SetLocalRootPos();
}
}
//只支持一个预制体
virtual public void setDataNoGrid(int size,float widthItem,float heightItem,float interval,gradViewBack back, bool useVec = true, GetGradViewInfo getGradViewInfo = null,float offset1 = 0.0f)
{
Vector2 shipei = new Vector2 (widthItem,heightItem);
utilsTools.DeviceAdaptationSize(ref shipei);
widthItem = shipei.x;
heightItem = shipei.y;
shipei.x = interval;
shipei.y = offset1;
utilsTools.DeviceAdaptationSize(ref shipei);
interval = shipei.x;
offset1 = shipei.y;
//Vector2 shipei = new Vector2 (widthItem,heightItem);
//utilsTools.DeviceAdaptationSize(ref shipei);
//widthItem = shipei.x;
//heightItem = shipei.y;
//shipei.x = interval;
//shipei.y = offset1;
//utilsTools.DeviceAdaptationSize(ref shipei);
//interval = shipei.x;
//offset1 = shipei.y;
if (perfabPaths.Count == 0)
{
perfabPaths.Add(perfabPath);
......@@ -367,5 +384,6 @@ public class gridView : MonoBehaviour
childTransform.SetParent(null);
GameObject.Destroy(childTransform.gameObject);
}
utilsTools.sendEventObjectParams("GroupIsLoadOver", null);
}
}
......@@ -469,6 +469,10 @@ public class mainGameView : MonoBehaviour //大图的处理、具体的玩法
for (int i = 0; i < gameidJsondata.roomDatas.Count; i++)
{
var item = gameidJsondata.roomDatas[i];
if (item.IsValid() == false)
{
continue;
}
if (digitMatrix.Data[item.px, item.py] >= 20)
{
item.tempExKey = "idFlg_" + item.gid.ToString() + "_"+item.id.ToString();
......@@ -1103,43 +1107,43 @@ public class mainGameView : MonoBehaviour //大图的处理、具体的玩法
{
baseUpdate();
if (Input.mouseScrollDelta.y < 0) //滚轮向前滚动
{
var scal = new Vector3(transform.localScale.x - Input.mouseScrollDelta.y, transform.localScale.y - Input.mouseScrollDelta.y, 0);
if (scal.x > 5)
scal = Vector3.one * 5;
transform.localScale = scal;
}
if (Input.mouseScrollDelta.y > 0) //滚轮向后滚动
{
var scal = new Vector3(transform.localScale.x + Input.mouseScrollDelta.y, transform.localScale.y + Input.mouseScrollDelta.y, 0);
if (scal.x < 1)
scal = Vector3.one;
transform.localScale = scal;
}
//if (Input.mouseScrollDelta.y < 0) //滚轮向前滚动
//{
// var scal = new Vector3(transform.localScale.x - Input.mouseScrollDelta.y, transform.localScale.y - Input.mouseScrollDelta.y, 0);
// if (scal.x > 5)
// scal = Vector3.one * 5;
// transform.localScale = scal;
//}
//if (Input.mouseScrollDelta.y > 0) //滚轮向后滚动
//{
// var scal = new Vector3(transform.localScale.x + Input.mouseScrollDelta.y, transform.localScale.y + Input.mouseScrollDelta.y, 0);
// if (scal.x < 1)
// scal = Vector3.one;
// transform.localScale = scal;
//}
if (Input.GetMouseButton(0)) //暂时先这样实现编辑器里的鼠标拖动
{
if (flag)
{
mouse_oldpos = mouse_nowpos;
mouse_nowpos = Input.mousePosition;
//if (Input.GetMouseButton(0)) //暂时先这样实现编辑器里的鼠标拖动
//{
// if (flag)
// {
// mouse_oldpos = mouse_nowpos;
// mouse_nowpos = Input.mousePosition;
var pos_x = mouse_nowpos.x - mouse_oldpos.x;
var pos_y=mouse_nowpos.y- mouse_oldpos.y;
// var pos_x = mouse_nowpos.x - mouse_oldpos.x;
// var pos_y=mouse_nowpos.y- mouse_oldpos.y;
transform.localPosition = new Vector3(transform.localPosition.x + pos_x, transform.localPosition.y + pos_y, 0);
// transform.localPosition = new Vector3(transform.localPosition.x + pos_x, transform.localPosition.y + pos_y, 0);
}
else
{
mouse_oldpos = Input.mousePosition;
}
mouse_nowpos = Input.mousePosition;
flag = true;
// }
// else
// {
// mouse_oldpos = Input.mousePosition;
// }
// mouse_nowpos = Input.mousePosition;
// flag = true;
}
//}
if (Input.GetMouseButtonUp(0))
{
flag = false;
......
using DG.Tweening;
using System;
using System.Collections;
using System.Collections.Generic;
......@@ -23,6 +24,8 @@ public class colorItem : MonoBehaviour
private List<Vector2> initScaleSize = new List<Vector2>();
private float offset = 0;
private Vector3 LocalPos_Root;//记录实例化出来后在本地的原始坐标
void initMember()
{
if(effectImg == null)
......@@ -34,6 +37,7 @@ public class colorItem : MonoBehaviour
normalScale = transform.localScale * 0.85f;
transform.localScale = normalScale;
}
transform.localScale = Vector3.one * 0.8f;
}
public bool IsSelect
{
......@@ -58,31 +62,39 @@ public class colorItem : MonoBehaviour
if (transform == null) return;
RectTransform rectTransform = (RectTransform)transform;
float x = transform.localPosition.x;
//if (isSelect)
//{
// transform.localPosition = new Vector2(x, 0 - (transform.localScale.y * rectTransform.rect.height) / 2 - offset);
// transform.localScale = normalScale;
// ActionManages.addMoveByScale(gameObject, normalScale * 1.2f, 0.25f);
//}
//else
//{
// transform.localScale = normalScale * 1.2f;
// transform.localPosition = new Vector2(x, 0 - (transform.localScale.y * rectTransform.rect.height) / 2 - offset);
// ActionManages.addMoveByScale(gameObject, normalScale, 0.25f);
//}
if (isSelect)
{
transform.localPosition = new Vector2(x, 0 - (transform.localScale.y * rectTransform.rect.height) / 2 - offset);
transform.localScale = normalScale;
ActionManages.addMoveByScale(gameObject, normalScale * 1.2f, 0.25f);
transform.DOScale(Vector3.one * 0.9f, 0.5f);
}
else
{
transform.localScale = normalScale * 1.2f;
transform.localPosition = new Vector2(x, 0 - (transform.localScale.y * rectTransform.rect.height) / 2 - offset);
ActionManages.addMoveByScale(gameObject, normalScale, 0.25f);
transform.DOScale(Vector3.one * 0.8f, 0.5f);
}
ActionManages.addCallBackByLen(gameObject, 1000, 0.25f, (float _) =>
{
//transform.localPosition = new Vector2(x, 0 - (transform.localScale.y * rectTransform.rect.height) / 2 - offset);
rectTransform.anchoredPosition = new Vector2(rectTransform.anchoredPosition.x, 0);
}, (GameObject gobject, int id) =>
{
//float a = transform.localScale.y * rectTransform.rect.height;
//transform.localPosition = new Vector2(x, 0 - (transform.localScale.y * rectTransform.rect.height) / 2 - offset);
rectTransform.anchoredPosition = new Vector2(rectTransform.anchoredPosition.x, 0);
});
//ActionManages.addCallBackByLen(gameObject, 1000, 0.25f, (float _) =>
//{
// //transform.localPosition = new Vector2(x, 0 - (transform.localScale.y * rectTransform.rect.height) / 2 - offset);
// rectTransform.anchoredPosition = new Vector2(rectTransform.anchoredPosition.x, 0);
//}, (GameObject gobject, int id) =>
//{
// //float a = transform.localScale.y * rectTransform.rect.height;
// //transform.localPosition = new Vector2(x, 0 - (transform.localScale.y * rectTransform.rect.height) / 2 - offset);
// rectTransform.anchoredPosition = new Vector2(rectTransform.anchoredPosition.x, 0);
//});
}
public void switchPlayAnimation1()
{
......@@ -204,7 +216,6 @@ public class colorItem : MonoBehaviour
// Start is called before the first frame update
void Start()
{
Debug.LogError($"Test{transform.name}");
initMember();
//IsSelect = isSelect;
//IdName = idName;
......@@ -236,4 +247,23 @@ public class colorItem : MonoBehaviour
public void resetSize(float x,float y)
{
}
public void SetLocalRootPos() //保存一下本地的原始坐标
{
LocalPos_Root = transform.localPosition;
}
public void ChangeLocalPos_Select(bool left,int clickindex,float clickpos) //当点击组的时候,其它往外面偏移一段
{
if (left) //左边
{
transform.DOLocalMoveX(clickpos - 120 * (clickindex - index) - 20, 0.5f);
//transform.DOLocalMoveX(LocalPos_Root.x - 10, 0.5f);
}
else
{
transform.DOLocalMoveX(clickpos + 120 * (index - clickindex) + 20, 0.5f);
//transform.DOLocalMoveX(LocalPos_Root.x + 10, 0.5f);
}
}
}
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