void Start() { playerHealth = GetComponent <PlayerHealth>(); scoreController = GetComponent <ScoreController>(); sectionSelector = GetComponent <SectionSelector>(); timer.Reset(); currentState = GameState.Generating; colorWheel = GameObject.Find("ColorWheel").GetComponent <ColorWheel>(); colorWheel.Deactivate(); }
void Update() { if (Input.GetKeyDown(KeyCode.Escape)) { // IF dead or won the game, exit the game if (currentState == GameState.Dead || currentState == GameState.Won) { PauseMenu.GetComponent <PauseMenu>().ExitGame(); return; } PauseMenu.SetActive(true); if (currentState == GameState.PickingColor) { colorWheel.Deactivate(); alreadySetupBeforePicking = false; alreadySetupBeforeColoring = false; currentState = GameState.PickingSection; } gameObject.SetActive(false); return; } // Check for interruption: if (InterruptTime > 0) { InterruptTime -= Time.deltaTime; return; } if (timer.IsCountingDown) { timer.Update(); } switch (currentState) { case GameState.Generating: Generate(); break; case GameState.PickingMonster: PickMonster(); break; case GameState.CreatingScene: CreateScene(); break; case GameState.PickingSection: if (alreadySetupBeforePicking == false) { SetStateBeforeSectionPicking(); } UpdateWhenPickingSection(); break; case GameState.PickingColor: if (alreadySetupBeforeColoring == false) { SetStateBeforeColoring(); } UpdateWhenColoring(); break; case GameState.TimeIsUp: UpdateWhenTimeIsUp(); break; case GameState.Dead: UpdateWhenDead(); break; case GameState.Won: PlayerHasWon(); break; } }