少年修仙传客户端代码仓库
hch
4 天以前 600733c8f592cb9e65f2b7a3e110ac1d686e6bfe
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
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
using vnxbqy.UI;
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
 
public class CrossServerBattleFieldResourceBehaviour : ILBehaviour
{
    List<Button> crystalBtns = new List<Button>();
    List<Image> crystalFlag = new List<Image>();
    List<Image> crystalImg = new List<Image>();
    List<UIAlphaTween> crystalAlpha = new List<UIAlphaTween>();
    List<Text> resRate = new List<Text>();
    Button buffBtn;
    Image buffImg;
    Button tyBossBtn;
    Text tyBossTxt;
    Button jfqBtn;
    Button jfghBtn;
    Text jfghCD;
 
    protected override void Awake()
    {
        for (int i = 0; i < 3; i++)
        {
            crystalBtns.Add(proxy.GetWidgtEx<Button>("Btn_Point" + i));
            crystalFlag.Add(proxy.GetWidgtEx<Image>("Btn_Point" + i));
            crystalImg.Add(proxy.GetWidgtEx<Image>("Crystal" + i));
            crystalAlpha.Add(proxy.GetWidgtEx<UIAlphaTween>("Crystal" + i));
            resRate.Add(proxy.GetWidgtEx<Text>("Rate" + i));
        }
        buffBtn = proxy.GetWidgtEx<Button>("SkillBottom3");
        buffImg = proxy.GetWidgtEx<Image>("Buff3");
        tyBossBtn = proxy.GetWidgtEx<Button>("Btn_tyboss");
        tyBossTxt = proxy.GetWidgtEx<Text>("Text1");
        jfqBtn = proxy.GetWidgtEx<Button>("Btn_jfq");
        jfghBtn = proxy.GetWidgtEx<Button>("Btn_jfgh");
        jfghCD = proxy.GetWidgtEx<Text>("Text2");
 
        for (int i = 0; i < 3; i++)
        {
            int index = i;
            crystalBtns[i].SetListener(() => {
                OnClickCrystalIcon(index);
            });
        }
    }
 
 
    protected override void OnEnable()
    {
        ILCrossServerModel.Instance.WorldInfoEvent += WorldInfoEvent;
        ILCrossServerModel.Instance.FactionInfEvent += FactionInfEvent;
        GlobalTimeEvent.Instance.secondEvent += OnSecondEvent;
        GameEvent.playerDataRefreshEvent += OnPlayerDataRefreshEvent;
 
        Display();
    }
 
    protected override void OnDisable()
    {
        ILCrossServerModel.Instance.WorldInfoEvent -= WorldInfoEvent;
        ILCrossServerModel.Instance.FactionInfEvent -= FactionInfEvent;
        GlobalTimeEvent.Instance.secondEvent -= OnSecondEvent;
        GameEvent.playerDataRefreshEvent -= OnPlayerDataRefreshEvent;
    }
 
 
    public void Display()
    {
        WorldInfoEvent();
        FactionInfEvent();
        OnSecondEvent();
    }
 
    void WorldInfoEvent()
    {
        var faction = Math.Max(PlayerDatas.Instance.baseData.faction, 1);
        for (int i = 0; i < 3; i++)
        {
            int npcID = ILCrossServerModel.Instance.crystalSortFaction[faction - 1][i];
            int _camp = 0;
            ILCrossServerModel.Instance.warCrystalDict.TryGetValue(npcID, out _camp);
            crystalFlag[i].SetSprite(_camp == 0 ? "GreyBottom" : _camp == 2 ? "RedBottom" : "BlueBottom");
            crystalImg[i].SetSprite(_camp == 0 ? "GrayCrystal" : _camp == 2 ? "RedCrystal" : "BlueCrystal");
            crystalAlpha[i].SetStartState();
            crystalAlpha[i].enabled = false;
 
            if (ILCrossServerModel.Instance.crystalAtkedList.Contains(npcID))
            {
                crystalAlpha[i].enabled = true;
            }
 
        }
 
 
        if (ILCrossServerModel.Instance.factionBuffNPCInfo.Count != 0)
        {
            buffBtn.SetActiveIL(true);
            var skillID = NPCConfig.Get(ILCrossServerModel.Instance.factionBuffNPCInfo[0]).Skill1;
            buffImg.SetSprite(SkillConfig.Get(skillID).IconName);
            int posX = ILCrossServerModel.Instance.factionBuffNPCInfo[1];
            int posY = ILCrossServerModel.Instance.factionBuffNPCInfo[2];
            buffBtn.SetListener(() =>
            {
                MoveToPos(posX, posY);
            });
        }
        else
        {
            buffBtn.SetActiveIL(false);
        }
 
        tyBossBtn.SetActiveIL(ILCrossServerModel.Instance.eventNPCID == ILCrossServerModel.Instance.CrossBattlefieldBossID);
        jfqBtn.SetActiveIL(ILCrossServerModel.Instance.eventNPCID == ILCrossServerModel.Instance.CrossBattlefieldScoreWallID);
        jfghBtn.SetActiveIL(ILCrossServerModel.Instance.eventNPCID == ILCrossServerModel.Instance.CrossBattlefieldScoreAuraID);
 
        int eventPosX = 0;
        int eventPosY = 0;
        if (ILCrossServerModel.Instance.eventNPCPos.Count == 2)
        {
            eventPosX = ILCrossServerModel.Instance.eventNPCPos[0];
            eventPosY = ILCrossServerModel.Instance.eventNPCPos[1];
        }
        tyBossBtn.SetListener(() => {
            MoveToPos(eventPosX, eventPosY, true);
        });
        jfqBtn.SetListener(() => {
            MoveToPos(eventPosX, eventPosY);
        });
        jfghBtn.SetListener(() => {
            MoveToPos(eventPosX, eventPosY);
        });
    }
 
