فهرست منبع

副本添加动效,代码优化。通用的item动效在基类处理

zhangyuqian 1 سال پیش
والد
کامیت
67adcc9ec3

+ 27 - 0
GameClient/Assets/Game/HotUpdate/Views/Studio/StudioBaseView.cs

@@ -14,6 +14,7 @@ namespace GFGGame
         private GTextField _txtTime;
         private GTextField _txtNum;
         private GButton _btnBuy;
+        private int _time = 0;
 
         protected StudioCfg _studioCfg;
         protected List<StoryLevelCfg> storyLevelCfgs;
@@ -79,6 +80,9 @@ namespace GFGGame
             // _valueBarController.Controller(1);
             _ui.m_loaBg.url = ResPathUtil.GetBgImgPath("gzs_bjbj");
 
+            //add by zyq
+            UpdateItem();
+
             UpdateView();
             Timers.inst.Add(1, 0, UpdateShowTime);
 
@@ -93,6 +97,8 @@ namespace GFGGame
             storyLevelCfgs = null;
             Timers.inst.Remove(UpdateShowTime);
 
+            Timers.inst.Remove(OnTimerUpdate);
+
         }
         protected override void RemoveEventListener()
         {
@@ -180,5 +186,26 @@ namespace GFGGame
         {
             ViewManager.Show<StudioBuyNumView>(this._studioCfg.limit);
         }
+
+        private void UpdateItem()
+        {
+            for (int i = 0; i < list.numChildren; i++)
+            {
+                list.GetChildAt(i).visible = false;
+            }
+            _time = 0;
+            Timers.inst.Add(0.2f, list.numChildren, OnTimerUpdate, 1);
+        }
+        private void OnTimerUpdate(object param)
+        {
+            list.GetChildAt(_time).visible = true;
+            UI_ListItem listItem = UI_ListItem.Proxy(list.GetChildAt(_time++));
+            //播放动效
+            if (listItem.m_test != null)
+            {
+                listItem.m_test.Play();
+            }
+            UI_ListItem.ProxyEnd();
+        }
     }
 }

+ 0 - 19
GameClient/Assets/Game/HotUpdate/Views/Studio/StudioFabricView.cs

@@ -8,7 +8,6 @@ namespace GFGGame
     //织物副本
     public class StudioFabricView : StudioBaseView
     {
-        private int _time = 0;
         public override void Dispose()
         {
             base.Dispose();
@@ -34,22 +33,12 @@ namespace GFGGame
             list.ScrollToView(curIndex);
             base.OnShown();
 
-            //add by zyq
-            for (int i = 0; i < list.numChildren; i++)
-            {
-                list.GetChildAt(i).visible = false;
-            }
-            _time = 0;
-            Timers.inst.Add(0.2f, list.numChildren, OnTimerUpdate, 1);
-
-           
 
         }
 
         protected override void OnHide()
         {
             base.OnHide(); 
-            Timers.inst.Remove(OnTimerUpdate);
         }
 
         private void OnClickBtnBack()
@@ -57,13 +46,5 @@ namespace GFGGame
             ViewManager.GoBackFrom(typeof(StudioFabricView).FullName);
         }
 
-        private void OnTimerUpdate(object param)
-        {
-            list.GetChildAt(_time).visible = true;
-            UI_ListItem listItem = UI_ListItem.Proxy(list.GetChildAt(_time++));
-            //播放动效
-            listItem.m_test.Play();
-            UI_ListItem.ProxyEnd();
-        }
     }
 }