zhangyuqian 1 жил өмнө
parent
commit
a22fc20de9

+ 6 - 0
GameClient/Assets/Game/HotUpdate/Views/MiniGame/Card.cs

@@ -39,9 +39,15 @@ public class Card : GButton
     public void Turn()
     {
         if (GTween.IsTweening(this))
+        {
+            ET.Log.Debug("toopen,this");
+            GTween.To(180, 360, 0.5f).SetTarget(this).SetEase(EaseType.QuadOut).OnUpdate(TurnInTween).SetUserData(false);
             return;
+        }
+           
 
         bool toOpen = !_front.visible;
+        ET.Log.Debug("toopen:" + toOpen);
         GTween.To(0, 180, 0.5f).SetTarget(this).SetEase(EaseType.QuadOut).OnUpdate(TurnInTween).SetUserData(toOpen);
     }
 

+ 46 - 68
GameClient/Assets/Game/HotUpdate/Views/MiniGame/FlipGameView.cs

@@ -50,7 +50,7 @@ namespace GFGGame
 
         private List<ActivityOpenCfg> activityGameDate;
         //假数据
-        private List<int> cardArray = new List<int> { 1,1, 2,2,  3, 3 , 4, 4 ,  5, 5 ,  6, 6 ,  8, 8 , 8, 8  };
+        private List<int> cardArray = new List<int> { 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 8, 8, 8, 8 };
 
         //Card _c1 = new Card();
         //从第一次点击开始超过一秒后禁止点击,然后对翻开列表进行处理并重置,
@@ -58,7 +58,6 @@ 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;
@@ -121,7 +120,7 @@ namespace GFGGame
             Timers.inst.Remove(UpdateBar);
             Timers.inst.Remove(UpdateHit);
             Timers.inst.Remove(StartTime);
-            Timers.inst.Remove(UpdateCard);
+            Timers.inst.Remove(UpdateOneHit);
             base.OnHide();
 
         }
@@ -148,7 +147,7 @@ namespace GFGGame
             Timers.inst.Remove(UpdateBar);
 
             string exitTip;
-            if(gameDate.bonusLoseArr.Length == 0)
+            if (gameDate.bonusLoseArr.Length == 0)
             {
                 exitTip = "退出游戏不保存进度,不扣除任何次数和道具,是否退出?";
             }
@@ -164,7 +163,7 @@ namespace GFGGame
             })
             .SetRightButton(true, "确定", async (object data) =>
             {
-                var result = await MiniGameProxy.ReqMiniGameEnd(gameID, gameDate.type, timeIndex, false, activityGameDate[0].id,true);
+                var result = await MiniGameProxy.ReqMiniGameEnd(gameID, gameDate.type, timeIndex, false, activityGameDate[0].id, true);
                 if (!result) return;
                 this.Hide();
             });
