少年修仙传客户端代码仓库
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
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
using UnityEngine;
using System.Collections;
using vnxbqy.UI;
 
public class GA_NpcClientFunc : GActorNpcNoFight
{
    private HeadUpName m_HeadUpName;
    // 用于触发点击的组件
    private NPCInteractProcessor m_NPCInteractProcessor;
 
    protected override void OnInit(GameNetPackBasic package)
    {
        IsUnInit = false;
        ActorInfo.PlayerName = NpcConfig.charName;
        // 功能NPC需要读取配置朝向
        GAStaticDefine.NPCLocation _npcLocation;
        if (GAStaticDefine.TryGetMapNPCLocation(NpcConfig.NPCID, out _npcLocation))
        {
            Rotation = MathUtility.GetClientRotationFromAngle(_npcLocation.face);
        }
        else
        {
            Rotation = Quaternion.Euler(0, UnityEngine.Random.Range(0, 360), 0);
        }
 
        ActorType = GameObjType.gotNPC;
        Root.gameObject.layer = LayerUtility.Monster;
 
        if (CanBeSelected())
        {
            CapsuleCollider _collider = Root.AddMissingComponent<CapsuleCollider>();
            _collider.center = new Vector3(0, NpcConfig.ModleHeight * .5f, 0);
            _collider.radius = NpcConfig.ModelRadius;
            _collider.height = NpcConfig.ModleHeight;
 
            m_NPCInteractProcessor = Root.AddMissingComponent<NPCInteractProcessor>();
            m_NPCInteractProcessor.npcIntergactEvent += OnClick;
        }
 
        if (NpcConfig.ModeProportion != 1)
        {
            Root.localScale = Vector3.one * NpcConfig.ModeProportion;
        }
 
        RequestShadow();
 
        if (NpcConfig.NPCEffect != 0)
        {
            m_AppearEffect = SFXPlayUtility.Instance.PlayBattleEffect(NpcConfig.NPCEffect, this);
        }
 
        int _loadNpcID = NpcConfig.NPCID;
        if (_loadNpcID == 10804101)
        {
            if (PlayerDatas.Instance.baseData.Job == 1)
            {
                _loadNpcID = 10404100;
            }
            else if (PlayerDatas.Instance.baseData.Job == 2)
            {
                _loadNpcID = 10404101;
            }
        }
 
        // 开始异步加载表现层
        InstanceResourcesLoader.AsyncLoadNpc(_loadNpcID, OnPrefabLoadFinished);
    }
 
    protected override void OnUnit()
    {
        base.OnUnit();
    }
 
    public override void OnClick()
    {
        if (GA_Hero.s_MapSwitching)
        {
            return;
        }
 
        GA_Hero _hero = PlayerDatas.Instance.hero;
        _hero.LockTarget = this;
        _hero.SelectTarget = this;
 
        float _chkDistSqrt = MathUtility.DistanceSqrtXZ(_hero.Pos, Pos);
 
        // 这里判断是否要走向此对象
        if (_chkDistSqrt > 2f)
        {
            MapTransferUtility.Instance.MoveToNPC(NpcConfig.NPCID);
        }
 
        if (_chkDistSqrt < 4)
        {
            if (!PreFightMission.Instance.IsFinished())
            {
                int _configID = -1;
                if (NpcConfig.NPCID == 10104001)
                {
                    _configID = 1007;
                }
                else if (NpcConfig.NPCID == 1006)
                {
                    _configID = 1009;
                }
 
                if (_configID > 0)
                {
                    if (!WindowCenter.Instance.IsOpen<GuideDialogueWin>())
                    {
                        GuideDialogueModel _model = ModelCenter.Instance.GetModel<GuideDialogueModel>();
                        _model.dialogID = _configID;
                        _model.onClose = null;
                        WindowCenter.Instance.Open<GuideDialogueWin>();
                    }
                }
            }
            else if (AdventureStage.Instance.IsInAdventureStage
                  || ClientDungeonStageUtility.isClientDungeon)
            {
                NPCInteractProcessor.InvokeEvent(E_NpcType.Func, NpcConfig.NPCID, ServerInstID);
            }
        }
    }
 
    protected override void OnLateUpdate() { }
    protected override void OnFixedUpdate() { }
    protected override void OnUpdate() { }
 
    public sealed override void Die() { }
    public sealed override void Hurt() { }
    public sealed override void HurtDown() { }
 
    public sealed override void RequestLifeBar() { }
    public sealed override void ReleaseLifeBar() { }
 
    public sealed override void RequestName()
    {
        ReleaseName();
 
        HeadUpName.Pattern _pattern = HeadUpName.Pattern.FunctionNPC;
 
        m_HeadUpName = HeadUpName.RequireHeadUpName(_pattern, MP_Name, 0, CameraController.Instance.CameraObject);
 
 
        if (NpcConfig.NPCID == 1006)
        {
            m_HeadUpName.SetNPCName(1007);
        }
        else
        {
            int _loadNpcID = NpcConfig.NPCID;
            if (_loadNpcID == 10804101)
            {
                if (PlayerDatas.Instance.baseData.Job == 1)
                {
                    _loadNpcID = 10404100;
                }
                else if (PlayerDatas.Instance.baseData.Job == 2)
                {
                    _loadNpcID = 10404101;
                }
            }
 
            m_HeadUpName.SetNPCName(_loadNpcID);
        }
 
    }
 
    public sealed override void ReleaseName()
    {
        if (m_HeadUpName)
        {
            m_HeadUpName.target = null;
            HeadUpName.Recycle(m_HeadUpName);
            m_HeadUpName = null;
        }
    }
 
    public override void OnSelect()
    {
        SelectionManager.Request(SelectionManager.E_Type.Green, this, (NpcConfig.ModelRadius * 2) / Root.transform.localScale.x);
 
        GA_Hero _hero = PlayerDatas.Instance.hero;
        Vector3 _forward = MathUtility.ForwardXZ(Pos, _hero.Pos);
        _hero.Forward = _forward;
 
        if (NpcConfig.AutomaticFace == 1)
        {
            _forward = MathUtility.ForwardXZ(_hero.Pos, Pos);
            Forward = _forward;
        }
    }
 
    public override void OnUnSelect()
    {
        SelectionManager.Release(SelectionManager.E_Type.Green);
    }
 
    public override bool CanBeSelected()
    {
        return true;
    }
}