zhaoyang 2 years ago
parent
commit
727e405b92

+ 5 - 2
GameClient/Assets/Game/HotUpdate/Views/Common/Controller/LuckyBoxController.cs

@@ -28,15 +28,16 @@ namespace GFGGame
             _comModel = UI_ComModel.Proxy(_com);
             _comModel = UI_ComModel.Proxy(_com);
             _curTime = _turnTime;
             _curTime = _turnTime;
             _luckyBoxCfg = LuckyBoxCfgArray.Instance.GetCfg(luckyBoxId);
             _luckyBoxCfg = LuckyBoxCfgArray.Instance.GetCfg(luckyBoxId);
-            _comModel.m_loaBg.url = ResPathUtil.GetBgImgPath(_luckyBoxCfg.resArr[0]);
+            _comModel.m_loaBg.url = ResPathUtil.GetBgImgPath(_luckyBoxCfg.resArr[_bgIndex]);
             if (_luckyBoxCfg.suitShowArr.Length > 0)
             if (_luckyBoxCfg.suitShowArr.Length > 0)
             {
             {
                 _dressUpObjUI.ResetSceneObj(100, false, false, null, false);
                 _dressUpObjUI.ResetSceneObj(100, false, false, null, false);
-                _dressUpObjUI.dressUpObj.PutOnSuitCfg(_luckyBoxCfg.suitShowArr[0][0], true, new int[] { ConstDressUpItemType.BEI_JING }, false, false);
+                _dressUpObjUI.dressUpObj.PutOnSuitCfg(_luckyBoxCfg.suitShowArr[_modelIndex][0], true, new int[] { ConstDressUpItemType.BEI_JING }, false, false);
                 _dressUpObjUI.UpdateWrapper(_comModel.m_holder);
                 _dressUpObjUI.UpdateWrapper(_comModel.m_holder);
             }
             }
             if (_luckyBoxCfg.resArr.Length > 1 || _luckyBoxCfg.suitShowArr.Length > 1)
             if (_luckyBoxCfg.resArr.Length > 1 || _luckyBoxCfg.suitShowArr.Length > 1)
             {
             {
+                Timers.inst.Remove(UpdateTime);
                 Timers.inst.Add(1, 0, UpdateTime);
                 Timers.inst.Add(1, 0, UpdateTime);
             }
             }
         }
         }
@@ -66,6 +67,8 @@ namespace GFGGame
         {
         {
             UI_ComModel.ProxyEnd();
             UI_ComModel.ProxyEnd();
             Timers.inst.Remove(UpdateTime);
             Timers.inst.Remove(UpdateTime);
+            _bgIndex = 0;
+            _modelIndex = 0;
         }
         }
 
 
         public void Dispose()
         public void Dispose()

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

@@ -12,6 +12,7 @@ namespace GFGGame
     {
     {
         private UI_LuckyBoxUI _ui;
         private UI_LuckyBoxUI _ui;
         private ValueBarController _valueBarController;
         private ValueBarController _valueBarController;
+        private List<LuckyBoxController> _lcukyBoxCtrl = new List<LuckyBoxController>();
 
 
         //private GameObject _gameObject;
         //private GameObject _gameObject;
         //private GoWrapper _wrapper;
         //private GoWrapper _wrapper;
@@ -42,6 +43,11 @@ namespace GFGGame
                 _valueBarController.Dispose();
                 _valueBarController.Dispose();
                 _valueBarController = null;
                 _valueBarController = null;
             }
             }
+            for (int i = 0; i < _lcukyBoxCtrl.Count; i++)
+            {
+                _lcukyBoxCtrl[i].Dispose();
+            }
+            _lcukyBoxCtrl.Clear();
             if (_dressUpObjUIXiHe != null)
             if (_dressUpObjUIXiHe != null)
             {
             {
                 _dressUpObjUIXiHe.Dispose();
                 _dressUpObjUIXiHe.Dispose();
@@ -52,6 +58,7 @@ namespace GFGGame
                 _dressUpObjUIChangXi.Dispose();
                 _dressUpObjUIChangXi.Dispose();
                 _dressUpObjUIChangXi = null;
                 _dressUpObjUIChangXi = null;
             }
             }
