public override void update() { if (!m_isRunning) { run(); } if (m_target == null || m_target.state == ActorState.DEAD || m_actor.state == ActorState.DEAD) { StopMoveEvtArg arg = new StopMoveEvtArg(); arg.ac = m_actor; m_actor.FireEvent(m_actor, EventType.EVT_STOP_MOVE, arg); m_bFinished = true; return; } if (Vector3.Distance(m_target.transform.position, m_actor.transform.position) > m_actor.attackRange) { BeginMoveEvtArg arg = new BeginMoveEvtArg(); arg.ac = m_actor; arg.position = m_target.transform.position; m_actor.FireEvent(m_actor, EventType.EVT_BEGIN_MOVE, arg); } else { //Debug.Log("AttackCommand : BeginAttackEvent"); BeginAttackEvtArg arg = new BeginAttackEvtArg(); arg.attackerID = m_actor.transform.GetInstanceID(); arg.targetID = m_target.transform.GetInstanceID(); arg.ac = m_actor; arg.target = m_target; m_actor.FireEvent(this, EventType.EVT_BEGIN_ATTACK, arg); } }
void stopMove() { agent.SetDestination(transform.position); StopMoveEvtArg arg = new StopMoveEvtArg(); arg.ac = this; FireEvent(this, EventType.EVT_STOP_MOVE, arg); }
void OnStopMove(object sender, EventArgs arg) { StopMoveEvtArg e = arg as StopMoveEvtArg; if (e.ac == this) { SetState(new IdleActorState(this)); } }
public override void update() { if (!m_isRunning) { run(); } if (Vector3.Distance(m_position, m_actor.transform.position) <= Global.MinUnitDistance) { m_bFinished = true; StopMoveEvtArg arg = new StopMoveEvtArg(); arg.ac = m_actor; m_actor.FireEvent(m_actor, EventType.EVT_STOP_MOVE, arg); return; } m_actor.agent.SetDestination(m_position); }