Exemplo n.º 1
0
 // Use this for initialization
 void Start()
 {
     player      = GameObject.FindGameObjectWithTag("Player");
     state       = new IdleAIState();
     pathfinding = GetComponent <EnemyPathFinding>();
     character   = GetComponent <PlatformerCharacter2D>();
 }
Exemplo n.º 2
0
    public override void Handle(EnemyController controller, EnemyPathFinding pathfinding, bool incomingArrow)
    {
        timer -= Time.deltaTime;
        //Check if we need to switch states
        if (incomingArrow)
        {
            controller.State = new AvoidAIState();
        }
        else if (controller.isPlayerNearAndTargetable())
        {
            controller.State = new AttackAIState();
        }
        else if (timer <= 0)
        {
            controller.State = new IdleAIState();
        }
        //Handle the state we are in
        if (controller.transform.position.x > pathfinding.rightLimit)
        {
            direction = -1;
        }

        else if (controller.transform.position.x < pathfinding.leftLimit)
        {
            direction = 1;
        }
        controller.character.Move(direction, false, false, false);
    }
 // Start is called before the first frame update
 void Start()
 {
     spotter     = GetComponent <EnemyPlayerSpotter>();
     pathFinding = GetComponent <EnemyPathFinding>();
     Invoke("ChooseRandomLocation", 2);
     alreadyInvoking = true;
     tooFarSec       = Random.Range(2, 6);
 }
Exemplo n.º 4
0
 public override void Handle(EnemyController controller, EnemyPathFinding pathfinding, bool incomingArrow)
 {
     timer -= Time.deltaTime;
     //Check if we need to switch states
     if (timer <= 0 && controller.character.Grounded)
     {
         controller.State = new WalkAIState();
     }
 }
Exemplo n.º 5
0
    private void Start()
    {
        anim = GetComponent <Animator>();
        text.GetComponentInParent <Animator>().SetBool("cutscene", GameManager.instance.PlayCutscene);
        enemy = FindObjectOfType <EnemyPathFinding>();

        if (!GameManager.instance.PlayCutscene)
        {
            CloseDoor();
            EndCutscene();
        }
    }
Exemplo n.º 6
0
    public override void Handle(EnemyController controller, EnemyPathFinding pathfinding, bool incomingArrow)
    {
        timer -= Time.deltaTime;
        //Check if we need to switch states
        if (incomingArrow)
        {
            controller.State = new AvoidAIState();
        }
        else if (controller.isPlayerNearAndTargetable())
        {
            controller.State = new AttackAIState();
        }
        else if (timer <= 0)
        {
            controller.State = new WalkAIState();
        }

        //Handle the state we are in
        controller.character.Move(0, false, false, false);
    }
Exemplo n.º 7
0
    public override void Handle(EnemyController controller, EnemyPathFinding pathfinding, bool incomingArrow)
    {
        //Check if we need to switch states
        if (incomingArrow)
        {
            controller.State = new AvoidAIState();
        }
        else if (!controller.isPlayerNearAndTargetable())
        {
            controller.State = new WalkAIState();
        }

        //Handle the state we are in
        if (controller.character.m_FacingRight != (controller.transform.position.x - controller.player.transform.position.x) < 0)
        {
            controller.character.Move((controller.transform.position.x - controller.player.transform.position.x) < 0? 0.1f:-0.1f, false, false, true);
        }
        else
        {
            controller.character.Move(0, false, false, true);
        }
    }
Exemplo n.º 8
0
 public override void init(EnemyController controller, EnemyPathFinding pathfinding)
 {
     controller.character.Move((controller.transform.position.x - controller.player.transform.position.x) < 0? 0.1f:-0.1f, false, false, true);
 }
Exemplo n.º 9
0
 public override void init(EnemyController controller, EnemyPathFinding pathfinding)
 {
     controller.character.Move(0, false, true, false);
     timer = 0.3f;
 }
Exemplo n.º 10
0
 public override void init(EnemyController controller, EnemyPathFinding pathfinding)
 {
     timer = Random.Range(1, 4);
 }
Exemplo n.º 11
0
 public override void init(EnemyController controller, EnemyPathFinding pathfinding)
 {
     timer     = Random.Range(4, 8);
     direction = Random.Range(0, 2) == 0 ? -1 : 1;
 }
Exemplo n.º 12
0
 public abstract void Handle(EnemyController controller, EnemyPathFinding pathfinding, bool incomingArrow);
Exemplo n.º 13
0
 public abstract void init(EnemyController controller, EnemyPathFinding pathfinding);