zhaoyang 3 жил өмнө
parent
commit
17ca02c557

+ 12 - 3
GameClient/Assets/Game/HotUpdate/Views/Studio/StudioBaseView.cs

@@ -42,7 +42,11 @@ namespace GFGGame
 
 
 
 
         }
         }
-
+        protected override void AddEventListener()
+        {
+            EventAgent.AddEventListener(ConstMessage.BUY_STUDIO_PLAY_TIMES, UpdateView);
+            EventAgent.AddEventListener(ConstMessage.NOTICE_STUDIO_PLAY_TIMES, UpdateView);
+        }
         protected override void OnShown()
         protected override void OnShown()
         {
         {
             base.OnShown();
             base.OnShown();
@@ -51,8 +55,7 @@ namespace GFGGame
 
 
             UpdateView();
             UpdateView();
             Timers.inst.Add(1, 0, UpdateShowTime);
             Timers.inst.Add(1, 0, UpdateShowTime);
-            EventAgent.AddEventListener(ConstMessage.BUY_STUDIO_PLAY_TIMES, UpdateView);
-            EventAgent.AddEventListener(ConstMessage.NOTICE_STUDIO_PLAY_TIMES, UpdateView);
+
         }
         }
 
 
         protected override void OnHide()
         protected override void OnHide()
@@ -63,6 +66,10 @@ namespace GFGGame
             storyLevelCfgs = null;
             storyLevelCfgs = null;
             studioData = null;
             studioData = null;
             Timers.inst.Remove(UpdateShowTime);
             Timers.inst.Remove(UpdateShowTime);
+
+        }
+        protected override void RemoveEventListener()
+        {
             EventAgent.RemoveEventListener(ConstMessage.BUY_STUDIO_PLAY_TIMES, UpdateView);
             EventAgent.RemoveEventListener(ConstMessage.BUY_STUDIO_PLAY_TIMES, UpdateView);
             EventAgent.RemoveEventListener(ConstMessage.NOTICE_STUDIO_PLAY_TIMES, UpdateView);
             EventAgent.RemoveEventListener(ConstMessage.NOTICE_STUDIO_PLAY_TIMES, UpdateView);
         }
         }
@@ -88,6 +95,7 @@ namespace GFGGame
             item.m_txtTitle.text = canFight ? storyLevelCfgs[index].name : content;
             item.m_txtTitle.text = canFight ? storyLevelCfgs[index].name : content;
             if (canFight) curIndex = index;
             if (canFight) curIndex = index;
             item.target.data = index;
             item.target.data = index;
+            UI_ListItem.ProxyEnd();
         }
         }
         private void OnCliclListItem(EventContext context)
         private void OnCliclListItem(EventContext context)
         {
         {
@@ -103,6 +111,7 @@ namespace GFGGame
             StudioDataManager.Instance.PROPERTY_SELECT_INDEX = _ui.m_listProperty.selectedIndex;
             StudioDataManager.Instance.PROPERTY_SELECT_INDEX = _ui.m_listProperty.selectedIndex;
             StudioDataManager.Instance.TYPE_SELECT_INDEX = _ui.m_c1.selectedIndex;
             StudioDataManager.Instance.TYPE_SELECT_INDEX = _ui.m_c1.selectedIndex;
             InstanceZonesController.ShowLevelView(storyLevelCfg.id, StudioDataManager.Instance.OnFinishStoryLevel);
             InstanceZonesController.ShowLevelView(storyLevelCfg.id, StudioDataManager.Instance.OnFinishStoryLevel);
+            UI_ListItem.ProxyEnd();
         }
         }
 
 
 
 

+ 18 - 11
GameClient/Assets/Game/HotUpdate/Views/Studio/StudioBuyNumView.cs

@@ -36,18 +36,11 @@ namespace GFGGame
             _ui.m_btnExchange.onClick.Add(() => { OnClickBtnBuy(BUY_TYPE_0); });
             _ui.m_btnExchange.onClick.Add(() => { OnClickBtnBuy(BUY_TYPE_0); });
             _ui.m_btnBuy.onClick.Add(() => { OnClickBtnBuy(BUY_TYPE_1); });
             _ui.m_btnBuy.onClick.Add(() => { OnClickBtnBuy(BUY_TYPE_1); });
 
 
-            EventAgent.AddEventListener(ConstMessage.BUY_STUDIO_PLAY_TIMES, () =>
-            {
-                PromptController.Instance.ShowFloatTextPrompt("购买成功", MessageType.SUCCESS);
-                UpdateView();
-                if (_studioData.BuyTimes == _studioCfg.buyNum)
-                {
-                    PromptController.Instance.ShowFloatTextPrompt("今日购买次数已达上限", MessageType.ERR);
-                    this.Hide();
-                }
-            });
         }
         }
-
+        protected override void AddEventListener()
+        {
+            EventAgent.AddEventListener(ConstMessage.BUY_STUDIO_PLAY_TIMES, OnListenerBuyTimeComplete);
+        }
         protected override void OnShown()
         protected override void OnShown()
         {
         {
             base.OnShown();
             base.OnShown();
@@ -74,6 +67,10 @@ namespace GFGGame
         {
         {
             base.OnHide();
             base.OnHide();
         }
         }
+        protected override void RemoveEventListener()
+        {
+            EventAgent.RemoveEventListener(ConstMessage.BUY_STUDIO_PLAY_TIMES, OnListenerBuyTimeComplete);
+        }
         private void OnClickBtnBuy(int type)
         private void OnClickBtnBuy(int type)
         {
         {
             if (_studioData.BuyTimes == _studioCfg.buyNum)
             if (_studioData.BuyTimes == _studioCfg.buyNum)
@@ -91,5 +88,15 @@ namespace GFGGame
             StudioSProxy.ReqBuyStudioPlayTimes(_chapterId, type, 1).Coroutine();
             StudioSProxy.ReqBuyStudioPlayTimes(_chapterId, type, 1).Coroutine();
 
 
         }
         }
+        private void OnListenerBuyTimeComplete()
+        {
+            PromptController.Instance.ShowFloatTextPrompt("购买成功", MessageType.SUCCESS);
+            UpdateView();
+            if (_studioData.BuyTimes == _studioCfg.buyNum)
+            {
+                PromptController.Instance.ShowFloatTextPrompt("今日购买次数已达上限", MessageType.ERR);
+                this.Hide();
+            }
+        }
     }
     }
 }
 }