Exemplo n.º 1
0
 public void Execute()
 {
     Idle();
     if (enemy.Target != null)
     {
         enemy.ChangeState(new PatrolState());
     }
 }
Exemplo n.º 2
0
        public void Execute()
        {
            Patrol();

            if (enemy.Target != null)
            {
                enemy.ChangeState(new AttackState());
            }
        }
Exemplo n.º 3
0
        public void Execute()
        {
            if (enemy.Target != null)
            {
                if (Vector3.Distance(enemy.Target.transform.position, enemy.transform.position) < enemy.attackRange)
                {
                    // Do attack
                    enemy.h      = 0;
                    enemy.attack = true;
                }
                else
                {
                    enemy.attack = false;
                    float xDir = enemy.Target.transform.position.x - enemy.transform.position.x;

                    if (xDir < 0)
                    {
                        enemy.h = -1;
                    }
                    else if (xDir > 0)
                    {
                        enemy.h = 1;
                    }
                    else
                    {
                        enemy.h = 0;
                    }
                }
            }
            else
            {
                enemy.attack = false;
                //maybe only do it if the AI reached the end of it's path
                enemy.ChangeState(new PatrolState());
            }
        }