zhaoyang 3 жил өмнө
parent
commit
8773794f54

+ 97 - 35
GameClient/Assets/Game/HotUpdate/Views/LuckyBox/LuckyBoxStarView.cs

@@ -13,16 +13,14 @@ namespace GFGGame
     {
         private UI_LuckyBoxStarUI _ui;
         private List<GObject> comStars = new List<GObject>();
+        private List<GObject> clickComStars = new List<GObject>();
+        private List<GObject> notClickComStars = new List<GObject>();
 
         private List<GameObject> _gameObjects = new List<GameObject>();
         private List<GoWrapper> _wrappers = new List<GoWrapper>();
         private List<GameObject> _gameObjects1 = new List<GameObject>();
         private List<GoWrapper> _wrappers1 = new List<GoWrapper>();
         private Dictionary<int, List<GameObject>> dicGameobj = new Dictionary<int, List<GameObject>>();
-        private Dictionary<int, List<GoWrapper>> dicWrappers = new Dictionary<int, List<GoWrapper>>();
-        private Dictionary<int, List<GameObject>> dicGameobj1 = new Dictionary<int, List<GameObject>>();
-        private Dictionary<int, List<GoWrapper>> dicWrappers1 = new Dictionary<int, List<GoWrapper>>();
-
 
         private GObject curComStar;//当前选中的星星
         private Vector2 lastPos;//鼠标的上一个位置,每颗星星初始时默认为Vector2.right;
@@ -43,14 +41,16 @@ namespace GFGGame
         {
             int index = 0;
             GObject star = _ui.target.GetChild(string.Format("comStar{0}_{1}_{2}", _ui.m_ctrlBuyType.selectedIndex, _ui.m_ctrlRewardsType.selectedIndex, index));
-
-            // while (star != null && star.visible == true)
-            // {
-            //     UI_ComStar comStar = UI_ComStar.Proxy(star);
-            //     if (comStar.target.numChildren > 1) comStar.target.RemoveChildAt(1);
-            //     if (comStar.target.numChildren > 1) comStar.target.RemoveChildAt(1);
-            //     index++;
-            // }
+            notClickComStars.Clear();
+            clickComStars.Clear();
+            dicGameobj.Clear();
+            foreach (List<GameObject> value in dicGameobj.Values)
+            {
+                for (int i = 0; i < value.Count; i++)
+                {
+                    SceneController.DestroyObjectFromView(value[i]);
+                }
+            }
         }
         protected override void OnInit()
         {
@@ -91,37 +91,24 @@ namespace GFGGame
             while (star != null && star.visible == true)
             {
                 UI_ComStar comStar = UI_ComStar.Proxy(star);
+                comStar.m_imgLine.visible = true;
+
                 comStar.m_c1.selectedIndex = 0;
                 comStar.m_imgLine.width = imgLineWidth;
                 comStar.m_imgLine.rotation = 0;
-                GComponent gcom;
-                if (comStar.target.numChildren > 1)
-                {
-                    gcom = comStar.target.GetChildAt(1).asCom;
-                }
-                else
-                {
-                    gcom = UIPackage.CreateObject("LuckyBox", "ComHolder").asCom;
-                    string resPath = ResPathUtil.GetViewEffectPath("ui_ck", "ui_ck");
-                    SceneController.AddObjectToView(null, null, gcom.GetChild("holder").asGraph, resPath, out GameObject gameObject, out GoWrapper wrapper);
-                }
+
+                GComponent gcom = CreateEffect(comStar, 1, "ui_ck"); ;
                 gcom.visible = true;
                 comStar.target.AddChildAt(gcom, 1);
 
-                GComponent gcom1;
-                if (comStar.target.numChildren > 2)
-                {
-                    gcom1 = comStar.target.GetChildAt(2).asCom;
-                }
-                else
-                {
-                    gcom1 = UIPackage.CreateObject("LuckyBox", "ComHolder").asCom;
-                    string resPath1 = ResPathUtil.GetViewEffectPath("ui_ck", "ui_ck_dj");
-                    SceneController.AddObjectToView(null, null, gcom1.GetChild("holder").asGraph, resPath1, out GameObject gameObject1, out GoWrapper wrapper1);
-                }
+                GComponent gcom1 = CreateEffect(comStar, 2, "ui_ck_dj");
                 gcom1.visible = false;
                 comStar.target.AddChildAt(gcom1, 2);
 
+                GComponent gcom2 = CreateEffect(comStar, 3, "ui_ck_xs");
+                gcom2.visible = false;
+                comStar.target.AddChildAt(gcom2, 3);
+
 
 
                 star.data = new Vector2(comStar.target.x, comStar.target.y);
@@ -132,6 +119,26 @@ namespace GFGGame
             }
 
         }
+        private GComponent CreateEffect(UI_ComStar comStar, int index, string name)
+        {
+            GComponent gcom;
+            if (comStar.target.numChildren > index)
+            {
+                gcom = comStar.target.GetChildAt(index).asCom;
+            }
+            else
+            {
+                gcom = UIPackage.CreateObject("LuckyBox", "ComHolder").asCom;
+                string resPath = ResPathUtil.GetViewEffectPath("ui_ck", name);
+                SceneController.AddObjectToView(null, null, gcom.GetChild("holder").asGraph, resPath, out GameObject gameObject, out GoWrapper wrapper);
+                if (!dicGameobj.ContainsKey(index))
+                {
+                    dicGameobj.Add(index, new List<GameObject>());
+                }
+                dicGameobj[index].Add(gameObject);
+            }
+            return gcom;
+        }
         private void OnClickUIBegin(EventContext context)
         {
             context.CaptureTouch();
@@ -171,6 +178,7 @@ namespace GFGGame
                     curComStar = comStars[i];
                     lastPos = Vector2.right;
 
+                    clickComStars.Add(comStars[i]);
                     comStars.RemoveAt(i);
 
                 }
@@ -204,6 +212,12 @@ namespace GFGGame
 
         private void OnClickUIEnd()
         {
+            if (clickComStars.Count <= 0) return;
+
+            UI_ComStar comStar = UI_ComStar.Proxy(clickComStars[clickComStars.Count - 1]);
+            comStar.m_imgLine.visible = false;
+
+
             if (showGuide && comStars.Count > 0)
             {
                 isFirst = false;
@@ -211,10 +225,58 @@ namespace GFGGame
             }
             else
             {
+                CheckNotClickComStar();
+                // SetComStarDarken();
+
+                for (int i = 0; i < notClickComStars.Count; i++)
+                {
+                    UI_ComStar notClickComStar = UI_ComStar.Proxy(notClickComStars[i]);
+                    notClickComStar.m_imgLine.visible = false;
+                    notClickComStar.target.GetChildAt(3).asCom.visible = true;
+                    notClickComStar.target.GetChildAt(1).asCom.visible = false;
+                }
+
+                Timers.inst.Add(2f, 1, ClickUIEnd);
                 TryCompleteGuide();
-                Timers.inst.Add(0.3f, 1, ClickUIEnd);
+
             }
         }
+        private void CheckNotClickComStar()
+        {
+            int index = 0;
+            GObject star = _ui.target.GetChild(string.Format("comStar{0}_{1}_{2}", _ui.m_ctrlBuyType.selectedIndex, _ui.m_ctrlRewardsType.selectedIndex, index));
+
+            while (star != null && star.visible == true)
+            {
+                if (clickComStars.IndexOf(star) < 0)
+                {
+                    notClickComStars.Add(star);
+                }
+                index++;
+                star = _ui.target.GetChild(string.Format("comStar{0}_{1}_{2}", _ui.m_ctrlBuyType.selectedIndex, _ui.m_ctrlRewardsType.selectedIndex, index));
+            }
+        }
+        private void UpdateComStarDarken(object param)
+        {
+            // Timers.inst.Remove(UpdateComStarDarken);
+
+
+        }
+        private void SetComStarDarken()
+        {
+            if (notClickComStars.Count == 0) return;
+
+        }
+
+        private void SetClickComStarAni()
+        {
+            //             for (int i = 0; i < clickComStars.Count; i++)
+            //             {
+            //                 UI_ComStar comStar = UI_ComStar.Proxy(clickComStars[i]);
+            // comStar.
+            //             }
+        }
+
         private void ClickUIEnd(object param)
         {
             if (curComStar != null)