// Use this for initialization
		void Start () {

			controlerStart ();

			characterControlling = gameObject.GetComponent<CharacterBehavior> ();
		
		}
Пример #2
0
		/// <summary>
		/// Adds a character to the game.
		/// </summary>
		/// <param name="character">Character.</param>
		public void addCharacterToGame(CharacterBehavior character){

			// If the character their trying to add is null
			if (character == null) {
				Debug.LogError("The character your trying to add to the Game Manager is null!");
				return;
			}

			// If the character their trying to add has already been added
			if (charactersInScene.Contains (character)) {
				Debug.LogError("The character your trying is add is already listed in the Game Manager!");
				return;
			}

			charactersInScene.Add (character);

			if (currentModeBeingPlayed != null) {

				// Alert the game mode.
				currentModeBeingPlayed.onCharacterAdd (character);

			} else {
				Debug.LogWarning("You just added a character to the scene while theres no game mode running!");
			}

		}
		/// <summary>
		/// When a bunny dies
		/// </summary>
		/// <param name="character">Character.</param>
		public void onCharacterDeath(CharacterBehavior character){

			// If the queen was killed
			if (bunnyQueen.Equals (character)) {

				roundsVacuumHaveWon ++;
				goToEndOfRound();

			} else {

				spawnBattery();

				// TODO spawn the player back in 10 seconds

				// TODO slow the vacuum for 5 seconds
			}

		}
		/// <summary>
		/// Removes the character from the game and alerta the game mode that
		/// it has died
		/// </summary>
		/// <param name="character">Character.</param>
		public void removeCharacterFromGame(CharacterBehavior character){
			
			// If the character their trying to remove is null
			if (character == null) {
				Debug.LogError("The character your trying to remove from the Game Manager is null!");
				return;
			}
			
			// If the character their trying to remove isn't here
			if (!charactersInScene.Contains (character)) {
				Debug.LogError("The character your trying to remove is not listed in the Game Manager!");
				return;
			}
			
			charactersInScene.Remove (character);
			
			if (currentModeBeingPlayed != null) {
				
				// Alert the game mode.
				currentModeBeingPlayed.onCharacterDeath (character);
				
			} else {
				Debug.LogWarning("You just removed a character from the scene while theres no game mode running!");
			}
			
		}
		public abstract void onCharacterAdd(CharacterBehavior character);
		public abstract void onCharacterDeath(CharacterBehavior character);
		/// <summary>
		/// Play a cool effect when a character is spawned
		/// </summary>
		/// <param name="character">Character.</param>
		public override void onCharacterAdd(CharacterBehavior character){
			//TODO play a cool effect when a character is spawned
			NotificationSystem.createNotification("A player has spawned!",2f);
		}
		public override void onCharacterAdd(CharacterBehavior character){

			Debug.Log (character.getName() + " has been added to the scene!");

		}
		public override void onCharacterDeath(CharacterBehavior character){

			Debug.Log (character.getName()+" has died!");

		}
		private void startRound(){

			currentRound ++;
			currentGameState = GameState.BeingPlayed;

			// Initialize timing variables
			lastBatterySpawnTime = Time.time;
			timeRoundStarted = Time.time;

			// Spawn all characters at appropriate places, bunnies clustered together and away from the vacuum
			Vector3 bunnySpawn = mapData.getRandomSpawnPoint (0);

			GameObject[] bunnies = new GameObject[3];
			bunnies[0] = BunnyFactory.createBunny (bunnySpawn);
			bunnies[1] = BunnyFactory.createBunny (new Vector3(bunnySpawn.x + Random.Range(1f, 2f), bunnySpawn.y, bunnySpawn.z + Random.Range(1f, 2f)));
			bunnies[2] = BunnyFactory.createBunny (new Vector3(bunnySpawn.x - Random.Range(1f, 2f), bunnySpawn.y, bunnySpawn.z - Random.Range(1f, 2f)));

			// Choose a random bunny to be the queen
			bunnyQueen = bunnies[Random.Range(0, bunnies.Length-1)].GetComponent<CharacterBehavior>();

			// Making sure the vacuum isn't in the same spawn area unless there is only one spawn area
			Vector3 vacuumSpawn = mapData.getRandomSpawnPoint (mapData.getSpawnAreas().Length-1);
			VacuumFactory.createVacuum (vacuumSpawn);

		}
		/// <summary>
		/// Play a cool effect when a character is spawned
		/// </summary>
		/// <param name="character">Character.</param>
		public void onCharacterAdd(CharacterBehavior character){
			//TODO play a cool effect when a character is spawned
		}