zhaoyang 2 年之前
父节点
当前提交
d9c566d7c9

+ 1 - 1
GameClient/Assets/Game/HotUpdate/Controller/GameController.cs

@@ -112,7 +112,7 @@ namespace GFGGame
             await StudioSProxy.ReqStudioInfos();
             await RoleInfoSProxy.ReqPersonalInfo();
             await ActivityGlobalSProxy.GetActivityInfo();
-
+            await LuckyBoxSProxy.ReqGetLuckyBoxRotatingInfo();
 
             GameGlobal.lastLoginTime = StorageDataManager.Instance.GetStorageValue(ConstStorageId.LAST_LOGIN_TIME);
             long lastTime = GameGlobal.myNumericComponent.GetAsInt(NumericType.OnlineTimeSecs);

+ 1 - 0
GameClient/Assets/Game/HotUpdate/Data/LuckyBoxDataManager.cs

@@ -18,6 +18,7 @@ namespace GFGGame
         private Dictionary<int, List<LuckyBoxBonusData>> _dicShowList = new Dictionary<int, List<LuckyBoxBonusData>>();
 
         public List<int> luckyBoxIds = new List<int>();//奖池列表
+        public int RotatingId = 0;//轮换活动id。0为未开启
         public long startTime = 1668873600000;
         public long endTime = 1672156799000;
 

+ 1 - 0
GameClient/Assets/Game/HotUpdate/ServerProxy/CommonSProxy.cs

@@ -56,6 +56,7 @@ namespace GFGGame
                     FieldSProxy.ReqFieldInstanceInfos().Coroutine();
                     ArenaSproxy.ReqArenaInfos().Coroutine();
                     EnduringGiftBoxSProxy.ReqGetAllGiftBagRebateStatus().Coroutine();
+                    LuckyBoxSProxy.ReqGetLuckyBoxRotatingInfo().Coroutine();
                     PromptController.Instance.ShowFloatTextPrompt("每日次数已重置", MessageType.SUCCESS);
                 }
             }

+ 1 - 0
GameClient/Assets/Game/HotUpdate/ServerProxy/LuckyBoxSProxy.cs

@@ -36,6 +36,7 @@ namespace GFGGame
             {
                 if (response.Error == ErrorCode.ERR_Success)
                 {
+                    LuckyBoxDataManager.Instance.RotatingId = response.RotatingId;
                     return response.RotatingId;
                 }
             }

+ 18 - 18
GameClient/Assets/Game/HotUpdate/Views/LuckyBox/LuckyBoxView.cs

@@ -12,7 +12,7 @@ namespace GFGGame
     {
         private UI_LuckyBoxUI _ui;
         private ValueBarController _valueBarController;
-        private List<LuckyBoxController> _lcukyBoxCtrl = new List<LuckyBoxController>();
+        private Dictionary<int, LuckyBoxController> _lcukyBoxCtrl = new Dictionary<int, LuckyBoxController>();
 
         //private GameObject _gameObject;
         //private GoWrapper _wrapper;
@@ -43,9 +43,9 @@ namespace GFGGame
                 _valueBarController.Dispose();
                 _valueBarController = null;
             }
-            for (int i = 0; i < _lcukyBoxCtrl.Count; i++)
+            foreach (int key in _lcukyBoxCtrl.Keys)
             {
-                _lcukyBoxCtrl[i].Dispose();
+                _lcukyBoxCtrl[key].Dispose();
             }
             _lcukyBoxCtrl.Clear();
             if (_dressUpObjUIXiHe != null)
@@ -104,7 +104,7 @@ namespace GFGGame
             EventAgent.AddEventListener(ConstMessage.ITEM_CHANGED, OnListBgScroll);
             EventAgent.AddEventListener(ConstMessage.NUMERIC_CHANGE, OnListBgScroll);
         }
