lemansky

Untitled

Apr 11th, 2021 (edited)
922
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.21 KB | None | 0 0
  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.  
Add Comment
Please, Sign In to add comment