using Snxxz.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(); _collider.center = new Vector3(0, .6f, 0); _collider.radius = .5f; _collider.height = 1.2f; m_NPCInteractProcessor = Root.AddMissingComponent(); 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(); } }