| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137 | 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, 10, true);            }));        }        public void Dispose()        {            if (_valueBar != null)            {                _valueBar.Dispose();            }            _valueBar = null;        }        public void OnShown()        {            UpdateCurrency();            UpdateNumeric();            UpdateCJExchange();            UpdateCJ(LuckyBoxDataManager.Instance.currentBoxId);            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()        {            UpdateCJExchange();            UpdateCJ(LuckyBoxDataManager.Instance.currentBoxId);            UpdateCurrency();        }        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()        {            int luckyBoxId1 = LuckyBoxDataManager.BOX_ID_2;            LuckyBoxCfg luckyBoxCfg1 = LuckyBoxCfgArray.Instance.GetCfg(luckyBoxId1);            _valueBar.m_btnCJLuoXing.text = "" + ItemDataManager.GetItemNum(luckyBoxCfg1.bonusArr[0][0]);            _valueBar.m_btnCJLuoXing.icon = ResPathUtil.GetCommonGameResPath(ItemCfgArray.Instance.GetCfg(luckyBoxCfg1.bonusArr[0][0]).res);            int luckyBoxId2 = LuckyBoxDataManager.BOX_ID_1;            LuckyBoxCfg luckyBoxCfg2 = LuckyBoxCfgArray.Instance.GetCfg(luckyBoxId2);            _valueBar.m_btnCJHuoDong.text = "" + ItemDataManager.GetItemNum(luckyBoxCfg2.bonusArr[0][0]);            _valueBar.m_btnCJHuoDong.icon = ResPathUtil.GetCommonGameResPath(ItemCfgArray.Instance.GetCfg(luckyBoxCfg2.bonusArr[0][0]).res);        }        public void UpdateCJ(int id)        {            LuckyBoxCfg luckyBoxCfg = LuckyBoxCfgArray.Instance.GetCfg(id);            if (luckyBoxCfg == null) return;            _valueBar.m_btnCJ.text = "" + ItemDataManager.GetItemNum(luckyBoxCfg.costID);            _valueBar.m_btnCJ.icon = ResPathUtil.GetCommonGameResPath(ItemCfgArray.Instance.GetCfg(luckyBoxCfg.costID).res);        }    }}
 |