// Update is called once per frame void Update () { if (playerDied) { if (!deathmenu) { Invoke("deathMenu", 2f); deathmenu = true; } //for BGM GetComponent<AudioSource>().volume = 0; GetComponent<Image>().color = new Vector4(GetComponent<Image>().color.r, GetComponent<Image>().color.g, GetComponent<Image>().color.b, 0.2f); } else { //Track the time taken for each stage. showTimeTaken(); GetComponent<AudioSource>().volume = PlayerPrefs.GetFloat("BGMvolume"); if (sceneIndex != 1) { if (tutorialOn) { Time.timeScale = 0f; GetComponent<Image>().color = new Vector4(GetComponent<Image>().color.r, GetComponent<Image>().color.g, GetComponent<Image>().color.b, 0.3f); timingTopLeft.SetActive(false); movementControls.SetActive(false); } else { Time.timeScale = 1f; GetComponent<Image>().color = new Vector4(GetComponent<Image>().color.r, GetComponent<Image>().color.g, GetComponent<Image>().color.b, 0f); timingTopLeft.SetActive(true); movementControls.SetActive(true); } } else { GetComponent<Image>().color = new Vector4(GetComponent<Image>().color.r, GetComponent<Image>().color.g, GetComponent<Image>().color.b, 0.3f); } if (pause) { Time.timeScale = 0f; pauseMenu.SetActive(true); } else { Time.timeScale = 1.0f; pauseMenu.SetActive(false); } if (gameClear) { Time.timeScale = 0; stageSelection.checkStarsObtained(); completionScreen.SetActive(true); } if (nextLevel) { Time.timeScale = 1; completionScreen.SetActive(false); print("Load Next level!"); levelManager.nextLevel(); } if (stageSelect) { startMenu.SetActive(false); pauseButton.SetActive(true); movementControls.SetActive(false); stageSelectMenu.SetActive(true); stagePageOne.SetActive(true); pauseMenu.SetActive(false); optionsMenu.SetActive(false); completionScreen.SetActive(false); dieMenu.SetActive(false); } if (options) { startMenu.SetActive(false); pauseButton.SetActive(true); movementControls.SetActive(false); stageSelectMenu.SetActive(false); stagePageOne.SetActive(true); pauseMenu.SetActive(false); optionsMenu.SetActive(true); completionScreen.SetActive(false); dieMenu.SetActive(false); } } // if (surePrompt){ // startMenu.SetActive(false); // pauseButton.SetActive(false); // movementControls.SetActive(false); // stageSelectMenu.SetActive(false); // stagePageOne.SetActive(false); // pauseMenu.SetActive(false); // optionsMenu.SetActive(false); // completionScreen.SetActive(false); // } }
// Update is called once per frame void Update() { if (playerDied) { if (!deathmenu) { Invoke("deathMenu", 2f); deathmenu = true; } //for BGM GetComponent <AudioSource>().volume = 0; GetComponent <Image>().color = new Vector4(GetComponent <Image>().color.r, GetComponent <Image>().color.g, GetComponent <Image>().color.b, 0.2f); } else { GetComponent <AudioSource>().volume = PlayerPrefs.GetFloat("BGMvolume"); if (sceneIndex == 0) { GetComponent <Image>().color = new Vector4(GetComponent <Image>().color.r, GetComponent <Image>().color.g, GetComponent <Image>().color.b, 0.3f); } else { if (videoPlayer != null) //if there is no video player attached { if (videoPlayer.activeInHierarchy) //executes when video player is active { timingTopLeft.SetActive(false); movementControls.SetActive(false); zoomButton.SetActive(false); pauseButton.SetActive(false); } else if (tutorialOn) //checks for tutorial { GetComponent <Image>().color = new Vector4(GetComponent <Image>().color.r, GetComponent <Image>().color.g, GetComponent <Image>().color.b, 0.3f); timingTopLeft.SetActive(false); movementControls.SetActive(false); zoomButton.SetActive(false); pauseButton.SetActive(true); } else //no tutorial { GetComponent <Image>().color = new Vector4(GetComponent <Image>().color.r, GetComponent <Image>().color.g, GetComponent <Image>().color.b, 0f); timingTopLeft.SetActive(true); movementControls.SetActive(true); zoomButton.SetActive(true); pauseButton.SetActive(true); } } else //if there is a video player attached { if (tutorialOn) //checks for tutorial { GetComponent <Image>().color = new Vector4(GetComponent <Image>().color.r, GetComponent <Image>().color.g, GetComponent <Image>().color.b, 0.3f); timingTopLeft.SetActive(false); movementControls.SetActive(false); zoomButton.SetActive(false); pauseButton.SetActive(true); } else //no tutorial { GetComponent <Image>().color = new Vector4(GetComponent <Image>().color.r, GetComponent <Image>().color.g, GetComponent <Image>().color.b, 0f); timingTopLeft.SetActive(true); movementControls.SetActive(true); zoomButton.SetActive(true); pauseButton.SetActive(true); } } } //controls time if (videoPlayer != null) { if (pause || tutorialOn || videoPlayer.activeInHierarchy) { } else { showTimeTaken(); } } else { if (pause || tutorialOn) { } else { showTimeTaken(); } } //executes pause if (pause) { pauseMenu.SetActive(true); } else { pauseMenu.SetActive(false); } if (gameClear) { Time.timeScale = 0; stageSelection.checkStarsObtained(); completionScreen.SetActive(true); timingTopLeft.SetActive(false); movementControls.SetActive(false); zoomButton.SetActive(false); pauseButton.SetActive(false); } if (nextLevel) { Time.timeScale = 1; completionScreen.SetActive(false); print("Load Next level!"); levelManager.nextLevel(); } if (stageSelect) { startMenu.SetActive(false); pauseButton.SetActive(true); movementControls.SetActive(false); stageSelectMenu.SetActive(true); stagePageOne.SetActive(true); pauseMenu.SetActive(false); optionsMenu.SetActive(false); completionScreen.SetActive(false); dieMenu.SetActive(false); } if (options) { startMenu.SetActive(false); pauseButton.SetActive(true); movementControls.SetActive(false); stageSelectMenu.SetActive(false); stagePageOne.SetActive(true); pauseMenu.SetActive(false); optionsMenu.SetActive(true); completionScreen.SetActive(false); dieMenu.SetActive(false); } } // if (surePrompt){ // startMenu.SetActive(false); // pauseButton.SetActive(false); // movementControls.SetActive(false); // stageSelectMenu.SetActive(false); // stagePageOne.SetActive(false); // pauseMenu.SetActive(false); // optionsMenu.SetActive(false); // completionScreen.SetActive(false); // } }