Guest User

GameController

a guest
Apr 11th, 2017
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.39 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. using UnityEngine.SceneManagement;
  6. using UnityEngine.UI;
  7.  
  8. public class GameManager : MonoBehaviour {
  9.  
  10.     public static GameManager GM;
  11.  
  12.     public GameObject player;
  13.     public float lowerLimit = -20f;
  14.  
  15.     public GameObject HUDHistoria;
  16.     public int coins = 0;
  17.     public Text coinsText;
  18.     public Text argumento;
  19.  
  20.     public GameObject HUD;
  21.     public GameObject deadMenu;
  22.  
  23.     public Text FinalCoins;
  24.  
  25.     // Use this for initialization
  26.     void Awake ()
  27.     {
  28.         if (GM == null)
  29.         {
  30.             GM = gameObject.GetComponent<GameManager> ();
  31.         }
  32.     }
  33.    
  34.     // Update is called once per frame
  35.     void Update ()
  36.     {
  37.         if(player.transform.position.y <= lowerLimit)
  38.         {
  39.             player.GetComponent<PlayerController> ().PlayerDead ();
  40.         }
  41.     }
  42.  
  43.     public void PickupCoin ()
  44.     {
  45.         coins++;
  46.         coinsText.text = coins.ToString ();
  47.  
  48.         if (coins == 2)
  49.         {
  50.             HUDHistoria.SetActive (true);
  51.             argumento.text = "Texto de prueba";
  52.         }
  53.  
  54.         if (coins == 8)
  55.         {
  56.             HUDHistoria.SetActive (true);
  57.             argumento.text = "Texto a probar";
  58.         }
  59.  
  60.     }
  61.  
  62.     public void EndGame ()
  63.     {
  64.         HUD.SetActive (false);
  65.  
  66.         FinalCoins.text = coins.ToString ();
  67.  
  68.         deadMenu.SetActive (true);
  69.     }
  70.  
  71.     public void Retry()
  72.     {  
  73.         SceneManager.LoadScene (SceneManager.GetActiveScene ().buildIndex);
  74.     }
  75.  
  76.     public void MainMenu()
  77.     {
  78.         SceneManager.LoadScene("MainMenu");
  79.     }
  80. }
Add Comment
Please, Sign In to add comment