+
             //SceneController.DestroyObjectFromView(_gameObject, _wrapper);
             //SceneController.DestroyObjectFromView(_gameObject, _wrapper);
             //SceneController.DestroyObjectFromView(_gameObject1, _wrapper1);
             //SceneController.DestroyObjectFromView(_gameObject1, _wrapper1);
             //SceneController.DestroyObjectFromView(_gameObject2, _wrapper2);
             //SceneController.DestroyObjectFromView(_gameObject2, _wrapper2);
@@ -143,7 +150,7 @@ namespace GFGGame
 
 
             OnListBgScroll();
             OnListBgScroll();
             updateBoxEffect();
             updateBoxEffect();
-            Timers.inst.Add(8, 0, UpdateBg);
+            // Timers.inst.Add(8, 0, UpdateBg);
             Timers.inst.AddUpdate(CheckGuide);
             Timers.inst.AddUpdate(CheckGuide);
         }
         }
         private string GetListItemResource(int index)
         private string GetListItemResource(int index)
@@ -163,53 +170,42 @@ namespace GFGGame
             int boxId = LuckyBoxDataManager.Instance.luckyBoxIds[index];
             int boxId = LuckyBoxDataManager.Instance.luckyBoxIds[index];
             LuckyBoxCfg cfg = LuckyBoxCfgArray.Instance.GetCfg(boxId);
             LuckyBoxCfg cfg = LuckyBoxCfgArray.Instance.GetCfg(boxId);
             LuckyBoxDataManager.Instance.InitData(boxId);
             LuckyBoxDataManager.Instance.InitData(boxId);
-            GLoader loaBg = (obj as GComponent).GetChild("loaBg").asLoader;
-            loaBg.url = ResPathUtil.GetBgImgPath(cfg.resArr[0]);
-            GButton btnPreview = (obj as GComponent).GetChild("btnPreview").asButton;
-            btnPreview.GetController("c1").selectedIndex = boxId;
-            // GButton btnExchange = (obj as GComponent).GetChild("btnExchange").asButton;
-            // btnExchange.GetController("c1").selectedIndex = boxId;
-            GTextField txtOwned = (obj as GComponent).GetChild("txtOwned").asTextField;
+
+            UI_ComBox comBox = UI_ComBox.Proxy(obj);
+
+            if (_lcukyBoxCtrl.Count <= index)
+            {
+                _lcukyBoxCtrl.Add(new LuckyBoxController(comBox.m_comModel.target));
+                _lcukyBoxCtrl[index].OnShown(boxId);
+            }
+
+            comBox.m_btnPreview.m_c1.selectedIndex = boxId;
             LuckyBoxDataManager.Instance.GetOwnedCount(boxId, out int count, out int totalCount);
             LuckyBoxDataManager.Instance.GetOwnedCount(boxId, out int count, out int totalCount);
-            txtOwned.SetVar("v1", "" + count).FlushVars();
-            txtOwned.SetVar("v2", "" + totalCount).FlushVars();
-            GTextField txtRemainTimes = (obj as GComponent).GetChild("txtRemainTimes").asTextField;
+            comBox.m_txtOwned.SetVar("v1", "" + count).FlushVars();
+            comBox.m_txtOwned.SetVar("v2", "" + totalCount).FlushVars();
             int boughtCount = GameGlobal.myNumericComponent.GetAsInt(cfg.numericType);
             int boughtCount = GameGlobal.myNumericComponent.GetAsInt(cfg.numericType);
-            txtRemainTimes.text = string.Format("今日剩余次数:{0}", cfg.maxCount - boughtCount);
-
-            GTextField txtCost = (obj as GComponent).GetChild("comCostOne").asCom.GetChild("txtCost").asTextField;
-            txtCost.text = cfg.costNum.ToString();
-            GLoader loaCost = (obj as GComponent).GetChild("comCostOne").asCom.GetChild("loaCost").asLoader;
-            loaCost.url = ResPathUtil.GetCommonGameResPath(ItemCfgArray.Instance.GetCfg(cfg.costID).res);
-            GTextField txtCostTen = (obj as GComponent).GetChild("comCostTen").asCom.GetChild("txtCost").asTextField;
-            txtCostTen.text = cfg.costNumTen.ToString();
-            GLoader loaCostTen = (obj as GComponent).GetChild("comCostTen").asCom.GetChild("loaCost").asLoader;
-            loaCostTen.url = ResPathUtil.GetCommonGameResPath(ItemCfgArray.Instance.GetCfg(cfg.costID).res);
-
-            GButton btnBuyOne = (obj as GComponent).GetChild("btnBuyOne").asButton;
-            if (btnBuyOne.data == null)
+            comBox.m_txtRemainTimes.text = string.Format("今日剩余次数:{0}", cfg.maxCount - boughtCount);
+            comBox.m_comCostOne.m_txtCost.text = cfg.costNum.ToString();
+            comBox.m_comCostOne.m_loaCost.url = ResPathUtil.GetCommonGameResPath(ItemCfgArray.Instance.GetCfg(cfg.costID).res);
+            comBox.m_comCostTen.m_txtCost.text = cfg.costNumTen.ToString();
+            comBox.m_comCostTen.m_loaCost.url = ResPathUtil.GetCommonGameResPath(ItemCfgArray.Instance.GetCfg(cfg.costID).res);
+            if (comBox.m_btnBuyOne.target.data == null)
             {
             {
-                btnBuyOne.onClick.Add(OnClickBtnBuyOne);
+                comBox.m_btnBuyOne.target.onClick.Add(OnClickBtnBuyOne);
             }
             }
