Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.SceneManagement;
- using TMPro;
- public class GameController : MonoBehaviour
- {
- GameObject playerObject;
- PlayerController player;
- public TextMeshProUGUI gameOverText;
- public TextMeshProUGUI restartText;
- void Start()
- {
- playerObject = GameObject.Find("Player");
- player = playerObject.GetComponent<PlayerController>();
- }
- void Update()
- {
- if (playerObject.transform.position.y < -5.0f)
- {
- player.LoseHealth(1);
- playerObject.transform.position = this.transform.position;
- }
- if (Input.GetKeyDown(KeyCode.R) && player.IsDead() == true)
- {
- SceneManager.LoadScene(0);
- }
- if (Input.GetKeyDown(KeyCode.Escape))
- {
- Application.Quit();
- }
- }
- public void GameOverSequence()
- {
- gameOverText.gameObject.SetActive(true);
- restartText.gameObject.SetActive(true);
- playerObject.SetActive(false);
- Spawner spawner = GameObject.Find("Spawner").GetComponent<Spawner>();
- spawner.StopSpawning();
- }
- }
Add Comment
Please, Sign In to add comment