少年修仙传客户端代码仓库
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
166
167
168
169
170
171
172
173
using vnxbqy.UI;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
 
//异兽入侵
public class BeastInvasionWin : OneLevelWin
{
    TextEx txtNPC;
    TextEx txtTime;
    TextEx txtCount;
    ImageEx imgTime;
    RawImage rawNPC;
    ButtonEx btnGo;
    ButtonEx btnReward;
    ButtonEx btnRank;
    List<ItemCell> itemCellList;
    int npcID;
    BeastInvasionModel beastInvasionModel { get { return ModelCenter.Instance.GetModel<BeastInvasionModel>(); } }
    DungeonModel dungeonModel { get { return ModelCenter.Instance.GetModel<DungeonModel>(); } }
    RankModel rankModel { get { return ModelCenter.Instance.GetModel<RankModel>(); } }
 
    protected override void BindController()
    {
        base.BindController();
        txtNPC = GetWidgt<TextEx>("txtNPC");
        txtTime = GetWidgt<TextEx>("txtTime");
        txtCount = GetWidgt<TextEx>("txtCount");
        rawNPC = GetWidgt<RawImage>("rawNPC");
        btnGo = GetWidgt<ButtonEx>("btnGo");
        btnReward = GetWidgt<ButtonEx>("btnReward");
        btnRank = GetWidgt<ButtonEx>("btnRank");
        imgTime = GetWidgt<ImageEx>("imgTime");
        itemCellList = new List<ItemCell>();
        for (int i = 0; i < beastInvasionModel.itemCellCount; i++)
        {
            itemCellList.Add(GetWidgt<ItemCell>("itemcell" + i));
        }
    }
 
    protected override void AddListeners()
    {
        base.AddListeners();
        btnReward.SetListener(() => { WindowCenter.Instance.Open<BeastInvasionRewardWin>(); });
        btnRank.SetListener(() =>
        {
            rankModel.QueryRankByPage(beastInvasionModel.rankType, 0, 100, 0, true);
            Clock.AlarmAfter(1.2f, () => { rankModel.QueryRankByPage(beastInvasionModel.rankType, 0, 20, 1, true); });
        });
        btnGo.SetListener(() =>
        {
            //今日次数不足
            if (dungeonModel.GetEnterTimes(beastInvasionModel.dataMapID) >= dungeonModel.GetMaxTimesShow(beastInvasionModel.dataMapID))
            {
                SysNotifyMgr.Instance.ShowTip("XBLimitCnt");
                return;
            }
 
            //不在开放时间
            if (!beastInvasionModel.isTimeOk())
            {
                SysNotifyMgr.Instance.ShowTip("FBIsNotOpen");
                return;
            }
 
            //其他副本开放条件
            int error = 0;
            dungeonModel.TestChallange(new Dungeon(beastInvasionModel.dataMapID, beastInvasionModel.lineID), out error);
            var dungeonConfig = DungeonConfig.Get(beastInvasionModel.dungeonID);
            switch (error)
            {
                case 1:
                    SysNotifyMgr.Instance.ShowTip("DungeoninCoolTime");
                    break;
                case 2:
                    SysNotifyMgr.Instance.ShowTip("DemonJar_Text2");
                    break;
                case 4:
                    SysNotifyMgr.Instance.ShowTip("GeRen_chenxin_268121", dungeonConfig.MapID);
                    break;
                case 5:
                    SysNotifyMgr.Instance.ShowTip("GeRen_chenxin_157069", dungeonConfig.MapID);
                    break;
            }
 
            TurnFightModel.Instance.StartTurnFight(beastInvasionModel.dataMapID, beastInvasionModel.lineID, 0, npcID);
        });
    }
 
    protected override void OnPreOpen()
    {
        base.OnPreOpen();
        rankModel.onMyRankRefresh += OnMyRefreshRank;
        GlobalTimeEvent.Instance.secondEvent += OnRefreshSecond;
        dungeonModel.dungeonRecordChangeEvent += OndungeonRecordChangeEvent;
        npcID = beastInvasionModel.GetTodayNPCID();
        var npcConfig = NPCConfig.Get(npcID);
        txtNPC.text = npcConfig.charName;
        UI3DModelExhibition.Instance.ShowNPC(npcID, npcConfig.UIModeLOffset, npcConfig.UIModelRotation + new Vector3(0, -45, 0), rawNPC);
        ChangeCountText();
        ChangeTime();
        for (int i = 0; i < beastInvasionModel.itemCellCount; i++)
        {
            int[] dropArr = beastInvasionModel.dropArr;
            if (i <= dropArr.Length - 1)
            {
                int itemID = dropArr[i];
                itemCellList[i].SetActive(true);
                itemCellList[i].Init(new ItemCellModel(itemID, false, 0));
                itemCellList[i].countText.SetActive(false);
                itemCellList[i].button.SetListener(() => { ItemTipUtility.Show(itemID); });
            }
            else
            {
                itemCellList[i].SetActive(false);
            }
        }
    }
 
    protected override void OnAfterOpen()
    {
        base.OnAfterOpen();
    }
 
    protected override void OnAfterClose()
    {
        base.OnAfterClose();
    }
 
    protected override void OnPreClose()
    {
        base.OnPreClose();
        rankModel.onMyRankRefresh -= OnMyRefreshRank;
        GlobalTimeEvent.Instance.secondEvent -= OnRefreshSecond;
        dungeonModel.dungeonRecordChangeEvent -= OndungeonRecordChangeEvent;
    }
 
    void OndungeonRecordChangeEvent(int dungeonId)
    {
        if (dungeonId != beastInvasionModel.dataMapID)
            return;
        ChangeCountText();
    }
 
    void ChangeCountText()
    {
        int totalCount = dungeonModel.GetMaxTimesShow(beastInvasionModel.dataMapID);
        int enterCount = dungeonModel.GetEnterTimes(beastInvasionModel.dataMapID);
        int remainCount = totalCount - enterCount;
        txtCount.colorType = remainCount > 0 ? TextColType.Green : TextColType.Red;
        txtCount.text = Language.Get("BlessedLand036", remainCount, totalCount);
    }
 
    void OnRefreshSecond()
    {
        ChangeTime();
    }
 
    void ChangeTime()
    {
        imgTime.SetActive(beastInvasionModel.dayReKind > 0);
        txtTime.text = beastInvasionModel.isTimeOk() ? Language.Get("BeastInvasion03", beastInvasionModel.GetRemainTime()) : Language.Get("BeastInvasion05");
    }
 
    void OnMyRefreshRank(int type)
    {
        if (type != beastInvasionModel.rankType)
            return;
        if (WindowCenter.Instance.IsOpen<BeastInvasionRankWin>())
            return;
        WindowCenter.Instance.Open<BeastInvasionRankWin>();
    }
}