少年修仙传客户端代码仓库
hch
2025-03-03 28785d6ddf9c08e49527ede9405c7b6c93c6ed32
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
using vnxbqy.UI;
using UnityEngine;
using UnityEngine.Events;
 
public class GA_NpcFightBoss : GA_NpcFightNorm
{
    /// <summary>
    /// 1. 实例ID, 2. Npc表ID
    /// </summary>
    public static UnityAction<uint, int, bool> s_OnSelect;
    /// <summary>
    /// 1. 实例ID, 2. Npc表ID, 3.当前血量, 4. 总血量
    /// </summary>
    public static UnityAction<uint, int, ulong, ulong> s_HpRefresh;
 
    protected override void OnInit(GameNetPackBasic package)
    {
        base.OnInit(package);
    }
 
    protected sealed override void OnMainModelLoaded()
    {
        base.OnMainModelLoaded();
 
        GA_Hero _hero = PlayerDatas.Instance.hero;
        if (_hero != null)
        {
            destForward = Forward = MathUtility.ForwardXZ(_hero.Pos, Pos);
        }
    }
 
    public sealed override void OnSelect()
    {
        if (ActorInfo.serverDie)
        {
            return;
        }
 
        SelectionManager.Request(SelectionManager.E_Type.Red, this);
        RequestName();
        if (s_OnSelect != null)
        {
            s_OnSelect(ServerInstID, NpcConfig.NPCID, true);
        }
    }
 
    public sealed override void OnUnSelect()
    {
        SelectionManager.Release(SelectionManager.E_Type.Red);
 
        if (s_OnSelect != null)
        {
            s_OnSelect(ServerInstID, NpcConfig.NPCID, false);
        }
    }
 
    public sealed override void RequestDialogueBubble()
    {
        if (m_DialogAppear)
        {
            NPCDialogueBubble.Recyle(m_DialogAppear);
        }
    }
 
    protected override sealed void UpdateTimeDialogueBubble()
    {
        if (!MP_Stun)
        {
            return;
        }
        // 瞎BB逻辑
        if (Time.realtimeSinceStartup - m_LastTalkTime > 5)
        {
            if (m_DialogTiming != null)
            {
                NPCDialogueBubble.Recyle(m_DialogTiming);
            }
            m_DialogTiming = NPCDialogueBubble.TimingShow(NpcConfig.NPCID, MP_Stun, CameraController.Instance.CameraObject);
            m_LastTalkTime = Time.realtimeSinceStartup;
        }
    }
 
    public override void RefreshLifeBar(ulong value)
    {
        var _hero = PlayerDatas.Instance.hero;
        if ((_hero != null
          && _hero.SelectTarget == this)
          || ModelCenter.Instance.GetModel<HazyDemonKingModel>().IsInDungeon)
        {
            // 非选中状态下不刷新
            if (s_HpRefresh != null)
            {
                s_HpRefresh(ServerInstID, NpcConfig.NPCID, ActorInfo.RealHp, ActorInfo.RealMaxHp);
            }
        }
    }
 
    private float m_LastPlayTime;
 
    public sealed override void PlayHurtAudio(GActorFight attacker)
    {
        base.PlayHurtAudio(attacker);
 
        if (Time.time - m_LastPlayTime > GeneralDefine.PlayBossHurtInterval)
        {
            if (m_AudioSource)
            {
                if (NpcConfig.Sounds != null)
                {
                    if (NpcConfig.Sounds.Length > 1)
                    {
                        SoundPlayer.Instance.PlayAudio(m_AudioSource, NpcConfig.Sounds[1]);
                    }
                }
            }
 
            m_LastPlayTime = Time.time;
        }
 
    }
    public override void RequestName()
    {
        ReleaseName();
    }
 
    #region Boss类型不需要实现的方法, 覆盖掉父类
    public sealed override void RequestLifeBar() { }
    public sealed override void ReleaseLifeBar() { }
    #endregion
}