|
@@ -3,23 +3,47 @@ using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine;
|
|
using UI.ActivityHuaRongDao;
|
|
using UI.ActivityHuaRongDao;
|
|
using FairyGUI;
|
|
using FairyGUI;
|
|
|
|
+using System.Threading.Tasks;
|
|
|
|
+using System.Threading;
|
|
|
|
+using System;
|
|
|
|
|
|
namespace GFGGame
|
|
namespace GFGGame
|
|
{
|
|
{
|
|
public class ActivityHuaRongDaoView : BaseWindow
|
|
public class ActivityHuaRongDaoView : BaseWindow
|
|
{
|
|
{
|
|
private UI_ActivityHuaRongDaoUI _ui;
|
|
private UI_ActivityHuaRongDaoUI _ui;
|
|
|
|
+
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// 格子类
|
|
|
|
+ /// </summary>
|
|
public class Grid
|
|
public class Grid
|
|
{
|
|
{
|
|
- public Vector2 pos;
|
|
|
|
|
|
+ public Vector2 pos; // UI坐标
|
|
public int num;
|
|
public int num;
|
|
}
|
|
}
|
|
|
|
|
|
- private Grid[,] _gridArr;
|
|
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// 格子的行列信息
|
|
|
|
+ /// </summary>
|
|
|
|
+ public class GridInfo
|
|
|
|
+ {
|
|
|
|
+ public int col;
|
|
|
|
+ public int row;
|
|
|
|
+ public int num;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private int _activityID;
|
|
|
|
+ // 行/列 格子数
|
|
private readonly int _gridNum = 3;
|
|
private readonly int _gridNum = 3;
|
|
- private List<GObject> _items;
|
|
|
|
private bool _gameStart;
|
|
private bool _gameStart;
|
|
- private HuarongRoadGame cfg;
|
|
|
|
|
|
+
|
|
|
|
+ private Grid[,] _gridArr;
|
|
|
|
+ private List<GObject> _items;
|
|
|
|
+ private HuarongRoadGame _cfg;
|
|
|
|
+ // 异步函数的取消控制
|
|
|
|
+ private CancellationTokenSource _cancellationTokenSource;
|
|
|
|
+ // 胜利后自动补齐的格子
|
|
|
|
+ private GObject _blankItem;
|
|
|
|
|
|
public override void Dispose()
|
|
public override void Dispose()
|
|
{
|
|
{
|
|
@@ -38,15 +62,26 @@ namespace GFGGame
|
|
packageName = UI_ActivityHuaRongDaoUI.PACKAGE_NAME;
|
|
packageName = UI_ActivityHuaRongDaoUI.PACKAGE_NAME;
|
|
_ui = UI_ActivityHuaRongDaoUI.Create();
|
|
_ui = UI_ActivityHuaRongDaoUI.Create();
|
|
viewCom = _ui.target;
|
|
viewCom = _ui.target;
|
|
- viewCom.Center();
|
|
|
|
|
|
+ isfullScreen = true;
|
|
|
|
+ _ui.m_loaBg.url = ResPathUtil.GetBgImgPath("gf_pjxq_bj");
|
|
isReturnView = true;
|
|
isReturnView = true;
|
|
- modal = true;
|
|
|
|
|
|
|
|
_ui.m_item.target.visible = false;
|
|
_ui.m_item.target.visible = false;
|
|
_ui.m_btnBack.onClick.Add(OnBtnBackClick);
|
|
_ui.m_btnBack.onClick.Add(OnBtnBackClick);
|
|
|
|
+ _ui.m_state.onChanged.Add(OnChangeLookOriginState);
|
|
|
|
+ _ui.m_btnRefresh.onClick.Add(OnClickBtnRefresh);
|
|
|
|
|
|
InitGridInfo();
|
|
InitGridInfo();
|
|
CreateItems();
|
|
CreateItems();
|
|
|
|
+ // 初始化空白处格子实体
|
|
|
|
+ if (_blankItem == null)
|
|
|
|
+ {
|
|
|
|
+ _blankItem = UIPackage.CreateObject("ActivityHuaRongDao", "item");
|
|
|
|
+ _ui.target.AddChild(_blankItem);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ _ui.m_maskTouch.onTouchBegin.Add(TouchBegin);
|
|
|
|
+ _ui.m_maskTouch.onTouchEnd.Add(TouchEnd);
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
@@ -54,18 +89,19 @@ namespace GFGGame
|
|
{
|
|
{
|
|
base.OnShown();
|
|
base.OnShown();
|
|
|
|
|
|
- cfg = (HuarongRoadGame)viewData;
|
|
|
|
- SetGridInfo();
|
|
|
|
- InitItems();
|
|
|
|
- _gameStart = false;
|
|
|
|
- ResetCountdown();
|
|
|
|
- Countdown(null);
|
|
|
|
- Timers.inst.Add(1, 0, Countdown);
|
|
|
|
|
|
+ object[] arr = viewData as object[];
|
|
|
|
+ _cfg = (HuarongRoadGame)arr[0];
|
|
|
|
+ _activityID = (int)arr[1];
|
|
|
|
+
|
|
|
|
+ RefreshData();
|
|
|
|
+ _cancellationTokenSource = new CancellationTokenSource();
|
|
|
|
+ Task task = StartAnimation(_cancellationTokenSource.Token);
|
|
}
|
|
}
|
|
|
|
|
|
protected override void OnHide()
|
|
protected override void OnHide()
|
|
{
|
|
{
|
|
base.OnHide();
|
|
base.OnHide();
|
|
|
|
+ StopMyAsyncFunction();
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
@@ -86,14 +122,10 @@ namespace GFGGame
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
- private void SetGridInfo()
|
|
|
|
|
|
+ private void SetGridInfo(List<int> numList)
|
|
{
|
|
{
|
|
//List<int> numList = GetRandomArr(1, 8);
|
|
//List<int> numList = GetRandomArr(1, 8);
|
|
- List<int> numList = GetArrByConfigStep(cfg.step);
|
|
|
|
- while (CheckListCorrect(numList))
|
|
|
|
- {
|
|
|
|
- numList = GetArrByConfigStep(cfg.step);
|
|
|
|
- }
|
|
|
|
|
|
+
|
|
Vector2 originPos = _ui.m_item.target.position;
|
|
Vector2 originPos = _ui.m_item.target.position;
|
|
|
|
|
|
for (int i = 0; i < _gridNum; i++)
|
|
for (int i = 0; i < _gridNum; i++)
|
|
@@ -123,32 +155,16 @@ namespace GFGGame
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
|
|
|
|
- /// <summary>
|
|
|
|
- /// 随机排序 min~max 连续的数字
|
|
|
|
- /// </summary>
|
|
|
|
- /// <param name="min"></param>
|
|
|
|
- /// <param name="max"></param>
|
|
|
|
- /// <returns></returns>
|
|
|
|
- private List<int> GetRandomArr(int min, int max)
|
|
|
|
|
|
+ private List<int> CreateIncreaseArr()
|
|
{
|
|
{
|
|
List<int> list = new List<int>();
|
|
List<int> list = new List<int>();
|
|
- for (int i = min; i <= max; i++)
|
|
|
|
- {
|
|
|
|
- list.Add(i);
|
|
|
|
- }
|
|
|
|
|
|
|
|
- System.Random r = new System.Random();
|
|
|
|
- for (int i = 0; i < list.Count; i++)
|
|
|
|
|
|
+ list.Add(0);
|
|
|
|
+ for (int i = 1; i <= 8; i++)
|
|
{
|
|
{
|
|
- int index = r.Next(list.Count);
|
|
|
|
- int temp = list[index];
|
|
|
|
- list[index] = list[i];
|
|
|
|
- list[i] = temp;
|
|
|
|
|
|
+ list.Add(i);
|
|
}
|
|
}
|
|
|
|
|
|
- // 最后一个是空的
|
|
|
|
- list.Add(0);
|
|
|
|
-
|
|
|
|
return list;
|
|
return list;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -159,13 +175,7 @@ namespace GFGGame
|
|
/// <returns></returns>
|
|
/// <returns></returns>
|
|
private List<int> GetArrByConfigStep(int configStep)
|
|
private List<int> GetArrByConfigStep(int configStep)
|
|
{
|
|
{
|
|
- List<int> list = new List<int>();
|
|
|
|
-
|
|
|
|
- list.Add(0);
|
|
|
|
- for (int i = 1; i <= 8; i++)
|
|
|
|
- {
|
|
|
|
- list.Add(i);
|
|
|
|
- }
|
|
|
|
|
|
+ List<int> list = CreateIncreaseArr();
|
|
|
|
|
|
int num = 0;
|
|
int num = 0;
|
|
Vector2 zeroPos = new Vector2(0, 0);
|
|
Vector2 zeroPos = new Vector2(0, 0);
|
|
@@ -173,7 +183,7 @@ namespace GFGGame
|
|
Vector2 lastPos = zeroPos;
|
|
Vector2 lastPos = zeroPos;
|
|
while (num < configStep)
|
|
while (num < configStep)
|
|
{
|
|
{
|
|
- int n = Random.Range(0, 4);
|
|
|
|
|
|
+ int n = UnityEngine.Random.Range(0, 4);
|
|
Vector2 tempPos = zeroPos + dirArr[n];
|
|
Vector2 tempPos = zeroPos + dirArr[n];
|
|
if (tempPos != lastPos && tempPos.x >= 0 && tempPos.y >= 0 && tempPos.x < _gridNum && tempPos.y < _gridNum)
|
|
if (tempPos != lastPos && tempPos.x >= 0 && tempPos.y >= 0 && tempPos.x < _gridNum && tempPos.y < _gridNum)
|
|
{
|
|
{
|
|
@@ -204,7 +214,8 @@ namespace GFGGame
|
|
_items[itemIndex].position = _gridArr[i, j].pos;
|
|
_items[itemIndex].position = _gridArr[i, j].pos;
|
|
UI_item item = UI_item.Proxy(_items[itemIndex]);
|
|
UI_item item = UI_item.Proxy(_items[itemIndex]);
|
|
item.m_index.text = _gridArr[i, j].num.ToString();
|
|
item.m_index.text = _gridArr[i, j].num.ToString();
|
|
- item.m_icon.url = string.Format("ui://ActivityHuaRongDao/hrd_1-{0}", _gridArr[i, j].num + 1);
|
|
|
|
|
|
+ int groupID = _cfg.resArr[0];
|
|
|
|
+ item.m_icon.url = GetPicRes(HuarongRoadCfgArray.Instance.GetCfgsByid(groupID)[_gridArr[i, j].num].resName);
|
|
_items[itemIndex].data = _gridArr[i, j].num;
|
|
_items[itemIndex].data = _gridArr[i, j].num;
|
|
UI_item.ProxyEnd();
|
|
UI_item.ProxyEnd();
|
|
++itemIndex;
|
|
++itemIndex;
|
|
@@ -221,102 +232,138 @@ namespace GFGGame
|
|
{
|
|
{
|
|
GObject gObject = UIPackage.CreateObject("ActivityHuaRongDao", "item");
|
|
GObject gObject = UIPackage.CreateObject("ActivityHuaRongDao", "item");
|
|
gObject.name = "item" + i;
|
|
gObject.name = "item" + i;
|
|
- gObject.onClick.Add(OnItemClick);
|
|
|
|
_ui.m_items.target.AddChild(gObject);
|
|
_ui.m_items.target.AddChild(gObject);
|
|
_items.Add(gObject);
|
|
_items.Add(gObject);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- private void OnItemClick(EventContext eventContext)
|
|
|
|
|
|
+ private void ControlMenuItemVisual(bool show = true)
|
|
{
|
|
{
|
|
- GObject obj = eventContext.sender as GObject;
|
|
|
|
- int num = (int)obj.data;
|
|
|
|
- Grid newGrid = CheckCanMove(num);
|
|
|
|
- if (newGrid != null)
|
|
|
|
- {
|
|
|
|
- _ui.m_items.target.touchable = false;
|
|
|
|
- obj.TweenMove(newGrid.pos, 0.1f).OnComplete(() =>
|
|
|
|
- {
|
|
|
|
- _ui.m_items.target.touchable = true;
|
|
|
|
- if (CheckWin())
|
|
|
|
- {
|
|
|
|
- Win();
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
- }
|
|
|
|
|
|
+ _ui.m_btnBack.visible = show;
|
|
|
|
+ _ui.m_btnLookPic.visible = show;
|
|
|
|
+ _ui.m_btnHidePic.visible = show;
|
|
|
|
+ _ui.m_btnRefresh.visible = show;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private Vector2 inputPos = new Vector2();
|
|
|
|
+
|
|
|
|
+ private void TouchBegin(EventContext context)
|
|
|
|
+ {
|
|
|
|
+ inputPos.x = context.inputEvent.x;
|
|
|
|
+ inputPos.y = context.inputEvent.y;
|
|
}
|
|
}
|
|
|
|
|
|
- private Grid CheckCanMove(int num)
|
|
|
|
|
|
+ private void TouchEnd(EventContext context)
|
|
{
|
|
{
|
|
- int indexX = 0;
|
|
|
|
- int indexY = 0;
|
|
|
|
|
|
+ GridInfo numGrid = null;
|
|
|
|
+ GridInfo nullGrid = new GridInfo();
|
|
|
|
|
|
- // 找到格子
|
|
|
|
|
|
+ // 找到空格子
|
|
for (int i = 0; i < _gridNum; i++)
|
|
for (int i = 0; i < _gridNum; i++)
|
|
{
|
|
{
|
|
for (int j = 0; j < _gridNum; j++)
|
|
for (int j = 0; j < _gridNum; j++)
|
|
{
|
|
{
|
|
- if (_gridArr[i, j].num == num)
|
|
|
|
|
|
+ if (_gridArr[i, j].num == 0)
|
|
{
|
|
{
|
|
- indexX = i;
|
|
|
|
- indexY = j;
|
|
|
|
|
|
+ nullGrid.row = i;
|
|
|
|
+ nullGrid.col = j;
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- // 判断格子四个方向是否有空格
|
|
|
|
- if (CheckHaveNullGrid(indexX - 1, indexY) || CheckHaveNullGrid(indexX, indexY - 1)
|
|
|
|
- || CheckHaveNullGrid(indexX + 1, indexY) || CheckHaveNullGrid(indexX, indexY + 1))
|
|
|
|
|
|
+ // 左
|
|
|
|
+ if ((context.inputEvent.x - inputPos.x) < 0 && Mathf.Abs(context.inputEvent.x - inputPos.x) > Mathf.Abs(context.inputEvent.y - inputPos.y))
|
|
{
|
|
{
|
|
- return UpdateGridInfo(num);
|
|
|
|
|
|
+ numGrid = CheckHaveNumGrid(nullGrid.row, nullGrid.col + 1);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 右
|
|
|
|
+ if ((context.inputEvent.x - inputPos.x) > 0 && Mathf.Abs(context.inputEvent.x - inputPos.x) > Mathf.Abs(context.inputEvent.y - inputPos.y))
|
|
|
|
+ {
|
|
|
|
+ numGrid = CheckHaveNumGrid(nullGrid.row, nullGrid.col - 1);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 上
|
|
|
|
+ if ((context.inputEvent.y - inputPos.y) < 0 && Mathf.Abs(context.inputEvent.y - inputPos.y) > Mathf.Abs(context.inputEvent.x - inputPos.x))
|
|
|
|
+ {
|
|
|
|
+ numGrid = CheckHaveNumGrid(nullGrid.row + 1, nullGrid.col);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 下
|
|
|
|
+ if ((context.inputEvent.y - inputPos.y) > 0 && Mathf.Abs(context.inputEvent.y - inputPos.y) > Mathf.Abs(context.inputEvent.x - inputPos.x))
|
|
|
|
+ {
|
|
|
|
+ numGrid = CheckHaveNumGrid(nullGrid.row - 1, nullGrid.col);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (numGrid != null)
|
|
|
|
+ {
|
|
|
|
+ int num = numGrid.num;
|
|
|
|
+ Grid grid = UpdateGridInfo(numGrid, nullGrid);
|
|
|
|
+ MoveItem(grid, num);
|
|
}
|
|
}
|
|
|
|
|
|
- return null;
|
|
|
|
}
|
|
}
|
|
|
|
|
|
- private bool CheckHaveNullGrid(int indexX, int indexY)
|
|
|
|
|
|
+ private void MoveItem(Grid newGrid, int changeNum)
|
|
{
|
|
{
|
|
- if (indexX >= 0 && indexX < _gridNum)
|
|
|
|
|
|
+ for(int i = 0; i < _items.Count; i++)
|
|
{
|
|
{
|
|
- if (indexY >= 0 && indexY < _gridNum)
|
|
|
|
|
|
+ GObject obj = _items[i];
|
|
|
|
+ int num = (int)obj.data;
|
|
|
|
+
|
|
|
|
+ if(num == changeNum)
|
|
{
|
|
{
|
|
- return _gridArr[indexX, indexY].num == 0;
|
|
|
|
|
|
+ _ui.m_maskGlobal.visible = true;
|
|
|
|
+ obj.TweenMove(newGrid.pos, 0.1f).OnComplete(() =>
|
|
|
|
+ {
|
|
|
|
+ _ui.m_maskGlobal.visible = false;
|
|
|
|
+ if (CheckWin())
|
|
|
|
+ {
|
|
|
|
+ ControlMenuItemVisual(false);
|
|
|
|
+ Win(_cancellationTokenSource.Token);
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ return;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
- return false;
|
|
|
|
}
|
|
}
|
|
|
|
|
|
- private Grid UpdateGridInfo(int num)
|
|
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// 查看空白格附近是否存在数字格
|
|
|
|
+ /// </summary>
|
|
|
|
+ /// <param name="indexX"></param>
|
|
|
|
+ /// <param name="indexY"></param>
|
|
|
|
+ /// <returns></returns>
|
|
|
|
+ private GridInfo CheckHaveNumGrid(int indexX, int indexY)
|
|
{
|
|
{
|
|
- Vector2 nullGridindex = new Vector2(-1, 0);
|
|
|
|
- Vector2 numGridindex = new Vector2(-1, 0);
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- for (int i = 0; i < _gridNum; i++)
|
|
|
|
|
|
+ if (indexX >= 0 && indexX < _gridNum)
|
|
{
|
|
{
|
|
- for (int j = 0; j < _gridNum; j++)
|
|
|
|
|
|
+ if (indexY >= 0 && indexY < _gridNum)
|
|
{
|
|
{
|
|
- if (_gridArr[i, j].num == num)
|
|
|
|
- {
|
|
|
|
- numGridindex = new Vector2(i, j);
|
|
|
|
- }
|
|
|
|
- else if (_gridArr[i, j].num == 0)
|
|
|
|
- {
|
|
|
|
- nullGridindex = new Vector2(i, j);
|
|
|
|
- }
|
|
|
|
- if (numGridindex.x != -1 && nullGridindex.x != -1)
|
|
|
|
- {
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
|
|
+ GridInfo grid = new GridInfo();
|
|
|
|
+ grid.row = indexX;
|
|
|
|
+ grid.col = indexY;
|
|
|
|
+ grid.num = _gridArr[indexX, indexY].num;
|
|
|
|
+ return grid;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- _gridArr[(int)numGridindex.x, (int)numGridindex.y].num = 0;
|
|
|
|
- _gridArr[(int)nullGridindex.x, (int)nullGridindex.y].num = num;
|
|
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// 交换数字格和空白格的数据
|
|
|
|
+ /// </summary>
|
|
|
|
+ /// <param name="numGrid"></param>
|
|
|
|
+ /// <param name="nullGrid"></param>
|
|
|
|
+ /// <returns></returns>
|
|
|
|
+ private Grid UpdateGridInfo(GridInfo numGrid, GridInfo nullGrid)
|
|
|
|
+ {
|
|
|
|
+ _gridArr[numGrid.row, numGrid.col].num = 0;
|
|
|
|
+ _gridArr[nullGrid.row, nullGrid.col].num = numGrid.num;
|
|
|
|
|
|
- return _gridArr[(int)nullGridindex.x, (int)nullGridindex.y];
|
|
|
|
|
|
+ return _gridArr[nullGrid.row, nullGrid.col];
|
|
}
|
|
}
|
|
|
|
|
|
private bool CheckWin()
|
|
private bool CheckWin()
|
|
@@ -358,36 +405,31 @@ namespace GFGGame
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
|
|
|
|
- private void Win()
|
|
|
|
|
|
+ private async Task Win(CancellationToken cancellationToken)
|
|
{
|
|
{
|
|
- // 关卡推进
|
|
|
|
- int passLevel = cfg.resArr[0];
|
|
|
|
- ActivityHuaRongDaoEntryView.curLevel = Mathf.Max(passLevel, ActivityHuaRongDaoEntryView.curLevel);
|
|
|
|
- EventAgent.DispatchEvent(ConstMessage.ACTIVITY_HUARONGDAO_UPDATE);
|
|
|
|
- // 弹出成功界面
|
|
|
|
- ViewManager.Show<ActivityHuaRongDaoSuccessView>(cfg);
|
|
|
|
- }
|
|
|
|
|
|
+ // 请求游戏结束协议
|
|
|
|
+ await MiniGameProxy.ReqMiniGameEnd(_cfg.id, _cfg.type, 0, true, _activityID, false);
|
|
|
|
|
|
- private int countDownNum;
|
|
|
|
- private void Countdown(object param)
|
|
|
|
- {
|
|
|
|
- _ui.m_seconds.text = countDownNum.ToString() + "s";
|
|
|
|
- --countDownNum;
|
|
|
|
-
|
|
|
|
- if (countDownNum < 0)
|
|
|
|
|
|
+ // 成功动画
|
|
|
|
+ _ui.m_showMask.Play(async () =>
|
|
{
|
|
{
|
|
- _ui.m_tips.visible = false;
|
|
|
|
- Timers.inst.Remove(Countdown);
|
|
|
|
|
|
+ _ui.m_hideMask.Play();
|
|
_gameStart = true;
|
|
_gameStart = true;
|
|
- return;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
|
|
- private void ResetCountdown()
|
|
|
|
- {
|
|
|
|
- countDownNum = 3;
|
|
|
|
- _ui.m_tips.visible = true;
|
|
|
|
- Timers.inst.Remove(Countdown);
|
|
|
|
|
|
+ await Task.Delay(400, cancellationToken);
|
|
|
|
+
|
|
|
|
+ // 刷新华容道入口界面UI
|
|
|
|
+ EventAgent.DispatchEvent(ConstMessage.ACTIVITY_HUARONGDAO_UPDATE);
|
|
|
|
+ // 弹出成功界面
|
|
|
|
+ ViewManager.Show<ActivityHuaRongDaoSuccessView>(_cfg);
|
|
|
|
+ });
|
|
|
|
+ await Task.Delay(200, cancellationToken);
|
|
|
|
+ _blankItem.visible = true;
|
|
|
|
+ _blankItem.position = _gridArr[0, 0].pos;
|
|
|
|
+ UI_item item = UI_item.Proxy(_blankItem);
|
|
|
|
+ int groupID = _cfg.resArr[0];
|
|
|
|
+ item.m_icon.url = GetPicRes(HuarongRoadCfgArray.Instance.GetCfgsByid(groupID)[0].resName);
|
|
|
|
+ UI_item.ProxyEnd();
|
|
}
|
|
}
|
|
|
|
|
|
private void OnBtnBackClick()
|
|
private void OnBtnBackClick()
|
|
@@ -406,5 +448,126 @@ namespace GFGGame
|
|
Hide();
|
|
Hide();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ private async Task StartAnimation(CancellationToken cancellationToken)
|
|
|
|
+ {
|
|
|
|
+ try
|
|
|
|
+ {
|
|
|
|
+ _ui.m_hideMask.Play();
|
|
|
|
+ _ui.m_maskGlobal.visible = true;
|
|
|
|
+ List<int> numList = CreateIncreaseArr();
|
|
|
|
+ SetGridInfo(numList);
|
|
|
|
+ InitItems();
|
|
|
|
+ CreateOriginPic();
|
|
|
|
+
|
|
|
|
+ // 隐藏所有
|
|
|
|
+ UI_item item;
|
|
|
|
+ for (int i = 0; i < _items.Count; i++)
|
|
|
|
+ {
|
|
|
|
+ item = UI_item.Proxy(_items[i]);
|
|
|
|
+ item.m_hide.Play();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 入场
|
|
|
|
+ for (int i = 0; i < _items.Count; i++)
|
|
|
|
+ {
|
|
|
|
+ item = UI_item.Proxy(_items[i]);
|
|
|
|
+ item.m_show.Play();
|
|
|
|
+ await Task.Delay(100, cancellationToken);
|
|
|
|
+ }
|
|
|
|
+ UI_item.ProxyEnd();
|
|
|
|
+
|
|
|
|
+ // 出现白色遮罩,刷新数组
|
|
|
|
+ await Task.Delay(900, cancellationToken);
|
|
|
|
+ _ui.m_showMask.Play(() =>
|
|
|
|
+ {
|
|
|
|
+ _ui.m_maskGlobal.visible = false;
|
|
|
|
+ _ui.m_hideMask.Play();
|
|
|
|
+ _gameStart = true;
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ await Task.Delay(200, cancellationToken);
|
|
|
|
+ numList = GetArrByConfigStep(_cfg.step);
|
|
|
|
+ while (CheckListCorrect(numList))
|
|
|
|
+ {
|
|
|
|
+ numList = GetArrByConfigStep(_cfg.step);
|
|
|
|
+ }
|
|
|
|
+ SetGridInfo(numList);
|
|
|
|
+ InitItems();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ catch (TaskCanceledException)
|
|
|
|
+ {
|
|
|
|
+ //Debug.Log("异步函数被停止");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private void RefreshData()
|
|
|
|
+ {
|
|
|
|
+ _blankItem.visible = false;
|
|
|
|
+ _gameStart = false;
|
|
|
|
+ _ui.m_state.selectedIndex = 0;
|
|
|
|
+ ControlMenuItemVisual();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 取消异步函数
|
|
|
|
+ public void StopMyAsyncFunction()
|
|
|
|
+ {
|
|
|
|
+ if (_cancellationTokenSource != null)
|
|
|
|
+ {
|
|
|
|
+ _cancellationTokenSource.Cancel();
|
|
|
|
+ _cancellationTokenSource.Dispose();
|
|
|
|
+ _cancellationTokenSource = null;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// 创建原图
|
|
|
|
+ /// </summary>
|
|
|
|
+ private void CreateOriginPic()
|
|
|
|
+ {
|
|
|
|
+ List<GObject> items = new List<GObject>();
|
|
|
|
+ for (int i = 1; i <= _gridNum * _gridNum; i++)
|
|
|
|
+ {
|
|
|
|
+ GObject gObject = UIPackage.CreateObject("ActivityHuaRongDao", "item");
|
|
|
|
+ _ui.m_itemsOrigin.target.AddChild(gObject);
|
|
|
|
+ items.Add(gObject);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ int itemIndex = 0;
|
|
|
|
+ for (int i = 0; i < _gridNum; i++)
|
|
|
|
+ {
|
|
|
|
+ for (int j = 0; j < _gridNum; j++)
|
|
|
|
+ {
|
|
|
|
+ items[itemIndex].position = _gridArr[i, j].pos;
|
|
|
|
+ UI_item item = UI_item.Proxy(items[itemIndex]);
|
|
|
|
+ item.m_index.text = _gridArr[i, j].num.ToString();
|
|
|
|
+ //item.m_icon.url = string.Format("ui://ActivityHuaRongDao/hrd_1-{0}", _gridArr[i, j].num + 1);
|
|
|
|
+ int groupID = _cfg.resArr[0];
|
|
|
|
+ item.m_icon.url = GetPicRes(HuarongRoadCfgArray.Instance.GetCfgsByid(groupID)[_gridArr[i, j].num].resName);
|
|
|
|
+ UI_item.ProxyEnd();
|
|
|
|
+ ++itemIndex;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private void OnChangeLookOriginState()
|
|
|
|
+ {
|
|
|
|
+ bool look = (_ui.m_state.selectedIndex == 1);
|
|
|
|
+ _ui.m_maskTouch.touchable = !look;
|
|
|
|
+ _ui.m_items.target.visible = !look;
|
|
|
|
+ _ui.m_itemsOrigin.target.visible = look;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private void OnClickBtnRefresh()
|
|
|
|
+ {
|
|
|
|
+ _ui.m_state.selectedIndex = 0;
|
|
|
|
+ StartAnimation(_cancellationTokenSource.Token);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private string GetPicRes(string res)
|
|
|
|
+ {
|
|
|
|
+ return ResPathUtil.GetHUARONGDAOPicPath(res);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|