| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144 | using System.Collections;using System.Collections.Generic;using ET;using FairyGUI;using UI.ClothingFoster;using UI.CommonGame;namespace GFGGame{    public class ClothingFosterView : BaseWindow    {        private UI_ClothingFosterUI _ui;        private int _suitId;        private int _index;        private SortedList _propertyList;        private Dictionary<int, int> _addPropertyList;        private bool _canFoster;        public override void Dispose()        {            if (_ui != null)            {                _ui.Dispose();                _ui = null;            }            base.Dispose();        }        protected override void OnInit()        {            base.OnInit();            packageName = UI_ClothingFosterUI.PACKAGE_NAME;            _ui = UI_ClothingFosterUI.Create();            this.viewCom = _ui.target;            this.viewCom.Center();            this.modal = true;            // viewAnimationType = EnumViewAnimationType.ZOOM_CENTER;            _ui.m_listMaterials.itemRenderer = ListMaterialItemRender;            _ui.m_listMaterials.onClickItem.Add(OnListMaterialsItem);            _ui.m_listPropertyAdd.itemRenderer = ListPropertyItemRender;            _ui.m_btnFoster.onClick.Add(OnClickBtnFoster);        }        protected override void AddEventListener()        {            base.AddEventListener();            EventAgent.AddEventListener(ConstMessage.JUMP_TO_SOURCE, this.Hide);        }        protected override void OnShown()        {            base.OnShown();            _suitId = (int)(this.viewData as object[])[0];            _index = (int)(this.viewData as object[])[1];            _propertyList = (this.viewData as object[])[2] as SortedList;            _addPropertyList = SuitFosterDataManager.Instance.GetAdditionPropertyData(_suitId, _index);            _canFoster = true;            SuitFosterCfg cfg = SuitFosterCfgArray.Instance.GetCfgsBysuitId(_suitId)[_index];            _ui.m_listMaterials.numItems = cfg.materialsArr.Length;            long has = ItemDataManager.GetItemNum(cfg.costId);            int need = cfg.costNum;            // UI_ComCostCurrency comConsume = UI_ComCostCurrency.Proxy(_ui.m_ComConsume);            // comConsume.m_txtNeed.text = need.ToString();            // UI_ComCostCurrency.ProxyEnd();            ItemUtil.UpdateItemNeedNum(_ui.m_ComConsume, cfg.costId, cfg.costNum);            if (_canFoster && has < need) _canFoster = false;            _ui.m_listPropertyAdd.numItems = _propertyList.Count;        }        protected override void OnHide()        {            base.OnHide();        }        protected override void RemoveEventListener()        {            base.RemoveEventListener();            EventAgent.RemoveEventListener(ConstMessage.JUMP_TO_SOURCE, this.Hide);        }        private void ListMaterialItemRender(int index, GObject obj)        {            UI_ListMaterialsItem item = UI_ListMaterialsItem.Proxy(obj);            int[][] materialsArr = SuitFosterCfgArray.Instance.GetCfgsBysuitId(_suitId)[_index].materialsArr;            ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(materialsArr[index][0]);            item.m_loaIcon.url = ResPathUtil.GetIconPath(itemCfg);            long has = ItemDataManager.GetItemNum(itemCfg.id);            item.m_txtHas.text = has.ToString();            int need = materialsArr[index][1];            item.m_txtNeed.text = need.ToString();            item.m_txtHas.text = StringUtil.GetColorText(has.ToString(), has >= need ? "#F2DB96" : "#C9F1A5");            if (_canFoster && has < need) _canFoster = false;            item.target.data = materialsArr[index];            UI_ListMaterialsItem.ProxyEnd();        }        private void OnListMaterialsItem(EventContext context)        {            int[] itemData = (int[])(context.data as GComponent).data;            // ViewManager.Show(ViewName.APPROACH_OF_ITEM_VIEW, new object[] { itemData[0], new object[] { typeof(ClothingView).FullName, (this.viewData as object[])[4] }, itemData[1] });            object[] sourceDatas = new object[] { itemData[0], new object[] { typeof(ClothingView).FullName, (this.viewData as object[])[3] }, itemData[1] };            GoodsItemTipsController.ShowItemTips(itemData[0], sourceDatas);        }        private void ListPropertyItemRender(int index, GObject obj)        {            UI_ListPropertyAddItem item = UI_ListPropertyAddItem.Proxy(obj);            UI_ListScoreItem comProperty = UI_ListScoreItem.Proxy(item.m_comProperty);            int score = (int)_propertyList.GetKey(index);            comProperty.m_txtProperty.text = _propertyList[score].ToString();            comProperty.m_loaIcon.url = ResPathUtil.GetCommonGameResPath("kp_sx_" + (score));            double addition = _addPropertyList[score] * 100 / 10000;            item.m_txtAdd.text = string.Format("+{0}%", addition);            UI_ListPropertyAddItem.ProxyEnd();            UI_ListScoreItem.ProxyEnd();        }        private async void OnClickBtnFoster()        {            SuitFosterCfg cfg = SuitFosterCfgArray.Instance.GetCfgsBysuitId(_suitId)[_index];            if (!ItemUtil.CheckItemEnough(cfg.costId, cfg.costNum))            {                long has = ItemDataManager.GetItemNum(cfg.costId);                ItemUtil.BuyCurrency(cfg.costId, cfg.costNum - has);                return;            }            for (int i = 0; i < cfg.materialsArr.Length; i++)            {                if (!ItemUtil.CheckItemEnough(cfg.materialsArr[i][0], cfg.materialsArr[i][1], true)) return;            }            int result = await SuitFosterProxy.SendMaintainSuit(_suitId, _index + 1);            if (result == ErrorCode.ERR_Success)            {                LogServerHelper.SendPlayParticipationLog((int)PlayParticipationEnum.FU_ZHUANG_YANG_CHENG, 2);                this.Hide();            }        }    }}
 |