-            btnBuyOne.data = boxId;
+            comBox.m_btnBuyOne.target.data = boxId;
 
 
-            GButton btnBuyTen = (obj as GComponent).GetChild("btnBuyTen").asButton;
-            if (btnBuyTen.data == null)
+            if (comBox.m_btnBuyTen.target.data == null)
             {
             {
-                btnBuyTen.onClick.Add(OnClickBtnBuyTen);
+                comBox.m_btnBuyTen.target.onClick.Add(OnClickBtnBuyTen);
             }
             }
-            btnBuyTen.data = boxId;
-
-            // if (btnExchange.data == null)
-            // {
-            //     btnExchange.onClick.Add(OnClickBtnExChange);
-            // }
-            // btnExchange.data = boxId;
-            if (btnPreview.data == null)
+            comBox.m_btnBuyTen.target.data = boxId;
+
+            if (comBox.m_btnPreview.target.data == null)
             {
             {
-                btnPreview.onClick.Add(OnClickBtnPreview);
+                comBox.m_btnPreview.target.onClick.Add(OnClickBtnPreview);
             }
             }
-            btnPreview.data = boxId;
+            comBox.m_btnPreview.target.data = boxId;
 
 
             obj.data = boxId;
             obj.data = boxId;
 
 
@@ -218,70 +214,53 @@ namespace GFGGame
                 long endTime = LuckyBoxDataManager.Instance.endTime;
                 long endTime = LuckyBoxDataManager.Instance.endTime;
                 long curTime = TimeHelper.ServerNow();
                 long curTime = TimeHelper.ServerNow();
                 TimeUtil.FormattingTime(curTime, endTime, out int num, out string str);
                 TimeUtil.FormattingTime(curTime, endTime, out int num, out string str);
-                (obj as GComponent).GetChild("txtTime").asTextField.text = string.Format("剩余{0}{1}", num, str);
-
-                GGraph holder = (obj as GComponent).GetChild("holder").asGraph;
-                holder.visible = false;
-                if (cfg.suitShowArr.Length > 0)
-                {
-                    holder.visible = true;
-                    holder.SetXY(cfg.suitShowArr[0][1], cfg.suitShowArr[0][2]);
-                    _dressUpObjUIXiHe.ResetSceneObj(100, false, false, null, false);
-                    _dressUpObjUIXiHe.dressUpObj.PutOnSuitCfg(cfg.suitShowArr[0][0], true, null, false, false);
-                    _dressUpObjUIXiHe.UpdateWrapper(holder);
-                }
+                comBox.m_txtTime.text = string.Format("剩余{0}{1}", num, str);
+            }
 
 
+            UI_ComBox.ProxyEnd();
 
 
-                GGraph holder1 = (obj as GComponent).GetChild("holder1").asGraph;
-                holder1.visible = false;
-                if (cfg.suitShowArr.Length > 1)
-                {
-                    holder1.visible = true;
-                    holder1.SetXY(cfg.suitShowArr[1][1], cfg.suitShowArr[1][2]);
-                    _dressUpObjUIChangXi.ResetSceneObj(100, false, false, null, false);
-                    _dressUpObjUIChangXi.dressUpObj.PutOnSuitCfg(cfg.suitShowArr[1][0], true, null, false, false);
-                    _dressUpObjUIChangXi.UpdateWrapper(holder1);
-                }
-            }
         }
         }
 
 
