using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; using vnxbqy.UI; using System; //翅膀弹框 namespace vnxbqy.UI { public class WingsBouncedWin : Window { [SerializeField] ScrollerController m_ScrollerController; [SerializeField] Button _CloseButton; private Dictionary WingDic = new Dictionary();//从背包获取相同职业的翅膀(1背包位置索引,2翅膀信息) List refineAttrConfigs; PackModel _playerPack; PackModel playerPack { get { return _playerPack ?? (_playerPack = ModelCenter.Instance.GetModel()); } } private int _Job;//得到职业 protected override void BindController() { refineAttrConfigs = WingRefineAttrConfig.GetValues(); } protected override void AddListeners() { _CloseButton.AddListener(OnClickCloseBtn); } protected override void OnPreOpen() { m_ScrollerController.OnRefreshCell += OnRefreshGridCell; playerPack.itemCntAddEvent += OnEquipRefreshEvent;//角色装备刷新 _Job = PlayerDatas.Instance.baseData.Job;//得到职业信息 WingType(); OnCreateGridLineCell(m_ScrollerController); } protected override void OnAfterOpen() { } void OnClickCloseBtn() { Close(); } protected override void OnPreClose() { playerPack.itemCntAddEvent -= OnEquipRefreshEvent;//角色装备刷新 m_ScrollerController.OnRefreshCell -= OnRefreshGridCell; } private void OnEquipRefreshEvent(PackType arg1, int arg2, int arg3) { if (PackType.Equip == arg1) { ItemModel itemModel = playerPack.GetItemByIndex(PackType.Equip, SpiritWeaponModel.WING_EQUIPINDEX); if (itemModel != null) { Close(); } } } void OnCreateGridLineCell(ScrollerController gridCtrl)//预制体创建 { gridCtrl.Refresh(); foreach (int key in WingDic.Keys) { gridCtrl.AddCell(ScrollerDataType.Header, key); } gridCtrl.Restart(); } private void OnRefreshGridCell(ScrollerDataType type, CellView cell) { int Index = cell.index; WingButton _WingButton = cell.GetComponent(); ItemConfig tagItem = ItemConfig.Get((int)WingDic[Index].itemId); ItemModel model = playerPack.GetItemByIndex(PackType.Item, Index); int color = ItemLogicUtility.Instance.GetItemQuality(model.itemId, model.useDataDict); _WingButton.IconBG.SetItemBackGround(color); _WingButton.Icon.SetSprite(tagItem.IconKey); _WingButton.WingsText.text = UIHelper.AppendColor((TextColType)color, tagItem.ItemName, true); int _currentRefining = 0;//当前精炼度 if (WingDic[Index].GetUseData(42) != null) _currentRefining = WingDic[Index].GetUseData(42)[0]; foreach (var config in refineAttrConfigs) { if (tagItem.LV == config.wingsPhase) { int _currentRefiningAll = config.EXPupper;//总精炼度 if (_currentRefining >= _currentRefiningAll) _currentRefining = _currentRefiningAll; string NumberText = Mathf.CeilToInt(((float)_currentRefining / _currentRefiningAll) * 100).ToString() + "%"; _WingButton.RefLvText.text = NumberText; } } _WingButton.WingBG.RemoveAllListeners(); _WingButton.WingBG.AddListener(() => { ItemOperateUtility.Instance.PutOnItem(model.guid); //string strJob = tagItem.JobLimit.ToString(); //if (_ReincarnationLv >= int.Parse(strJob.Substring(strJob.Length - 1, 1))) //{ // C0703_tagCEquipItem _tagC0703 = new C0703_tagCEquipItem(); // _tagC0703.RoleEquipType = (int)RoleEquipType.retWing; // _tagC0703.ItemIndex = (byte)Index; // GameNetSystem.Instance.SendInfo(_tagC0703); // Close(); //} //else //{ // ServerTipDetails.DisplayNormalTip(Language.Get("Z1019"));//"翅膀未达到穿戴条件" //} }); } protected override void OnAfterClose() { } void WingType() { SinglePack singlePack = playerPack.GetSinglePack(PackType.Item); if (singlePack == null) { return; } WingDic.Clear(); Dictionary backpack_dic = singlePack.GetAllItems(); if (backpack_dic.Count == 0)//得到背包的所有物品 { return; } foreach (int index in backpack_dic.Keys) { int itemId = (int)backpack_dic[index].itemId; if (!WingRefineExpConfig.Has(itemId) || !ItemLogicUtility.Instance.IsWing(itemId)) { continue; } var wingConfig = ItemConfig.Get(itemId); if (wingConfig.Type == 113 && ItemLogicUtility.Instance.IsJobCompatibleItem(itemId)) { WingDic.Add(index, backpack_dic[index]); } } } } }