@@ -203,7 +202,7 @@ namespace GFGGame
         private void UpdateView()
         {
             gameTime = CardGameArray.Instance.GetCfg(gameID).time;
-            for(int i = 0;i<3;i++)
+            for (int i = 0; i < 3; i++)
             {
                 switch (i)
                 {
@@ -237,7 +236,7 @@ namespace GFGGame
             _ui.m_ScareBar.max = gameTime;
             _ui.m_ScareBar.min = 0;
             _ui.m_ScareBar.value = gameTime;
-            _ui.m_star1.SetPosition(((float)(gameTime - CustemsNum[0])/(float)gameTime) * _ui.m_ScareBar.width + 70,_ui.m_star1.position.y, _ui.m_star1.position.z);
+            _ui.m_star1.SetPosition(((float)(gameTime - CustemsNum[0]) / (float)gameTime) * _ui.m_ScareBar.width + 70, _ui.m_star1.position.y, _ui.m_star1.position.z);
             _ui.m_star2.SetPosition(((float)(gameTime - CustemsNum[1]) / (float)gameTime) * _ui.m_ScareBar.width + 10, _ui.m_star1.position.y, _ui.m_star1.position.z);
             _ui.m_star3.SetPosition(((float)(gameTime - CustemsNum[2]) / (float)gameTime) * _ui.m_ScareBar.width, _ui.m_star1.position.y, _ui.m_star1.position.z);
 
@@ -246,10 +245,10 @@ namespace GFGGame
             _ui.m_barEffect.x = _ui.m_ScareBar.width;
 
             _ui.m_cardList.touchable = true;
-            //计时器
-            Timers.inst.Add(1.0f, 0, UpdateTime);
-            //进度条计时器
-            Timers.inst.Add(0.1f, 0, UpdateBar);
+            ////计时器
+            //Timers.inst.Add(1.0f, 0, UpdateTime);
+            ////进度条计时器
+            //Timers.inst.Add(0.1f, 0, UpdateBar);
         }
 
         private void UpdateList()
@@ -259,7 +258,7 @@ namespace GFGGame
         }
         private void OnClickCardItem(EventContext context)
         {
-            if(!canHit)
+            if (!canHit)
             {
                 return;
             }
@@ -267,25 +266,28 @@ namespace GFGGame
             Dictionary<string, int> cardInfo = (Dictionary<string, int>)cardItem.data;
             UI_cardItem item = UI_cardItem.Proxy(_ui.m_cardList.GetChildAt(cardInfo["index"]));
 
-            if(StartHit)
+            if (StartHit)
             {
                 StartHit = false;
                 Timers.inst.Add(1.0f, 1, StartTime);
             }
             Card card = (Card)item.m_card;
-            bool isSame = false; 
+            bool isSame = false;
             for (int i = 0; i < cardList.Count; i++)
             {
                 if (cardInfo["index"] == cardList[i]["index"] && firstHit)
-                { 
-                        cardInfo["state"] = 0;
-                        //翻牌
-                        card.Turn();
-                        //.
-                        cardList.RemoveAt(0);
-                        isSame = true;
-                        break;
-                 }
+                {
+                    cardInfo["state"] = 0;
+                    //翻牌
+                    card.Turn();
+                    _ui.m_cardList.touchable = false;
+                    canHit = false;
+                    cardList.RemoveAt(0);
+
+                    Timers.inst.Add(0.5f, 1,UpdateOneHit);
+                    isSame = true;
+                    break;
+                }
                 else
                 {
                     if (cardInfo["index"] == cardList[i]["index"])
@@ -311,8 +313,13 @@ namespace GFGGame
 
             _ui.m_cardList.touchable = false;
             canHit = false;
-
-            removeList = new List<Dictionary<string, int>>();
+            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)
             {
                 if (cardList[i]["id"] == cardList[i - 1]["id"])
@@ -343,9 +350,8 @@ namespace GFGGame
                 cardList.Remove(removeList[i]);
             }
             removeList.Clear();
-
             //后处理翻牌的列表
-            for (int i = 1; i < cardList.Count - 1; i++)
+            for (int i = 1; i < cardList.Count; i++)
             {
 
                 UI_cardItem item = UI_cardItem.Proxy(_ui.m_cardList.GetChildAt(cardList[i - 1]["index"]));
@@ -367,40 +373,6 @@ namespace GFGGame
                 }
             }
 
-            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;
-                    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();
-                    }
-            }
-
             if (cardList.Count % 2 == 0)
             {
                 cardList.Clear();
@@ -408,13 +380,13 @@ namespace GFGGame
             else
             {
                 int j = cardList.Count;
-                for(int i = 0;i < j-1;i++)
+                for (int i = 0; i < j - 1; i++)
                 {
                     cardList.RemoveAt(0);
                 }
             }
 
-            Timers.inst.Add(0.5f, 1, UpdateHit);
+            Timers.inst.Add(0.6f, 1, UpdateHit);
         }
         private void UpdateHit(object param = null)
         {
@@ -424,13 +396,19 @@ namespace GFGGame
             _ui.m_cardList.touchable = true;
             Timers.inst.Remove(UpdateHit);
         }
+        private void UpdateOneHit(object param = null)
+        {
+            canHit = true;
+            _ui.m_cardList.touchable = true;
+            Timers.inst.Remove(UpdateOneHit);
+        }
         private void UpdateTime(object param = null)
         {
             timeIndex++;
             currentGameTime--;
             //_ui.m_ScareBar.value = currentGameTime;
-            _ui.m_timeText.text = string.Format ("{0}", currentGameTime);
-            if(currentGameTime <= 0)
+            _ui.m_timeText.text = string.Format("{0}", currentGameTime);
+            if (currentGameTime <= 0)
             {
                 Gameover(false);
             }
@@ -439,7 +417,7 @@ namespace GFGGame
         {
             barTime -= 0.1f;
             _ui.m_ScareBar.value = barTime;
-            _ui.m_barEffect.x -= (880.0f/ (float)(gameTime*10));
+            _ui.m_barEffect.x -= (880.0f / (float)(gameTime * 10));
         }
 
         private void Gameover(bool isPass = false)
@@ -466,12 +444,12 @@ namespace GFGGame
         {
             int numCount = CardCfgArray.Instance.dataArray.Length;
             List<int> tArray = new List<int>();
-            for(int i=0;i<numCount;i++)
+            for (int i = 0; i < numCount; i++)
             {
                 tArray.Add(i);
             }
             RandomCardList(tArray, numCount);
-            for(int i = 0;i <cardNum;i+=2)
+            for (int i = 0; i < cardNum; i += 2)
             {
                 cardArray[i] = tArray[i];
                 cardArray[i + 1] = tArray[i];