lemansky

Untitled

Apr 11th, 2021
699
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.SceneManagement;
  5. using TMPro;
  6. public class GameController : MonoBehaviour
  7. {
  8.  
  9.     GameObject _playerObject;
  10.     PlayerController _player;
  11.  
  12.     public TextMeshProUGUI gameOverText;
  13.     public TextMeshProUGUI restartText;
  14.     void Start()
  15.     {
  16.         _playerObject = GameObject.Find("Player");
  17.         _player = _playerObject.GetComponent<PlayerController>();
  18.     }
  19.  
  20.     void Update()
  21.     {
  22.         if (_playerObject.transform.position.y < -5.0f)
  23.         {
  24.             _player.LoseHealth(1);
  25.  
  26.             _playerObject.transform.position = this.transform.position;
  27.         }
  28.  
  29.         if (Input.GetKeyDown(KeyCode.R) && _player.IsDead() == true)
  30.         {
  31.             SceneManager.LoadScene(0);
  32.         }
  33.  
  34.         if (Input.GetKeyDown(KeyCode.Escape))
  35.         {
  36.             Application.Quit();
  37.         }
  38.     }
  39.  
  40.     public void GameOverSequence()
  41.     {
  42.         gameOverText.gameObject.SetActive(true);
  43.         restartText.gameObject.SetActive(true);
  44.         _playerObject.SetActive(false);
  45.         Spawner spawner = GameObject.Find("Spawner").GetComponent<Spawner>();
  46.         spawner.StopSpawning();
  47.     }
  48.  
  49. }
  50.  
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×