| Fight/Actor/AI/AI_Npc_198.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
| Fight/Actor/AI/AI_Npc_198.cs.meta | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
| Fight/Actor/AI/SampleAI.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
| Fight/Actor/HeroBehaviour.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
| Fight/GameActor/GA_NpcClientFightNorm.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
Fight/Actor/AI/AI_Npc_198.cs
New file @@ -0,0 +1,84 @@ using UnityEngine; public class AI_Npc_198 : SampleAI { public AI_Npc_198(GA_NpcClientFightNorm owner, Vector3 bornPosition) : base(owner, bornPosition) { m_SleepTime = 1f; owner.OnAttacked += OnAttacked; m_RunAwayStep = 0; } public override void UnInit() { base.UnInit(); m_Owner.OnAttacked -= OnAttacked; } public void OnAttacked() { } public override void Update() { // ai休眠时间 if (Time.realtimeSinceStartup - m_LastThinkTime > m_SleepTime) { _Thinking(); } switch (m_AIStatus) { case E_AIStatus.Patrol: break; case E_AIStatus.MoveToBornPos: break; case E_AIStatus.RunAway: break; } } private byte m_RunAwayStep = 0; private Vector3 m_Dest; private void _RunAway() { switch (m_RunAwayStep) { case 0: // 选择一个逃跑点 break; case 1: break; } } private void _Thinking() { float _compareDis; var _hero = PlayerDatas.Instance.hero; if (_hero == null || _hero.ActorInfo.serverDie) { // 主角不存在或者死亡了 // 在出生点附近 _compareDis = MathUtility.DistanceSqrtXZ(BornPos, m_Owner.Pos); if (_compareDis < 4) { m_AIStatus = E_AIStatus.Patrol; } // 巡逻 // 不在出生点附近 else { // 回到出生点 m_AIStatus = E_AIStatus.MoveToBornPos; } } else { _compareDis = MathUtility.DistanceSqrtXZ(m_Owner.Pos, BornPos); } } } Fight/Actor/AI/AI_Npc_198.cs.meta
New file @@ -0,0 +1,12 @@ fileFormatVersion: 2 guid: 763a044dd191f9f488407103aa8e17f2 timeCreated: 1555317155 licenseType: Pro MonoImporter: serializedVersion: 2 defaultReferences: [] executionOrder: 0 icon: {instanceID: 0} userData: assetBundleName: assetBundleVariant: Fight/Actor/AI/SampleAI.cs
@@ -9,6 +9,7 @@ MoveToTarget,// 向目标移动 Attack,// 攻击 MoveToBornPos,// 向出生点移动 RunAway,// 逃离 } public Vector3 BornPos; @@ -285,4 +286,6 @@ m_Owner.CastSkill(_skill.id); } public virtual void UnInit() { } } Fight/Actor/HeroBehaviour.cs
@@ -879,7 +879,7 @@ var _clientNpc = _target as GA_NpcClientFightNorm; if (_clientNpc != null) { _clientNpc.heroAttacked = true; _clientNpc.BeAttacked(); } skill.hurtClntFightNpcList.Add(_hurtObject); Fight/GameActor/GA_NpcClientFightNorm.cs
@@ -55,6 +55,18 @@ public bool heroAttacked; public int posIndex = -1; public UnityEngine.Events.UnityAction OnAttacked; public void BeAttacked() { if (OnAttacked != null) { OnAttacked(); } heroAttacked = true; } protected override void OnInit(GameNetPackBasic package) { base.OnInit(package); @@ -135,7 +147,11 @@ m_NPCInteractProcessor = null; } m_AIHandler = null; if (m_AIHandler != null) { m_AIHandler.UnInit(); m_AIHandler = null; } if (m_Obstacle) {