public void StartButtonPressed() { Debug.Log("pressed start button"); m_questionManager = QuestionManager.GetQuestionManager(); m_audioManager = AudioManager.GetAudioManager(); m_settingsManager = SettingsManager.GetSettingsManager(); m_settingsManager.ResetSettings(); PlayerProgress playerProgress = PlayerProgress.GetPlayerProgress(); if (playerProgress.TotalPlayerScore() == 0) { // player is completely new. Go straight into the game with the first quiz. QuestionManager qm = QuestionManager.GetQuestionManager(); qm.SetQuiz(0, 0); string sceneName = qm.GetQuizSceneNameForCurrentMode(); Debug.Log("scene name : " + sceneName); SceneManager.LoadScene(sceneName); } else { // player has played the game before. Go into level select. SceneManager.LoadScene("jigsaw Level Select"); } }
public static PlayerProgress GetPlayerProgress() { // tries to find in the scene // if not, then create one and initialise it. GameObject playerProgressObject = GameObject.Find("PlayerProgressPrefab(Clone)"); if (playerProgressObject) { // return the existing one return(playerProgressObject.GetComponent <PlayerProgress>()); } else { // create a new one playerProgressObject = Instantiate(Resources.Load("PlayerProgressPrefab")) as GameObject; PlayerProgress playerProgress = playerProgressObject.GetComponent <PlayerProgress>(); DontDestroyOnLoad(playerProgress.gameObject); // make it persist between scenes playerProgress.Init(); return(playerProgress); } }