|
@@ -23,7 +23,9 @@ namespace GFGGame
|
|
private GoWrapper _wrapper3;
|
|
private GoWrapper _wrapper3;
|
|
|
|
|
|
private bool isActiveBoxOpen = false;
|
|
private bool isActiveBoxOpen = false;
|
|
- private int bgIndex = 0;
|
|
|
|
|
|
+ private int _bgIndex = 0;
|
|
|
|
+ private int _boxId = 0;
|
|
|
|
+ private int _curIndex = 0;
|
|
|
|
|
|
public override void Dispose()
|
|
public override void Dispose()
|
|
{
|
|
{
|
|
@@ -57,24 +59,22 @@ namespace GFGGame
|
|
_valueBarController = new ValueBarController(_ui.m_valueBar);
|
|
_valueBarController = new ValueBarController(_ui.m_valueBar);
|
|
_ui.m_btnBack.onClick.Add(OnClickBtnBack);
|
|
_ui.m_btnBack.onClick.Add(OnClickBtnBack);
|
|
_ui.m_btnHome.onClick.Add(OnClickBtnHome);
|
|
_ui.m_btnHome.onClick.Add(OnClickBtnHome);
|
|
- _ui.m_btnBuyOne.target.onClick.Add(OnClickBtnBuyOne);
|
|
|
|
- _ui.m_btnBuyTen.target.onClick.Add(OnClickBtnBuyTen);
|
|
|
|
- _ui.m_btnPreview.target.onClick.Add(OnClickBtnPreview);
|
|
|
|
- _ui.m_btnExchange.target.onClick.Add(OnClickBtnExChange);
|
|
|
|
- _ui.m_btnLeft.onClick.Add(() => { onClickChange(-1); });
|
|
|
|
- _ui.m_btnRight.onClick.Add(() => { onClickChange(1); });
|
|
|
|
|
|
|
|
|
|
+ _ui.m_btnLeft.onClick.Add(OnBtnLeftClick);
|
|
|
|
+ _ui.m_btnRight.onClick.Add(OnBtnRightClick);
|
|
|
|
+
|
|
|
|
+ _ui.m_listBg.SetVirtual();
|
|
_ui.m_listBg.itemRenderer = RenderListBgItem;
|
|
_ui.m_listBg.itemRenderer = RenderListBgItem;
|
|
- _ui.m_c1.onChanged.Add(OnListBgScroll);//分页控制器
|
|
|
|
|
|
+ _ui.m_listBg.itemProvider = GetListItemResource;
|
|
|
|
+ _ui.m_listBg.scrollPane.onScrollEnd.Add(OnListBgScroll);
|
|
|
|
|
|
- // Reset();//初始默认值
|
|
|
|
}
|
|
}
|
|
protected override void AddEventListener()
|
|
protected override void AddEventListener()
|
|
{
|
|
{
|
|
base.AddEventListener();
|
|
base.AddEventListener();
|
|
|
|
|
|
- EventAgent.AddEventListener(ConstMessage.ITEM_CHANGED, UpdateNormal);
|
|
|
|
- EventAgent.AddEventListener(ConstMessage.NUMERIC_CHANGE, UpdateNormal);
|
|
|
|
|
|
+ EventAgent.AddEventListener(ConstMessage.ITEM_CHANGED, OnListBgScroll);
|
|
|
|
+ EventAgent.AddEventListener(ConstMessage.NUMERIC_CHANGE, OnListBgScroll);
|
|
}
|
|
}
|
|
protected override void OnShown()
|
|
protected override void OnShown()
|
|
{
|
|
{
|
|
@@ -94,15 +94,10 @@ namespace GFGGame
|
|
boxId = (int)this.viewData;
|
|
boxId = (int)this.viewData;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ _boxId = boxId;
|
|
|
|
+ LuckyBoxDataManager.Instance.currentBoxId = _boxId;
|
|
|
|
|
|
- LuckyBoxDataManager.Instance.currentBoxId = boxId;
|
|
|
|
isActiveBoxOpen = Array.IndexOf(LuckyBoxDataManager.Instance.luckyBoxIds, LuckyBoxDataManager.BOX_ID_1) >= 0;
|
|
isActiveBoxOpen = Array.IndexOf(LuckyBoxDataManager.Instance.luckyBoxIds, LuckyBoxDataManager.BOX_ID_1) >= 0;
|
|
- bgIndex = 0;
|
|
|
|
-
|
|
|
|
- int index = Array.IndexOf(LuckyBoxDataManager.Instance.luckyBoxIds, LuckyBoxDataManager.Instance.currentBoxId);
|
|
|
|
- _ui.m_listBg.numItems = LuckyBoxDataManager.Instance.luckyBoxIds.Length;
|
|
|
|
- _ui.m_listBg.ScrollToView(index);
|
|
|
|
- _ui.m_listBg.scrollPane.decelerationRate = 0.8f;
|
|
|
|
if (isActiveBoxOpen)
|
|
if (isActiveBoxOpen)
|
|
{
|
|
{
|
|
Timers.inst.Add(1, 0, CheckTime);
|
|
Timers.inst.Add(1, 0, CheckTime);
|
|
@@ -111,186 +106,224 @@ namespace GFGGame
|
|
_valueBarController.OnShown();
|
|
_valueBarController.OnShown();
|
|
_valueBarController.Controller(4);
|
|
_valueBarController.Controller(4);
|
|
|
|
|
|
|
|
+ _curIndex = Array.IndexOf(LuckyBoxDataManager.Instance.luckyBoxIds, boxId);
|
|
|
|
+ _ui.m_listBg.numItems = LuckyBoxDataManager.Instance.luckyBoxIds.Length;
|
|
|
|
+ _ui.m_listBg.ScrollToView(_curIndex);
|
|
|
|
+ _ui.m_listBg.scrollPane.decelerationRate = 0.8f;
|
|
|
|
|
|
- // onClickChange(0);
|
|
|
|
- // UpdateNormal();
|
|
|
|
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 void RenderListBgItem(int index, GObject obj)
|
|
|
|
|
|
+ private string GetListItemResource(int index)
|
|
{
|
|
{
|
|
- UI_ComListBgItem item = UI_ComListBgItem.Proxy(obj);
|
|
|
|
- int id = LuckyBoxDataManager.Instance.luckyBoxIds[index];
|
|
|
|
- LuckyBoxCfg cfg = LuckyBoxCfgArray.Instance.GetCfg(id);
|
|
|
|
-
|
|
|
|
- item.m_loaBg.url = ResPathUtil.GetBgImgPath(cfg.resArr[0]);
|
|
|
|
- item.target.data = id;
|
|
|
|
- UI_ComListBgItem.ProxyEnd();
|
|
|
|
|
|
+ int boxId = LuckyBoxDataManager.Instance.luckyBoxIds[index];
|
|
|
|
+ return string.Format("UI://LuckyBox/ComBox_{0}", boxId);
|
|
}
|
|
}
|
|
- private void CheckTime(object param = null)
|
|
|
|
|
|
+ private void RenderListBgItem(int index, GObject obj)
|
|
{
|
|
{
|
|
- if (!isActiveBoxOpen)
|
|
|
|
|
|
+ int boxId = LuckyBoxDataManager.Instance.luckyBoxIds[index];
|
|
|
|
+ LuckyBoxCfg cfg = LuckyBoxCfgArray.Instance.GetCfg(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;
|
|
|
|
+ int count = LuckyBoxDataManager.Instance.GetOwnedCount(boxId);
|
|
|
|
+ txtOwned.SetVar("v1", "" + count).FlushVars();
|
|
|
|
+ GTextField txtRemainTimes = (obj as GComponent).GetChild("txtRemainTimes").asTextField;
|
|
|
|
+ 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.costNum.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)
|
|
{
|
|
{
|
|
- //活动未开启
|
|
|
|
- LuckyBoxDataManager.Instance.currentBoxId = LuckyBoxDataManager.Instance.luckyBoxIds[0];
|
|
|
|
-
|
|
|
|
- Timers.inst.Remove(CheckTime);
|
|
|
|
- return;
|
|
|
|
|
|
+ btnBuyOne.onClick.Add(OnClickBtnBuyOne);
|
|
}
|
|
}
|
|
- int endTime = LuckyBoxDataManager.Instance.endTime;
|
|
|
|
- int curTime = TimeHelper.ServerNowSecs;
|
|
|
|
- TimeUtil.FormattingTime(curTime, endTime, out int num, out string str);
|
|
|
|
- UI_ComListBgItem.Proxy(_ui.m_listBg.GetChildAt(0)).m_txtTime.text = string.Format("{0}", num);
|
|
|
|
- UI_ComListBgItem.Proxy(_ui.m_listBg.GetChildAt(0)).m_txtTimeStr.text = string.Format("{0}", str);
|
|
|
|
- UI_ComListBgItem.ProxyEnd();
|
|
|
|
- }
|
|
|
|
- private void OnListBgScroll()
|
|
|
|
- {
|
|
|
|
- UI_ComListBgItem item = UI_ComListBgItem.Proxy(_ui.m_listBg.GetChildAt(_ui.m_c1.selectedIndex));
|
|
|
|
- LuckyBoxDataManager.Instance.currentBoxId = (int)item.target.data;// LuckyBoxDataManager.Instance.luckyBoxIds[_ui.m_c1.selectedIndex];
|
|
|
|
|
|
+ btnBuyOne.data = boxId;
|
|
|
|
|
|
- item.m_grpTime.visible = LuckyBoxDataManager.Instance.currentBoxId == LuckyBoxDataManager.BOX_ID_1;
|
|
|
|
- item.m_imgTitle.visible = LuckyBoxDataManager.Instance.currentBoxId == LuckyBoxDataManager.BOX_ID_1;
|
|
|
|
- item.m_holder.visible = isActiveBoxOpen && LuckyBoxDataManager.Instance.currentBoxId == LuckyBoxDataManager.BOX_ID_1;
|
|
|
|
- item.m_holder1.visible = isActiveBoxOpen && LuckyBoxDataManager.Instance.currentBoxId == LuckyBoxDataManager.BOX_ID_1;
|
|
|
|
- item.m_loaImg.visible = LuckyBoxDataManager.Instance.currentBoxId == LuckyBoxDataManager.BOX_ID_3;
|
|
|
|
|
|
+ GButton btnBuyTen = (obj as GComponent).GetChild("btnBuyTen").asButton;
|
|
|
|
+ if (btnBuyTen.data == null)
|
|
|
|
+ {
|
|
|
|
+ btnBuyTen.onClick.Add(OnClickBtnBuyTen);
|
|
|
|
+ }
|
|
|
|
+ btnBuyTen.data = boxId;
|
|
|
|
|
|
|
|
+ if (btnExchange.data == null)
|
|
|
|
+ {
|
|
|
|
+ btnExchange.onClick.Add(OnClickBtnExChange);
|
|
|
|
+ }
|
|
|
|
+ btnExchange.data = boxId;
|
|
|
|
+ if (btnPreview.data == null)
|
|
|
|
+ {
|
|
|
|
+ btnPreview.onClick.Add(OnClickBtnPreview);
|
|
|
|
+ }
|
|
|
|
+ btnPreview.data = boxId;
|
|
|
|
|
|
- onClickChange(0);
|
|
|
|
- UpdateNormal();
|
|
|
|
|
|
+ obj.data = boxId;
|
|
}
|
|
}
|
|
|
|
|
|
- private void UpdateNormal()
|
|
|
|
|
|
+ private void UpdateBg(object param)
|
|
{
|
|
{
|
|
- LuckyBoxCfg luckyBoxCfg = LuckyBoxCfgArray.Instance.GetCfg(LuckyBoxDataManager.Instance.currentBoxId);
|
|
|
|
- _valueBarController.UpdateCJ(LuckyBoxDataManager.Instance.currentBoxId);
|
|
|
|
-
|
|
|
|
- _ui.m_comCostOne.m_txtCost.text = luckyBoxCfg.costNum.ToString();
|
|
|
|
- _ui.m_comCostTen.m_txtCost.text = luckyBoxCfg.costNumTen.ToString();
|
|
|
|
- _ui.m_comCostOne.m_loaCost.url = ResPathUtil.GetCommonGameResPath(ItemCfgArray.Instance.GetCfg(luckyBoxCfg.costID).res);
|
|
|
|
- _ui.m_comCostTen.m_loaCost.url = ResPathUtil.GetCommonGameResPath(ItemCfgArray.Instance.GetCfg(luckyBoxCfg.costID).res);
|
|
|
|
|
|
+ string[] resArr = LuckyBoxCfgArray.Instance.GetCfg(_boxId).resArr;
|
|
|
|
+ _bgIndex++;
|
|
|
|
+ if (_bgIndex >= resArr.Length) _bgIndex = 0;
|
|
|
|
+ GLoader loaBg = _ui.m_listBg.GetChildAt(0).asCom.GetChild("loaBg").asLoader;
|
|
|
|
+ loaBg.url = ResPathUtil.GetBgImgPath(resArr[_bgIndex]);
|
|
|
|
+ }
|
|
|
|
|
|
- _ui.m_btnPreview.m_c1.selectedIndex = _ui.m_c1.selectedIndex;
|
|
|
|
- _ui.m_btnExchange.m_c1.selectedIndex = _ui.m_c1.selectedIndex;
|
|
|
|
|
|
|
|
- int count = LuckyBoxDataManager.Instance.GetOwnedCount();
|
|
|
|
- _ui.m_txtOwned.SetVar("v1", "" + count).FlushVars();
|
|
|
|
|
|
+ private void OnBtnLeftClick()
|
|
|
|
+ {
|
|
|
|
+ _curIndex--;
|
|
|
|
+ _curIndex = Mathf.Max(0, _curIndex);
|
|
|
|
+ _ui.m_listBg.ScrollToView(_curIndex, true);
|
|
|
|
+ OnListBgScroll();
|
|
|
|
+ }
|
|
|
|
|
|
- int boughtCount = GameGlobal.myNumericComponent.GetAsInt(luckyBoxCfg.numericType);
|
|
|
|
- _ui.m_txtRemainTimes.text = string.Format("今日剩余次数:{0}", luckyBoxCfg.maxCount - boughtCount);
|
|
|
|
|
|
+ private void OnBtnRightClick()
|
|
|
|
+ {
|
|
|
|
+ _curIndex++;
|
|
|
|
+ _curIndex = Mathf.Min(_ui.m_listBg.numItems - 1, _curIndex);
|
|
|
|
+ _ui.m_listBg.ScrollToView(_curIndex, true);
|
|
|
|
+ OnListBgScroll();
|
|
}
|
|
}
|
|
|
|
|
|
- private void onClickChange(int count)
|
|
|
|
|
|
+ private void OnListBgScroll()
|
|
{
|
|
{
|
|
- _ui.m_c1.selectedIndex = _ui.m_c1.selectedIndex + count;
|
|
|
|
- _ui.m_imgSpecial.visible = LuckyBoxDataManager.Instance.currentBoxId == LuckyBoxDataManager.BOX_ID_1;
|
|
|
|
- _ui.m_btnRight.visible = _ui.m_c1.selectedIndex != _ui.m_listBg.numItems - 1;
|
|
|
|
- _ui.m_btnLeft.visible = _ui.m_c1.selectedIndex != 0;
|
|
|
|
- _ui.m_btnBuyOne.m_holder.visible = LuckyBoxDataManager.Instance.currentBoxId == LuckyBoxDataManager.BOX_ID_1;
|
|
|
|
- _ui.m_btnBuyTen.m_holder.visible = LuckyBoxDataManager.Instance.currentBoxId == LuckyBoxDataManager.BOX_ID_1;
|
|
|
|
|
|
+ _curIndex = _ui.m_listBg.ChildIndexToItemIndex(0);
|
|
|
|
+ _boxId = LuckyBoxDataManager.Instance.luckyBoxIds[_curIndex];
|
|
|
|
+ _valueBarController.UpdateCJ(_boxId);
|
|
|
|
+ _bgIndex = 0;
|
|
|
|
+ LuckyBoxDataManager.Instance.currentBoxId = _boxId;
|
|
|
|
+
|
|
|
|
+ _ui.m_btnLeft.grayed = _curIndex <= 0;
|
|
|
|
+ _ui.m_btnRight.grayed = _curIndex >= _ui.m_listBg.numItems - 1;
|
|
|
|
+ if (_boxId == LuckyBoxDataManager.BOX_ID_1)
|
|
|
|
+ {
|
|
|
|
+ Timers.inst.Add(1, 0, CheckTime);
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ Timers.inst.Remove(CheckTime);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ private void CheckTime(object param = null)
|
|
|
|
+ {
|
|
|
|
+ int endTime = LuckyBoxDataManager.Instance.endTime;
|
|
|
|
+ int curTime = TimeHelper.ServerNowSecs;
|
|
|
|
+ TimeUtil.FormattingTime(curTime, endTime, out int num, out string str);
|
|
|
|
+ _ui.m_listBg.GetChildAt(0).asCom.GetChild("txtTime").asTextField.text = string.Format("{0}", num);
|
|
|
|
+ _ui.m_listBg.GetChildAt(0).asCom.GetChild("txtTimeStr").asTextField.text = string.Format("{0}", str);
|
|
|
|
+ }
|
|
private void updateBoxEffect()
|
|
private void updateBoxEffect()
|
|
{
|
|
{
|
|
if (isActiveBoxOpen)
|
|
if (isActiveBoxOpen)
|
|
{
|
|
{
|
|
- int index = Array.IndexOf(LuckyBoxDataManager.Instance.luckyBoxIds, LuckyBoxDataManager.BOX_ID_1);
|
|
|
|
- UI_ComListBgItem item = UI_ComListBgItem.Proxy(_ui.m_listBg.GetChildAt(index));
|
|
|
|
- string resPath = ResPathUtil.GetViewEffectPath("ui_cj", "ui_cj_bt");
|
|
|
|
- SceneController.AddObjectToView(_gameObject, _wrapper, item.m_holder, resPath, out _gameObject, out _wrapper);
|
|
|
|
- string resPath3 = ResPathUtil.GetDressUpAnimationPath("dz_jiyuet");
|
|
|
|
- SceneController.AddObjectToView(_gameObject3, _wrapper3, item.m_holder1, resPath3, out _gameObject3, out _wrapper3, 120);
|
|
|
|
-
|
|
|
|
- string resPath1 = ResPathUtil.GetViewEffectPath("ui_cj", "ui_cj_sl");
|
|
|
|
- SceneController.AddObjectToView(_gameObject1, _wrapper1, _ui.m_btnBuyOne.m_holder, resPath1, out _gameObject1, out _wrapper1);
|
|
|
|
- SceneController.AddObjectToView(_gameObject2, _wrapper2, _ui.m_btnBuyTen.m_holder, resPath1, out _gameObject2, out _wrapper2);
|
|
|
|
- UI_ComListBgItem.ProxyEnd();
|
|
|
|
|
|
+ // int index = Array.IndexOf(LuckyBoxDataManager.Instance.luckyBoxIds, LuckyBoxDataManager.BOX_ID_1);
|
|
|
|
+ // UI_ComListBgItem item = UI_ComListBgItem.Proxy(_ui.m_listBg.GetChildAt(index));
|
|
|
|
+ // string resPath = ResPathUtil.GetViewEffectPath("ui_cj", "ui_cj_bt");
|
|
|
|
+ // SceneController.AddObjectToView(_gameObject, _wrapper, item.m_holder, resPath, out _gameObject, out _wrapper);
|
|
|
|
+ // string resPath3 = ResPathUtil.GetDressUpAnimationPath("dz_jiyuet");
|
|
|
|
+ // SceneController.AddObjectToView(_gameObject3, _wrapper3, item.m_holder1, resPath3, out _gameObject3, out _wrapper3, 120);
|
|
|
|
+
|
|
|
|
+ // string resPath1 = ResPathUtil.GetViewEffectPath("ui_cj", "ui_cj_sl");
|
|
|
|
+ // SceneController.AddObjectToView(_gameObject1, _wrapper1, _ui.m_btnBuyOne.m_holder, resPath1, out _gameObject1, out _wrapper1);
|
|
|
|
+ // SceneController.AddObjectToView(_gameObject2, _wrapper2, _ui.m_btnBuyTen.m_holder, resPath1, out _gameObject2, out _wrapper2);
|
|
|
|
+ // UI_ComListBgItem.ProxyEnd();
|
|
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- private void OnClickBtnExChange()
|
|
|
|
|
|
+ private void OnClickBtnExChange(EventContext context)
|
|
{
|
|
{
|
|
- int storeId = LuckyBoxDataManager.Instance.currentBoxId == LuckyBoxDataManager.BOX_ID_1 ? ConstStoreId.LUCKY_BOX_ACTIVITY_STORE_ID : ConstStoreId.LUCKY_BOX_STORE_ID;
|
|
|
|
- ViewManager.Show(ViewName.CLOTHING_SHOP_VIEW, new object[] { storeId }, new object[] { ViewName.LUCKY_BOX_VIEW, LuckyBoxDataManager.Instance.currentBoxId });
|
|
|
|
|
|
+ GObject obj = context.sender as GObject;
|
|
|
|
+ int boxId = (int)obj.data;
|
|
|
|
+ int storeId = boxId == LuckyBoxDataManager.BOX_ID_1 ? ConstStoreId.LUCKY_BOX_ACTIVITY_STORE_ID : ConstStoreId.LUCKY_BOX_STORE_ID;
|
|
|
|
+ ViewManager.Show(ViewName.CLOTHING_SHOP_VIEW, new object[] { storeId }, new object[] { ViewName.LUCKY_BOX_VIEW, boxId });
|
|
this.Hide();
|
|
this.Hide();
|
|
}
|
|
}
|
|
- private void OnClickBtnPreview()
|
|
|
|
|
|
+ private void OnClickBtnPreview(EventContext context)
|
|
{
|
|
{
|
|
- ViewManager.Show(ViewName.LUCKY_BOX_PRE_SHOW_VIEW);
|
|
|
|
|
|
+ GObject obj = context.sender as GObject;
|
|
|
|
+ int boxId = (int)obj.data;
|
|
|
|
+ ViewManager.Show(ViewName.LUCKY_BOX_PRE_SHOW_VIEW, boxId);
|
|
}
|
|
}
|
|
- private void OnClickBtnBuyOne()
|
|
|
|
|
|
+ private void OnClickBtnBuyOne(EventContext context)
|
|
{
|
|
{
|
|
- LuckyBoxCfg luckyBoxCfg = LuckyBoxCfgArray.Instance.GetCfg(LuckyBoxDataManager.Instance.currentBoxId);
|
|
|
|
|
|
+ GObject obj = context.sender as GObject;
|
|
|
|
+ int boxId = (int)obj.data;
|
|
|
|
+ LuckyBoxCfg luckyBoxCfg = LuckyBoxCfgArray.Instance.GetCfg(boxId);
|
|
int boughtCount = GameGlobal.myNumericComponent.GetAsInt(luckyBoxCfg.numericType);
|
|
int boughtCount = GameGlobal.myNumericComponent.GetAsInt(luckyBoxCfg.numericType);
|
|
if (boughtCount + LuckyBoxDataManager.ONCE_TIME > luckyBoxCfg.maxCount)
|
|
if (boughtCount + LuckyBoxDataManager.ONCE_TIME > luckyBoxCfg.maxCount)
|
|
{
|
|
{
|
|
PromptController.Instance.ShowFloatTextPrompt("抽奖次数不足");
|
|
PromptController.Instance.ShowFloatTextPrompt("抽奖次数不足");
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
- LuckyBoxDataManager.Instance.CheckItemEnough(LuckyBoxDataManager.Instance.currentBoxId, LuckyBoxDataManager.ONCE_TIME, async () =>
|
|
|
|
|
|
+ LuckyBoxDataManager.Instance.CheckItemEnough(boxId, LuckyBoxDataManager.ONCE_TIME, async () =>
|
|
{
|
|
{
|
|
- bool result = await LuckyBoxSProxy.ReqGetBonus(LuckyBoxDataManager.Instance.currentBoxId, LuckyBoxDataManager.ONCE_TIME);
|
|
|
|
|
|
+ bool result = await LuckyBoxSProxy.ReqGetBonus(boxId, LuckyBoxDataManager.ONCE_TIME);
|
|
if (result)
|
|
if (result)
|
|
{
|
|
{
|
|
- ViewManager.Show(ViewName.LUCKY_BOX_STAR_VIEW, null, new object[] { ViewName.LUCKY_BOX_VIEW, LuckyBoxDataManager.Instance.currentBoxId });
|
|
|
|
|
|
+ ViewManager.Show(ViewName.LUCKY_BOX_STAR_VIEW, null, new object[] { ViewName.LUCKY_BOX_VIEW, boxId });
|
|
LogServerHelper.SendNodeLog((int)PlayParticipationEnum.ZAI_XING, 2);
|
|
LogServerHelper.SendNodeLog((int)PlayParticipationEnum.ZAI_XING, 2);
|
|
|
|
|
|
}
|
|
}
|
|
});
|
|
});
|
|
}
|
|
}
|
|
|
|
|
|
- private void OnClickBtnBuyTen()
|
|
|
|
|
|
+ private void OnClickBtnBuyTen(EventContext context)
|
|
{
|
|
{
|
|
- LuckyBoxCfg luckyBoxCfg = LuckyBoxCfgArray.Instance.GetCfg(LuckyBoxDataManager.Instance.currentBoxId);
|
|
|
|
|
|
+ GObject obj = context.sender as GObject;
|
|
|
|
+ int boxId = (int)obj.data;
|
|
|
|
+ LuckyBoxCfg luckyBoxCfg = LuckyBoxCfgArray.Instance.GetCfg(boxId);
|
|
int boughtCount = GameGlobal.myNumericComponent.GetAsInt(luckyBoxCfg.numericType);
|
|
int boughtCount = GameGlobal.myNumericComponent.GetAsInt(luckyBoxCfg.numericType);
|
|
if (boughtCount + LuckyBoxDataManager.TEN_TIME > luckyBoxCfg.maxCount)
|
|
if (boughtCount + LuckyBoxDataManager.TEN_TIME > luckyBoxCfg.maxCount)
|
|
{
|
|
{
|
|
PromptController.Instance.ShowFloatTextPrompt("抽奖次数不足");
|
|
PromptController.Instance.ShowFloatTextPrompt("抽奖次数不足");
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
- LuckyBoxDataManager.Instance.CheckItemEnough(LuckyBoxDataManager.Instance.currentBoxId, LuckyBoxDataManager.TEN_TIME, async () =>
|
|
|
|
|
|
+ LuckyBoxDataManager.Instance.CheckItemEnough(boxId, LuckyBoxDataManager.TEN_TIME, async () =>
|
|
{
|
|
{
|
|
- bool result = await LuckyBoxSProxy.ReqGetBonus(LuckyBoxDataManager.Instance.currentBoxId, LuckyBoxDataManager.TEN_TIME);
|
|
|
|
|
|
+ bool result = await LuckyBoxSProxy.ReqGetBonus(boxId, LuckyBoxDataManager.TEN_TIME);
|
|
if (result)
|
|
if (result)
|
|
{
|
|
{
|
|
|
|
|
|
- ViewManager.Show(ViewName.LUCKY_BOX_STAR_VIEW, null, new object[] { ViewName.LUCKY_BOX_VIEW, LuckyBoxDataManager.Instance.currentBoxId });
|
|
|
|
|
|
+ ViewManager.Show(ViewName.LUCKY_BOX_STAR_VIEW, null, new object[] { ViewName.LUCKY_BOX_VIEW, boxId });
|
|
LogServerHelper.SendNodeLog((int)PlayParticipationEnum.ZAI_XING, 2);
|
|
LogServerHelper.SendNodeLog((int)PlayParticipationEnum.ZAI_XING, 2);
|
|
|
|
|
|
}
|
|
}
|
|
});
|
|
});
|
|
}
|
|
}
|
|
|
|
|
|
- private void UpdateBg(object param)
|
|
|
|
- {
|
|
|
|
- int index = Array.IndexOf(LuckyBoxDataManager.Instance.luckyBoxIds, LuckyBoxDataManager.Instance.currentBoxId);
|
|
|
|
- UI_ComListBgItem item = UI_ComListBgItem.Proxy(_ui.m_listBg.GetChildAt(index));
|
|
|
|
- int id = (int)item.target.data;
|
|
|
|
- string[] resArr = LuckyBoxCfgArray.Instance.GetCfg(id).resArr;
|
|
|
|
- bgIndex++;
|
|
|
|
- if (bgIndex >= resArr.Length) bgIndex = 0;
|
|
|
|
- item.m_loaBg.url = ResPathUtil.GetBgImgPath(resArr[bgIndex]);
|
|
|
|
- UI_ComListBgItem.ProxyEnd();
|
|
|
|
- }
|
|
|
|
|
|
+
|
|
protected override void OnHide()
|
|
protected override void OnHide()
|
|
{
|
|
{
|
|
base.OnHide();
|
|
base.OnHide();
|
|
_valueBarController.OnHide();
|
|
_valueBarController.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);
|
|
}
|
|
}
|
|
protected override void RemoveEventListener()
|
|
protected override void RemoveEventListener()
|
|
{
|
|
{
|
|
base.RemoveEventListener();
|
|
base.RemoveEventListener();
|
|
- EventAgent.RemoveEventListener(ConstMessage.ITEM_CHANGED, UpdateNormal);
|
|
|
|
- EventAgent.RemoveEventListener(ConstMessage.NUMERIC_CHANGE, UpdateNormal);
|
|
|
|
|
|
+ EventAgent.RemoveEventListener(ConstMessage.ITEM_CHANGED, OnListBgScroll);
|
|
|
|
+ EventAgent.RemoveEventListener(ConstMessage.NUMERIC_CHANGE, OnListBgScroll);
|
|
}
|
|
}
|
|
private void OnClickBtnBack()
|
|
private void OnClickBtnBack()
|
|
{
|
|
{
|
|
@@ -307,7 +340,7 @@ namespace GFGGame
|
|
}
|
|
}
|
|
private void Reset()
|
|
private void Reset()
|
|
{
|
|
{
|
|
- LuckyBoxDataManager.Instance.currentBoxId = LuckyBoxDataManager.BOX_ID_1;
|
|
|
|
|
|
+ LuckyBoxDataManager.Instance.currentBoxId = LuckyBoxDataManager.Instance.luckyBoxIds[0];
|
|
|
|
|
|
}
|
|
}
|
|
private void CheckGuide(object param)
|
|
private void CheckGuide(object param)
|
|
@@ -326,7 +359,9 @@ namespace GFGGame
|
|
protected override void UpdateToCheckGuide(object param)
|
|
protected override void UpdateToCheckGuide(object param)
|
|
{
|
|
{
|
|
if (!ViewManager.CheckIsTopView(this.viewCom)) return;
|
|
if (!ViewManager.CheckIsTopView(this.viewCom)) return;
|
|
- GuideController.TryGuide(_ui.m_btnBuyTen.target, ConstGuideId.LUCKY_BOX, 3, "点击摘取十次。");
|
|
|
|
|
|
+ GButton btnBuyTen = _ui.m_listBg.GetChildAt(0).asCom.GetChild("btnBuyTen").asButton;
|
|
|
|
+
|
|
|
|
+ GuideController.TryGuide(btnBuyTen, ConstGuideId.LUCKY_BOX, 3, "点击摘取十次。");
|
|
|
|
|
|
GuideController.TryGuide(_ui.m_btnBack, ConstGuideId.FREEDOM_DRESS, 1, "获得一套完整的服装啦,马上去试穿一下。");
|
|
GuideController.TryGuide(_ui.m_btnBack, ConstGuideId.FREEDOM_DRESS, 1, "获得一套完整的服装啦,马上去试穿一下。");
|
|
}
|
|
}
|