public void OnTriggerEnter(Collider collision)
 {
     if (collision.gameObject == owner.GetTarget() && !owner.GetTargetInTerritory())
     {
         owner.SetTargetInTerritory(true);
     }
 }
Beispiel #2
0
 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));
     }
 }