using UnityEngine;
|
|
public class CmdB402 : CmdBase
|
{
|
private uint m_PlayerID;
|
private Vector3 m_TargetPostion = Vector3.zero;
|
private float m_LimitTime;
|
|
public override void Init(GameNetPackBasic netPack)
|
{
|
HB402_tagMCRush m_NetPack = netPack as HB402_tagMCRush;
|
m_PlayerID = m_NetPack.ID;
|
m_TargetPostion.x = (m_NetPack.PosX - GA_Hero.MapOffset.x) * .5f;
|
m_TargetPostion.z = (m_NetPack.PosY - GA_Hero.MapOffset.z) * .5f;
|
|
m_LimitTime = Time.realtimeSinceStartup;
|
}
|
|
public override void Update()
|
{
|
if (m_TargetPostion == Vector3.zero)
|
{
|
m_Finished = true;
|
return;
|
}
|
|
GActorPlayerBase _player = GAMgr.Instance.GetBySID(m_PlayerID) as GActorPlayerBase;
|
|
if (_player == null || _player.ActorInfo.serverDie)
|
{
|
m_Finished = true;
|
return;
|
}
|
|
_player.StartRush();
|
|
float _chkDistance = MathUtility.DistanceSqrtXZ(_player.Pos, m_TargetPostion);
|
|
_player.MoveToPosition(m_TargetPostion);
|
|
if (_chkDistance < 0.5f)
|
{
|
_player.StopRush();
|
m_Finished = true;
|
}
|
|
if (Time.realtimeSinceStartup - m_LimitTime > 2f)
|
{
|
_player.StopRush();
|
m_Finished = true;
|
}
|
|
}
|
|
}
|