|
@@ -12,6 +12,7 @@ namespace GFGGame
|
|
|
{
|
|
|
private UI_LuckyBoxUI _ui;
|
|
|
private ValueBarController _valueBarController;
|
|
|
+ private List<LuckyBoxController> _lcukyBoxCtrl = new List<LuckyBoxController>();
|
|
|
|
|
|
//private GameObject _gameObject;
|
|
|
//private GoWrapper _wrapper;
|
|
@@ -42,6 +43,11 @@ namespace GFGGame
|
|
|
_valueBarController.Dispose();
|
|
|
_valueBarController = null;
|
|
|
}
|
|
|
+ for (int i = 0; i < _lcukyBoxCtrl.Count; i++)
|
|
|
+ {
|
|
|
+ _lcukyBoxCtrl[i].Dispose();
|
|
|
+ }
|
|
|
+ _lcukyBoxCtrl.Clear();
|
|
|
if (_dressUpObjUIXiHe != null)
|
|
|
{
|
|
|
_dressUpObjUIXiHe.Dispose();
|
|
@@ -52,6 +58,7 @@ namespace GFGGame
|
|
|
_dressUpObjUIChangXi.Dispose();
|
|
|
_dressUpObjUIChangXi = null;
|
|
|
}
|
|
|
+
|
|
|
//SceneController.DestroyObjectFromView(_gameObject, _wrapper);
|
|
|
//SceneController.DestroyObjectFromView(_gameObject1, _wrapper1);
|
|
|
//SceneController.DestroyObjectFromView(_gameObject2, _wrapper2);
|
|
@@ -88,7 +95,7 @@ namespace GFGGame
|
|
|
_ui.m_listBg.itemProvider = GetListItemResource;
|
|
|
_ui.m_listBg.scrollPane.onScrollEnd.Add(OnListBgScroll);
|
|
|
|
|
|
-
|
|
|
+ _ui.m_loaBg.url = ResPathUtil.GetBgImgPath("jingzhongh_bg");
|
|
|
}
|
|
|
protected override void AddEventListener()
|
|
|
{
|
|
@@ -104,24 +111,6 @@ namespace GFGGame
|
|
|
LuckyBoxDataManager.Instance.luckyBoxIds.Clear();
|
|
|
LuckyBoxDataManager.Instance.luckyBoxIds.Add(LuckyBoxDataManager.BOX_ID_2);
|
|
|
LuckyBoxDataManager.Instance.luckyBoxIds.Add(LuckyBoxDataManager.BOX_ID_3);
|
|
|
-
|
|
|
- int boxId = LuckyBoxDataManager.Instance.luckyBoxIds[0];
|
|
|
- if (this.viewData != null)
|
|
|
- {
|
|
|
- object[] datas = (this.viewData as object[]);
|
|
|
- if (datas != null && datas.Length > 1)
|
|
|
- {
|
|
|
- boxId = (int)datas[1];
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- boxId = (int)this.viewData;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- if (GuideDataManager.IsGuideFinish(ConstGuideId.LUCKY_BOX) <= 0) boxId = LuckyBoxDataManager.BOX_ID_2;
|
|
|
- LuckyBoxDataManager.Instance.currentBoxId = boxId;
|
|
|
-
|
|
|
_activeBoxId = 0;
|
|
|
int result = await LuckyBoxSProxy.ReqGetLuckyBoxRotatingInfo();
|
|
|
if (result > 0)
|
|
@@ -130,9 +119,27 @@ namespace GFGGame
|
|
|
_activeBoxId = rotatingLuckyBox.luckyBoxId;
|
|
|
LuckyBoxDataManager.Instance.endTime = TimeUtil.GetTimestamp(rotatingLuckyBox.endTime);
|
|
|
LuckyBoxDataManager.Instance.luckyBoxIds.Insert(0, _activeBoxId);
|
|
|
- Timers.inst.Add(1, 0, CheckTime);
|
|
|
}
|
|
|
|
|
|
+ int boxId = LuckyBoxDataManager.Instance.luckyBoxIds[0];
|
|
|
+ if (this.viewData != null)
|
|
|
+ {
|
|
|
+ // object[] datas = (this.viewData as object[]);
|
|
|
+ // if (datas != null && datas.Length > 1)
|
|
|
+ // {
|
|
|
+ // boxId = (int)datas[1];
|
|
|
+ // }
|
|
|
+ // else
|
|
|
+ // {
|
|
|
+ boxId = (int)this.viewData;
|
|
|
+ // }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (GuideDataManager.IsGuideFinish(ConstGuideId.LUCKY_BOX) <= 0) boxId = LuckyBoxDataManager.BOX_ID_2;
|
|
|
+ LuckyBoxDataManager.Instance.currentBoxId = boxId;
|
|
|
+
|
|
|
+ if (_activeBoxId > 0) Timers.inst.Add(1, 0, CheckTime);
|
|
|
+
|
|
|
_valueBarController.OnShown();
|
|
|
_valueBarController.Controller(4);
|
|
|
|
|
@@ -143,7 +150,7 @@ namespace GFGGame
|
|
|
|
|
|
OnListBgScroll();
|
|
|
updateBoxEffect();
|
|
|
- Timers.inst.Add(8, 0, UpdateBg);
|
|
|
+ // Timers.inst.Add(8, 0, UpdateBg);
|
|
|
Timers.inst.AddUpdate(CheckGuide);
|
|
|
}
|
|
|
private string GetListItemResource(int index)
|
|
@@ -163,53 +170,45 @@ namespace GFGGame
|
|
|
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;
|
|
|
+
|
|
|
+ UI_ComBox comBox = UI_ComBox.Proxy(obj);
|
|
|
+ comBox.m_comModel.m_loaBg.url = ResPathUtil.GetBgImgPath(cfg.resArr[_bgIndex]);
|
|
|
+ if (_lcukyBoxCtrl.Count <= index)
|
|
|
+ {
|
|
|
+ _lcukyBoxCtrl.Add(new LuckyBoxController(comBox.m_comModel.target));
|
|
|
+ if (_ui.m_listBg.ChildIndexToItemIndex(0) == index)
|
|
|
+ {
|
|
|
+ _lcukyBoxCtrl[index].OnShown(boxId);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ comBox.m_btnPreview.m_c1.selectedIndex = boxId;
|
|
|
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);
|
|
|
- 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;
|
|
|
|
|
@@ -218,71 +217,53 @@ namespace GFGGame
|
|
|
long endTime = LuckyBoxDataManager.Instance.endTime;
|
|
|
long curTime = TimeHelper.ServerNow();
|
|
|
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.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)
|
|
|
- {
|
|
|
- //羲和
|
|
|
- holder.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()
|
|
|
{
|
|
|
- _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()
|
|
|
{
|
|
|
- _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()
|
|
|
{
|
|
|
+ _lcukyBoxCtrl[_curIndex].OnHide();
|
|
|
_curIndex = _ui.m_listBg.ChildIndexToItemIndex(0);
|
|
|
LuckyBoxDataManager.Instance.currentBoxId = LuckyBoxDataManager.Instance.luckyBoxIds[_curIndex];
|
|
|
_bgIndex = 0;
|
|
|
_valueBarController.UpdateCJ();
|
|
|
-
|
|
|
+ _lcukyBoxCtrl[_curIndex].OnShown(LuckyBoxDataManager.Instance.currentBoxId);
|
|
|
_ui.m_btnLeft.grayed = _curIndex <= 0;
|
|
|
_ui.m_btnRight.grayed = _curIndex >= _ui.m_listBg.numItems - 1;
|
|
|
|
|
@@ -391,9 +372,13 @@ namespace GFGGame
|
|
|
{
|
|
|
base.OnHide();
|
|
|
_valueBarController.OnHide();
|
|
|
+ for (int i = 0; i < _lcukyBoxCtrl.Count; i++)
|
|
|
+ {
|
|
|
+ _lcukyBoxCtrl[i].OnHide();
|
|
|
+ }
|
|
|
|
|
|
Timers.inst.Remove(CheckTime);
|
|
|
- Timers.inst.Remove(UpdateBg);
|
|
|
+ // Timers.inst.Remove(UpdateBg);
|
|
|
Timers.inst.Remove(CheckGuide);
|
|
|
// Timers.inst.Remove(UpdateTime);
|
|
|
}
|