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;
|
}
|
}
|