    //buff资源加成 boss归属
    void FactionInfEvent()
    {
        var faction = Math.Max(PlayerDatas.Instance.baseData.faction, 1);
        bool isAddBuff = false;
 
        if (faction == 1)
        {
            isAddBuff = ILCrossServerModel.Instance.factionInfo_1.factionBuffInfo.Contains(7005);
        }
        else if (faction == 2)
        {
            isAddBuff = ILCrossServerModel.Instance.factionInfo_2.factionBuffInfo.Contains(7005);
        }
 
        for (int i = 0; i < 3; i++)
        {
            int npcID = ILCrossServerModel.Instance.crystalSortFaction[faction - 1][i];
            int _camp = 0;
            ILCrossServerModel.Instance.warCrystalDict.TryGetValue(npcID, out _camp);
 
            if (_camp == faction && isAddBuff)
            {
                resRate[i].SetActiveIL(true);
                resRate[i].text = "Buff 100%";
            }
            else
            {
                resRate[i].SetActiveIL(false);
            }
 
        }
 
        if (ILCrossServerModel.Instance.eventNPCID == ILCrossServerModel.Instance.CrossBattlefieldBossID)
        {
            int owner = 0;
            if (ILCrossServerModel.Instance.factionInfo_1.hurtBossValue > ILCrossServerModel.Instance.factionInfo_2.hurtBossValue)
            {
                owner = 1;
            }
            else if (ILCrossServerModel.Instance.factionInfo_1.hurtBossValue < ILCrossServerModel.Instance.factionInfo_2.hurtBossValue)
            {
                owner = 2;
            }
            tyBossTxt.text = Language.Get("CrossBattleField65") + Language.Get(owner == 0 ? "CrossBattleField37" : ("CrossBattleField20_" + owner));
 
        }
    }
 
    //积分光环倒计时
    void OnSecondEvent()
    {
        if (ILCrossServerModel.Instance.eventNPCID == ILCrossServerModel.Instance.CrossBattlefieldScoreAuraID)
        {
            var passTime = ((int)Time.time - ILCrossServerModel.Instance.startAuraTime);
            jfghCD.text = TimeUtility.SecondsToMS(Math.Max(ILCrossServerModel.Instance.eventEndTick / 1000 - passTime, 0));
        }
    }
 
    void OnPlayerDataRefreshEvent(PlayerDataType dataType)
    {
        if (dataType != PlayerDataType.Faction)
        {
            return;
        }
        Display();
    }
 
    //等待时间还未分配阵营
    void OnClickCrystalIcon(int index)
    {
        var faction = PlayerDatas.Instance.baseData.faction;
        if (faction == 0) return;
        int npcID = ILCrossServerModel.Instance.crystalSortFaction[faction - 1][index];
 
        //水晶有客户端挖洞的障碍点处理
        var destX = ILCrossServerModel.Instance.crystaPosDict[npcID][0];
        var destY = ILCrossServerModel.Instance.crystaPosDict[npcID][1];
        int pos1 = PlayerDatas.Instance.baseData.PosX;
        int pos2 = PlayerDatas.Instance.baseData.PosY;
        var posXFix = PlayerDatas.Instance.baseData.PosX > destX ? destX + 3 : destX - 3;
        var posYFix = PlayerDatas.Instance.baseData.PosY > destY ? destY + 3 : destY - 3;
 
        MoveToPos(posXFix, posYFix);
    }
 
    void MoveToPos(int posX, int posY, bool startAuto = false)
    {
        Vector2 vec = HeroControler.Instance.GetClientPos(posX, posY);
        PlayerDatas.Instance.hero.Behaviour.StopHandupAI(true);
        PlayerDatas.Instance.hero.IdleImmediate();
        PlayerDatas.Instance.hero.StopPathFind();
 
        if (startAuto)
        {
            PlayerDatas.Instance.hero.OnPathFindStop -= PathFindStop;
            PlayerDatas.Instance.hero.OnPathFindStop += PathFindStop;
        }
        MapTransferUtility.Instance.MoveToLocalMapPosition(vec);
 
    }
 
 
    void PathFindStop()
    {
        PlayerDatas.Instance.hero.OnPathFindStop -= PathFindStop;
        PlayerDatas.Instance.hero.Behaviour.StartHandupAI();
    }
}