| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220 | 
							- using FairyGUI;
 
- using UI.LuckyBox;
 
- using UI.CommonGame;
 
- using System;
 
- using System.Collections.Generic;
 
- using UnityEngine;
 
- using ET;
 
- namespace GFGGame
 
- {
 
-     public class LuckyBoxActivityView : BaseWindow
 
-     {
 
-         private UI_LuckyBoxActivityUI _ui;
 
-         private ValueBarController _valueBarController;
 
-         private LuckyBoxController _luckyBoxCtrl;
 
-         private ActivityOpenCfg _activityCfg;
 
-         private LuckyBoxCfg _luckyBoxCfg;
 
-         private int _activityId;
 
-         public override void Dispose()
 
-         {
 
-             if (_valueBarController != null)
 
-             {
 
-                 _valueBarController.Dispose();
 
-                 _valueBarController = null;
 
-             }
 
-             if (_luckyBoxCtrl != null)
 
-             {
 
-                 _luckyBoxCtrl.Dispose();
 
-                 _luckyBoxCtrl = null;
 
-             }
 
-             if (_ui != null)
 
-             {
 
-                 _ui.Dispose();
 
-                 _ui = null;
 
-             }
 
-             base.Dispose();
 
-         }
 
-         protected override void OnInit()
 
-         {
 
-             base.OnInit();
 
-             packageName = UI_LuckyBoxActivityUI.PACKAGE_NAME;
 
-             _ui = UI_LuckyBoxActivityUI.Create();
 
-             this.viewCom = _ui.target;
 
-             isfullScreen = true;
 
-             _valueBarController = new ValueBarController(_ui.m_valueBar);
 
-             _luckyBoxCtrl = new LuckyBoxController(_ui.m_comBox.m_comModel.target);
 
-             _ui.m_btnBack.onClick.Add(OnClickBtnBack);
 
-             _ui.m_btnReward.onClick.Add(OnClikcBtnReward);
 
-             _ui.m_btnShop.onClick.Add(OnClikcBtnShop);
 
-             _ui.m_btnGiftBag.onClick.Add(OnClikcBtnGiftBag);
 
-         }
 
-         protected override void AddEventListener()
 
-         {
 
-             base.AddEventListener();
 
-             EventAgent.AddEventListener(ConstMessage.ACTIVITY_LUCKY_BOX, UpdateView);
 
-         }
 
-         protected override void OnShown()
 
-         {
 
-             base.OnShown();
 
-             _activityId = (int)this.viewData;
 
-             _activityCfg = ActivityOpenCfgArray.Instance.GetCfg(_activityId);
 
-             _luckyBoxCfg = LuckyBoxCfgArray.Instance.GetCfg(_activityCfg.paramsArr[0]);
 
-             _valueBarController.OnShown();
 
-             _valueBarController.UpdateList(new List<int>() { _luckyBoxCfg.costID });
 
-             _luckyBoxCtrl.OnShown(_luckyBoxCfg.id);
 
-             UpdateView();
 
-             Timers.inst.Add(1, 0, UpdateTime);
 
-         }
 
-         private void UpdateTime(object param = null)
 
-         {
 
-             long endTime = TimeUtil.DateTimeToTimestamp(_activityCfg.endTime);
 
-             long curTime = TimeHelper.ServerNow();
 
-             if (endTime < curTime)
 
-             {
 
-                 PromptController.Instance.ShowFloatTextPrompt("活动已结束");
 
-                 Timers.inst.Remove(UpdateTime);
 
-                 OnClickBtnBack();
 
-                 return;
 
-             }
 
-             TimeUtil.FormattingTime(curTime, endTime, out int num, out string str);
 
-             _ui.m_txtTime.text = TimeUtil.FormattingTimeTo_DDHHmm(endTime - curTime);
 
-         }
 
-         private void UpdateView()
 
-         {
 
-             _ui.m_txtCount.SetVar("value", ActivityDataManager.Instance.lastCount.ToString()).FlushVars();
 
-             _ui.m_txtCount.SetVar("name", _activityCfg.themeName).FlushVars();
 
-             UI_ComBox_4 comBox = UI_ComBox_4.Proxy(_ui.m_comBox.target);
 
-             LuckyBoxDataManager.Instance.InitData(_luckyBoxCfg.id);
 
-             comBox.m_comModel.m_loaBg.url = ResPathUtil.GetBgImgPath(_luckyBoxCfg.resArr[0]);
 
-             comBox.m_btnPreview.m_c1.selectedIndex = 1;
 
-             LuckyBoxDataManager.Instance.GetOwnedCount(_luckyBoxCfg.id, 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(_luckyBoxCfg.numericType);
 
-             comBox.m_txtRemainTimes.text = string.Format("今日剩余次数:{0}", _luckyBoxCfg.maxCount - boughtCount);
 
-             comBox.m_comCostOne.m_txtCost.text = _luckyBoxCfg.costNum.ToString();
 
-             comBox.m_comCostOne.m_loaCost.url = ResPathUtil.GetCommonGameResPath(ItemCfgArray.Instance.GetCfg(_luckyBoxCfg.costID).res);
 
-             comBox.m_comCostTen.m_txtCost.text = _luckyBoxCfg.costNumTen.ToString();
 
-             comBox.m_comCostTen.m_loaCost.url = ResPathUtil.GetCommonGameResPath(ItemCfgArray.Instance.GetCfg(_luckyBoxCfg.costID).res);
 
-             if (comBox.m_btnBuyOne.target.data == null)
 
-             {
 
-                 comBox.m_btnBuyOne.target.onClick.Add(OnClickBtnBuyOne);
 
-             }
 
-             comBox.m_btnBuyOne.target.data = _luckyBoxCfg.id;
 
-             if (comBox.m_btnBuyTen.target.data == null)
 
-             {
 
-                 comBox.m_btnBuyTen.target.onClick.Add(OnClickBtnBuyTen);
 
-             }
 
-             comBox.m_btnBuyTen.target.data = _luckyBoxCfg.id;
 
-             if (comBox.m_btnPreview.target.data == null)
 
-             {
 
-                 comBox.m_btnPreview.target.onClick.Add(OnClickBtnPreview);
 
-             }
 
-             comBox.m_btnPreview.target.data = _luckyBoxCfg.id;
 
-             comBox.target.data = _luckyBoxCfg.id;
 
-             UI_ComBox_4.ProxyEnd();
 
-         }
 
-         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)
 
-         {
 
-             int boughtCount = GameGlobal.myNumericComponent.GetAsInt(_luckyBoxCfg.numericType);
 
-             if (boughtCount + LuckyBoxDataManager.ONCE_TIME > _luckyBoxCfg.maxCount)
 
-             {
 
-                 PromptController.Instance.ShowFloatTextPrompt("抽奖次数不足");
 
-                 return;
 
-             }
 
-             LuckyBoxDataManager.Instance.CheckItemEnough(_luckyBoxCfg.id, LuckyBoxDataManager.ONCE_TIME, async () =>
 
-              {
 
-                  bool result = await LuckyBoxSProxy.ReqGetBonus(_luckyBoxCfg.id, LuckyBoxDataManager.ONCE_TIME);
 
-                  if (result)
 
-                  {
 
-                      ViewManager.Show<LuckyBoxStarView>(null, new object[] { typeof(LuckyBoxActivityView).FullName, _activityId }, true);
 
-                      //  LogServerHelper.SendPlayParticipationLog((int)PlayParticipationEnum.ZAI_XING, 2);
 
-                  }
 
-              });
 
-         }
 
-         private void OnClickBtnBuyTen(EventContext context)
 
-         {
 
-             GObject obj = context.sender as GObject;
 
-             int boughtCount = GameGlobal.myNumericComponent.GetAsInt(_luckyBoxCfg.numericType);
 
-             if (boughtCount + LuckyBoxDataManager.TEN_TIME > _luckyBoxCfg.maxCount)
 
-             {
 
-                 PromptController.Instance.ShowFloatTextPrompt("抽奖次数不足");
 
-                 return;
 
-             }
 
-             LuckyBoxDataManager.Instance.CheckItemEnough(this._luckyBoxCfg.id, LuckyBoxDataManager.TEN_TIME, async () =>
 
-             {
 
-                 bool result = await LuckyBoxSProxy.ReqGetBonus(this._luckyBoxCfg.id, LuckyBoxDataManager.TEN_TIME);
 
-                 if (result)
 
-                 {
 
-                     ViewManager.Show<LuckyBoxStarView>(null, new object[] { typeof(LuckyBoxActivityView).FullName, _activityId }, true);
 
-                     // LogServerHelper.SendPlayParticipationLog((int)PlayParticipationEnum.ZAI_XING, 2);
 
-                 }
 
-             });
 
-         }
 
-         private void OnClikcBtnReward()
 
-         {
 
-             ViewManager.Show<ActivityThemeLuckyBoxBonusView>();
 
-         }
 
-         private void OnClikcBtnShop()
 
-         {
 
-         }
 
-         private void OnClikcBtnGiftBag()
 
-         {
 
-         }
 
-         protected override void OnHide()
 
-         {
 
-             base.OnHide();
 
-             _valueBarController.OnHide();
 
-             _luckyBoxCtrl.OnHide();
 
-             Timers.inst.Remove(UpdateTime);
 
-         }
 
-         protected override void RemoveEventListener()
 
-         {
 
-             base.RemoveEventListener();
 
-         }
 
-         private void OnClickBtnBack()
 
-         {
 
-             ViewManager.GoBackFrom(typeof(LuckyBoxActivityView).FullName);
 
-         }
 
-         protected override void UpdateToCheckGuide(object param)
 
-         {
 
-             if (!ViewManager.CheckIsTopView(this.viewCom)) return;
 
-         }
 
-         protected override void TryCompleteGuide()
 
-         {
 
-             base.TryCompleteGuide();
 
-         }
 
-     }
 
- }
 
 
  |