少年修仙传客户端代码仓库
hch
2025-07-24 50e53441950268933694eeb5aad36147bbe1014d
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
using vnxbqy.UI;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine.UI;
 
class SpiritEquipBagWin : ILWindow
{
 
    EquipPlaceCell dragonSpiritEqu;
    EquipPlaceCell killWorldEqu;
    EquipPlaceCell winEqu;
    EquipPlaceCell eatGodEqu;
    RawImage role;
    ScrollerController gridLineCrtl;
    Text powerText;
    PackModel packModel;
 
    RoleEquipType[] equTypes = new RoleEquipType[]
     {
       RoleEquipType.Guard,
       RoleEquipType.Wing,
       RoleEquipType.PeerlessWeapon1,
       RoleEquipType.PeerlessWeapon2,
     };
 
    protected override void BindController()
    {
        base.BindController();
        this.dragonSpiritEqu = this.transform.FindComponentEx<EquipPlaceCell>("Equ_DragonSpirit");
        this.killWorldEqu = this.transform.FindComponentEx<EquipPlaceCell>("Equip_KillWorld");
        this.winEqu = this.transform.FindComponentEx<EquipPlaceCell>("Equip_Wing");
        this.eatGodEqu = this.transform.FindComponentEx<EquipPlaceCell>("Equip_EatGod");
        this.role = this.transform.FindComponentEx<RawImage>("RoleBG");
        this.gridLineCrtl = this.transform.FindComponentEx<ScrollerController>("Resolution/GridLineCtrl");
        this.gridLineCrtl.OnRefreshCell += OnRefreshGridCell;
        this.gridLineCrtl.vertical = true;
        this.gridLineCrtl.lockType = EnhanceLockType.KeepVertical;
        this.powerText = this.transform.FindComponentEx<Text>("Container_Power/Text_Power");
        this.packModel = ModelCenter.Instance.GetModelEx<PackModel>();
    }
 
 
    protected override void OnAfterOpen()
    {
        base.OnAfterOpen();
        RefreshUI();
        SpiritEquipModel.Instance.refreshShowItemEvent += RefreshUI;
    }
 
    protected override void OnPreClose()
    {
        base.OnPreClose();
        SpiritEquipModel.Instance.refreshShowItemEvent -= RefreshUI;
    }
 
    void RefreshUI()
    {
        this.RefreshEquCells();
        this.OnCreateGridLineCell(this.gridLineCrtl);
        UI3DModelExhibition.Instance.ShowPlayer(this.role, PlayerDatas.Instance.baseData.Job);
        var totalScore = 0;
        for (int i = 0; i < this.equTypes.Length; i++)
        {
            var place = new Int2(0, (int)equTypes[i]);
            var index = EquipSet.ClientPlaceToServerPlace(place);
            var itemModel = this.packModel.GetItemByIndex(PackType.Equip, index);
            if (itemModel != null)
            {
                var config = SpiritWeaponConfig.Get(itemModel.itemId);
                if (config != null)
                    totalScore = totalScore + EquipFightPower.Instance.GetSpiritWeaponPower(itemModel.itemId);
                else
                    DebugEx.LogErrorFormat("灵器属性表 未配置 ID:{0}", itemModel.itemId);
            }
        }
        this.powerText.text = UIHelper.ReplaceLargeArtNum(totalScore);
    }
 
    void RefreshEquCells()
    {
        this.winEqu.Display(RoleEquipType.Wing);
        this.dragonSpiritEqu.Display(RoleEquipType.Guard);
        this.eatGodEqu.Display(RoleEquipType.PeerlessWeapon1);
        this.killWorldEqu.Display(RoleEquipType.PeerlessWeapon2);
    }
 
    void OnCreateGridLineCell(ScrollerController gridCtrl)
    {
        if (gridCtrl.GetNumberOfCells(gridCtrl.m_Scorller) > 0)
            gridCtrl.m_Scorller.RefreshActiveCellViews();
        else
        {
            gridCtrl.Refresh();
            for (int i = 0; i <= 19; i++)
            {
                gridCtrl.AddCell(ScrollerDataType.Header, i);
            }
            gridCtrl.Restart();
        }
    }
 
    void OnRefreshGridCell(ScrollerDataType type, CellView cell)
    {
        var gridlineIndex = cell.index;
        for (int i = 0; i < cell.transform.childCount; i++)
        {
            var gridCell = cell.transform.GetChild(i).GetComponentEx<GridCell>();
            if (gridCell == null)
                gridCell = cell.transform.GetChild(i).gameObject.AddComponentEx<GridCell>();
            var cellCount = cell.transform.childCount * gridlineIndex + i;
            gridCell.itemCell.SetActiveIL(false);
            gridCell.gridLock.SetActive(false);
            gridCell.cdImag.fillAmount = 0;
            gridCell.cdImag.SetActiveIL(false);
            var itemModel = SpiritEquipModel.Instance.showItemTable.Get(cellCount);
            if (itemModel != null)
            {
                gridCell.itemCell.SetActiveIL(true);
                gridCell.itemCell.Init(itemModel, true);
                gridCell.itemCellBtn.SetListener(() =>
                {
                    ItemTipUtility.Show(itemModel.guid, true);
                });
                gridCell.SetModel(itemModel);
            }
        }
    }
 
}