public override void Enter() { SceneManager.LoadScene("scene1"); fleetManager = owner.GetComponent <FleetManager>(); // Get VideoManager videoManager = GameObject.Find("VideoManager").GetComponent <VideoManager>(); // Set the first 3 ships to attack for (int i = 0; i < fleetManager.ships.Count && i < 3; i++) { Boid ship = fleetManager.ships[i]; ship.GetComponent <StateMachine>().ChangeState(new AttackState(fleetManager.borg)); ship.maxSpeed = Random.Range(20.0f, 30.0f); ship.StartCoroutine(ship.ChangeSpeed()); } // Change Camera Target FollowCamera mainCamera = Camera.main.GetComponent <FollowCamera>(); mainCamera.target = fleetManager.GetComponent <GameObject>(); videoPlayed = false; fleetManager.audioSource.Stop(); fleetManager.audioSource.clip = fleetManager.battleMusic; fleetManager.audioSource.loop = true; fleetManager.audioSource.Play(); //foreach (Ship ship in fleetManager.shipComp) { // ship.audioSource.loop = true; // ship.audioSource.clip = fleetManager.flybySound; // ship.audioSource.Play(); //} }
void NextWave() { // Set more ships to attack shipsToAttack = Random.Range(3, 10); int attackingShips = 0; for (int i = 0; i < fleetManager.ships.Count && attackingShips < shipsToAttack; i++) { Boid ship = fleetManager.ships[i]; StateMachine stateMachine = ship.GetComponent <StateMachine>(); if (stateMachine.state.GetType().Name == "IdleState") { ship.GetComponent <StateMachine>().ChangeState(new AttackState(fleetManager.borg)); ship.maxSpeed = Random.Range(20.0f, 30.0f); ship.StartCoroutine(ship.ChangeSpeed()); attackingShips++; } } // Remove the no of ships attacking if the no exceeds the total no of ships shipsToAttack = attackingShips < shipsToAttack ? attackingShips : shipsToAttack; initialShipsAlive = fleetManager.ships.Count; }
public override void Enter() { fleetManager = owner.GetComponent <FleetManager>(); // Get inital no of ships alive initialShipsAlive = fleetManager.ships.Count; // Set more ships to attack shipsToAttack = Random.Range(3, 5); for (int i = 1; i < fleetManager.ships.Count && i < shipsToAttack; i++) { Boid ship = fleetManager.ships[i]; ship.GetComponent <StateMachine>().ChangeState(new AttackState(fleetManager.borg)); ship.maxSpeed = Random.Range(20.0f, 30.0f); ship.StartCoroutine(ship.ChangeSpeed()); } // Load the scene and wait for it to initiallise fleetManager.StartCoroutine(LoadScene()); }