|
@@ -33,7 +33,6 @@ namespace GFGGame
|
|
|
|
|
|
private bool isActiveBoxOpen = false;
|
|
private bool isActiveBoxOpen = false;
|
|
private int _activeBoxId = 0;
|
|
private int _activeBoxId = 0;
|
|
- private int _bgIndex = 0;
|
|
|
|
private int _curIndex = 0;
|
|
private int _curIndex = 0;
|
|
|
|
|
|
public override void Dispose()
|
|
public override void Dispose()
|
|
@@ -85,17 +84,17 @@ namespace GFGGame
|
|
// _ui.m_txtRemainTimes.visible = false;
|
|
// _ui.m_txtRemainTimes.visible = false;
|
|
_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_btnLeft.onClick.Add(OnBtnLeftClick);
|
|
_ui.m_btnLeft.onClick.Add(OnBtnLeftClick);
|
|
_ui.m_btnRight.onClick.Add(OnBtnRightClick);
|
|
_ui.m_btnRight.onClick.Add(OnBtnRightClick);
|
|
|
|
|
|
- _ui.m_listBg.SetVirtual();
|
|
|
|
|
|
+ // _ui.m_listBg.SetVirtual();
|
|
_ui.m_listBg.itemRenderer = RenderListBgItem;
|
|
_ui.m_listBg.itemRenderer = RenderListBgItem;
|
|
- _ui.m_listBg.itemProvider = GetListItemResource;
|
|
|
|
|
|
+ // _ui.m_listBg.itemProvider = GetListItemResource;
|
|
_ui.m_listBg.scrollPane.onScrollEnd.Add(OnListBgScroll);
|
|
_ui.m_listBg.scrollPane.onScrollEnd.Add(OnListBgScroll);
|
|
|
|
|
|
- _ui.m_loaBg.url = ResPathUtil.GetBgImgPath("jingzhongh_bg");
|
|
|
|
|
|
+ _ui.m_loaBg.url = ResPathUtil.GetBgImgPath("zx_bg");
|
|
}
|
|
}
|
|
protected override void AddEventListener()
|
|
protected override void AddEventListener()
|
|
{
|
|
{
|
|
@@ -144,94 +143,30 @@ namespace GFGGame
|
|
|
|
|
|
Timers.inst.AddUpdate(CheckGuide);
|
|
Timers.inst.AddUpdate(CheckGuide);
|
|
}
|
|
}
|
|
- private string GetListItemResource(int index)
|
|
|
|
- {
|
|
|
|
- if (index == 0 && _activeBoxId > 0)
|
|
|
|
- {
|
|
|
|
- return "UI://LuckyBox/ComBox";
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- int boxId = LuckyBoxDataManager.Instance.luckyBoxIds[index];
|
|
|
|
- return string.Format("UI://LuckyBox/ComBox_{0}", boxId);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+ // private string GetListItemResource(int index)
|
|
|
|
+ // {
|
|
|
|
+ // if (index == 0 && _activeBoxId > 0)
|
|
|
|
+ // {
|
|
|
|
+ // return "UI://LuckyBox/ComBox";
|
|
|
|
+ // }
|
|
|
|
+ // else
|
|
|
|
+ // {
|
|
|
|
+ // int boxId = LuckyBoxDataManager.Instance.luckyBoxIds[index];
|
|
|
|
+ // return string.Format("UI://LuckyBox/ComBox_{0}", boxId);
|
|
|
|
+ // }
|
|
|
|
+ // }
|
|
private void RenderListBgItem(int index, GObject obj)
|
|
private void RenderListBgItem(int index, GObject obj)
|
|
{
|
|
{
|
|
int boxId = LuckyBoxDataManager.Instance.luckyBoxIds[index];
|
|
int boxId = LuckyBoxDataManager.Instance.luckyBoxIds[index];
|
|
- LuckyBoxCfg cfg = LuckyBoxCfgArray.Instance.GetCfg(boxId);
|
|
|
|
- LuckyBoxDataManager.Instance.InitData(boxId);
|
|
|
|
-
|
|
|
|
- UI_ComBox comBox = UI_ComBox.Proxy(obj);
|
|
|
|
- comBox.m_comModel.m_loaBg.url = ResPathUtil.GetBgImgPath(cfg.resArr[_bgIndex]);
|
|
|
|
- if (!_lcukyBoxCtrl.ContainsKey(boxId))
|
|
|
|
- {
|
|
|
|
- _lcukyBoxCtrl.Add(boxId, new LuckyBoxController(comBox.m_comModel.target));
|
|
|
|
- if (_ui.m_listBg.ChildIndexToItemIndex(0) == index)
|
|
|
|
- {
|
|
|
|
- _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();
|
|
|
|
- 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();
|
|
|
|
- comBox.m_comCostTen.m_loaCost.url = ResPathUtil.GetCommonGameResPath(ItemCfgArray.Instance.GetCfg(cfg.costID).res);
|
|
|
|
- if (comBox.m_btnBuyOne.target.data == null)
|
|
|
|
- {
|
|
|
|
- comBox.m_btnBuyOne.target.onClick.Add(OnClickBtnBuyOne);
|
|
|
|
- }
|
|
|
|
- comBox.m_btnBuyOne.target.data = boxId;
|
|
|
|
|
|
+ // LuckyBoxCfg cfg = LuckyBoxCfgArray.Instance.GetCfg(boxId);
|
|
|
|
+ // LuckyBoxDataManager.Instance.InitData(boxId);
|
|
|
|
|
|
- if (comBox.m_btnBuyTen.target.data == null)
|
|
|
|
- {
|
|
|
|
- comBox.m_btnBuyTen.target.onClick.Add(OnClickBtnBuyTen);
|
|
|
|
- }
|
|
|
|
- comBox.m_btnBuyTen.target.data = boxId;
|
|
|
|
|
|
+ // UI_ComBox1 comBox = UI_ComBox1.Proxy(obj);
|
|
|
|
|
|
- if (comBox.m_btnPreview.target.data == null)
|
|
|
|
- {
|
|
|
|
- comBox.m_btnPreview.target.onClick.Add(OnClickBtnPreview);
|
|
|
|
- }
|
|
|
|
- comBox.m_btnPreview.target.data = boxId;
|
|
|
|
-
|
|
|
|
- obj.data = boxId;
|
|
|
|
- // if (comBox.m_grpLuckyBox != null)
|
|
|
|
- // {
|
|
|
|
- // comBox.m_grpLuckyBox.visible = boxId == _activeBoxId;
|
|
|
|
- // }
|
|
|
|
- if (boxId == _activeBoxId)
|
|
|
|
- {
|
|
|
|
- long endTime = LuckyBoxDataManager.Instance.endTime;
|
|
|
|
- long curTime = TimeHelper.ServerNow();
|
|
|
|
- TimeUtil.FormattingTime(curTime, endTime, out int num, out string str);
|
|
|
|
- comBox.m_txtTime.text = string.Format("剩余{0}{1}", num, str);
|
|
|
|
- comBox.m_grpLuckyBox.visible = boxId == _activeBoxId;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- UI_ComBox.ProxyEnd();
|
|
|
|
|
|
|
|
|
|
+ // UI_ComBox1.ProxyEnd();
|
|
}
|
|
}
|
|
|
|
|
|
- // 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()
|
|
{
|
|
{
|
|
int index = _curIndex - 1;
|
|
int index = _curIndex - 1;
|
|
@@ -252,18 +187,82 @@ namespace GFGGame
|
|
|
|
|
|
private void OnListBgScroll()
|
|
private void OnListBgScroll()
|
|
{
|
|
{
|
|
- _lcukyBoxCtrl[LuckyBoxDataManager.Instance.currentBoxId].OnHide();
|
|
|
|
- _curIndex = _ui.m_listBg.ChildIndexToItemIndex(0);
|
|
|
|
|
|
+ if (_lcukyBoxCtrl.ContainsKey(LuckyBoxDataManager.Instance.currentBoxId)) _lcukyBoxCtrl[LuckyBoxDataManager.Instance.currentBoxId].OnHide();
|
|
|
|
+ _curIndex = _ui.m_listBg.GetFirstChildInView();
|
|
LuckyBoxDataManager.Instance.currentBoxId = LuckyBoxDataManager.Instance.luckyBoxIds[_curIndex];
|
|
LuckyBoxDataManager.Instance.currentBoxId = LuckyBoxDataManager.Instance.luckyBoxIds[_curIndex];
|
|
-
|
|
|
|
- _bgIndex = 0;
|
|
|
|
_valueBarController.UpdateCJ();
|
|
_valueBarController.UpdateCJ();
|
|
- _lcukyBoxCtrl[LuckyBoxDataManager.Instance.currentBoxId].OnShown(LuckyBoxDataManager.Instance.currentBoxId);
|
|
|
|
|
|
+ UpdateListItem();
|
|
_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;
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ private void UpdateListItem()
|
|
|
|
+ {
|
|
|
|
+ int boxId = LuckyBoxDataManager.Instance.luckyBoxIds[_curIndex];
|
|
|
|
+ LuckyBoxCfg cfg = LuckyBoxCfgArray.Instance.GetCfg(boxId);
|
|
|
|
+ LuckyBoxDataManager.Instance.InitData(boxId);
|
|
|
|
+
|
|
|
|
+ GObject obj = _ui.m_listBg.GetChildAt(_curIndex);
|
|
|
|
+ UI_ComBox1 comBox = UI_ComBox1.Proxy(obj);
|
|
|
|
+
|
|
|
|
+ if (!_lcukyBoxCtrl.ContainsKey(boxId))
|
|
|
|
+ {
|
|
|
|
+ _lcukyBoxCtrl.Add(boxId, new LuckyBoxController(comBox.m_comModel.target));
|
|
|
|
+ // if (_ui.m_listBg.ChildIndexToItemIndex(0) == _curIndex)
|
|
|
|
+ // {
|
|
|
|
+ // _lcukyBoxCtrl[boxId].OnShown(boxId);
|
|
|
|
+ // }
|
|
|
|
+ }
|
|
|
|
+ _lcukyBoxCtrl[LuckyBoxDataManager.Instance.currentBoxId].OnShown(LuckyBoxDataManager.Instance.currentBoxId);
|
|
|
|
+
|
|
|
|
+ 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);
|
|
|
|
+ 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.data == null)
|
|
|
|
+ {
|
|
|
|
+ comBox.m_btnBuyOne.onClick.Add(OnClickBtnBuyOne);
|
|
|
|
+ }
|
|
|
|
+ comBox.m_btnBuyOne.data = boxId;
|
|
|
|
+
|
|
|
|
+ if (comBox.m_btnBuyTen.data == null)
|
|
|
|
+ {
|
|
|
|
+ comBox.m_btnBuyTen.onClick.Add(OnClickBtnBuyTen);
|
|
|
|
+ }
|
|
|
|
+ comBox.m_btnBuyTen.data = boxId;
|
|
|
|
+
|
|
|
|
+ if (comBox.m_btnPreview.data == null)
|
|
|
|
+ {
|
|
|
|
+ comBox.m_btnPreview.onClick.Add(OnClickBtnPreview);
|
|
|
|
+ }
|
|
|
|
+ comBox.m_btnPreview.data = boxId;
|
|
|
|
+
|
|
|
|
+ obj.data = boxId;
|
|
|
|
+
|
|
|
|
+ comBox.m_grpTime.visible = boxId == _activeBoxId;
|
|
|
|
+ if (boxId == _activeBoxId)
|
|
|
|
+ {
|
|
|
|
+ long endTime = LuckyBoxDataManager.Instance.endTime;
|
|
|
|
+ long curTime = TimeHelper.ServerNow();
|
|
|
|
+ // TimeUtil.FormattingTime(curTime, endTime, out int num, out string str);
|
|
|
|
+ long time = endTime - curTime;
|
|
|
|
+ string strTime = time > TimeUtil.SECOND_PER_DAY * 100 ? TimeUtil.FormattingTimeTo_DDHHmm(time) : TimeUtil.FormattingTimeTo_HHmmss(time);
|
|
|
|
+ comBox.m_txtTime.text = string.Format("活动时间:剩余{0}", strTime);
|
|
|
|
+ comBox.m_loaTitle.url = "ui://LuckyBox/zx_title_1";
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ comBox.m_loaTitle.url = string.Format("ui://LuckyBox/zx_title_{0}", boxId);
|
|
|
|
+ }
|
|
|
|
+ UI_ComBox1.ProxyEnd();
|
|
|
|
+ }
|
|
private void CheckTime(object param = null)
|
|
private void CheckTime(object param = null)
|
|
{
|
|
{
|
|
if (LuckyBoxDataManager.Instance.currentBoxId != _activeBoxId) return;
|
|
if (LuckyBoxDataManager.Instance.currentBoxId != _activeBoxId) return;
|
|
@@ -275,34 +274,19 @@ namespace GFGGame
|
|
if (item == null) return;
|
|
if (item == null) return;
|
|
GObject textField = item.asCom.GetChild("txtTime");
|
|
GObject textField = item.asCom.GetChild("txtTime");
|
|
if (textField == null) return;
|
|
if (textField == null) return;
|
|
- textField.asTextField.text = string.Format("剩余{0}{1}", num, str);
|
|
|
|
|
|
+
|
|
|
|
+ long time = endTime - curTime;
|
|
|
|
+ string strTime = time > TimeUtil.SECOND_PER_DAY * 100 ? TimeUtil.FormattingTimeTo_DDHHmm(time) : TimeUtil.FormattingTimeTo_HHmmss(time);
|
|
|
|
+ textField.asTextField.text = string.Format("活动时间:剩余{0}", strTime);
|
|
}
|
|
}
|
|
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();
|
|
|
|
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- // private void OnClickBtnExChange(EventContext context)
|
|
|
|
- // {
|
|
|
|
- // 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();
|
|
|
|
- // }
|
|
|
|
|
|
+
|
|
private void OnClickBtnPreview(EventContext context)
|
|
private void OnClickBtnPreview(EventContext context)
|
|
{
|
|
{
|
|
GObject obj = context.sender as GObject;
|
|
GObject obj = context.sender as GObject;
|