using System.Collections;
using UnityEngine;
using UnityEngine.UI;
public class GameManger : MonoBehaviour
{
public GameObject playButton;
public GameObject playerShip;
public GameObject enemySpawner;
public GameObject enemySpawner2;
public GameObject deathMenu;
private ScoreManager theScoreManager;
public enum GameManagerState
{
Opening,
Gameplay,
GameOver,
Restart,
}
GameManagerState GMState;
void Start ()
{
GMState = GameManagerState.Opening;
theScoreManager = FindObjectOfType<ScoreManager> ();
}
void UpdateGameManagerState()
{
switch (GMState)
{
case GameManagerState.Opening:
playButton.SetActive (true);
break;
case GameManagerState.Gameplay:
playButton.SetActive (false);
playerShip.GetComponent<PlayerControl> ().Init ();
enemySpawner.GetComponent<EnemySpawner> ().ScheduleEnemySpawner ();
theScoreManager.scoreIncreasing = true;
break;
case GameManagerState.GameOver:
enemySpawner.GetComponent<EnemySpawner> ().UnscheduleEnemySpawner ();
deathMenu.SetActive (true);
theScoreManager.scoreIncreasing = false;
theScoreManager.scoreCount = 0;
Invoke("ChangeToOpeningState", 4f);
break;
}
}
public void SetGameManagerState(GameManagerState state)
{
GMState = state;
UpdateGameManagerState ();
}
public void StartGamePlay()
{
GMState = GameManagerState.Gameplay;
UpdateGameManagerState ();
}
public void ChangeToOpeningState()
{
SetGameManagerState (GameManagerState.Opening);
}
}
Everything that is stated to happen in Game state “GameOver”, doesn’t execute, such as the enemy spawner stopping and the score to stop increasing. Whats causing this? The only thing that executes correctly would be the enemy spawner starting, it actually starts when i click the play button. I am an extreme newbie around this stuff, so give me a bit of slack.