-        protected override async void OnShown()
+        protected override void OnShown()
         {
             base.OnShown();
 
@@ -112,10 +112,9 @@ namespace GFGGame
             LuckyBoxDataManager.Instance.luckyBoxIds.Add(LuckyBoxDataManager.BOX_ID_2);
             LuckyBoxDataManager.Instance.luckyBoxIds.Add(LuckyBoxDataManager.BOX_ID_3);
             _activeBoxId = 0;
-            int result = await LuckyBoxSProxy.ReqGetLuckyBoxRotatingInfo();
-            if (result > 0)
+            if (LuckyBoxDataManager.Instance.RotatingId > 0)
             {
-                RotatingLuckyBoxCfg rotatingLuckyBox = RotatingLuckyBoxCfgArray.Instance.GetCfg(result);
+                RotatingLuckyBoxCfg rotatingLuckyBox = RotatingLuckyBoxCfgArray.Instance.GetCfg(LuckyBoxDataManager.Instance.RotatingId);
                 _activeBoxId = rotatingLuckyBox.luckyBoxId;
                 LuckyBoxDataManager.Instance.endTime = TimeUtil.GetTimestamp(rotatingLuckyBox.endTime);
                 LuckyBoxDataManager.Instance.luckyBoxIds.Insert(0, _activeBoxId);
@@ -173,15 +172,15 @@ namespace GFGGame
 
             UI_ComBox comBox = UI_ComBox.Proxy(obj);
             comBox.m_comModel.m_loaBg.url = ResPathUtil.GetBgImgPath(cfg.resArr[_bgIndex]);
-            if (_lcukyBoxCtrl.Count <= index)
+            if (!_lcukyBoxCtrl.ContainsKey(boxId))
             {
-                _lcukyBoxCtrl.Add(new LuckyBoxController(comBox.m_comModel.target));
-                if (_ui.m_listBg.ChildIndexToItemIndex(0) == index)
-                {
-                    _lcukyBoxCtrl[index].OnShown(boxId);
-                }
+                _lcukyBoxCtrl.Add(boxId, new LuckyBoxController(comBox.m_comModel.target));
+                // if (_ui.m_listBg.ChildIndexToItemIndex(0) == index)
+                // {
+                //     _lcukyBoxCtrl[index].OnShown(boxId);
+                // }
             }
-
+            if (_lcukyBoxCtrl.ContainsKey(boxId)) _lcukyBoxCtrl[boxId].OnShown(boxId);
             comBox.m_btnPreview.m_c1.selectedIndex = boxId;
             LuckyBoxDataManager.Instance.GetOwnedCount(boxId, out int count, out int totalCount);
             comBox.m_txtOwned.SetVar("v1", "" + count).FlushVars();
@@ -262,12 +261,13 @@ namespace GFGGame
 
         private void OnListBgScroll()
         {
-            _lcukyBoxCtrl[_curIndex].OnHide();
+            _lcukyBoxCtrl[LuckyBoxDataManager.Instance.currentBoxId].OnHide();
             _curIndex = _ui.m_listBg.ChildIndexToItemIndex(0);
             LuckyBoxDataManager.Instance.currentBoxId = LuckyBoxDataManager.Instance.luckyBoxIds[_curIndex];
+
             _bgIndex = 0;
             _valueBarController.UpdateCJ();
-            _lcukyBoxCtrl[_curIndex].OnShown(LuckyBoxDataManager.Instance.currentBoxId);
+            _lcukyBoxCtrl[LuckyBoxDataManager.Instance.currentBoxId].OnShown(LuckyBoxDataManager.Instance.currentBoxId);
             _ui.m_btnLeft.grayed = _curIndex <= 0;
             _ui.m_btnRight.grayed = _curIndex >= _ui.m_listBg.numItems - 1;
 
@@ -376,9 +376,9 @@ namespace GFGGame
         {
             base.OnHide();
             _valueBarController.OnHide();
-            for (int i = 0; i < _lcukyBoxCtrl.Count; i++)
+            foreach (int key in _lcukyBoxCtrl.Keys)
             {
-                _lcukyBoxCtrl[i].OnHide();
+                _lcukyBoxCtrl[key].OnHide();
             }
 
             Timers.inst.Remove(CheckTime);