|
@@ -90,6 +90,10 @@ namespace GFGGame
|
|
{
|
|
{
|
|
//List<int> numList = GetRandomArr(1, 8);
|
|
//List<int> numList = GetRandomArr(1, 8);
|
|
List<int> numList = GetArrByConfigStep(cfg.step);
|
|
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++)
|
|
@@ -103,6 +107,23 @@ namespace GFGGame
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
|
|
+ /// 检测是否是连续数组
|
|
|
|
+ /// </summary>
|
|
|
|
+ /// <param name="numList"></param>
|
|
|
|
+ /// <returns></returns>
|
|
|
|
+ private bool CheckListCorrect(List<int> numList)
|
|
|
|
+ {
|
|
|
|
+ for (int i = 0; i < numList.Count - 1; i++)
|
|
|
|
+ {
|
|
|
|
+ if (numList[i + 1] != numList[i] + 1)
|
|
|
|
+ {
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return true;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /// <summary>
|
|
/// 随机排序 min~max 连续的数字
|
|
/// 随机排序 min~max 连续的数字
|
|
/// </summary>
|
|
/// </summary>
|
|
/// <param name="min"></param>
|
|
/// <param name="min"></param>
|
|
@@ -139,15 +160,15 @@ namespace GFGGame
|
|
private List<int> GetArrByConfigStep(int configStep)
|
|
private List<int> GetArrByConfigStep(int configStep)
|
|
{
|
|
{
|
|
List<int> list = new List<int>();
|
|
List<int> list = new List<int>();
|
|
|
|
+
|
|
|
|
+ list.Add(0);
|
|
for (int i = 1; i <= 8; i++)
|
|
for (int i = 1; i <= 8; i++)
|
|
{
|
|
{
|
|
list.Add(i);
|
|
list.Add(i);
|
|
}
|
|
}
|
|
- // 最后一个是空的
|
|
|
|
- list.Add(0);
|
|
|
|
|
|
|
|
int num = 0;
|
|
int num = 0;
|
|
- Vector2 zeroPos = new Vector2(2, 2);
|
|
|
|
|
|
+ Vector2 zeroPos = new Vector2(0, 0);
|
|
Vector2[] dirArr = { new Vector2(-1, 0), new Vector2(1, 0), new Vector2(0, -1), new Vector2(0, 1) };
|
|
Vector2[] dirArr = { new Vector2(-1, 0), new Vector2(1, 0), new Vector2(0, -1), new Vector2(0, 1) };
|
|
Vector2 lastPos = zeroPos;
|
|
Vector2 lastPos = zeroPos;
|
|
while (num < configStep)
|
|
while (num < configStep)
|
|
@@ -183,6 +204,7 @@ 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);
|
|
_items[itemIndex].data = _gridArr[i, j].num;
|
|
_items[itemIndex].data = _gridArr[i, j].num;
|
|
UI_item.ProxyEnd();
|
|
UI_item.ProxyEnd();
|
|
++itemIndex;
|
|
++itemIndex;
|
|
@@ -213,10 +235,13 @@ namespace GFGGame
|
|
if (newGrid != null)
|
|
if (newGrid != null)
|
|
{
|
|
{
|
|
_ui.m_items.target.touchable = false;
|
|
_ui.m_items.target.touchable = false;
|
|
- obj.TweenMove(newGrid.pos, 0.1f).OnComplete(()=>
|
|
|
|
|
|
+ obj.TweenMove(newGrid.pos, 0.1f).OnComplete(() =>
|
|
{
|
|
{
|
|
_ui.m_items.target.touchable = true;
|
|
_ui.m_items.target.touchable = true;
|
|
- CheckWin();
|
|
|
|
|
|
+ if (CheckWin())
|
|
|
|
+ {
|
|
|
|
+ Win();
|
|
|
|
+ }
|
|
});
|
|
});
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -294,7 +319,7 @@ namespace GFGGame
|
|
return _gridArr[(int)nullGridindex.x, (int)nullGridindex.y];
|
|
return _gridArr[(int)nullGridindex.x, (int)nullGridindex.y];
|
|
}
|
|
}
|
|
|
|
|
|
- private void CheckWin()
|
|
|
|
|
|
+ private bool CheckWin()
|
|
{
|
|
{
|
|
int num = 0;
|
|
int num = 0;
|
|
for (int i = 0; i < _gridNum; i++)
|
|
for (int i = 0; i < _gridNum; i++)
|
|
@@ -304,9 +329,9 @@ namespace GFGGame
|
|
if (i == 0 && j == 0)
|
|
if (i == 0 && j == 0)
|
|
{
|
|
{
|
|
num = _gridArr[i, j].num;
|
|
num = _gridArr[i, j].num;
|
|
- if(num != 1)
|
|
|
|
|
|
+ if (num != 0)
|
|
{
|
|
{
|
|
- return;
|
|
|
|
|
|
+ return false;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
else
|
|
else
|
|
@@ -314,7 +339,7 @@ namespace GFGGame
|
|
// 不连续 没有胜利
|
|
// 不连续 没有胜利
|
|
if (_gridArr[i, j].num != num + 1)
|
|
if (_gridArr[i, j].num != num + 1)
|
|
{
|
|
{
|
|
- return;
|
|
|
|
|
|
+ return false;
|
|
}
|
|
}
|
|
// 继续检测
|
|
// 继续检测
|
|
else
|
|
else
|
|
@@ -323,24 +348,30 @@ namespace GFGGame
|
|
// 胜利
|
|
// 胜利
|
|
if (num == _gridNum * _gridNum - 1)
|
|
if (num == _gridNum * _gridNum - 1)
|
|
{
|
|
{
|
|
- // 关卡推进
|
|
|
|
- int passLevel = cfg.resArr[0];
|
|
|
|
- ActivityHuaRongDaoEntryView.curLevel = Mathf.Max(passLevel, ActivityHuaRongDaoEntryView.curLevel);
|
|
|
|
- EventAgent.DispatchEvent(ConstMessage.ACTIVITY_HUARONGDAO_UPDATE);
|
|
|
|
- // 弹出成功界面
|
|
|
|
- ViewManager.Show<ActivityHuaRongDaoSuccessView>(cfg);
|
|
|
|
|
|
+ return true;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private void Win()
|
|
|
|
+ {
|
|
|
|
+ // 关卡推进
|
|
|
|
+ int passLevel = cfg.resArr[0];
|
|
|
|
+ ActivityHuaRongDaoEntryView.curLevel = Mathf.Max(passLevel, ActivityHuaRongDaoEntryView.curLevel);
|
|
|
|
+ EventAgent.DispatchEvent(ConstMessage.ACTIVITY_HUARONGDAO_UPDATE);
|
|
|
|
+ // 弹出成功界面
|
|
|
|
+ ViewManager.Show<ActivityHuaRongDaoSuccessView>(cfg);
|
|
}
|
|
}
|
|
|
|
|
|
private int countDownNum;
|
|
private int countDownNum;
|
|
private void Countdown(object param)
|
|
private void Countdown(object param)
|
|
{
|
|
{
|
|
- _ui.m_seconds.text = countDownNum.ToString();
|
|
|
|
|
|
+ _ui.m_seconds.text = countDownNum.ToString() + "s";
|
|
--countDownNum;
|
|
--countDownNum;
|
|
|
|
|
|
if (countDownNum < 0)
|
|
if (countDownNum < 0)
|