| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218 | using System.Collections.Generic;using ET;using FairyGUI;using UI.Studio;namespace GFGGame{    public class StudioBaseView : BaseWindow    {        protected UI_StudioEctypeUI _ui;        private ValueBarController _valueBarController;        public GList list;        private GTextField _txtTime;        private GTextField _txtNum;        private GButton _btnBuy;        private int _time = 0;        protected StudioCfg _studioCfg;        protected List<StoryLevelCfg> storyLevelCfgs;        protected int curIndex = 0;        public override void Dispose()        {            if (_valueBarController != null)            {                _valueBarController.Dispose();                _valueBarController = null;            }            if (_ui != null)            {                _ui.Dispose();                _ui = null;            }            base.Dispose();        }        protected override void OnInit()        {            base.OnInit();            packageName = UI_StudioEctypeUI.PACKAGE_NAME;            _ui = UI_StudioEctypeUI.Create();            this.viewCom = _ui.target;            isfullScreen = true;            isReturnView = true;            _valueBarController = new ValueBarController(_ui.m_valueBar);            // _ui.m_list.itemRenderer = ListItemRender;            // // _ui.m_list.onClickItem.Add(OnCliclListItem);            // _ui.m_list.SetVirtual();            // _ui.m_btnBuy.onClick.Add(OnCliclBtnBuy);        }        protected override void AddEventListener()        {            base.AddEventListener();            EventAgent.AddEventListener(ConstMessage.NOTICE_LIMIT_CHANGED, OnLimitChanged);        }        public void AddChildCom(GComponent com,bool isNeedRender = true)        {            _ui.target.AddChildAt(com, 1);            list = com.GetChild("list").asList;            _txtNum = com.GetChild("txtNum").asTextField;            _txtTime = com.GetChild("txtTime").asTextField;            _btnBuy = com.GetChild("btnBuy").asButton;           if (isNeedRender)            {                list.itemRenderer = ListItemRender;            }            _btnBuy.onClick.Add(OnCliclBtnBuy);        }        protected override void OnShown()        {            base.OnShown();            _valueBarController.OnShown();            // _valueBarController.Controller(1);            //_ui.m_loaBg.url = ResPathUtil.GetBgImgPath("gzs_bjbj");            //add by zyq            UpdateItem();            UpdateView();            Timers.inst.Add(1, 0, UpdateShowTime);        }        protected override void OnHide()        {            _ui.target.RemoveChildAt(1);            base.OnHide();            _valueBarController.OnHide();            _studioCfg = null;            storyLevelCfgs = null;            Timers.inst.Remove(UpdateShowTime);            Timers.inst.Remove(OnTimerUpdate);        }        protected override void RemoveEventListener()        {            base.RemoveEventListener();            EventAgent.RemoveEventListener(ConstMessage.NOTICE_LIMIT_CHANGED, OnLimitChanged);        }        private void OnLimitChanged(EventContext context)        {            int limitId = (int)context.data;            if (this._studioCfg.limit != limitId)            {                return;            }            UpdateView();        }        protected void UpdateView()        {            var limitData = RoleLimitDataManager.GetLimitData(this._studioCfg.limit);            _txtNum.text = string.Format("剩余次数:{0}/{1}", limitData.TotalPlayMax - limitData.PlayTimes,                limitData.MaxStorageCount);        }        private void UpdateView(int limitId)        {        }        private void UpdateShowTime(object param)        {            long curTime = TimeHelper.ServerNow();            long endTime = GameGlobal.myNumericComponent.GetAsInt(NumericType.DailyResetSecs);            _txtTime.text = string.Format("{0}后刷新", TimeUtil.FormattingTime(curTime, endTime * 1000));        }        protected virtual void ListItemRender(int index, GObject obj)        {            UI_ListItem item = UI_ListItem.Proxy(obj);            StudioDataManager.Instance.IsCanFight(storyLevelCfgs, index, out bool canFight, out string content);            ItemData itemData = StoryBonusDataCache.GetBonusData(storyLevelCfgs[index].id).bonusBase[0];            ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(itemData.id);            item.m_loaIcon.url = ResPathUtil.GetIconPath(itemCfg);            item.m_star.selectedIndex = InstanceZonesDataManager.GetStarCountHistory(storyLevelCfgs[index].id);            item.m_imgLock.visible = canFight ? false : true;            if (item.m_imgLockBg != null)            {                item.m_imgLockBg.visible = canFight ? false : true;            }            item.m_txtTitle.text = canFight ? storyLevelCfgs[index].name : content;            if (canFight) curIndex = index;            if (item.m_loaIcon.data == null)            {                item.m_loaIcon.onClick.Add(OnLoaItemClick);            }            item.m_loaIcon.data = index;            if (item.m_loaBg.data == null)            {                item.m_loaBg.onClick.Add(OnCliclListItem);            }            item.m_loaBg.data = index;            UI_ListItem.ProxyEnd();        }        public void OnCliclListItem(EventContext context)        {            GObject obj = context.sender as GObject;            int index = (int)obj.data;            StoryLevelCfg storyLevelCfg = storyLevelCfgs[index];            StudioDataManager.Instance.IsCanFight(storyLevelCfgs, index, out bool canFight, out string content);            if (!canFight)            {                PromptController.Instance.ShowFloatTextPrompt(content);                return;            }            // StudioDataManager.Instance.PROPERTY_SELECT_INDEX = _ui.m_listProperty.selectedIndex;            // StudioDataManager.Instance.TYPE_SELECT_INDEX = _ui.m_c1.selectedIndex;            InstanceZonesController.ShowLevelView(storyLevelCfg.id, StudioDataManager.Instance.OnFinishStudioStoryLevel);        }        public void OnLoaItemClick(EventContext context)        {            GObject obj = context.sender as GObject;            int index = (int)obj.data;            ItemData itemData = StoryBonusDataCache.GetBonusData(storyLevelCfgs[index].id).bonusBase[0];            ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(itemData.id);            GoodsItemTipsController.ShowItemTips(itemCfg.id);        }        private void OnCliclBtnBuy()        {            ViewManager.Show<StudioBuyNumView>(this._studioCfg.limit);        }        private void UpdateItem()        {            for (int i = 0; i < list.numChildren; i++)            {                list.GetChildAt(i).visible = false;            }            _time = 0;            Timers.inst.Add(0.07f, list.numChildren, OnTimerUpdate, 1);        }        private void OnTimerUpdate(object param)        {            list.GetChildAt(_time).visible = true;            UI_ListItem listItem = UI_ListItem.Proxy(list.GetChildAt(_time++));            //播放动效            if (listItem.m_test != null)            {                listItem.m_test.Play();            }            UI_ListItem.ProxyEnd();        }    }}
 |