public void Execute() { if (owner.GetTargetInTerritory()) { owner.GetStateMachineEnemy().SetState(new EnemyMovingState(owner)); } else if (owner.InRangeToAttack()) { owner.GetStateMachineEnemy().SetState(new EnemyAttackState(owner)); } }
public void Execute() { if (owner.GetTargetInTerritory()) { if (owner.InRangeToAttack()) { owner.GetStateMachineEnemy().SetState(new EnemyAttackState(owner)); } else if (owner.GetDistanceFromTarget() > 1f) { owner.GetAgent().SetDestination(owner.GetTarget().transform.position); } } else if (!owner.GetTargetInTerritory() && owner.GetDistanceFromInitialPos() > 1f) { owner.GetAgent().SetDestination(owner.GetInitialPosition()); } else { owner.GetStateMachineEnemy().SetState(new EnemyIdleState(owner)); } }
public void Execute() { if (owner.InRangeToAttack()) { if (owner.GetTimeToAttack() > 0) { owner.DecreaseTimeToAttack(Time.deltaTime); owner.GetAnimator().SetBool("attack", false); } else { owner.GetAnimator().SetBool("attack", true); owner.PerformAttack(); owner.ResetTimeToAttack(); } } else { owner.GetStateMachineEnemy().SetState(new EnemyMovingState(owner)); } }