public override void Reason() { if (swarm.defenseTarget == null) { controller.PerformTransition(Transition.Patrol); } }
public override void Reason() { if (swarm.defenseTarget != null) { //Enter defend state mode controller.PerformTransition(Transition.Defend); } if (swarm.player != null) { //Check distance to player if (Vector3.Distance(controller.transform.position, swarm.player.transform.position) <= controller.PlayerDistance) { if (AIManager.aiManager.CanAttack(controller.aiType)) { controller.PerformTransition(Transition.Attack); } } } else { swarm.player = GameObject.FindGameObjectWithTag("Player"); } //Check waypoint distance if (controller.waypoints.Length > 0) { if (Vector3.Distance(controller.transform.position, controller.waypoints[patrolID].transform.position) <= controller.WaypointDistance) //Check distance to current waypoint { if (randomPoint) { patrolID = Random.Range(0, controller.waypoints.Length); //Choose random patrol point } else { patrolID++;//Progress to next waypoint if (patrolID >= controller.waypoints.Length) { patrolID = 0; //Circle back to first waypoint } } } } }