少年修仙传客户端代码仓库
hch
2025-04-03 c154ac0832fe4379a00d3e1cda700e7d2a7383c7
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
164
165
using vnxbqy.UI;
using System;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
 
class TreasurePavilionCell : ILBehaviour
{
    ButtonEx gubaoBtn;
    ImageEx gubaoImg;
    ImageEx gubaoGrayImg;
    List<Transform> starObjs = new List<Transform>();
    ImageEx labImg;
    Text name;
    RedpointBehaviour redpoint;
    IntensifySmoothSlider slider;
    Text process;
    UIEffect uieffect;
 
    PackModel packModel { get { return ModelCenter.Instance.GetModelEx<PackModel>(); } }
 
    protected override void Awake()
    {
        gubaoBtn = proxy.GetWidgtEx<ButtonEx>("gubaoBtn");
        //特效层级和mask的遮挡问题未解决,目前用两张图片灰色正常遮挡
        gubaoImg = proxy.GetWidgtEx<ImageEx>("gubaoIcon");
        gubaoGrayImg = proxy.GetWidgtEx<ImageEx>("gubaoIconGray");
        var canvas = gubaoImg.AddMissingComponent<Canvas>();
        canvas.sortingLayerName = "UI"; //使图片在特效上层
 
        for (int i = 0; i < 10; i++)
        {
            starObjs.Add(proxy.GetWidgtEx<Transform>("starBG" + i));
        }
        labImg = proxy.GetWidgtEx<ImageEx>("lab");
        name = proxy.GetWidgtEx<Text>("name");
        redpoint = proxy.GetWidgtEx<RedpointBehaviour>("RedPoint");
        slider = proxy.GetWidgtEx<IntensifySmoothSlider>("ExpSlider");
        process = proxy.GetWidgtEx<Text>("ExpNum");
        uieffect = proxy.GetWidgtEx<UIEffect>("uieffect");
    }
 
 
 
    public void Display(int gubaoID, float scale = 1)
    {
        uieffect.StopImediatly();
        var gubaoInfo = TreasurePavilionModel.Instance.TryGetGubaoInfo(gubaoID);
        var config = ILGubaoConfig.Get(gubaoID);
        var cnt = TreasurePavilionModel.Instance.GetGubaoItemCount(gubaoID); //packModel.GetItemCountByID(PackType.Item, config.UnlockItemID);
 
        gubaoImg.SetSprite(config.Icon);
        gubaoGrayImg.SetSprite(config.Icon);
        if (gubaoInfo.Count == 0 && cnt < config.UnlockItemCnt)
        {
            gubaoGrayImg.SetActiveIL(true);
            gubaoImg.SetActiveIL(false);
        }
        else
        {
            gubaoGrayImg.SetActiveIL(false);
            gubaoImg.SetActiveIL(true);
        }
        gubaoBtn.SetListener(()=> {
            OpenGubaoTip(gubaoID);
        });
        var maxStar = ILGubaoStarConfig.GetMaxStar(gubaoID);
        for (int i = 0; i < starObjs.Count; i++)
        {
            if (i < maxStar)
            {
                starObjs[i].SetActiveIL(true);
                if (gubaoInfo.Count > 0 && gubaoInfo[0] > i)
                {
                    Image star = starObjs[i].Find("star").GetComponent<Image>();
                    star.SetActiveIL(true);
                    // 根据星级设置不同颜色的星星
                    if (gubaoInfo[0] <= 10)
                    {
                        star.SetSprite("TreasureStar1"); // 黄色星星
                    }
                    else if (gubaoInfo[0] <= 20)
                    {
                        int blueStars = gubaoInfo[0] - 10;
                        if (i < blueStars)
                        {
                            star.SetSprite("TreasureStar2"); // 蓝色星星
                        }
                        else
                        {
                            star.SetSprite("TreasureStar1"); // 黄色星星
                        }
                    }
                    else
                    {
                        int purpleStars = gubaoInfo[0] - 20;
                        if (i < purpleStars)
                        {
                            star.SetSprite("TreasureStar3"); // 紫色星星
                        }
                        else
                        {
                            star.SetSprite("TreasureStar2"); // 蓝色星星
                        }
                    }
                }
                else
                {
                    starObjs[i].Find("star").GetComponent<Image>().SetActiveIL(false);
                }
            }
            else
            {
                starObjs[i].SetActiveIL(false);
            }
        }
 
        labImg.SetSprite(TreasurePavilionModel.Instance.gubaoDiIconDict[config.GubaoQuality]);
 
        if (gubaoInfo.Count > 0 && gubaoInfo[1] > 0)
        {
            name.text = config.Name + UIHelper.AppendColor(TextColType.Green, "+" + gubaoInfo[1]);
        }
        else
        {
            name.text = config.Name;
        }
        redpoint.redpointId = MainRedPoint.cbgRedpoint * 10000 + config.GubaoID;
        if (gubaoInfo.Count == 0)
        {
            slider.SetActiveIL(true);
            
            slider.value = Math.Min(1, (float)cnt / config.UnlockItemCnt);
            process.text = cnt + "/" + config.UnlockItemCnt;
            uieffect.effect = TreasurePavilionModel.Instance.gubaoEffectDict[config.GubaoQuality];
            uieffect.effectScl = Vector3.one * scale;
            if (cnt >= config.UnlockItemCnt)
            {
                uieffect.Play();
            }
            else
            {
                uieffect.StopImediatly();
            }
        }
        else
        {
            
            slider.SetActiveIL(false);
            uieffect.effect = TreasurePavilionModel.Instance.gubaoEffectDict[config.GubaoQuality];
            uieffect.effectScl = Vector3.one * scale;
            uieffect.Play();
        }
    }
 
    void OpenGubaoTip(int gubaoID)
    {
        TreasurePavilionModel.Instance.selectGubao = gubaoID;
        WindowCenter.Instance.OpenIL<TreasurePavilionTipWin>();
        if (TreasurePavilionModel.Instance.selectTagIndex == 1)
        {
            TreasurePavilionModel.Instance.selectResonanceID = GubaoResonanceConfig.GetGubaoIDToResonanceIDDict()[gubaoID];
        }
    }
}