//Handle states private void Update() { //Get the game state GameStateManager.GameState GAME_STATE = GameStateManager.STATE; //Always be able to reset if (Input.GetKeyDown(KeyCode.R)) { Restart(); } //Handle each game state switch (GAME_STATE) { case GameStateManager.GameState.Init: //Increment our week number WEEK++; //Load any emails taht start on this week LoadEmails(); //Init the actions list, set our day begin screen off, then change states. InitActionList(); //Load in a status and turn it on LoadStatus(); STATUS_BAR.SetActive(true); DAY_BEGIN_SCREEN.SetActive(false); ALL_EMAIL_SCREEN.GetComponent <AllEmailScreenManager>().InitList(EMAIL_LIST); GameStateManager.SetCurrentState(GameStateManager.GameState.PlayerInput); break; case GameStateManager.GameState.PlayerInput: //Handle the state of player input switch (STATE) { case EmailSiteState.AllEmails: //If this isn't on, turn it on. if (!ALL_EMAIL_SCREEN.activeSelf) { DAY_BEGIN_SCREEN.SetActive(false); PROCESS_SCREEN.SetActive(false); ONE_EMAIL_SCREEN.SetActive(false); BM.ApplyColors(BackgroundManager.BackgroundStates.Inbox); ALL_EMAIL_SCREEN.SetActive(true); } //Update the list ALL_EMAIL_SCREEN.GetComponent <AllEmailScreenManager>().UpdateList(ACTION_LIST); break; case EmailSiteState.OneEmail: ONE_EMAIL_SCREEN.GetComponent <OneEmailScreenManager>().SetEmail(SELECTED_EMAIL); //If this isn't on, turn it on, and turn the other one off. if (!ONE_EMAIL_SCREEN.activeSelf) { DAY_BEGIN_SCREEN.SetActive(false); PROCESS_SCREEN.SetActive(false); ALL_EMAIL_SCREEN.SetActive(false); BM.ApplyColors(BackgroundManager.BackgroundStates.Email); ONE_EMAIL_SCREEN.SetActive(true); } break; default: Debug.Log("Error, shouldn't happen. Email site state is invalid."); break; } break; case GameStateManager.GameState.Processing: //Disable relevent screens and enable the right one. if (!PROCESS_SCREEN.activeSelf) { DAY_BEGIN_SCREEN.SetActive(false); ALL_EMAIL_SCREEN.SetActive(false); ONE_EMAIL_SCREEN.SetActive(false); STATUS_BAR.SetActive(false); BM.ApplyColors(BackgroundManager.BackgroundStates.Sleep); PROCESS_SCREEN.SetActive(true); } break; case GameStateManager.GameState.Waiting: if (!DAY_BEGIN_SCREEN.activeSelf) { //If we just finished week 4, we should end the game, else do the default if (WEEK != 4) { ALL_EMAIL_SCREEN.SetActive(false); ONE_EMAIL_SCREEN.SetActive(false); PROCESS_SCREEN.SetActive(false); BM.ApplyColors(BackgroundManager.BackgroundStates.Message); DAY_BEGIN_SCREEN.SetActive(true); DAY_BEGIN_SCREEN.GetComponent <DayBeginScreenManager>().InitScreen(); } else { //Do the final message thing ALL_EMAIL_SCREEN.SetActive(false); ONE_EMAIL_SCREEN.SetActive(false); PROCESS_SCREEN.SetActive(false); DAY_BEGIN_SCREEN.SetActive(false); BM.ApplyColors(BackgroundManager.BackgroundStates.End); END_SCREEN.SetActive(true); END_SCREEN.GetComponent <EndScreenManager>().EndGame(); } } break; case GameStateManager.GameState.Restarting: Debug.Log("restarting"); //Find any missing objects if (DAY_BEGIN_SCREEN == null) { Debug.Log("Looking for replacements"); DESKTOP = GameObject.Find("Desktop"); DAY_BEGIN_SCREEN = FindObject(DESKTOP, "Day Begin Screen"); ALL_EMAIL_SCREEN = FindObject(DESKTOP, "All Emails Screen"); ONE_EMAIL_SCREEN = FindObject(DESKTOP, "One Email Screen"); PROCESS_SCREEN = FindObject(DESKTOP, "Process Screen"); STATUS_BAR = FindObject(DESKTOP, "StatusBar"); END_SCREEN = FindObject(DESKTOP, "End Screen"); BM = GameObject.Find("Background").GetComponent <BackgroundManager>(); if (DAY_BEGIN_SCREEN != null) { Debug.Log("Replacement found"); //Set to init. InitActionList(); InitEmailList(); SetGameStateManager(1); } } break; default: Debug.Log("Invalid game state!"); break; } }
//Load in a possible status public void LoadStatus() { STATUS_BAR.GetComponent <StatusController>().LoadStatus(WEEK, HAPPINESS); }