| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230 | using UI.CommonGame;using FairyGUI;using ET;using System.Collections.Generic;namespace GFGGame{    public class ValueBarController    {        private UI_ComponentValueBar _valueBar;        public ValueBarController(GComponent valueBar, int ctrlSelected = 0)        {            _valueBar = UI_ComponentValueBar.Create(valueBar);            _valueBar.m_btnGold.target.onClick.Add(OnClickGold);            _valueBar.m_btnPower.target.onClick.Add(OnClickPower);            _valueBar.m_btnDiamondPurple.target.onClick.Add(OnClickDiamondPurple);            _valueBar.m_btnDiamondRed.target.onClick.Add(OnClickDiamondRed);            _valueBar.m_btnTravel.target.onClick.Add(OnClickTravel);            _valueBar.m_btnGallery.target.onClick.Add(OnClickGallery);            _valueBar.m_btnLeagueContribuation.target.onClick.Add(OnClickLeagueContribuation);        }        private void OnClickGold()        {            ItemUtil.AddGold();        }        private void OnClickPower()        {            ItemUtil.AddPower();        }        private void OnClickDiamondPurple()        {            ItemUtil.AddDiamondPurple();        }        private void OnClickDiamondRed()        {            ItemUtil.AddDiamondRed();        }        private void OnClickTravel()        {            object[] sourceDatas = new object[] { GlobalCfgArray.globalCfg.travelCostArr[0], new object[] { typeof(TravelView).FullName, null } };            GoodsItemTipsController.ShowItemTips(GlobalCfgArray.globalCfg.travelCostArr[0], sourceDatas);        }        private void OnClickGallery()        {            ViewManager.Show<PoemGalleryRuleView>();        }        private void OnClickLeagueContribuation()        {            object[] sourceDatas = new object[] { ConstItemID.LEAGUE_CONTRIBUTION, new object[] { typeof(LeagueSkillUpView).FullName, null } };            GoodsItemTipsController.ShowItemTips(ConstItemID.LEAGUE_CONTRIBUTION, sourceDatas);        }        public void Dispose()        {            if (_valueBar != null)            {                _valueBar.Dispose();            }            _valueBar = null;        }        public void OnShown()        {            UpdateNumeric();            UpdateItem();            EventAgent.AddEventListener(ConstMessage.NUMERIC_CHANGE, UpdateNumeric);            EventAgent.AddEventListener(ConstMessage.ITEM_CHANGED, UpdateItem);        }        public void Controller(int ctrlSelected)        {            _valueBar.m_c1.selectedIndex = ctrlSelected;        }        public void OnHide()        {            EventAgent.RemoveEventListener(ConstMessage.NUMERIC_CHANGE, UpdateNumeric);            EventAgent.RemoveEventListener(ConstMessage.ITEM_CHANGED, UpdateItem);        }        private void UpdateItem()        {            UpdateCurrency();            UpdateCJExchange();            UpdateCJAExchange();            UpdateCJ();            UpdateTravel();            UpdateGallery();            UpdateArena();            UpdateLeagueContribution();            _valueBar.m_list.numItems = _valueBar.m_list.numItems;        }        private void UpdateCurrency()        {            _valueBar.m_btnGold.target.text = "" + RoleDataManager.gold;            _valueBar.m_btnDiamondPurple.target.text = "" + RoleDataManager.diaP;            _valueBar.m_btnDiamondRed.target.text = "" + RoleDataManager.diaR;        }        private void UpdateNumeric()        {            _valueBar.m_btnPower.target.text = string.Format("{0}/{1}", RoleDataManager.power, RoleDataManager.powerLimit);        }        //ժ�ǣ��齱���һ�        private void UpdateCJExchange()        {            _valueBar.m_btnCJLuoXing.target.text = "" + ItemDataManager.GetItemNum(ConstItemID.LUCKYBOX_STORE_COST);            _valueBar.m_btnCJLuoXing.target.icon = ResPathUtil.GetCommonGameResPath(ItemCfgArray.Instance.GetCfg(ConstItemID.LUCKYBOX_STORE_COST).res);        }        private void UpdateCJAExchange()        {            _valueBar.m_btnCJHuoDong.target.text = "" + ItemDataManager.GetItemNum(ConstItemID.LUCKYBOX_ACTIVITY_STORE_COST);            _valueBar.m_btnCJHuoDong.target.icon = ResPathUtil.GetCommonGameResPath(ItemCfgArray.Instance.GetCfg(ConstItemID.LUCKYBOX_ACTIVITY_STORE_COST).res);        }        public void UpdateCJ()        {            LuckyBoxCfg luckyBoxCfg = LuckyBoxCfgArray.Instance.GetCfg(LuckyBoxDataManager.Instance.currentBoxId);            if (luckyBoxCfg == null) return;            _valueBar.m_btnCJ.target.text = "" + ItemDataManager.GetItemNum(luckyBoxCfg.costID);            _valueBar.m_btnCJ.target.icon = ResPathUtil.GetCommonGameResPath(ItemCfgArray.Instance.GetCfg(luckyBoxCfg.costID).res);        }        private void UpdateTravel()        {            int itemId = GlobalCfgArray.globalCfg.travelCostArr[0];            _valueBar.m_btnTravel.target.text = "" + ItemDataManager.GetItemNum(itemId);            _valueBar.m_btnTravel.target.icon = ResPathUtil.GetCommonGameResPath(ItemCfgArray.Instance.GetCfg(itemId).res);        }        private void UpdateGallery()        {            _valueBar.m_btnGallery.target.text = "" + ItemDataManager.GetItemNum(ConstItemID.GALLERY_STORE_COST);            _valueBar.m_btnGallery.target.icon = ResPathUtil.GetCommonGameResPath(ItemCfgArray.Instance.GetCfg(ConstItemID.GALLERY_STORE_COST).res);        }        private void UpdateArena()        {            _valueBar.m_btnArena.m_imgAdd.visible = false;            _valueBar.m_btnArena.target.text = "" + ItemDataManager.GetItemNum(GlobalCfgArray.globalCfg.bonusSpecialWinArr[0][0]);            _valueBar.m_btnArena.target.icon = ResPathUtil.GetCommonGameResPath(ItemCfgArray.Instance.GetCfg(GlobalCfgArray.globalCfg.bonusSpecialWinArr[0][0]).res);        }        private void UpdateLeagueContribution()        {            _valueBar.m_btnLeagueContribuation.target.text = "" + ItemDataManager.GetItemNum(ConstItemID.LEAGUE_CONTRIBUTION);            _valueBar.m_btnLeagueContribuation.target.icon = ResPathUtil.GetCommonGameResPath(ItemCfgArray.Instance.GetCfg(ConstItemID.LEAGUE_CONTRIBUTION).res);        }        public void UpdateList(List<int> itemIds)        {            itemIds.Sort((x, y) => -x.CompareTo(y));            if (_valueBar.m_list.data == null)            {                _valueBar.m_list.itemRenderer = RenderListItem;            }            _valueBar.m_list.data = itemIds;            _valueBar.m_list.numItems = itemIds.Count;        }        private void RenderListItem(int index, GObject obj)        {            int itemId = (obj.parent.data as List<int>)[index];            UpdateButton(obj, itemId);        }        private void UpdateButton(GObject obj, int itemId)        {            UI_ButtonInValueBar button = UI_ButtonInValueBar.Proxy(obj);            button.target.text = "" + ItemDataManager.GetItemNum(itemId);            button.target.icon = ResPathUtil.GetCommonGameResPath(ItemCfgArray.Instance.GetCfg(itemId).res);            switch (itemId)            {                case ConstItemID.GOLD:                case ConstItemID.POWER:                case ConstItemID.DIAMOND_PURPLE:                case ConstItemID.DIAMOND_RED:                case ConstItemID.TRAVEL:                case ConstItemID.GALLERY_STORE_COST:                case ConstItemID.LEAGUE_CONTRIBUTION:                    button.m_imgAdd.visible = true;                    break;                default:                    button.m_imgAdd.visible = false;                    break;            }            if (button.target.data == null)            {                button.target.onClick.Add(OnBtnClick);            }            button.target.data = itemId;            UI_ButtonInValueBar.ProxyEnd();        }        private void OnBtnClick(EventContext context)        {            int itemId = (int)(context.sender as GObject).data;            OnBtnClick(itemId);        }        private void OnBtnClick(int itemId)        {            switch (itemId)            {                case ConstItemID.GOLD:                    OnClickGold();                    break;                case ConstItemID.POWER:                    OnClickPower();                    break;                case ConstItemID.DIAMOND_PURPLE:                    OnClickDiamondPurple();                    break;                case ConstItemID.DIAMOND_RED:                    OnClickDiamondRed();                    break;                case ConstItemID.TRAVEL:                    OnClickGold();                    break;                case ConstItemID.GALLERY_STORE_COST:                    OnClickGallery();                    break;                case ConstItemID.LEAGUE_CONTRIBUTION:                    OnClickLeagueContribuation();                    break;            }        }    }}
 |