| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400 | 
							- using FairyGUI;
 
- using UI.LuckyBox;
 
- using UI.CommonGame;
 
- using System;
 
- using System.Collections.Generic;
 
- using UnityEngine;
 
- using ET;
 
- namespace GFGGame
 
- {
 
-     public class LuckyBoxView : BaseView
 
-     {
 
-         private UI_LuckyBoxUI _ui;
 
-         private ValueBarController _valueBarController;
 
-         private GameObject _gameObject;
 
-         private GoWrapper _wrapper;
 
-         private GameObject _gameObject1;
 
-         private GoWrapper _wrapper1;
 
-         private GameObject _gameObject2;
 
-         private GoWrapper _wrapper2;
 
-         private GameObject _gameObject3;
 
-         private GoWrapper _wrapper3;
 
-         private GameObject _gameObject4;
 
-         private GoWrapper _wrapper4;
 
-         private GameObject _gameObject5;
 
-         private GoWrapper _wrapper5;
 
-         private bool isActiveBoxOpen = false;
 
-         private int _bgIndex = 0;
 
-         // private int _boxId = 0;
 
-         private int _curIndex = 0;
 
-         public override void Dispose()
 
-         {
 
-             if (_valueBarController != null)
 
-             {
 
-                 _valueBarController.Dispose();
 
-                 _valueBarController = null;
 
-             }
 
-             SceneController.DestroyObjectFromView(_gameObject, _wrapper);
 
-             SceneController.DestroyObjectFromView(_gameObject1, _wrapper1);
 
-             SceneController.DestroyObjectFromView(_gameObject2, _wrapper2);
 
-             SceneController.DestroyObjectFromView(_gameObject3, _wrapper3);
 
-             if (_ui != null)
 
-             {
 
-                 _ui.Dispose();
 
-                 _ui = null;
 
-             }
 
-             base.Dispose();
 
-         }
 
-         protected override void OnInit()
 
-         {
 
-             base.OnInit();
 
-             packageName = UI_LuckyBoxUI.PACKAGE_NAME;
 
-             _ui = UI_LuckyBoxUI.Create();
 
-             this.viewCom = _ui.target;
 
-             isfullScreen = true;
 
-             // _ui.m_txtRemainTimes.visible = false;
 
-             _valueBarController = new ValueBarController(_ui.m_valueBar);
 
-             _ui.m_btnBack.onClick.Add(OnClickBtnBack);
 
-             _ui.m_btnHome.onClick.Add(OnClickBtnHome);
 
-             _ui.m_btnLeft.onClick.Add(OnBtnLeftClick);
 
-             _ui.m_btnRight.onClick.Add(OnBtnRightClick);
 
-             _ui.m_listBg.SetVirtual();
 
-             _ui.m_listBg.itemRenderer = RenderListBgItem;
 
-             _ui.m_listBg.itemProvider = GetListItemResource;
 
-             _ui.m_listBg.scrollPane.onScrollEnd.Add(OnListBgScroll);
 
-         }
 
-         protected override void AddEventListener()
 
-         {
 
-             base.AddEventListener();
 
-             EventAgent.AddEventListener(ConstMessage.ITEM_CHANGED, OnListBgScroll);
 
-             EventAgent.AddEventListener(ConstMessage.NUMERIC_CHANGE, OnListBgScroll);
 
-         }
 
-         protected override void OnShown()
 
-         {
 
-             base.OnShown();
 
-             if (GuideDataManager.IsGuideFinish(ConstGuideId.LUCKY_BOX) <= 0)
 
-             {
 
-                 GRoot.inst.touchable = false;
 
-             }
 
-             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;
 
-             isActiveBoxOpen = Array.IndexOf(LuckyBoxDataManager.Instance.luckyBoxIds, LuckyBoxDataManager.BOX_ID_1) >= 0;
 
-             if (isActiveBoxOpen)
 
-             {
 
-                 Timers.inst.Add(1, 0, CheckTime);
 
-             }
 
-             _valueBarController.OnShown();
 
-             _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;
 
-             OnListBgScroll();
 
-             updateBoxEffect();
 
-             Timers.inst.Add(8, 0, UpdateBg);
 
-             Timers.inst.AddUpdate(CheckGuide);
 
-         }
 
-         private string GetListItemResource(int index)
 
-         {
 
-             int boxId = LuckyBoxDataManager.Instance.luckyBoxIds[index];
 
-             return string.Format("UI://LuckyBox/ComBox_{0}", boxId);
 
-         }
 
-         private void RenderListBgItem(int index, GObject obj)
 
-         {
 
-             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.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)
 
-             {
 
-                 btnBuyOne.onClick.Add(OnClickBtnBuyOne);
 
-             }
 
-             btnBuyOne.data = boxId;
 
-             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;
 
-             obj.data = boxId;
 
-             if (boxId == 1)
 
-             {
 
-                 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;
 
-                 GGraph holder1 = (obj as GComponent).GetChild("holder1").asGraph;
 
-                 SuitCfg suitCfg = SuitCfgArray.Instance.GetCfg(201013);//羲和
 
-                 string resPath1 = ResPathUtil.GetDressUpAnimationPath(suitCfg.picRes);
 
-                 SceneController.AddObjectToView(_gameObject4, _wrapper4, holder, resPath1, out _gameObject4, out _wrapper4);
 
-                 SuitCfg suitCfg1 = SuitCfgArray.Instance.GetCfg(201006);//常曦
 
-                 string resPath2 = ResPathUtil.GetDressUpAnimationPath(suitCfg1.picRes);
 
-                 SceneController.AddObjectToView(_gameObject5, _wrapper5, holder1, resPath2, out _gameObject5, out _wrapper5);
 
-             }
 
-         }
 
-         // private void UpdateTime(object param)
 
-         // {
 
-         //     GTextField txtTime = _ui.m_listBg.GetChildAt(0).asCom.GetChild("txtTime").asTextField;
 
-         //     txtTime.text = TimeUtil.FormattingTime(LuckyBoxDataManager.Instance.startTime, LuckyBoxDataManager.Instance.startTime);
 
-         // }
 
-         private void UpdateBg(object param)
 
-         {
 
-             string[] resArr = LuckyBoxCfgArray.Instance.GetCfg(LuckyBoxDataManager.Instance.currentBoxId).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]);
 
