Commit 73f1d334 authored by JiangWanZhi's avatar JiangWanZhi

更新长按选中组的表现

parent 42e43354
......@@ -124,6 +124,7 @@ public class MainData : MonoBehaviour
{
return;
}
curGroupId = id;
List<int> list = new List<int>();
List<RoomGroupsData> l = json.roomGroupsData;
......@@ -152,6 +153,7 @@ public class MainData : MonoBehaviour
{
GameMgr.Ins.giMgr.Create(this, dic[list[i]], list[i]);
}
EventDispatcher.Dispatch(EventName.Event.Event_ChoiseGroupByPic, curGroupId);
}
public void OnLongPressPos(Vector2 v)
......
......@@ -84,7 +84,7 @@ public class gameSceneLogic : MonoBehaviour, IEventHandler
onEvent(EventName.Event.Event_GroupIsLoadOver, onGroupIsLoadOver); //组的成员加载完成,就是组列表下的item
transform.Find("ingameLoad/loadImg").gameObject.SetActive(false);
//gameScenUser
transform.Find("areaGroupList/groupListBg").gameObject.SetActive(false);
//transform.Find("areaGroupList/groupListBg").gameObject.SetActive(false);
transform.Find("areaGroupList/gameProgress/gameProgressText").gameObject.SetActive(false);
transform.Find("areaGroupList/gameProgress").gameObject.SetActive(false);
transform.Find("gameEndOperBase").gameObject.SetActive(false);
......@@ -314,7 +314,7 @@ public class gameSceneLogic : MonoBehaviour, IEventHandler
return;
}
areaGroupList.SetActive(true);
transform.Find("areaGroupList/groupListBg").gameObject.SetActive(true);
//transform.Find("areaGroupList/groupListBg").gameObject.SetActive(true);
if (autoSwitchGroup == false) nowidx = -1;
var cellSize = gridViewList.getCellSize();
gradViewBack gradView = (GameObject gobject, int idx, ListViewBackTypeEnum lvbType) => {
......
......@@ -45,24 +45,51 @@ public class GroupListManager : MonoBehaviour
EventDispatcher.RegisterEvent(EventName.Event.Event_ChoiseGroupByPic, Event_ChoiseGroupByPic, flag);
}
public int idd=5;
private void Update()
{
if (Input.GetKeyDown(KeyCode.A))
{
EventDispatcher.Dispatch(EventName.Event.Event_ChoiseGroupByPic, idd);
}
}
//private void Update()
//{
// if (Input.GetKeyDown(KeyCode.A)) //后面还要用上的,先不删
// {
// var item = AllItem[AllItem.Count - 1];
// if (item != null)
// {
// RemoveAGroup(item);
// }
// }
// if (Input.GetKeyDown(KeyCode.S))
// {
// var item = AllItem[AllItem.Count - 2];
// if (item != null)
// {
// RemoveAGroup(item);
// }
// }
//}
private void Event_ChoiseGroupByPic(object[] values) //图片区域长按选择一个组
{
int Gid = (int)values[0];
var item = AllItem.FirstOrDefault((a) => a.GID == Gid);
float childsize = item.GetComponent<RectTransform>().sizeDelta.x;
if (item != null)
{
float targetpos = childsize * item.index - scrollview.flexibleWidth;
//Content.transform.DOLocalMoveX();
float childsize = item.GetComponent<RectTransform>().sizeDelta.x;
float targetpos = childsize * item.index - scrollview.transform.GetComponent<RectTransform>().sizeDelta.x / 2f + childsize / 2f;//让选中组在中间
if (targetpos > 0)
{
Content.transform.DOLocalMoveX(-targetpos, 0.5f);
}
else
{
Content.transform.DOLocalMoveX(0, 0.5f);
}
var oldselect = AllItem.FirstOrDefault((a) => a.IsSelect == true);
if (oldselect != null)
{
oldselect.IsSelect = false;
oldselect.switchPlayAnimation();
}
item.IsSelect = true;
item.switchPlayAnimation();
}
}
......@@ -86,24 +113,52 @@ public class GroupListManager : MonoBehaviour
}
}
private void RemoveAGroup(colorItem item)
private void RemoveAGroup(colorItem removeitem)
{
AllItem.Remove(item);
AllItem.Remove(removeitem);
item.transform.DOScale(Vector3.zero, 0.3f).onComplete = () =>
removeitem.transform.DOScale(Vector3.zero, 0.3f).onComplete = () =>
{
item.gameObject.SetActive(false);
removeitem.gameObject.SetActive(false);
};
//var nowselect= AllItem.FirstOrDefault(()=>)
int NextItemIndex = 0;
float childsize = removeitem.transform.GetComponent<RectTransform>().sizeDelta.x;
if (removeitem.index < AllItem.Count)
{
NextItemIndex = removeitem.index + 1;
}
else
{
NextItemIndex = AllItem.Count - 1;
for (int i = 0; i < AllItem.Count; i++)
{
var ite = AllItem[i];
ite.transform.DOLocalMoveX(ite.transform.localPosition.x + childsize, 0.3f);
if (ite.index == NextItemIndex)
{
ite.IsSelect = true;
ite.switchPlayAnimation();
}
}
return;
}
for (int i = 0; i < AllItem.Count; i++)
{
var ite = AllItem[i];
if (ite.index > item.index)
if (ite.index > removeitem.index)
{
ite.transform.DOLocalMoveX(ite.transform.localPosition.x - childsize, 0.3f);
if (ite.index == NextItemIndex)
{
ite.IsSelect = true;
ite.switchPlayAnimation();
}
ite.index--;
ite.transform.DOLocalMoveX(ite.transform.localPosition.x - item.transform.GetComponent<RectTransform>().rect.x, 0.3f);
}
}
}
......@@ -166,8 +221,9 @@ public class GroupListManager : MonoBehaviour
IEnumerator Delay()
{
foreach (var item in AllItem)
for (int i = 0; i < AllItem.Count; i++)
{
var item = AllItem[i];
yield return new WaitForSeconds(0.05f);
item.SetLocalRootPos();
item.PlayInitAni();
......
......@@ -99,14 +99,13 @@ public class colorItem : MonoBehaviour, IPointerDownHandler, IPointerUpHandler
{
transform.DOScale(Vector3.one* SelectAniScale, 0.2f).SetEase(Ease.OutSine).onComplete = () =>
{
CanPlayAniFlag = true;
transform.DOScale(Vector3.one * SelectScale, 0.1f);
};
}
else
{
transform.DOScale(Vector3.one * NotSelectScale, 0.2f).SetEase(Ease.OutSine).onComplete = () => { CanPlayAniFlag = false; };
transform.DOScale(Vector3.one * NotSelectScale, 0.2f).SetEase(Ease.OutSine);
}
}
......
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