| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665 | 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 : BaseView    {        private UI_LuckyBoxUI _ui;        private ValueBarController _valueBarController;        private Dictionary<int, LuckyBoxController> _lcukyBoxCtrl = new Dictionary<int, LuckyBoxController>();        private EffectUI _effectUI1;        private EffectUI _effectUI2;        private DressUpObjUI _dressUpObjUIXiHe;        private DressUpObjUI _dressUpObjUIChangXi;        private bool isActiveBoxOpen = false;        private int _activeBoxId = 0;        private int _curIndex = 0;        private int _activityId = 0;        public override void Dispose()        {            EffectUIPool.Recycle(_effectUI1);            _effectUI1 = null;            if (_valueBarController != null)            {                _valueBarController.Dispose();                _valueBarController = null;            }            foreach (int key in _lcukyBoxCtrl.Keys)            {                _lcukyBoxCtrl[key].Dispose();            }            _lcukyBoxCtrl.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");            // _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);            _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");            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[1];            if (this.viewData != null)            {                boxId = (int)this.viewData;            }            if (GuideDataManager.IsGuideFinish(ConstGuideId.LUCKY_BOX) <= 0)                 boxId = LuckyBoxDataManager.BOX_ID_1;            if (_activityId > 0 && boxId == LuckyBoxDataManager.BOX_ID_2)                GetWishingPoolInfo(_activityId);            LuckyBoxDataManager.Instance.currentBoxId = boxId;            if (_activeBoxId > 0 || boxId == LuckyBoxDataManager.BOX_ID_2) Timers.inst.Add(1, 0, CheckTime);            _valueBarController.OnShown();            _valueBarController.Controller(4);            _curIndex = LuckyBoxDataManager.Instance.luckyBoxIds.IndexOf(boxId);            _ui.m_listBg.numItems = LuckyBoxDataManager.Instance.luckyBoxIds.Count;            _ui.m_listBg.ScrollToView(_curIndex);            _ui.m_listBg.scrollPane.decelerationRate = 0.8f;            LuckyBoxDataManager.Instance.luckyBoxIndex = _curIndex;            OnListBgScroll();            updateBoxEffect();            Timers.inst.AddUpdate(CheckGuide);            Timers.inst.Add(1f, 0, OnTimerUpdate, 1);        }        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<LuckyBoxWishView>(ConstLimitTimeActivityType.ActLimitTsy);            }        }        private void OnTimerUpdate(object param)        {            int boxId = LuckyBoxDataManager.Instance.luckyBoxIds[_curIndex];            long freeTime = LuckyBoxDataManager.Instance.GetFreeTime(boxId);            GObject obj = _ui.m_listBg.GetChildAt(_curIndex);            UI_ComBox1 comBox = UI_ComBox1.Proxy(obj);            if (freeTime > 0)            {                long timeDifference = freeTime - TimeHelper.ServerNow();                if (timeDifference > 0)                {                    comBox.m_comLuckBoxBtn.m_comCostOne.m_c1.selectedIndex = 0;                    comBox.m_comLuckBoxBtn.m_txtFreeTime.visible = true;                    string strFreeTime = TimeUtil.FormattingTimeTo_HHmmss(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;                }                RedDotController.Instance.SetComRedDot(comBox.m_comLuckBoxBtn.m_btnBuyOne, comBox.m_comLuckBoxBtn.m_comCostOne.m_c1.selectedIndex == 1);            }            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();        }        private void RenderListBgItem(int index, GObject obj)        {            int boxId = LuckyBoxDataManager.Instance.luckyBoxIds[index];        }        private void OnBtnLeftClick()        {            int index = _curIndex - 1;            if (index < 0) return;            _ui.m_listBg.ScrollToView(index, true);            if (_activityId > 0 && _curIndex == LuckyBoxDataManager.BOX_ID_2)                GetWishingPoolInfo(_activityId);        }        private void OnBtnRightClick()        {            int index = _curIndex + 1;            // if (index >= LuckyBoxDataManager.Instance.luckyBoxIds.Count) return;            index = Mathf.Min(_ui.m_listBg.numItems - 1, index);            _ui.m_listBg.ScrollToView(index, true);            if (_activityId > 0 && _curIndex == LuckyBoxDataManager.BOX_ID_2)                GetWishingPoolInfo(_activityId);        }        private void OnListBgScroll()        {            if (_lcukyBoxCtrl.ContainsKey(LuckyBoxDataManager.Instance.currentBoxId)) _lcukyBoxCtrl[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();            UpdateListItem();            _ui.m_btnLeft.grayed = _curIndex <= 0;            _ui.m_btnRight.grayed = _curIndex >= _ui.m_listBg.numItems - 1;            LuckyBoxDataManager.Instance.luckyBoxIndex = _curIndex;        }        List<GObject> _listActivityBtnObj = new List<GObject>();        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);            _listActivityBtnObj.Add(obj);            int activityId = ActivityDataManager.Instance.GetCurOpenActiveByType(ConstLimitTimeActivityType.ActLimitTsy);            if (activityId > 0 && boxId == LuckyBoxDataManager.BOX_ID_2)            {                comBox.m_showActivityType.selectedIndex = 1;                UpGiftBox(comBox);            }            else                 comBox.m_showActivityType.selectedIndex = 0;            if (!_lcukyBoxCtrl.ContainsKey(boxId))            {                _lcukyBoxCtrl.Add(boxId, new LuckyBoxController(comBox.m_comModel.target));            }            _lcukyBoxCtrl[LuckyBoxDataManager.Instance.currentBoxId].OnShown(LuckyBoxDataManager.Instance.currentBoxId);            comBox.m_comLuckBoxBtn.m_imgSpecial.visible = boxId != LuckyBoxDataManager.BOX_ID_3;            //GGraph holder = comBox.m_comLuckBoxBtn.m_btnBuyTen.GetChild("holder").asGraph;            //holder.visible = boxId != LuckyBoxDataManager.BOX_ID_3;            comBox.m_comLuckBoxBtn.m_holder.visible = boxId != LuckyBoxDataManager.BOX_ID_3;            if (_effectUI2 != null) {                EffectUIPool.Recycle(_effectUI2);                _effectUI2 = null;            }            //_effectUI1 = EffectUIPool.CreateEffectUI(holder, "ui_LuckyBox", "Button_Glow");            _effectUI2 = EffectUIPool.CreateEffectUI(comBox.m_comLuckBoxBtn.m_holder, "ui_LuckyBox", "but_text_dc");            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);            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)            {                comBox.m_comLuckBoxBtn.m_btnBuyTen.onClick.Add(OnClickBtnBuyTen);            }            comBox.m_comLuckBoxBtn.m_btnBuyTen.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();                // 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();            UpdateListItemData();            UpdateFreeInfo();        }        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));                comBox.m_txtCount.SetVar("value", ActivityDataManager.Instance.lastTsyDrawCount.ToString()).FlushVars();            }        }        private void OnClikcBtnReward()        {            ViewManager.Show<ActivityThemeLuckyBoxBonusView>(ConstLimitTimeActivityType.ActLimitTsy);        }        private void OnClikcBtnShop()        {            ViewManager.Show<StoreView>(new object[] { ConstStoreTabId.STORE_GIFT_BAG, ConstStoreSubId.STORE_GIFT_BAG_TSY }, new object[] { typeof(LuckyBoxView).FullName });        }        //刷新摘星活动期间的数据        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<RushSaleGiftBoxView>(new object[] { ActivityType.XSLB3, this.viewData });            }        }        private void UpdateListItemData()        {            int boxId = LuckyBoxDataManager.Instance.luckyBoxIds[_curIndex];            LuckyBoxCfg cfg = LuckyBoxCfgArray.Instance.GetCfg(boxId);            GObject obj = _ui.m_listBg.GetChildAt(_curIndex);            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)            {                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);            }            else if(LuckyBoxDataManager.Instance.currentBoxId == LuckyBoxDataManager.BOX_ID_2)            {                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 = 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);                textField.asTextField.text = "概率提升剩余: " + TimeUtil.FormattingTimeTo_DDHHmm(endTime - curTime);                //=====限时礼包倒计时                //UpGiftBox();                //EventAgent.DispatchEvent(ConstMessage.LUCKY_BOX_TIME);                //=====限时礼包倒计时END            }        }        private void UpdateTime(object param = null)        {                    }        private void updateBoxEffect()        {            if (isActiveBoxOpen)            {            }        }        private void OnClickBtnPreview(EventContext context)        {            GObject obj = context.sender as GObject;            int boxId = (int)obj.data;            ViewManager.Show<LuckyBoxPreShowView>(boxId);        }        private void OnClickBtnBuyOne(EventContext context)        {            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<LuckyBoxStarView>(null, new object[] { typeof(LuckyBoxView).FullName, boxId });                     LogServerHelper.SendPlayParticipationLog((int)PlayParticipationEnum.ZAI_XING, 2);                 }             });        }        private void OnClickBtnBuyTen(EventContext context)        {            GuideCfg cfg = GuideCfgArray.Instance.GetCfg(ConstGuideId.LUCKY_BOX);            if (GuideDataManager.IsGuideFinish(ConstGuideId.LUCKY_BOX) <= 0 && (GuideDataManager.currentGuideId == 0 || 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<LuckyBoxStarView>(null, new object[] { typeof(LuckyBoxView).FullName, boxId });                    LogServerHelper.SendPlayParticipationLog((int)PlayParticipationEnum.ZAI_XING, 2);                }            });        }        protected override void OnHide()        {            base.OnHide();            EffectUIPool.Recycle(_effectUI2);            _effectUI2 = null;            _valueBarController.OnHide();            foreach (int key in _lcukyBoxCtrl.Keys)            {                _lcukyBoxCtrl[key].OnHide();            }            Timers.inst.Remove(OnTimerUpdate);            Timers.inst.Remove(CheckTime);            // Timers.inst.Remove(UpdateBg);            Timers.inst.Remove(CheckGuide);            // Timers.inst.Remove(UpdateTime);            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();            //this.Hide();            ViewManager.GoBackFrom(typeof(LuckyBoxView).FullName);        }        private void OnClickBtnHome()        {            GameController.GoBackToMainView();        }        private void Reset()        {            LuckyBoxDataManager.Instance.currentBoxId = LuckyBoxDataManager.Instance.luckyBoxIds[0];        }        private void CheckGuide(object param)        {            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;            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, "点击摘取十次。");        }        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];            LuckyBoxCfg cfg = LuckyBoxCfgArray.Instance.GetCfg(boxId);            long freeTime = LuckyBoxDataManager.Instance.GetFreeTime(boxId);            GObject obj = _ui.m_listBg.GetChildAt(_curIndex);            UI_ComBox1 comBox = UI_ComBox1.Proxy(obj);            if (freeTime > 0)            {                if (freeTime > TimeHelper.ServerNow())                {                    comBox.m_comLuckBoxBtn.m_comCostOne.m_c1.selectedIndex = 0;                    comBox.m_comLuckBoxBtn.m_txtFreeTime.visible = true;                }                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);            UI_ComBox1.ProxyEnd();        }    }}
 |