using FairyGUI; using UI.LuckyBox; using UI.CommonGame; using System; using System.Collections.Generic; using UnityEngine; using ET; using System.Linq; namespace GFGGame { public class LuckyBoxView : BaseWindow { private UI_LuckyBoxUI _ui; private ValueBarController _valueBarController; private Dictionary _luckyBoxCtrl = new Dictionary(); private Dictionary _effectUIDic = new Dictionary(); private DressUpObjUI _dressUpObjUIXiHe; private DressUpObjUI _dressUpObjUIChangXi; private string activityEndTime = "[2024][2][2][00:00]"; Dictionary _listActivityBtnObj = new Dictionary(); private int _activeBoxId = 0; private int _curIndex = 0; private int _activityId = 0; private bool scrollTouch = true; //左右箭头点击等滑动完成后才可以再次点击 public override void Dispose() { // Clear Effect foreach (var v in _effectUIDic) { EffectUIPool.Recycle(v.Value); } _effectUIDic.Clear(); if (_valueBarController != null) { _valueBarController.Dispose(); _valueBarController = null; } foreach (int key in _luckyBoxCtrl.Keys) { _luckyBoxCtrl[key].Dispose(); } _luckyBoxCtrl.Clear(); if (_dressUpObjUIXiHe != null) { _dressUpObjUIXiHe.Dispose(); _dressUpObjUIXiHe = null; } if (_dressUpObjUIChangXi != null) { _dressUpObjUIChangXi.Dispose(); _dressUpObjUIChangXi = null; } 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; isReturnView = true; _dressUpObjUIXiHe = new DressUpObjUI("SceneDressUp"); _dressUpObjUIChangXi = new DressUpObjUI("SceneDressUp"); _valueBarController = new ValueBarController(_ui.m_valueBar); _ui.m_btnBack.onClick.Add(OnClickBtnBack); _ui.m_btnLeft.onClick.Add(OnBtnLeftClick); _ui.m_btnRight.onClick.Add(OnBtnRightClick); _ui.m_listBg.itemRenderer = RenderListBgItem; _ui.m_listBg.SetVirtualAndLoop(); //虚拟循环列表 _ui.m_listBg.scrollPane.onScrollEnd.Add(OnScrollEnd); _ui.m_loaBg.url = ResPathUtil.GetBgImgPath("zx_bg"); } protected override void AddEventListener() { base.AddEventListener(); EventAgent.AddEventListener(ConstMessage.ITEM_CHANGED, UpdateListItemData); EventAgent.AddEventListener(ConstMessage.NUMERIC_CHANGE, UpdateListItemData); EventAgent.AddEventListener(ConstMessage.LUCKY_BOX_FREE_TIME_CHANGED, UpdateFreeInfo); EventAgent.AddEventListener(ConstMessage.LUCKY_BOX_ACTIVITY_REWARD, UpdateBtnReward); EventAgent.AddEventListener(ConstMessage.ACTIVITY_LUCKY_BOX, UpdateBtnReward); } protected override void OnShown() { base.OnShown(); Debug.Log("OnShown:LuckyBoxView"); //防止引导检测之前触发点击事件 GRoot.inst.touchable = false; _valueBarController.OnShown(); _valueBarController.Controller(4); LuckyBoxDataManager.Instance.luckyBoxIds.Clear(); LuckyBoxDataManager.Instance.luckyBoxIds.Add(LuckyBoxDataManager.BOX_ID_2); LuckyBoxDataManager.Instance.luckyBoxIds.Add(LuckyBoxDataManager.BOX_ID_3); _activeBoxId = 0; _activityId = ActivityDataManager.Instance.GetCurOpenActiveByType(ConstLimitTimeActivityType.ActLimitTsy); //第一个活动可能为轮换活动 if (LuckyBoxDataManager.Instance.RotatingId > 0) { RotatingLuckyBoxCfg rotatingLuckyBox = RotatingLuckyBoxCfgArray.Instance.GetCfg(LuckyBoxDataManager.Instance.RotatingId); _activeBoxId = rotatingLuckyBox.luckyBoxId; LuckyBoxDataManager.Instance.endTime = TimeUtil.GetTimestamp(rotatingLuckyBox.endTime); LuckyBoxDataManager.Instance.luckyBoxIds.Insert(0, _activeBoxId); } int boxId = LuckyBoxDataManager.Instance.luckyBoxIds[0]; //默认跳转进来是第一个活动 if (this.viewData != null) { int index = (int)this.viewData; //传入的值为第几个活动,不是活动id boxId = LuckyBoxDataManager.Instance.luckyBoxIds[index - 1];//是1的时候,就使用轮换活动,不是1就是传入的固定活动 } //新手引导选中第一个活动 if (GuideDataManager.IsGuideFinish(ConstGuideId.LUCKY_BOX) <= 0) boxId = LuckyBoxDataManager.Instance.luckyBoxIds[0]; //第二个活动会有许愿活动出现 if (_activityId > 0 && boxId == LuckyBoxDataManager.BOX_ID_2) GetWishingPoolInfo(_activityId); LuckyBoxDataManager.Instance.currentBoxId = boxId; _curIndex = LuckyBoxDataManager.Instance.luckyBoxIds.IndexOf(boxId); LuckyBoxDataManager.Instance.luckyBoxIndex = _curIndex; _listActivityBtnObj.Clear(); _ui.m_listBg.numItems = LuckyBoxDataManager.Instance.luckyBoxIds.Count; _ui.m_listBg.ScrollToView(_curIndex); _ui.m_listBg.scrollPane.decelerationRate = 0.8f; OnListBgScroll(); bool actLimitTsyOpen = LuckyBoxDataManager.Instance.GetActLimitTsyOpen(); //时间倒计时 if (_activeBoxId > 0) Timers.inst.Add(1, 0, CheckTime); //第二个活动的倒计时 if (actLimitTsyOpen)// && LuckyBoxDataManager.Instance.currentBoxId == LuckyBoxDataManager.BOX_ID_2 Timers.inst.Add(1, 0, UpdateTime); //第二个活动的模拟活动倒计时 if (!actLimitTsyOpen && boxId == LuckyBoxDataManager.BOX_ID_2) Timers.inst.Add(1, 0, UpdateImitateTime); Timers.inst.AddUpdate(CheckGuide); } private void RenderListBgItem(int index, GObject obj) { int boxId = LuckyBoxDataManager.Instance.luckyBoxIds[index]; UI_ComBox1 comBox = UI_ComBox1.Proxy(obj); LuckyBoxCfg cfg = LuckyBoxCfgArray.Instance.GetCfg(boxId); LuckyBoxDataManager.Instance.InitData(boxId); if(!_listActivityBtnObj.ContainsKey(boxId)) _listActivityBtnObj.Add(boxId,obj); else _listActivityBtnObj[boxId] = obj; comBox.m_ImgUp.visible = index == 0; int activityId = ActivityDataManager.Instance.GetCurOpenActiveByType(ConstLimitTimeActivityType.ActLimitTsy); if (activityId > 0 && boxId == LuckyBoxDataManager.BOX_ID_2) { comBox.m_showActivityType.selectedIndex = 1; UpGiftBox(comBox); } else if (boxId == LuckyBoxDataManager.BOX_ID_2) { long endTime = TimeUtil.DateTimeToTimestamp(activityEndTime); if (endTime < TimeHelper.ServerNow()) comBox.m_showActivityType.selectedIndex = 0; else { comBox.m_showActivityType.selectedIndex = 2; long curTime = TimeHelper.ServerNow(); if (endTime >= curTime) comBox.m_txtHasTime.text = "剩余时间: " + TimeUtil.FormattingTimeTo_DDHHmm(endTime - curTime); } } else comBox.m_showActivityType.selectedIndex = 0; if (cfg.costNumfifty > 0) comBox.m_comLuckBoxBtn.m_btnNumberType.selectedIndex = 1; else comBox.m_comLuckBoxBtn.m_btnNumberType.selectedIndex = 0; if (_luckyBoxCtrl.ContainsKey(boxId)) { _luckyBoxCtrl[boxId].OnHide(); _luckyBoxCtrl[boxId].Dispose(); _luckyBoxCtrl.Remove(boxId); } _luckyBoxCtrl.Add(boxId, new LuckyBoxController(comBox.m_comModel.target)); //comBox.m_comLuckBoxBtn.m_holder.visible = boxId != LuckyBoxDataManager.BOX_ID_3; comBox.m_comLuckBoxBtn.m_comCostOne.m_txtCost.text = cfg.costNum.ToString(); comBox.m_comLuckBoxBtn.m_comCostOne.m_loaCost.url = ResPathUtil.GetCommonGameResPath(ItemCfgArray.Instance.GetCfg(cfg.costID).res); comBox.m_comLuckBoxBtn.m_comCostTen.m_txtCost.text = cfg.costNumTen.ToString(); comBox.m_comLuckBoxBtn.m_comCostTen.m_loaCost.url = ResPathUtil.GetCommonGameResPath(ItemCfgArray.Instance.GetCfg(cfg.costID).res); comBox.m_comLuckBoxBtn.m_comCostFifty.m_txtCost.text = cfg.costNumfifty.ToString(); comBox.m_comLuckBoxBtn.m_comCostFifty.m_loaCost.url = ResPathUtil.GetCommonGameResPath(ItemCfgArray.Instance.GetCfg(cfg.costID).res); if (comBox.m_comLuckBoxBtn.m_btnBuyOne.data == null) comBox.m_comLuckBoxBtn.m_btnBuyOne.onClick.Add(OnClickBtnBuyOne); comBox.m_comLuckBoxBtn.m_btnBuyOne.data = boxId; if (comBox.m_comLuckBoxBtn.m_btnBuyTen.data == null) { if (boxId != LuckyBoxDataManager.BOX_ID_3) { if (!_effectUIDic.ContainsKey("Button_Text_DianCang" + boxId)) _effectUIDic.Add("Button_Text_DianCang" + boxId, EffectUIPool.CreateEffectUI(comBox.m_comLuckBoxBtn.m_Special_eff, "ui_LuckyBox", "Button_Text_DianCang")); if(!_effectUIDic.ContainsKey("Button_public" + boxId)) _effectUIDic.Add("Button_public" + boxId, EffectUIPool.CreateEffectUI(comBox.m_comLuckBoxBtn.m_btnBuyTen_eff, "ui_LuckyBox", "Button_public")); } comBox.m_comLuckBoxBtn.m_btnBuyTen.onClick.Add(OnClickBtnBuyTen); } comBox.m_comLuckBoxBtn.m_btnBuyTen.data = boxId; if (comBox.m_comLuckBoxBtn.m_btnBuyFifty.data == null) comBox.m_comLuckBoxBtn.m_btnBuyFifty.onClick.Add(OnClickBtnBuyFifty); comBox.m_comLuckBoxBtn.m_btnBuyFifty.data = boxId; if (comBox.m_btnPreview.data == null) comBox.m_btnPreview.onClick.Add(OnClickBtnPreview); comBox.m_btnPreview.data = boxId; if (comBox.m_btnReward.data == null) { comBox.m_btnReward.onClick.Add(OnClikcBtnReward); comBox.m_btnShop.onClick.Add(OnClikcBtnShop); comBox.m_btnGiftBag.onClick.Add(OnClikcBtnGiftBag); } comBox.m_btnReward.data = boxId; obj.data = boxId; comBox.m_grpTime.visible = (boxId == _activeBoxId); if (boxId == _activeBoxId) { long endTime = LuckyBoxDataManager.Instance.endTime; long curTime = TimeHelper.ServerNow(); 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); } UI_ComBox1.ProxyEnd(); } private async void GetWishingPoolInfo(int activityId) { bool result = await LuckyBoxSProxy.ReqGetWishingPoolInfo(); if (result) { int index = LuckyBoxDataManager.Instance.KsActivityId.IndexOf(activityId); if (index < 0 || !LuckyBoxDataManager.Instance.VsStatus[index]) ViewManager.Show(ConstLimitTimeActivityType.ActLimitTsy); } } private void OnBtnLeftClick() { if (!scrollTouch) return; scrollTouch = false; int index = _curIndex - 1; _ui.m_listBg.ScrollToView(index, true); if (_activityId > 0 && index + 1 == LuckyBoxDataManager.BOX_ID_2) GetWishingPoolInfo(_activityId); } private void OnBtnRightClick() { if (!scrollTouch) return; scrollTouch = false; int index = _curIndex + 1; _ui.m_listBg.ScrollToView(index, true); if (_activityId > 0 && index + 1 == LuckyBoxDataManager.BOX_ID_2) GetWishingPoolInfo(_activityId); } private void OnScrollEnd() { scrollTouch = true; // 未更新滚动位置的时候,不更新,防止不停的播放渐入动画 int index = _ui.m_listBg.GetFirstChildInView(); if (index == _curIndex) { return; } OnListBgScroll(); } private void OnListBgScroll() { LuckyBoxController valueBox; _luckyBoxCtrl.TryGetValue(LuckyBoxDataManager.Instance.currentBoxId, out valueBox); if (valueBox != null) _luckyBoxCtrl[LuckyBoxDataManager.Instance.currentBoxId].OnHide(); _curIndex = _ui.m_listBg.GetFirstChildInView(); LuckyBoxDataManager.Instance.currentBoxId = LuckyBoxDataManager.Instance.luckyBoxIds[_curIndex]; if (LuckyBoxDataManager.Instance.currentBoxId == LuckyBoxDataManager.BOX_ID_3) { _valueBarController.Controller(3); } else { _valueBarController.Controller(4); } _valueBarController.UpdateCJ(); _luckyBoxCtrl[LuckyBoxDataManager.Instance.currentBoxId].OnShown(LuckyBoxDataManager.Instance.currentBoxId); LuckyBoxDataManager.Instance.luckyBoxIndex = _curIndex; UpdateFreeInfo(); UpdateListItemData(); } private void UpdateBtnReward() { if (_curIndex == 1) { GObject obj = _ui.m_listBg.GetChildAt(_curIndex); UI_ComBox1 comBox = UI_ComBox1.Proxy(obj); RedDotController.Instance.SetComRedDot(comBox.m_btnReward, RedDotDataManager.Instance.GetActLuckyBoxRewardRed(ConstLimitTimeActivityType.ActLimitTsy), "", -21, 18); comBox.m_txtCount.SetVar("value", ActivityDataManager.Instance.lastTsyDrawCount.ToString()).FlushVars(); UI_ComBox1.ProxyEnd(); } } private void OnClikcBtnReward() { ViewManager.Show(ConstLimitTimeActivityType.ActLimitTsy); } private void OnClikcBtnShop() { //ViewManager.Show(new object[] { ConstStoreTabId.STORE_GIFT_BAG, ConstStoreSubId.STORE_GIFT_BAG_TSY }); } //刷新摘星活动期间的数据 private void UpGiftBox(UI_ComBox1 comBox) { int boxId = LuckyBoxDataManager.Instance.luckyBoxIds[_curIndex]; LuckyBoxCfg cfg = LuckyBoxCfgArray.Instance.GetCfg(boxId); comBox.m_txtCount.SetVar("value", ActivityDataManager.Instance.lastTsyDrawCount.ToString()).FlushVars(); comBox.m_txtCount.SetVar("name", cfg.name).FlushVars(); int activityId = ActivityDataManager.Instance.GetCurOpenActiveByType(ConstLimitTimeActivityType.ActLimitTsy); var activityInfoByTypeList = ActivityGlobalDataManager.Instance.GetActivityInfoByTypeAndID(ActivityType.XSLB3, activityId); var list = activityInfoByTypeList.Where(a => a.EndTime > TimeInfo.Instance.ServerNow()).ToList(); if (list.Count == 0) { comBox.m_comBagTime.target.visible = false; comBox.m_btnGiftBag.visible = false; } else { bool isSoldOut = true; foreach (var activityInfo in list) { ActivityOpenCfg activityOpenCfg = ActivityOpenCfgArray.Instance.GetCfg(activityInfo.ActivityId); var paramsArr = activityOpenCfg.paramsArr; foreach (var shopCfgId in paramsArr) { var shopCfg = ShopCfgArray.Instance.GetCfg(shopCfgId); var remainBuyNum = shopCfg.maxBuyNum - ShopDataManager.Instance.GetGoodsBuyNumById(shopCfgId); //只要有一个商品还能购买,就不是售罄 if (remainBuyNum > 0) { isSoldOut = false; break; } } } if (isSoldOut) { comBox.m_comBagTime.target.visible = false; comBox.m_btnGiftBag.visible = false; } else { comBox.m_comBagTime.m_txtGiftBagTime.text = TimeUtil.GetTimeLeft(TimeInfo.Instance.ServerNow(), list[0].EndTime); comBox.m_comBagTime.target.visible = true; comBox.m_btnGiftBag.visible = true; } } UpdateBtnReward(); } //限时礼包按钮点击执行方法 private void OnClikcBtnGiftBag() { var activityInfoByTypeList = ActivityGlobalDataManager.Instance.GetActivityInfoByType(ActivityType.XSLB3); var list = activityInfoByTypeList .Where(a => a.EndTime > TimeInfo.Instance.ServerNow()).ToList(); if (list.Count == 0) PromptController.Instance.ShowFloatTextPrompt("活动已结束"); else ViewManager.Show(new object[] { ActivityType.XSLB3, this.viewData }); } private void UpdateListItemData() { int boxId = LuckyBoxDataManager.Instance.luckyBoxIds[_curIndex]; LuckyBoxCfg cfg = LuckyBoxCfgArray.Instance.GetCfg(boxId); GObject obj = _listActivityBtnObj[boxId]; UI_ComBox1 comBox = UI_ComBox1.Proxy(obj); 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_comLuckBoxBtn.m_txtRemainTimes.text = string.Format("今日剩余次数:{0}", cfg.maxCount - boughtCount); UI_ComBox1.ProxyEnd(); } private void CheckTime(object param = null) { if (LuckyBoxDataManager.Instance.currentBoxId != _activeBoxId) return; long endTime = LuckyBoxDataManager.Instance.endTime; long curTime = TimeHelper.ServerNow(); TimeUtil.FormattingTime(curTime, endTime, out int num, out string str); GObject item = _ui.m_listBg.GetChildAt(0); if (item == null) return; GObject textField = item.asCom.GetChild("txtTime"); if (textField == null) return; 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 UpdateImitateTime(object param = null) { GObject item = _ui.m_listBg.GetChildAt(1); GObject textField = item.asCom.GetChild("txtHasTime"); if (textField == null) return; long curTime = TimeHelper.ServerNow(); long endTime = TimeUtil.DateTimeToTimestamp(activityEndTime); if (endTime < curTime) { Timers.inst.Remove(UpdateImitateTime); endTime = curTime; } textField.asTextField.text = "剩余时间: " + TimeUtil.FormattingTimeTo_DDHHmm(endTime - curTime); } private void UpdateTime(object param = null) { GObject item = _ui.m_listBg.GetChildAt(1); if (item == null) return; GObject textField = item.asCom.GetChild("txtTsyTime"); if (textField == null) return; int activityId = ActivityDataManager.Instance.GetCurOpenActiveByType(ConstLimitTimeActivityType.ActLimitTsy); var activityCfg = ActivityOpenCfgArray.Instance.GetCfg(activityId); long endTime = 0; if (activityCfg != null) endTime = TimeUtil.DateTimeToTimestamp(activityCfg.endTime); long curTime = TimeHelper.ServerNow(); if (endTime < curTime) { PromptController.Instance.ShowFloatTextPrompt("活动已结束"); Timers.inst.Remove(UpdateTime); endTime = curTime; } TimeUtil.FormattingTime(curTime, endTime, out int num, out string str); textField.asTextField.text = "概率提升剩余: " + TimeUtil.FormattingTimeTo_DDHHmm(endTime - curTime); //=====限时礼包倒计时 //UpGiftBox(); //EventAgent.DispatchEvent(ConstMessage.LUCKY_BOX_TIME); //=====限时礼包倒计时END } private void OnClickBtnPreview(EventContext context) { GObject obj = context.sender as GObject; int boxId = (int)obj.data; ViewManager.Show(boxId); } private void OnClickBtnBuyOne(EventContext context) { GetSuitItemController.showSingle = true; GObject obj = context.sender as GObject; int boxId = (int)obj.data; LuckyBoxCfg luckyBoxCfg = LuckyBoxCfgArray.Instance.GetCfg(boxId); long freeTime = LuckyBoxDataManager.Instance.GetFreeTime(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 () => { int activityId = 0; if (boxId == LuckyBoxDataManager.BOX_ID_2) { activityId = ActivityDataManager.Instance.GetCurOpenActiveByType(ConstLimitTimeActivityType.ActLimitTsy); } bool freeType = (freeTime > 0 && freeTime < TimeHelper.ServerNow()); bool result = await LuckyBoxSProxy.ReqGetBonus(boxId, LuckyBoxDataManager.ONCE_TIME, freeType, activityId); if (result) { ViewManager.Show(); LogServerHelper.SendPlayParticipationLog((int)PlayParticipationEnum.ZAI_XING, 2); GetSuitItemController.showSingle = false; } }); } private void OnClickBtnBuyTen(EventContext context) { GetSuitItemController.showSingle = true; GuideCfg cfg = GuideCfgArray.Instance.GetCfg(ConstGuideId.LUCKY_BOX); if (GuideDataManager.IsGuideFinish(ConstGuideId.LUCKY_BOX) <= 0 && (GuideDataManager.currentGuideId == 0 || (GuideDataManager.currentGuideId == cfg.id && GuideDataManager.currentGuideIdIndex != 2))) { //防止点击太快,在引导开启前就被点击到,导致引导卡死 return; } 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 () => { int activityId = 0; if (boxId == LuckyBoxDataManager.BOX_ID_2) { activityId = ActivityDataManager.Instance.GetCurOpenActiveByType(ConstLimitTimeActivityType.ActLimitTsy); } bool result = await LuckyBoxSProxy.ReqGetBonus(boxId, LuckyBoxDataManager.TEN_TIME,false, activityId); if (result) { ViewManager.Show(); LogServerHelper.SendPlayParticipationLog((int)PlayParticipationEnum.ZAI_XING, 2); GetSuitItemController.showSingle = false; } }); } private void OnClickBtnBuyFifty(EventContext context) { GetSuitItemController.showSingle = true; 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.FIFTY_TIME > luckyBoxCfg.maxCount) { PromptController.Instance.ShowFloatTextPrompt("抽奖次数不足"); return; } LuckyBoxDataManager.Instance.CheckItemEnough(boxId, LuckyBoxDataManager.FIFTY_TIME, async () => { bool result = await LuckyBoxSProxy.ReqGetBonus(boxId, LuckyBoxDataManager.FIFTY_TIME, false, 0); if (result) { BonusController.TryShowBonusList(LuckyBoxDataManager.Instance.RewardList); LogServerHelper.SendPlayParticipationLog((int)PlayParticipationEnum.ZAI_XING, 3); GetSuitItemController.showSingle = false; } }); } protected override void OnHide() { base.OnHide(); GRoot.inst.touchable = true; _valueBarController.OnHide(); foreach (int key in _luckyBoxCtrl.Keys) { _luckyBoxCtrl[key].OnHide(); } Timers.inst.Remove(CheckTime); Timers.inst.Remove(UpdateTime); Timers.inst.Remove(UpdateImitateTime); Timers.inst.Remove(CheckGuide); Debug.Log("OnHide: LuckyBoxView"); } protected override void RemoveEventListener() { base.RemoveEventListener(); EventAgent.RemoveEventListener(ConstMessage.ITEM_CHANGED, UpdateListItemData); EventAgent.RemoveEventListener(ConstMessage.NUMERIC_CHANGE, UpdateListItemData); EventAgent.RemoveEventListener(ConstMessage.LUCKY_BOX_FREE_TIME_CHANGED, UpdateFreeInfo); EventAgent.RemoveEventListener(ConstMessage.LUCKY_BOX_ACTIVITY_REWARD, UpdateBtnReward); EventAgent.RemoveEventListener(ConstMessage.ACTIVITY_LUCKY_BOX, UpdateBtnReward); } private void OnClickBtnBack() { Reset(); ViewManager.GoBackFrom(typeof(LuckyBoxView).FullName); } private void Reset() { LuckyBoxDataManager.Instance.currentBoxId = LuckyBoxDataManager.Instance.luckyBoxIds[0]; } private void CheckGuide(object param) { GRoot.inst.touchable = true; if (GuideDataManager.IsGuideFinish(ConstGuideId.LUCKY_BOX) <= 0) UpdateToCheckGuide(null); else Timers.inst.Remove(CheckGuide); } protected override void UpdateToCheckGuide(object param) { if (!ViewManager.CheckIsTopView(this.viewCom)) return; if (_curIndex >= _ui.m_listBg.numItems) return; ET.Log.Error("UpdateToCheckGuide _curIndex of num =" + _curIndex); GObject gObject = _ui.m_listBg.GetChildAt(_curIndex); if (gObject == null) return; GButton btnBuyTen = gObject.asCom.GetChild("comLuckBoxBtn").asCom.GetChild("btnBuyTen").asButton; GuideController.TryGuide(null, ConstGuideId.LUCKY_BOX, 1, "“摘星”里可以通过星辰的力量获得服饰。", -1, true, _ui.target.height - 600); GuideController.TryGuide(btnBuyTen, ConstGuideId.LUCKY_BOX, 2, "点击摘取十次。"); GuideController.TryCompleteGuide( ConstGuideId.LUCKY_BOX, 2); } protected override void TryCompleteGuide() { base.TryCompleteGuide(); GuideCfg cfg = GuideCfgArray.Instance.GetCfg(ConstGuideId.LUCKY_BOX); GuideController.TryCompleteGuideIndex(ConstGuideId.LUCKY_BOX, 2); } private void UpdateFreeInfo() { int boxId = LuckyBoxDataManager.Instance.luckyBoxIds[_curIndex]; long freeTime = LuckyBoxDataManager.Instance.GetFreeTime(boxId); GObject obj = _listActivityBtnObj[boxId]; UI_ComBox1 comBox = UI_ComBox1.Proxy(obj); if (freeTime > 0) { long timeDifference = freeTime - TimeHelper.ServerNow(); if (freeTime > TimeHelper.ServerNow()) { comBox.m_comLuckBoxBtn.m_comCostOne.m_c1.selectedIndex = 0; comBox.m_comLuckBoxBtn.m_txtFreeTime.visible = true; string strFreeTime = TimeUtil.FormattingTimeTo_DDHHmm(timeDifference); comBox.m_comLuckBoxBtn.m_txtFreeTime.text = string.Format("{0}后免费", strFreeTime); } else { comBox.m_comLuckBoxBtn.m_comCostOne.m_c1.selectedIndex = 1; comBox.m_comLuckBoxBtn.m_txtFreeTime.visible = false; } } else { comBox.m_comLuckBoxBtn.m_comCostOne.m_c1.selectedIndex = 0; comBox.m_comLuckBoxBtn.m_txtFreeTime.visible = false; } RedDotController.Instance.SetComRedDot(comBox.m_comLuckBoxBtn.m_btnBuyOne, comBox.m_comLuckBoxBtn.m_comCostOne.m_c1.selectedIndex == 1, "", -29, 9); RedDotController.Instance.SetComRedDot(_ui.m_btnLeft, LuckyBoxDataManager.Instance.RedBtnLeft(_curIndex)); RedDotController.Instance.SetComRedDot(_ui.m_btnRight, LuckyBoxDataManager.Instance.RedBtnRight(_curIndex), "", -60, 70); UI_ComBox1.ProxyEnd(); } } }