少年修仙传客户端代码仓库
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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
 
using System;
 
namespace vnxbqy.UI
{
    public class CeremonyOutOfPrintWin : Window
    {
        [SerializeField] Text firstNameText;
        [SerializeField] Text secondNameText;
        [SerializeField] Text thirdNameText;
        [SerializeField] Text remainTimeText;
        [SerializeField] List<UIEffect> rankEffectlist = new List<UIEffect>();
        [SerializeField] List<CommonItemBaisc> firstItemlist = new List<CommonItemBaisc>();
        [SerializeField] List<CommonItemBaisc> secondItemlist = new List<CommonItemBaisc>();
        [SerializeField] List<CommonItemBaisc> thirdItemlist = new List<CommonItemBaisc>();
        [SerializeField] Button m_Recharge;
 
        FairylandCeremonyModel ceremonyModel { get { return ModelCenter.Instance.GetModel<FairylandCeremonyModel>(); } }
        KingFairyModel kingFairyModel { get { return ModelCenter.Instance.GetModel<KingFairyModel>(); } }
        RankModel rankModel { get { return ModelCenter.Instance.GetModel<RankModel>(); } }
        protected override void BindController()
        {
 
        }
 
        protected override void AddListeners()
        {
            m_Recharge.SetListener(GotoRecharge);
        }
 
        protected override void OnPreOpen()
        {
            GlobalTimeEvent.Instance.secondEvent += RefreshSecond;
            rankModel.onRankRefresh += OnRefreshRankList;
            Init();
        }
 
        protected override void OnAfterOpen()
        {
 
        }
 
        protected override void OnPreClose()
        {
            GlobalTimeEvent.Instance.secondEvent -= RefreshSecond;
            rankModel.onRankRefresh -= OnRefreshRankList;
        }
 
        protected override void OnAfterClose()
        {
 
        }
 
        private void Init()
        {
            ceremonyModel.SendGetRankInfo(RankType.Def_BT_FCCostGold);
            SetRankAward(firstItemlist, ceremonyModel.GetRankAwardByLv(1));
            SetRankAward(secondItemlist, ceremonyModel.GetRankAwardByLv(2));
            SetRankAward(thirdItemlist, ceremonyModel.GetRankAwardByLv(3));
            RefreshRankInfo();
            RefreshSecond();
        }
 
        private void OnRefreshRankList(int type)
        {
            if (type != (int)RankType.Def_BT_FCCostGold) return;
 
            RefreshRankInfo();
        }
 
        private void RefreshRankInfo()
        {
            List<RankData> list = null;
            rankModel.TryGetRanks((int)RankType.Def_BT_FCCostGold, out list);
            firstNameText.text = Language.Get("CeremoneyOutOfPrint");
            secondNameText.text = Language.Get("CeremoneyOutOfPrint");
            thirdNameText.text = Language.Get("CeremoneyOutOfPrint");
 
            if (list != null)
            {
                if (list.Count > 0)
                {
                    firstNameText.text = list[0].name1;
                    SetRankEffect(0, (int)list[0].id);
                }
 
                if (list.Count > 1)
                {
                    secondNameText.text = list[1].name1;
                    SetRankEffect(1, (int)list[1].id);
                }
 
                if (list.Count > 2)
                {
                    thirdNameText.text = list[2].name1;
                    SetRankEffect(2, (int)list[2].id);
                }
            }
        }
 
        private void SetRankEffect(int rank, int playerId)
        {
            for (int i = 0; i < rankEffectlist.Count; i++)
            {
                if (rank == i && playerId == PlayerDatas.Instance.baseData.PlayerID)
                {
                    if (!rankEffectlist[i].IsPlaying)
                    {
                        rankEffectlist[i].Play();
                    }
                }
                else
                {
                    if (rankEffectlist[i].IsPlaying)
                    {
                        rankEffectlist[i].Stop();
                    }
                }
            }
        }
 
        private void RefreshSecond()
        {
            int seconds = OperationTimeHepler.Instance.GetOperationSurplusTime(Operation.FairyCeremony);
            if (seconds > 0)
            {
                remainTimeText.text = StringUtility.Contact("<color=#8DDC11FF>", TimeUtility.SecondsToHMS(seconds), "</color>");
            }
            else
            {
                remainTimeText.text = UIHelper.AppendColor(TextColType.Red, Language.Get("XMZZ110"));
            }
 
        }
 
        private void SetRankAward(List<CommonItemBaisc> baiscs, List<FairylandCeremonyModel.AwardItem> list)
        {
            if (list == null) return;
 
            for (int i = 0; i < baiscs.Count; i++)
            {
                if (i < list.Count)
                {
                    baiscs[i].SetActive(true);
                    FairylandCeremonyModel.AwardItem itemData = list[i];
                    ItemCellModel cellModel = new ItemCellModel(itemData.itemId, true, (ulong)itemData.itemCount);
                    baiscs[i].Init(cellModel);
                    baiscs[i].button.RemoveAllListeners();
                    baiscs[i].button.AddListener(() =>
                    {
                        switch (itemData.itemId)
                        {
                            case 2278:
                                kingFairyModel.ViewKingFairyChest(itemData.itemId, itemData.itemCount);
                                break;
                            default:
                                ItemTipUtility.Show(itemData.itemId);
                                break;
                        }
 
                    });
                }
                else
                {
                    baiscs[i].SetActive(false);
                }
            }
        }
 
        private void GotoRecharge()
        {
            WindowJumpMgr.Instance.WindowJumpTo( JumpUIType.VipRechargeFunc1);
        }
 
    }
}