Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using UnityEngine.SceneManagement;
- using UnityEngine.UI;
- public class GameController : MonoBehaviour
- {
- public static GameController instance;
- public GameObject gameOverText;
- public Text scoreText;
- private int score = 0;
- private bool gameOver = false;
- void Awake()
- {
- if (instance == null)
- {
- instance = this;
- }
- else if (instance != this)
- {
- Destroy(gameObject);
- }
- }
- void Update()
- {
- if (gameOver && Input.GetMouseButtonDown(0))
- {
- SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex);
- }
- }
- public void BirdScored()
- {
- if (gameOver)
- {
- return;
- }
- score++;
- scoreText.text = "Score: " + score.ToString();
- }
- public void BirdDied()
- {
- gameOverText.SetActive(true);
- gameOver = true;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment