|
@@ -58,6 +58,7 @@ namespace GFGGame
|
|
|
private bool StartHit = true;
|
|
|
private bool firstHit = true;
|
|
|
private bool canHit = true;
|
|
|
+ List<Dictionary<string, int>> removeList = new List<Dictionary<string, int>>();
|
|
|
|
|
|
|
|
|
private EffectUI _effectUI1;
|
|
@@ -120,7 +121,7 @@ namespace GFGGame
|
|
|
Timers.inst.Remove(UpdateBar);
|
|
|
Timers.inst.Remove(UpdateHit);
|
|
|
Timers.inst.Remove(StartTime);
|
|
|
-
|
|
|
+ Timers.inst.Remove(UpdateCard);
|
|
|
base.OnHide();
|
|
|
|
|
|
}
|
|
@@ -310,16 +311,11 @@ namespace GFGGame
|
|
|
|
|
|
_ui.m_cardList.touchable = false;
|
|
|
canHit = false;
|
|
|
- UpdateCard();
|
|
|
- }
|
|
|
- //这里是处理已翻开的数量
|
|
|
- private void UpdateCard()
|
|
|
- {
|
|
|
- Timers.inst.Remove(StartTime);
|
|
|
- List<Dictionary<string, int>> removeList = new List<Dictionary<string, int>>();
|
|
|
- for (int i = 1; i < cardList.Count; i+= 2)
|
|
|
+
|
|
|
+ removeList = new List<Dictionary<string, int>>();
|
|
|
+ for (int i = 1; i < cardList.Count; i += 2)
|
|
|
{
|
|
|
- if(cardList[i]["id"] == cardList[i-1]["id"])
|
|
|
+ if (cardList[i]["id"] == cardList[i - 1]["id"])
|
|
|
{
|
|
|
cardList[i]["state"] = 2;
|
|
|
//消除
|
|
@@ -327,30 +323,65 @@ namespace GFGGame
|
|
|
item1.m_t0.Play();
|
|
|
UI_cardItem.ProxyEnd();
|
|
|
|
|
|
- UI_cardItem item2 = UI_cardItem.Proxy(_ui.m_cardList.GetChildAt(cardList[i-1]["index"]));
|
|
|
+ UI_cardItem item2 = UI_cardItem.Proxy(_ui.m_cardList.GetChildAt(cardList[i - 1]["index"]));
|
|
|
item2.m_t0.Play();
|
|
|
UI_cardItem.ProxyEnd();
|
|
|
|
|
|
currentCardNum -= 2;
|
|
|
- removeList.Add(cardList[i-1]);
|
|
|
+ removeList.Add(cardList[i - 1]);
|
|
|
removeList.Add(cardList[i]);
|
|
|
}
|
|
|
}
|
|
|
- if(currentCardNum <= 0)
|
|
|
+ if (currentCardNum <= 0)
|
|
|
{
|
|
|
Gameover(true);
|
|
|
return;
|
|
|
- }
|
|
|
+ }
|
|
|
//先处理消除的列表
|
|
|
- for(int i = 0;i<removeList.Count;i++)
|
|
|
+ for (int i = 0; i < removeList.Count; i++)
|
|
|
{
|
|
|
cardList.Remove(removeList[i]);
|
|
|
}
|
|
|
removeList.Clear();
|
|
|
+
|
|
|
//后处理翻牌的列表
|
|
|
- for (int i = 1; i < cardList.Count; i++)
|
|
|
+ for (int i = 1; i < cardList.Count - 1; i++)
|
|
|
{
|
|
|
|
|
|
+ UI_cardItem item = UI_cardItem.Proxy(_ui.m_cardList.GetChildAt(cardList[i - 1]["index"]));
|
|
|
+ //翻回去
|
|
|
+ Card card = (Card)item.m_card;
|
|
|
+ card.Turn();
|
|
|
+ item.m_flipEffect.visible = false;
|
|
|
+ cardList[i - 1]["state"] = 0;
|
|
|
+ UI_cardItem.ProxyEnd();
|
|
|
+ if (cardList.Count % 2 == 0 && i == cardList.Count - 1)
|
|
|
+ {
|
|
|
+ UI_cardItem carditem = UI_cardItem.Proxy(_ui.m_cardList.GetChildAt(cardList[i]["index"]));
|
|
|
+ //翻回去
|
|
|
+ Card cardLast = (Card)carditem.m_card;
|
|
|
+ cardLast.Turn();
|
|
|
+ carditem.m_flipEffect.visible = false;
|
|
|
+ cardList[i]["state"] = 0;
|
|
|
+ UI_cardItem.ProxyEnd();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ Timers.inst.Add(0.5f,1, UpdateCard);
|
|
|
+ }
|
|
|
+ //这里是处理已翻开的数量
|
|
|
+ private void UpdateCard(object param = null)
|
|
|
+ {
|
|
|
+ Timers.inst.Remove(StartTime);
|
|
|
+
|
|
|
+
|
|
|
+ //后处理翻牌的列表
|
|
|
+ for (int i = cardList.Count - 1; i < cardList.Count; i++)
|
|
|
+ {
|
|
|
+ if( i-1 < 0)
|
|
|
+ {
|
|
|
+ break;
|
|
|
+ }
|
|
|
UI_cardItem item = UI_cardItem.Proxy(_ui.m_cardList.GetChildAt(cardList[i - 1]["index"]));
|
|
|
//翻回去
|
|
|
Card card = (Card)item.m_card;
|
|
@@ -383,7 +414,7 @@ namespace GFGGame
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- Timers.inst.Add(0.6f, 1, UpdateHit);
|
|
|
+ Timers.inst.Add(0.5f, 1, UpdateHit);
|
|
|
}
|
|
|
private void UpdateHit(object param = null)
|
|
|
{
|