using UnityEngine;
|
using vnxbqy.UI;
|
using System.Collections.Generic;
|
|
|
/// <summary>
|
/// 跑跑跑副本AI行为
|
/// 当追逐到终点的时候默认会回到起点从新开始选怪的逻辑
|
/// </summary>
|
public class HeroAI_D3_BackToStartPos : HeroAI_Auto
|
{
|
private DungeonModel m_DungeonModel;
|
private DungeonModel DgModel
|
{
|
get { return m_DungeonModel ?? (m_DungeonModel = ModelCenter.Instance.GetModel<DungeonModel>()); }
|
}
|
|
private Vector3 m_StartPos;
|
private Vector3 m_EndPos;
|
private bool m_DoingMovingToStart;
|
|
#region 配置相关
|
#endregion
|
|
public sealed override bool Condition()
|
{
|
GA_Hero _hero = PlayerDatas.Instance.hero;
|
if (_hero == null)
|
{
|
return false;
|
}
|
|
if (_hero.aiHandler.currentType == E_HeroAIType.D3_BackToStartPos)
|
{
|
return true;
|
}
|
|
return base.Condition();
|
}
|
|
protected override void OnEnter()
|
{
|
m_LockTargetSID = 0;
|
m_DoingMovingToStart = false;
|
|
FuncConfigConfig func = FuncConfigConfig.Get("AI197Point");
|
LitJson.JsonData _data = LitJson.JsonMapper.ToObject(func.Numerical1);
|
foreach (var _key in _data.Keys)
|
{
|
if (_key.Equals(PlayerDatas.Instance.baseData.MapID.ToString()))
|
{
|
m_StartPos = new Vector3(((int)_data[_key][0][0] - GA_Hero.MapOffset.x) * .5f, 0, ((int)_data[_key][0][1] - GA_Hero.MapOffset.z) * .5f);
|
m_EndPos = new Vector3(((int)_data[_key][1][0] - GA_Hero.MapOffset.x) * .5f, 0, ((int)_data[_key][1][1] - GA_Hero.MapOffset.z) * .5f);
|
}
|
}
|
|
m_HandupRange = 10;
|
}
|
|
protected override bool OnUpdate()
|
{
|
GA_Hero _hero = PlayerDatas.Instance.hero;
|
|
if (_hero == null)
|
{
|
return false;
|
}
|
|
float _chkDistSqrt;
|
if (m_DoingMovingToStart)
|
{
|
_chkDistSqrt = MathUtility.DistanceSqrtXZ(_hero.Pos, m_StartPos);
|
if (_chkDistSqrt > 1)
|
{
|
if (_hero.State != E_ActorState.AutoRun)
|
{
|
m_StartPos.y = _hero.Pos.y;
|
_hero.MoveToPosition(m_StartPos);
|
}
|
return true;
|
}
|
m_DoingMovingToStart = false;
|
}
|
else
|
{
|
if (m_EndPos != Vector3.zero)
|
{
|
_chkDistSqrt = MathUtility.DistanceSqrtXZ(_hero.Pos, m_EndPos);
|
if (_chkDistSqrt < 9)
|
{
|
m_DoingMovingToStart = true;
|
}
|
}
|
}
|
|
return false;
|
}
|
|
protected sealed override void OnExit()
|
{
|
}
|
|
public sealed override bool IsOver()
|
{
|
if (base.IsOver())
|
{
|
return true;
|
}
|
|
return PlayerDatas.Instance.hero.aiHandler.currentType
|
!= E_HeroAIType.D3_BackToStartPos;
|
}
|
|
protected sealed override GActorFight SelectTarget()
|
{
|
return DecideAttackTarget(PlayerDatas.Instance.hero.Pos,
|
m_HandupRange);
|
}
|
|
}
|