|
@@ -12,12 +12,19 @@ namespace GFGGame
|
|
|
public class ActivityHuaRongDaoView : BaseWindow
|
|
|
{
|
|
|
private UI_ActivityHuaRongDaoUI _ui;
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 格子类
|
|
|
+ /// </summary>
|
|
|
public class Grid
|
|
|
{
|
|
|
public Vector2 pos; // UI坐标
|
|
|
public int num;
|
|
|
}
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ /// 格子的行列信息
|
|
|
+ /// </summary>
|
|
|
public class GridInfo
|
|
|
{
|
|
|
public int col;
|
|
@@ -25,13 +32,17 @@ namespace GFGGame
|
|
|
public int num;
|
|
|
}
|
|
|
|
|
|
- private Grid[,] _gridArr;
|
|
|
+ private int _activityID;
|
|
|
+ // 行/列 格子数
|
|
|
private readonly int _gridNum = 3;
|
|
|
- private List<GObject> _items;
|
|
|
private bool _gameStart;
|
|
|
+
|
|
|
+ private Grid[,] _gridArr;
|
|
|
+ private List<GObject> _items;
|
|
|
private HuarongRoadGame _cfg;
|
|
|
- private int _activityID;
|
|
|
+ // 异步函数的取消控制
|
|
|
private CancellationTokenSource _cancellationTokenSource;
|
|
|
+ // 胜利后自动补齐的格子
|
|
|
private GObject _blankItem;
|
|
|
|
|
|
public override void Dispose()
|
|
@@ -52,19 +63,17 @@ namespace GFGGame
|
|
|
_ui = UI_ActivityHuaRongDaoUI.Create();
|
|
|
viewCom = _ui.target;
|
|
|
isfullScreen = true;
|
|
|
- _ui.m_loaBg.url = ResPathUtil.GetBgImgPath("quanping_moren_bg");
|
|
|
+ _ui.m_loaBg.url = ResPathUtil.GetBgImgPath("gf_pjxq_bj");
|
|
|
isReturnView = true;
|
|
|
|
|
|
_ui.m_item.target.visible = false;
|
|
|
_ui.m_btnBack.onClick.Add(OnBtnBackClick);
|
|
|
_ui.m_state.onChanged.Add(OnChangeLookOriginState);
|
|
|
- //_ui.m_btnLookPic.onClick.Add(OnClickBtnShowOriginPic);
|
|
|
- //_ui.m_btnHidePic.onClick.Add(OnClickBtnHideOriginPic);
|
|
|
_ui.m_btnRefresh.onClick.Add(OnClickBtnRefresh);
|
|
|
|
|
|
InitGridInfo();
|
|
|
CreateItems();
|
|
|
- // 初始化空白处图片
|
|
|
+ // 初始化空白处格子实体
|
|
|
if (_blankItem == null)
|
|
|
{
|
|
|
_blankItem = UIPackage.CreateObject("ActivityHuaRongDao", "item");
|
|
@@ -87,11 +96,6 @@ namespace GFGGame
|
|
|
RefreshData();
|
|
|
_cancellationTokenSource = new CancellationTokenSource();
|
|
|
Task task = StartAnimation(_cancellationTokenSource.Token);
|
|
|
-
|
|
|
- // 倒计时相关
|
|
|
- //ResetCountdown();
|
|
|
- //Countdown(null);
|
|
|
- //Timers.inst.Add(1, 0, Countdown);
|
|
|
}
|
|
|
|
|
|
protected override void OnHide()
|
|
@@ -122,7 +126,6 @@ namespace GFGGame
|
|
|
{
|
|
|
//List<int> numList = GetRandomArr(1, 8);
|
|
|
|
|
|
-
|
|
|
Vector2 originPos = _ui.m_item.target.position;
|
|
|
|
|
|
for (int i = 0; i < _gridNum; i++)
|
|
@@ -152,35 +155,6 @@ namespace GFGGame
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
- /// <summary>
|
|
|
- /// 随机排序 min~max 连续的数字
|
|
|
- /// </summary>
|
|
|
- /// <param name="min"></param>
|
|
|
- /// <param name="max"></param>
|
|
|
- /// <returns></returns>
|
|
|
- private List<int> GetRandomArr(int min, int max)
|
|
|
- {
|
|
|
- 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++)
|
|
|
- {
|
|
|
- int index = r.Next(list.Count);
|
|
|
- int temp = list[index];
|
|
|
- list[index] = list[i];
|
|
|
- list[i] = temp;
|
|
|
- }
|
|
|
-
|
|
|
- // 最后一个是空的
|
|
|
- list.Add(0);
|
|
|
-
|
|
|
- return list;
|
|
|
- }
|
|
|
-
|
|
|
private List<int> CreateIncreaseArr()
|
|
|
{
|
|
|
List<int> list = new List<int>();
|
|
@@ -241,7 +215,7 @@ namespace GFGGame
|
|
|
UI_item item = UI_item.Proxy(_items[itemIndex]);
|
|
|
item.m_index.text = _gridArr[i, j].num.ToString();
|
|
|
int groupID = _cfg.resArr[0];
|
|
|
- item.m_icon.url = ResPathUtil.GetMiniGamePicPath(HuarongRoadCfgArray.Instance.GetCfgsByid(groupID)[_gridArr[i, j].num].resName);
|
|
|
+ item.m_icon.url = GetPicRes(HuarongRoadCfgArray.Instance.GetCfgsByid(groupID)[_gridArr[i, j].num].resName);
|
|
|
_items[itemIndex].data = _gridArr[i, j].num;
|
|
|
UI_item.ProxyEnd();
|
|
|
++itemIndex;
|
|
@@ -258,17 +232,11 @@ namespace GFGGame
|
|
|
{
|
|
|
GObject gObject = UIPackage.CreateObject("ActivityHuaRongDao", "item");
|
|
|
gObject.name = "item" + i;
|
|
|
- //gObject.onClick.Add(OnItemClick);
|
|
|
- //gObject.onTouchEnd.Add(TouchEnd);
|
|
|
- //gObject.onTouchBegin.Add(TouchBegin);
|
|
|
_ui.m_items.target.AddChild(gObject);
|
|
|
- UI_item item = UI_item.Proxy(gObject);
|
|
|
_items.Add(gObject);
|
|
|
- UI_item.ProxyEnd();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
private void ControlMenuItemVisual(bool show = true)
|
|
|
{
|
|
|
_ui.m_btnBack.visible = show;
|
|
@@ -460,7 +428,7 @@ namespace GFGGame
|
|
|
_blankItem.position = _gridArr[0, 0].pos;
|
|
|
UI_item item = UI_item.Proxy(_blankItem);
|
|
|
int groupID = _cfg.resArr[0];
|
|
|
- item.m_icon.url = ResPathUtil.GetMiniGamePicPath(HuarongRoadCfgArray.Instance.GetCfgsByid(groupID)[0].resName);
|
|
|
+ item.m_icon.url = GetPicRes(HuarongRoadCfgArray.Instance.GetCfgsByid(groupID)[0].resName);
|
|
|
UI_item.ProxyEnd();
|
|
|
}
|
|
|
|
|
@@ -576,7 +544,7 @@ namespace GFGGame
|
|
|
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 = ResPathUtil.GetMiniGamePicPath(HuarongRoadCfgArray.Instance.GetCfgsByid(groupID)[_gridArr[i, j].num].resName);
|
|
|
+ item.m_icon.url = GetPicRes(HuarongRoadCfgArray.Instance.GetCfgsByid(groupID)[_gridArr[i, j].num].resName);
|
|
|
UI_item.ProxyEnd();
|
|
|
++itemIndex;
|
|
|
}
|
|
@@ -596,5 +564,10 @@ namespace GFGGame
|
|
|
_ui.m_state.selectedIndex = 0;
|
|
|
StartAnimation(_cancellationTokenSource.Token);
|
|
|
}
|
|
|
+
|
|
|
+ private string GetPicRes(string res)
|
|
|
+ {
|
|
|
+ return ResPathUtil.GetHUARONGDAOPicPath(res);
|
|
|
+ }
|
|
|
}
|
|
|
}
|