-         }
 
-         private void OnBtnLeftClick()
 
-         {
 
-             _curIndex--;
 
-             _curIndex = Mathf.Max(0, _curIndex);
 
-             _ui.m_listBg.ScrollToView(_curIndex, true);
 
-             OnListBgScroll();
 
-         }
 
-         private void OnBtnRightClick()
 
-         {
 
-             _curIndex++;
 
-             _curIndex = Mathf.Min(_ui.m_listBg.numItems - 1, _curIndex);
 
-             _ui.m_listBg.ScrollToView(_curIndex, true);
 
-             OnListBgScroll();
 
-         }
 
-         private void OnListBgScroll()
 
-         {
 
-             _curIndex = _ui.m_listBg.ChildIndexToItemIndex(0);
 
-             LuckyBoxDataManager.Instance.currentBoxId = LuckyBoxDataManager.Instance.luckyBoxIds[_curIndex];
 
-             _bgIndex = 0;
 
-             _valueBarController.UpdateCJ();
 
-             _ui.m_btnLeft.grayed = _curIndex <= 0;
 
-             _ui.m_btnRight.grayed = _curIndex >= _ui.m_listBg.numItems - 1;
 
-             if (LuckyBoxDataManager.Instance.currentBoxId == LuckyBoxDataManager.BOX_ID_1)
 
-             {
 
-                 Timers.inst.Add(1, 0, CheckTime);
 
-             }
 
-             else
 
-             {
 
-                 Timers.inst.Remove(CheckTime);
 
-             }
 
-         }
 
-         private void CheckTime(object param = null)
 
-         {
 
-             long endTime = LuckyBoxDataManager.Instance.endTime;
 
-             long curTime = TimeHelper.ServerNow();
 
-             TimeUtil.FormattingTime(curTime, endTime, out int num, out string str);
 
-             _ui.m_listBg.GetChildAt(0).asCom.GetChild("txtTime").asTextField.text = string.Format("剩余{0}{1}", num, str);
 
-             // _ui.m_listBg.GetChildAt(0).asCom.GetChild("txtTimeStr").asTextField.text = string.Format("{0}", str);
 
-         }
 
-         private void updateBoxEffect()
 
-         {
 
-             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)
 
-         {
 
-             GObject obj = context.sender as GObject;
 
-             int boxId = (int)obj.data;
 
-             ViewManager.Show(ViewName.LUCKY_BOX_PRE_SHOW_VIEW, boxId);
 
-         }
 
-         private void OnClickBtnBuyOne(EventContext context)
 
