少年修仙传客户端代码仓库
client_linchunjie
2019-03-04 2a86bfa84ad4ed870703022ea765e29f16d25a08
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
using UnityEngine;
using System.Collections;
using Snxxz.UI;
 
public class GA_NpcClientFunc : GActorNpcNoFight
{
    private HeadUpName m_HeadUpName;
    // 用于触发点击的组件
    private NPCInteractProcessor m_NPCInteractProcessor;
 
    protected override void OnInit(GameNetPackBasic package)
    {
        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);
        }
 
        if (CanBeSelected())
        {
            m_NPCInteractProcessor = Root.AddMissingComponent<NPCInteractProcessor>();
            m_NPCInteractProcessor.npcIntergactEvent += OnClick;
        }
    }
 
    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)
        {
            _hero.MoveToPosition(Pos, 1f);
        }
 
        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>();
                    }
                }
            }
        }
    }
 
    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
        {
            m_HeadUpName.SetNPCName(NpcConfig.NPCID);
        }
 
    }
 
    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;
 
        _forward = MathUtility.ForwardXZ(_hero.Pos, Pos);
        Forward = _forward;
    }
 
    public override void OnUnSelect()
    {
        SelectionManager.Release(SelectionManager.E_Type.Green);
    }
 
    public override bool CanBeSelected()
    {
        return true;
    }
}