using UnityEngine;
|
|
public class Cmd0501 : CmdBase
|
{
|
private uint ObjID;
|
private byte MoveType;
|
private Vector3 m_TargetPosition;
|
|
public override void Init(GameNetPackBasic netPack)
|
{
|
H0501_tagObjMove m_NetPack = netPack as H0501_tagObjMove;
|
ObjID = m_NetPack.ObjID;
|
MoveType = m_NetPack.MoveType;
|
m_TargetPosition.x = (m_NetPack.DestPosX - GA_Hero.MapOffset.x) * .5f;
|
m_TargetPosition.z = (m_NetPack.DestPosY - GA_Hero.MapOffset.z) * .5f;
|
|
GActorFight _actor = GAMgr.Instance.GetBySID(ObjID) as GActorFight;
|
if (_actor != null && _actor.ActorInfo.serverDie == false)
|
{
|
_actor.ActorInfo.moveSpeed = 500f / m_NetPack.Speed;
|
}
|
}
|
|
public override void Update()
|
{
|
if (m_TargetPosition == Vector3.zero)
|
{
|
m_Finished = true;
|
return;
|
}
|
|
GActorFight _actor = GAMgr.Instance.GetBySID(ObjID) as GActorFight;
|
|
if (_actor == null
|
|| _actor.ActorInfo.serverDie)
|
{
|
m_Finished = true;
|
return;
|
}
|
|
if (_actor.SkillMgr.CurCastSkill != null)
|
{
|
if (_actor.SkillMgr.CurCastSkill.SkillCompelete == false)
|
{
|
return;
|
}
|
}
|
|
m_TargetPosition.y = _actor.Pos.y;
|
|
float _chkDistance = MathUtility.DistanceSqrtXZ(_actor.Pos, m_TargetPosition);
|
|
if (_chkDistance < 0.5f)
|
{
|
if (_actor.ActorType == GameObjType.gotPlayer)
|
{
|
(_actor as GActorPlayerBase).StopRush();
|
}
|
m_Finished = true;
|
}
|
else
|
{
|
if (_actor.State != E_ActorState.AutoRun)
|
{
|
_actor.MoveToPosition(m_TargetPosition);
|
}
|
}
|
}
|
}
|