-        private void UpdateBg(object param)
-        {
-            string[] resArr = LuckyBoxCfgArray.Instance.GetCfg(LuckyBoxDataManager.Instance.currentBoxId).resArr;
-            _bgIndex++;
-            if (_bgIndex >= resArr.Length) _bgIndex = 0;
-            GObject gObject = _ui.m_listBg.GetChildAt(0);
-            if (gObject == null) return;
-            GComponent item = gObject.asCom;
-            if (item.gameObjectName != "ComBox_2") return;
-            GLoader loaBg = item.GetChild("loaBg").asLoader;
-            loaBg.url = ResPathUtil.GetBgImgPath(resArr[_bgIndex]);
-        }
+        // private void UpdateBg(object param)
+        // {
+        //     string[] resArr = LuckyBoxCfgArray.Instance.GetCfg(LuckyBoxDataManager.Instance.currentBoxId).resArr;
+        //     _bgIndex++;
+        //     if (_bgIndex >= resArr.Length) _bgIndex = 0;
+        //     GObject gObject = _ui.m_listBg.GetChildAt(0);
+        //     if (gObject == null) return;
+        //     GComponent item = gObject.asCom;
+        //     if (item.gameObjectName != "ComBox_2") return;
+        //     GLoader loaBg = item.GetChild("loaBg").asLoader;
+        //     loaBg.url = ResPathUtil.GetBgImgPath(resArr[_bgIndex]);
+        // }
 
 
 
 
         private void OnBtnLeftClick()
         private void OnBtnLeftClick()
         {
         {
-            _curIndex--;
-            _curIndex = Mathf.Max(0, _curIndex);
-            _ui.m_listBg.ScrollToView(_curIndex, true);
-            OnListBgScroll();
+            int index = _curIndex - 1;
+            // _curIndex--;
+            index = Mathf.Max(0, index);
+            _ui.m_listBg.ScrollToView(index, true);
+            // OnListBgScroll();
         }
         }
 
 
         private void OnBtnRightClick()
         private void OnBtnRightClick()
         {
         {
-            _curIndex++;
-            _curIndex = Mathf.Min(_ui.m_listBg.numItems - 1, _curIndex);
-            _ui.m_listBg.ScrollToView(_curIndex, true);
-            OnListBgScroll();
+            int index = _curIndex + 1;
+            // _curIndex++;
+            index = Mathf.Min(_ui.m_listBg.numItems - 1, index);
+            _ui.m_listBg.ScrollToView(index, true);
+            // OnListBgScroll();
         }
         }
 
 
         private void OnListBgScroll()
         private void OnListBgScroll()
         {
         {
+            _lcukyBoxCtrl[_curIndex].OnHide();
             _curIndex = _ui.m_listBg.ChildIndexToItemIndex(0);
             _curIndex = _ui.m_listBg.ChildIndexToItemIndex(0);
             LuckyBoxDataManager.Instance.currentBoxId = LuckyBoxDataManager.Instance.luckyBoxIds[_curIndex];
             LuckyBoxDataManager.Instance.currentBoxId = LuckyBoxDataManager.Instance.luckyBoxIds[_curIndex];
             _bgIndex = 0;
             _bgIndex = 0;
             _valueBarController.UpdateCJ();
             _valueBarController.UpdateCJ();
-
+            _lcukyBoxCtrl[_curIndex].OnShown(LuckyBoxDataManager.Instance.currentBoxId);
             _ui.m_btnLeft.grayed = _curIndex <= 0;
             _ui.m_btnLeft.grayed = _curIndex <= 0;
             _ui.m_btnRight.grayed = _curIndex >= _ui.m_listBg.numItems - 1;
             _ui.m_btnRight.grayed = _curIndex >= _ui.m_listBg.numItems - 1;
 
 
@@ -390,9 +369,13 @@ namespace GFGGame
         {
         {
             base.OnHide();
             base.OnHide();
             _valueBarController.OnHide();
             _valueBarController.OnHide();
+            for (int i = 0; i < _lcukyBoxCtrl.Count; i++)
+            {
+                _lcukyBoxCtrl[i].OnHide();
+            }
 
 
             Timers.inst.Remove(CheckTime);
             Timers.inst.Remove(CheckTime);
-            Timers.inst.Remove(UpdateBg);
+            // Timers.inst.Remove(UpdateBg);
             Timers.inst.Remove(CheckGuide);
             Timers.inst.Remove(CheckGuide);
             // Timers.inst.Remove(UpdateTime);
             // Timers.inst.Remove(UpdateTime);
         }
         }