private void Start() { //get the gamemode and add yourself to the onDistanceUpdate delegate InGameGameMode GM = InGameGameMode.GetGameMode(); GM.OnDistanceUpdate += DistanceUpdate; //hide the object till its ready gameObject.SetActive(false); }
//unPauses the game void UnPauseGame() { //Unpauses the gamemode InGameGameMode.GetGameMode()?.UnPauseGame(); //hides objects PauseMenu.SetActive(false); //shows objects btnPause.gameObject.SetActive(true); //plays the button sound is sound manager exists. SoundManager.GetSoundManager()?.PlayButtonPressed(); }
void Start() { //add on button click events btnPause.onClick.AddListener(PauseGame); btnUnpause.onClick.AddListener(UnPauseGame); btnRestart.onClick.AddListener(Restart); //assigning update distance text to the delegate in the game mode InGameGameMode GM = InGameGameMode.GetGameMode(); GM.OnDistanceUpdate += DistanceUpdate; //hides and shows UI objects txtDistance.gameObject.SetActive(false); btnPause.gameObject.SetActive(false); PauseMenu.SetActive(false); GameOverMenu.SetActive(false); }
//If the player hits one of the triggers, then they fell out of the world private void OnTriggerEnter(Collider other) { //if the thing that entered the trigger the player if (!other.gameObject.GetComponent <PlayerController>()) { return; } //if the game is running if (InGameGameMode.GetGameMode().IsGameRunning()) { //Get the GameMode & call fall out world InGameGameMode.GetGameMode()?.PlayerFellOutWorld(); //play the fell out of world sound effect. SoundManager.GetSoundManager()?.PlayFallOutWorld(); } }
private void OnTriggerEnter(Collider other) { //see if what hit you was the player collider PlayerController PC = other.gameObject.GetComponent <PlayerController>(); if (!PC) { return; } //get the game mode if (InGameGameMode.GetGameMode().IsGameRunning()) { //spawn the particles in the world WorldGen.GetWorld()?.PlayParticles(PC.transform.position); //play the cleared pipe sound effect. SoundManager.GetSoundManager()?.PlayClearedPipe(); } }
//If the player hits one of the triggers, then they Hit Something private void OnTriggerEnter(Collider other) { //if the thing that entered the trigger the player if (!other.gameObject.GetComponent <PlayerController>()) { return; } //if the game is running if (InGameGameMode.GetGameMode().IsGameRunning()) { //Get the GameMode & call hit something InGameGameMode.GetGameMode()?.PlayerHitSomething(); //Get the sound Manager and play the hit sound SoundManager.GetSoundManager()?.PlayPlayerHit(); //Play the screen shake FindObjectOfType <ScreenShake>()?.SetShakerTime(.4f); } }
//The animation for fading text in and out IEnumerator CountDown() { yield return(new WaitForSeconds(1.0f)); txtCountDown.text = "3"; animator.SetTrigger("PulseText"); yield return(new WaitForSeconds(0.5f)); SoundManager.GetSoundManager()?.PlayCountDownBeep(); yield return(new WaitForSeconds(0.5f)); txtCountDown.text = "2"; animator.SetTrigger("PulseText"); yield return(new WaitForSeconds(0.5f)); SoundManager.GetSoundManager()?.PlayCountDownBeep(); yield return(new WaitForSeconds(0.5f)); txtCountDown.text = "1"; animator.SetTrigger("PulseText"); yield return(new WaitForSeconds(0.5f)); SoundManager.GetSoundManager()?.PlayCountDownBeep(); yield return(new WaitForSeconds(0.5f)); txtCountDown.text = "GO!"; animator.SetTrigger("PulseText"); yield return(new WaitForSeconds(0.5f)); SoundManager.GetSoundManager()?.PlayGameStartSound(); InGameGameMode.GetGameMode().StartGame(); yield return(new WaitForSeconds(1f)); //hid the go, destroy the UI; Destroy(gameObject); }
private void Start() { //find the gamemode gameMode = InGameGameMode.GetGameMode(); }
private void Start() { GM = InGameGameMode.GetGameMode(); }