少年修仙传客户端代码仓库
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
using vnxbqy.UI;
using UnityEngine;
 
public class GA_NpcSummonFunc : GA_NpcFunc
{
    private H0408_tagPlayerSummonNPCAppear m_H0408;
 
    protected override void OnInit(GameNetPackBasic package)
    {
        m_H0408 = package as H0408_tagPlayerSummonNPCAppear;
 
        if (m_H0408 == null)
        {
            Debug.LogErrorFormat("Npc 执行初始化时, 传入的包错误...{0}", package.GetType());
        }
 
        // 初始化坐标
        AdjustPos(m_H0408.PosX, m_H0408.PosY);
 
        // 功能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);
        }
 
        GActor _owner = GAMgr.Instance.GetBySID(m_H0408.PlayerID);
        if (_owner != null)
        {
            ActorInfo.PlayerName = _owner.ActorInfo.PlayerName;
        }
        else
        {
            ActorInfo.PlayerName = NpcConfig.charName;
        }
 
        CapsuleCollider _collider = Root.AddMissingComponent<CapsuleCollider>();
        _collider.center = new Vector3(0, .6f, 0);
        _collider.radius = .5f;
        _collider.height = 1.2f;
 
        m_NPCInteractProcessor = Root.AddMissingComponent<NPCInteractProcessor>();
        m_NPCInteractProcessor.npcIntergactEvent += OnClick;
 
        RequestName();
 
        GAStaticDefine.NpcID2ServerInstID[NpcConfig.NPCID] = ServerInstID;
    }
 
    public override void OnClick()
    {
        GA_Hero _hero = PlayerDatas.Instance.hero;
        if (_hero == null)
        {
            return;
        }
 
        if (_hero.IsDaZuo())
        {
            return;
        }
 
        base.OnClick();
    }
}