少年修仙传客户端代码仓库
lcy
2024-12-16 a39c35fc6449430cd02bccb681c4a0a880e46cd9
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
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<int, ItemModel> WingDic = new Dictionary<int, ItemModel>();//从背包获取相同职业的翅膀(1背包位置索引,2翅膀信息)
        List<WingRefineAttrConfig> refineAttrConfigs;
 
        PackModel _playerPack;
        PackModel playerPack { get { return _playerPack ?? (_playerPack = ModelCenter.Instance.GetModel<PackModel>()); } }
 
        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<WingButton>();
            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<int, ItemModel> 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]);
                }
            }
 
        }
    }
}