少年修仙传客户端代码仓库
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
using vnxbqy.UI;
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
 
public class ClientHazyDemonKingStage : DungeonStage
{
    static readonly Vector3 playerBornPosition = new Vector3(10, 6.38f, 6.67f);
    static readonly Vector3 bossBornPosition = new Vector3(8.35f, 6.37f, 9.7f);
 
    static GA_NpcClientFightBoss s_ClientBoss = null;
 
    float stepTimer = 0f;
    float exitTime = 10f;
 
    Step m_Step = Step.Fight;
    public Step step
    {
        get { return m_Step; }
        set
        {
            m_Step = value;
        }
    }
 
    HazyDemonKingModel model { get { return ModelCenter.Instance.GetModel<HazyDemonKingModel>(); } }
    HazyRegionModel hazyRegionModel { get { return ModelCenter.Instance.GetModel<HazyRegionModel>(); } }
    DungeonModel dungeonModel { get { return ModelCenter.Instance.GetModel<DungeonModel>(); } }
 
    public override void Initialize()
    {
        base.Initialize();
 
        m_Step = Step.None;
 
        dungeonModel.onDungeonResultEvent += OnDungeonResultEvent;
        PersonalEnemy.OnNpcAppear += OnNpcAppear;
    }
 
    protected override void OnStageLoadFinish()
    {
        base.OnStageLoadFinish();
 
        InitializePlayer();
        InitializeBoss();
 
        step = Step.Fight;
 
        DTC0403_tagPlayerLoginLoadOK.playerLoginOkEvent += PlayerLoginOkEvent;
    }
 
    public static uint GetClientBossSid()
    {
        if (s_ClientBoss != null)
        {
            return s_ClientBoss.ServerInstID;
        }
        return 0;
    }
 
    void InitializePlayer()
    {
        var hero = PlayerDatas.Instance.hero;
        hero.Pos = playerBornPosition;
        if (hero.Behaviour != null)
        {
            hero.Behaviour.StartHandupAI();
        }
        CameraController.Instance.Apply();
    }
 
 
    void InitializeBoss()
    {
        uint hp = 0;
        uint hpEx = 0;
        var position = bossBornPosition;
        if (s_ClientBoss != null)
        {
            hp = (uint)(s_ClientBoss.ActorInfo.Hp % Constants.ExpPointValue);
            hpEx = (uint)(s_ClientBoss.ActorInfo.Hp / Constants.ExpPointValue);
            position = s_ClientBoss.Pos;
            PersonalEnemy.Release(s_ClientBoss);
        }
 
        var incidentId = hazyRegionModel.GetIncidentId(ClientDungeonStageUtility.dungeonInfo.mapId, ClientDungeonStageUtility.dungeonInfo.lineId);
        var config = HazyRegionConfig.Get(incidentId);
        PersonalEnemy.Create((uint)config.npcId, E_ActorGroup.Enemy, position, hp, hpEx);
    }
 
    private void OnDungeonResultEvent()
    {
        step = Step.Settle;
        dungeonModel.UpdateCoolDown(DungeonCoolDownType.LeaveMap, 10 * 1000);
    }
 
    private void OnNpcAppear(GA_NpcClientFightNorm _npc)
    {
        var incidentId = hazyRegionModel.GetIncidentId(ClientDungeonStageUtility.dungeonInfo.mapId, ClientDungeonStageUtility.dungeonInfo.lineId);
        var config = HazyRegionConfig.Get(incidentId);
        if (_npc.NpcConfig.NPCID == config.npcId)
        {
            s_ClientBoss = _npc as GA_NpcClientFightBoss;
        }
    }
 
 
    private void PlayerLoginOkEvent()
    {
        if (step <= Step.Fight)
        {
            InitializeBoss();
        }
    }
 
    public override void UnInitialize()
    {
        base.UnInitialize();
 
        if (s_ClientBoss != null)
        {
            s_ClientBoss = null;
        }
 
        dungeonModel.onDungeonResultEvent -= OnDungeonResultEvent;
        PersonalEnemy.OnNpcAppear -= OnNpcAppear;
        DTC0403_tagPlayerLoginLoadOK.playerLoginOkEvent -= PlayerLoginOkEvent;
    }
 
#if UNITY_EDITOR
    private void OnGUI()
    {
        if (GUILayout.Button("Exit"))
        {
            ClientDungeonStageUtility.ExitNormalClientDungeon();
        }
    }
#endif
 
    public enum Step
    {
        None,
        Fight,
        Settle,
    }
}