|
@@ -12,7 +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 Dictionary<int, LuckyBoxController> _lcukyBoxCtrl = new Dictionary<int, LuckyBoxController>();
|
|
|
|
|
|
//private GameObject _gameObject;
|
|
//private GameObject _gameObject;
|
|
//private GoWrapper _wrapper;
|
|
//private GoWrapper _wrapper;
|
|
@@ -43,9 +43,9 @@ namespace GFGGame
|
|
_valueBarController.Dispose();
|
|
_valueBarController.Dispose();
|
|
_valueBarController = null;
|
|
_valueBarController = null;
|
|
}
|
|
}
|
|
- for (int i = 0; i < _lcukyBoxCtrl.Count; i++)
|
|
|
|
|
|
+ foreach (int key in _lcukyBoxCtrl.Keys)
|
|
{
|
|
{
|
|
- _lcukyBoxCtrl[i].Dispose();
|
|
|
|
|
|
+ _lcukyBoxCtrl[key].Dispose();
|
|
}
|
|
}
|
|
_lcukyBoxCtrl.Clear();
|
|
_lcukyBoxCtrl.Clear();
|
|
if (_dressUpObjUIXiHe != null)
|
|
if (_dressUpObjUIXiHe != null)
|
|
@@ -104,7 +104,7 @@ namespace GFGGame
|
|
EventAgent.AddEventListener(ConstMessage.ITEM_CHANGED, OnListBgScroll);
|
|
EventAgent.AddEventListener(ConstMessage.ITEM_CHANGED, OnListBgScroll);
|
|
EventAgent.AddEventListener(ConstMessage.NUMERIC_CHANGE, OnListBgScroll);
|
|
EventAgent.AddEventListener(ConstMessage.NUMERIC_CHANGE, OnListBgScroll);
|
|
}
|
|
}
|
|
- protected override async void OnShown()
|
|
|
|
|
|
+ protected override void OnShown()
|
|
{
|
|
{
|
|
base.OnShown();
|
|
base.OnShown();
|
|
|
|
|
|
@@ -112,10 +112,9 @@ namespace GFGGame
|
|
LuckyBoxDataManager.Instance.luckyBoxIds.Add(LuckyBoxDataManager.BOX_ID_2);
|
|
LuckyBoxDataManager.Instance.luckyBoxIds.Add(LuckyBoxDataManager.BOX_ID_2);
|
|
LuckyBoxDataManager.Instance.luckyBoxIds.Add(LuckyBoxDataManager.BOX_ID_3);
|
|
LuckyBoxDataManager.Instance.luckyBoxIds.Add(LuckyBoxDataManager.BOX_ID_3);
|
|
_activeBoxId = 0;
|
|
_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;
|
|
_activeBoxId = rotatingLuckyBox.luckyBoxId;
|
|
LuckyBoxDataManager.Instance.endTime = TimeUtil.GetTimestamp(rotatingLuckyBox.endTime);
|
|
LuckyBoxDataManager.Instance.endTime = TimeUtil.GetTimestamp(rotatingLuckyBox.endTime);
|
|
LuckyBoxDataManager.Instance.luckyBoxIds.Insert(0, _activeBoxId);
|
|
LuckyBoxDataManager.Instance.luckyBoxIds.Insert(0, _activeBoxId);
|
|
@@ -173,15 +172,15 @@ namespace GFGGame
|
|
|
|
|
|
UI_ComBox comBox = UI_ComBox.Proxy(obj);
|
|
UI_ComBox comBox = UI_ComBox.Proxy(obj);
|
|
comBox.m_comModel.m_loaBg.url = ResPathUtil.GetBgImgPath(cfg.resArr[_bgIndex]);
|
|
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;
|
|
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);
|
|
comBox.m_txtOwned.SetVar("v1", "" + count).FlushVars();
|
|
comBox.m_txtOwned.SetVar("v1", "" + count).FlushVars();
|
|
@@ -262,12 +261,13 @@ namespace GFGGame
|
|
|
|
|
|
private void OnListBgScroll()
|
|
private void OnListBgScroll()
|
|
{
|
|
{
|
|
- _lcukyBoxCtrl[_curIndex].OnHide();
|
|
|
|
|
|
+ _lcukyBoxCtrl[LuckyBoxDataManager.Instance.currentBoxId].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);
|
|
|
|
|
|
+ _lcukyBoxCtrl[LuckyBoxDataManager.Instance.currentBoxId].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;
|
|
|
|
|
|
@@ -376,9 +376,9 @@ namespace GFGGame
|
|
{
|
|
{
|
|
base.OnHide();
|
|
base.OnHide();
|
|
_valueBarController.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);
|
|
Timers.inst.Remove(CheckTime);
|