| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160 | using UI.CommonGame;using FairyGUI;using ET;namespace GFGGame{    public class ValueBarController    {        private UI_ComponentValueBar _valueBar;        public ValueBarController(GComponent valueBar, int ctrlSelected = 0)        {            _valueBar = UI_ComponentValueBar.Create(valueBar);            // _valueBar.m_c1.selectedIndex = ctrlSelected;            // _valueBar.target.x = 370;            _valueBar.m_btnGold.onClick.Add(() =>            {                ItemUtil.AddGold();            });            _valueBar.m_btnPower.onClick.Add(() =>            {                ItemUtil.AddPower();            });            _valueBar.m_btnDiamondPurple.onClick.Add(() =>            {                ItemUtil.AddDiamondPurple();            });            _valueBar.m_btnDiamondRed.onClick.Add(() =>            {                ItemUtil.AddDiamondRed();            });            _valueBar.m_btnCJLuoXing.onClick.Add(() =>            {                ViewManager.Show(ViewName.LUCKY_BOX_VIEW);            });            _valueBar.m_btnCJHuoDong.onClick.Add(() =>            {                ViewManager.Show(ViewName.LUCKY_BOX_VIEW);            });            _valueBar.m_btnCJ.onClick.Add((EventCallback0)(() =>            {                int luckyBoxId = LuckyBoxDataManager.Instance.currentBoxId;                LuckyBoxCfg luckyBoxCfg = LuckyBoxCfgArray.Instance.GetCfg(luckyBoxId);                ItemUtil.ExchangeItemById(luckyBoxCfg.costID, 1, true);            }));            _valueBar.m_btnTravel.onClick.Add(() =>            {                GoodsItemTipsController.ShowItemTips(GlobalCfgArray.globalCfg.travelCostArr[0]);            });            _valueBar.m_btnGallery.onClick.Add(() =>            {                ViewManager.Show<PoemGalleryRuleView>();            });        }        public void Dispose()        {            if (_valueBar != null)            {                _valueBar.Dispose();            }            _valueBar = null;        }        public void OnShown()        {            UpdateCurrency();            UpdateNumeric();            UpdateCJExchange();            UpdateCJAExchange();            UpdateCJ();            UpdateTravel();            UpdateGallery();            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();        }        private void UpdateCurrency()        {            _valueBar.m_btnGold.text = "" + RoleDataManager.gold;            _valueBar.m_btnDiamondPurple.text = "" + RoleDataManager.diaP;            _valueBar.m_btnDiamondRed.text = "" + RoleDataManager.diaR;        }        private void UpdateNumeric()        {            // _valueBar.m_btnGold.text = "" + RoleDataManager.gold; //GameGlobal.myNumericComponent.GetAsInt(NumericType.Gold);            _valueBar.m_btnPower.text = string.Format("{0}/{1}", RoleDataManager.power, GameGlobal.myNumericComponent.GetAsInt(NumericType.PowerLimit));            // _valueBar.m_btnDiamondPurple.text = "" + RoleDataManager.diaP;// GameGlobal.myNumericComponent.GetAsInt(NumericType.DiamondP);            // _valueBar.m_btnDiamondRed.text = "" + RoleDataManager.diaR;// GameGlobal.myNumericComponent.GetAsInt(NumericType.DiamondR);        }        //ժ�ǣ��齱���һ�        private void UpdateCJExchange()        {            _valueBar.m_btnCJLuoXing.text = "" + ItemDataManager.GetItemNum(ConstItemID.LUCKYBOX_STORE_COST);            _valueBar.m_btnCJLuoXing.icon = ResPathUtil.GetCommonGameResPath(ItemCfgArray.Instance.GetCfg(ConstItemID.LUCKYBOX_STORE_COST).res);        }        private void UpdateCJAExchange()        {            _valueBar.m_btnCJHuoDong.text = "" + ItemDataManager.GetItemNum(ConstItemID.LUCKYBOX_ACTIVITY_STORE_COST);            _valueBar.m_btnCJHuoDong.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.text = "" + ItemDataManager.GetItemNum(luckyBoxCfg.costID);            _valueBar.m_btnCJ.icon = ResPathUtil.GetCommonGameResPath(ItemCfgArray.Instance.GetCfg(luckyBoxCfg.costID).res);        }        private void UpdateTravel()        {            int itemId = GlobalCfgArray.globalCfg.travelCostArr[0];            _valueBar.m_btnTravel.text = "" + ItemDataManager.GetItemNum(itemId);            _valueBar.m_btnTravel.icon = ResPathUtil.GetCommonGameResPath(ItemCfgArray.Instance.GetCfg(itemId).res);        }        private void UpdateGallery()        {            _valueBar.m_btnGallery.text = "" + ItemDataManager.GetItemNum(ConstItemID.GALLERY_STORE_COST);            _valueBar.m_btnGallery.icon = ResPathUtil.GetCommonGameResPath(ItemCfgArray.Instance.GetCfg(ConstItemID.GALLERY_STORE_COST).res);        }    }}
 |