// Use this for initialization void Start() { player = GameObject.FindGameObjectWithTag("Player"); state = new IdleAIState(); pathfinding = GetComponent <EnemyPathFinding>(); character = GetComponent <PlatformerCharacter2D>(); }
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); }
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(); } }
private void Start() { anim = GetComponent <Animator>(); text.GetComponentInParent <Animator>().SetBool("cutscene", GameManager.instance.PlayCutscene); enemy = FindObjectOfType <EnemyPathFinding>(); if (!GameManager.instance.PlayCutscene) { CloseDoor(); EndCutscene(); } }
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); }
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); } }
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); }
public override void init(EnemyController controller, EnemyPathFinding pathfinding) { controller.character.Move(0, false, true, false); timer = 0.3f; }
public override void init(EnemyController controller, EnemyPathFinding pathfinding) { timer = Random.Range(1, 4); }
public override void init(EnemyController controller, EnemyPathFinding pathfinding) { timer = Random.Range(4, 8); direction = Random.Range(0, 2) == 0 ? -1 : 1; }
public abstract void Handle(EnemyController controller, EnemyPathFinding pathfinding, bool incomingArrow);
public abstract void init(EnemyController controller, EnemyPathFinding pathfinding);