|
@@ -88,8 +88,8 @@ namespace GFGGame
|
|
|
{
|
|
|
base.AddEventListener();
|
|
|
|
|
|
- EventAgent.AddEventListener(ConstMessage.ITEM_CHANGED, OnListBgScroll);
|
|
|
- EventAgent.AddEventListener(ConstMessage.NUMERIC_CHANGE, OnListBgScroll);
|
|
|
+ EventAgent.AddEventListener(ConstMessage.ITEM_CHANGED, UpdateListItemData);
|
|
|
+ EventAgent.AddEventListener(ConstMessage.NUMERIC_CHANGE, UpdateListItemData);
|
|
|
}
|
|
|
protected override void OnShown()
|
|
|
{
|
|
@@ -143,13 +143,14 @@ namespace GFGGame
|
|
|
private void OnBtnLeftClick()
|
|
|
{
|
|
|
int index = _curIndex - 1;
|
|
|
- index = Mathf.Max(0, index);
|
|
|
+ if (index < 0) return;
|
|
|
_ui.m_listBg.ScrollToView(index, true);
|
|
|
}
|
|
|
|
|
|
private void OnBtnRightClick()
|
|
|
{
|
|
|
int index = _curIndex + 1;
|
|
|
+ // if (index >= LuckyBoxDataManager.Instance.luckyBoxIds.Count) return;
|
|
|
index = Mathf.Min(_ui.m_listBg.numItems - 1, index);
|
|
|
_ui.m_listBg.ScrollToView(index, true);
|
|
|
}
|
|
@@ -187,9 +188,9 @@ namespace GFGGame
|
|
|
{
|
|
|
_lcukyBoxCtrl.Add(boxId, new LuckyBoxController(comBox.m_comModel.target));
|
|
|
}
|
|
|
+
|
|
|
_lcukyBoxCtrl[LuckyBoxDataManager.Instance.currentBoxId].OnShown(LuckyBoxDataManager.Instance.currentBoxId);
|
|
|
|
|
|
- LuckyBoxDataManager.Instance.GetOwnedCount(boxId, out int count, out int totalCount);
|
|
|
comBox.m_imgSpecial.visible = boxId != LuckyBoxDataManager.BOX_ID_3;
|
|
|
GGraph holder = comBox.m_btnBuyTen.GetChild("holder").asGraph;
|
|
|
holder.visible = boxId != LuckyBoxDataManager.BOX_ID_3;
|
|
@@ -200,10 +201,6 @@ namespace GFGGame
|
|
|
string resPath1 = ResPathUtil.GetViewEffectPath("ui_LuckyBox", "but_text_dc");
|
|
|
SceneController.AddObjectToView(_gameObject1, _wrapper1, comBox.m_holder, resPath1, out _gameObject1, out _wrapper1);
|
|
|
|
|
|
- comBox.m_txtOwned.SetVar("v1", "" + count).FlushVars();
|
|
|
- comBox.m_txtOwned.SetVar("v2", "" + totalCount).FlushVars();
|
|
|
- int boughtCount = GameGlobal.myNumericComponent.GetAsInt(cfg.numericType);
|
|
|
- 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();
|
|
@@ -244,6 +241,20 @@ namespace GFGGame
|
|
|
comBox.m_loaTitle.url = string.Format("ui://LuckyBox/zx_title_{0}", boxId);
|
|
|
}
|
|
|
UI_ComBox1.ProxyEnd();
|
|
|
+ UpdateListItemData();
|
|
|
+ }
|
|
|
+ private void UpdateListItemData()
|
|
|
+ {
|
|
|
+ int boxId = LuckyBoxDataManager.Instance.luckyBoxIds[_curIndex];
|
|
|
+ LuckyBoxCfg cfg = LuckyBoxCfgArray.Instance.GetCfg(boxId);
|
|
|
+ GObject obj = _ui.m_listBg.GetChildAt(_curIndex);
|
|
|
+ UI_ComBox1 comBox = UI_ComBox1.Proxy(obj);
|
|
|
+ LuckyBoxDataManager.Instance.GetOwnedCount(boxId, out int count, out int totalCount);
|
|
|
+ comBox.m_txtOwned.SetVar("v1", "" + count).FlushVars();
|
|
|
+ comBox.m_txtOwned.SetVar("v2", "" + totalCount).FlushVars();
|
|
|
+ int boughtCount = GameGlobal.myNumericComponent.GetAsInt(cfg.numericType);
|
|
|
+ comBox.m_txtRemainTimes.text = string.Format("今日剩余次数:{0}", cfg.maxCount - boughtCount);
|
|
|
+ UI_ComBox1.ProxyEnd();
|
|
|
}
|
|
|
|
|
|
private void UpdateEffect()
|
|
@@ -354,8 +365,8 @@ namespace GFGGame
|
|
|
protected override void RemoveEventListener()
|
|
|
{
|
|
|
base.RemoveEventListener();
|
|
|
- EventAgent.RemoveEventListener(ConstMessage.ITEM_CHANGED, OnListBgScroll);
|
|
|
- EventAgent.RemoveEventListener(ConstMessage.NUMERIC_CHANGE, OnListBgScroll);
|
|
|
+ EventAgent.RemoveEventListener(ConstMessage.ITEM_CHANGED, UpdateListItemData);
|
|
|
+ EventAgent.RemoveEventListener(ConstMessage.NUMERIC_CHANGE, UpdateListItemData);
|
|
|
}
|
|
|
|
|
|
private void OnClickBtnBack()
|