-         {
 
-             GObject obj = context.sender as GObject;
 
-             int boxId = (int)obj.data;
 
-             LuckyBoxCfg luckyBoxCfg = LuckyBoxCfgArray.Instance.GetCfg(boxId);
 
-             int boughtCount = GameGlobal.myNumericComponent.GetAsInt(luckyBoxCfg.numericType);
 
-             if (boughtCount + LuckyBoxDataManager.ONCE_TIME > luckyBoxCfg.maxCount)
 
-             {
 
-                 PromptController.Instance.ShowFloatTextPrompt("抽奖次数不足");
 
-                 return;
 
-             }
 
-             LuckyBoxDataManager.Instance.CheckItemEnough(boxId, LuckyBoxDataManager.ONCE_TIME, async () =>
 
-              {
 
-                  bool result = await LuckyBoxSProxy.ReqGetBonus(boxId, LuckyBoxDataManager.ONCE_TIME);
 
-                  if (result)
 
-                  {
 
-                      ViewManager.Show(ViewName.LUCKY_BOX_STAR_VIEW, null, new object[] { ViewName.LUCKY_BOX_VIEW, boxId });
 
-                      LogServerHelper.SendNodeLog((int)PlayParticipationEnum.ZAI_XING, 2);
 
-                  }
 
-              });
 
-         }
 
-         private void OnClickBtnBuyTen(EventContext context)
 
-         {
 
-             GObject obj = context.sender as GObject;
 
-             int boxId = (int)obj.data;
 
-             LuckyBoxCfg luckyBoxCfg = LuckyBoxCfgArray.Instance.GetCfg(boxId);
 
-             int boughtCount = GameGlobal.myNumericComponent.GetAsInt(luckyBoxCfg.numericType);
 
-             if (boughtCount + LuckyBoxDataManager.TEN_TIME > luckyBoxCfg.maxCount)
 
-             {
 
-                 PromptController.Instance.ShowFloatTextPrompt("抽奖次数不足");
 
-                 return;
 
-             }
 
-             LuckyBoxDataManager.Instance.CheckItemEnough(boxId, LuckyBoxDataManager.TEN_TIME, async () =>
 
-             {
 
-                 bool result = await LuckyBoxSProxy.ReqGetBonus(boxId, LuckyBoxDataManager.TEN_TIME);
 
-                 if (result)
 
-                 {
 
-                     ViewManager.Show(ViewName.LUCKY_BOX_STAR_VIEW, null, new object[] { ViewName.LUCKY_BOX_VIEW, boxId });
 
-                     LogServerHelper.SendNodeLog((int)PlayParticipationEnum.ZAI_XING, 2);
 
-                 }
 
-             });
 
-         }
 
-         protected override void OnHide()
 
-         {
 
-             base.OnHide();
 
-             _valueBarController.OnHide();
 
-             Timers.inst.Remove(CheckTime);
 
-             Timers.inst.Remove(UpdateBg);
 
-             Timers.inst.Remove(CheckGuide);
 
-             // Timers.inst.Remove(UpdateTime);
 
-         }
 
-         protected override void RemoveEventListener()
 
-         {
 
-             base.RemoveEventListener();
 
-             EventAgent.RemoveEventListener(ConstMessage.ITEM_CHANGED, OnListBgScroll);
 
-             EventAgent.RemoveEventListener(ConstMessage.NUMERIC_CHANGE, OnListBgScroll);
 
-         }
 
-         private void OnClickBtnBack()
 
-         {
 
-             this.Hide();
 
-             Reset();
 
-             ViewManager.GoBackFrom(ViewName.LUCKY_BOX_VIEW);
 
-         }
 
-         private void OnClickBtnHome()
 
-         {
 
-             GameController.GoBackToMainView();
 
-             // Reset();
 
-         }
 
-         private void Reset()
 
-         {
 
-             LuckyBoxDataManager.Instance.currentBoxId = LuckyBoxDataManager.Instance.luckyBoxIds[0];
 
-         }
 
-         private void CheckGuide(object param)
 
-         {
 
-             if (GuideDataManager.IsGuideFinish(ConstGuideId.LUCKY_BOX) <= 0)
 
-             {
 
-                 GRoot.inst.touchable = true;
 
-                 UpdateToCheckGuide(null);
 
-             }
 
-             else
 
-             {
 
-                 Timers.inst.Remove(CheckGuide);
 
-             }
 
-         }
 
-         protected override void UpdateToCheckGuide(object param)
 
-         {
 
-             if (!ViewManager.CheckIsTopView(this.viewCom)) return;
 
-             GButton btnBuyTen = _ui.m_listBg.GetChildAt(0).asCom.GetChild("btnBuyTen").asButton;
 
-             GuideController.TryGuide(null, ConstGuideId.LUCKY_BOX, 1, "“摘星”里可以通过星辰的力量获得服饰。", -1, true, _ui.target.height - 600);
 
-             GuideController.TryGuide(btnBuyTen, ConstGuideId.LUCKY_BOX, 2, "点击摘取十次。");
 
-         }
 
-     }
 
- }
 
 
  |