private void Start() { // For debuggin and testing (normally game starts at scene START) if (SceneManager.GetActiveScene().buildIndex == INGAME) { GetInGameVariables(); pauseScreen.UnPause(); gameOverSeq.enabled = false; music = GameObject.Find("Background Music").GetComponent <BackgroundMusic>(); music.Init(); music.StartVariatedLoop(); showIntro = true; worldMan.enabled = false; introSeq.enabled = true; } // Make sure this class can only be instantiated once if (instance == null) { SceneManager.sceneLoaded += OnSceneLoaded; DontDestroyOnLoad(gameObject); instance = this; } else { Destroy(gameObject); } //print(SceneManager.GetActiveScene().name); if (SceneManager.GetActiveScene().name == scenePaths[START]) { startMenu = GameObject.Find("Start Menu").GetComponent <StartMenu>(); music = GameObject.Find("Background Music").GetComponent <BackgroundMusic>(); music.Init(); music.StartNormalLoop(); startMenu.StartMenuInit(); showIntro = true; diffLvl = 1; // Set default difficult level to 1 (normal) //print("In active scene start in gamecontroller start"); } }
/* Initiates the end of the game session. Retrives information required by GAME_OVER scene, * disables WorldManager and either switches to GAME_OVER scene or enables GameOverSeq. */ public void GameOver() { nrRescuedVictims = worldMan.player.nrRescuedVictims; gameplayTime = (int)Time.time - worldMan.player.gamePlayStartTime; gameSuccess = nrRescuedVictims == VictimFactory.maxVictims[instance.diffLvl]; worldMan.enabled = false; worldMan.intManager.ResetInRangeInteractable(); worldMan.player.infoBox.Close(); music.StartNormalLoop(); if (gameSuccess) { SwitchScene(GAME_OVER); } else { gameOverSeq.enabled = true; gameOverSeq.Init(); } }