Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2014
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 4.21 KB | None | 0 0
  1. using UnityEngine;
  2. using UnityEngine.UI;
  3. using System.Collections;
  4.  
  5. //[ExecuteInEditMode]
  6. public class GUIScript : MonoBehaviour {
  7.     private static GUIScript instance = null;
  8.    
  9.     public static GUIScript Instance {
  10.         get {
  11.             return instance;
  12.         }
  13.     }
  14.  
  15.  
  16.     public GUISkin skin;
  17.     public GameObject restartBtn;
  18.     public GameObject startBtn;
  19.     public GameObject tapToPlay;
  20.  
  21.     public GameObject introMenu;
  22.     public GameObject restartMenu;
  23.  
  24.     public GameObject shieldText;
  25.     public GameObject targetText;
  26.     public GameObject slowText;
  27.     public GameObject gameOverText;
  28.  
  29.     public bool slowler;
  30.  
  31.     public GameObject scoreText;
  32.     public Text scoreGUI;
  33.  
  34.     void Start () {
  35.         if (instance != null && instance != this) {
  36.             Destroy (this);
  37.             return;
  38.         }
  39.         instance = this;
  40.         slowler = false;
  41.         LoadGUI ();
  42.         CreateIntroMenu ();
  43.         CreateRestartMenu ();
  44.     }
  45.    
  46.     void LoadGUI()
  47.     {
  48.         Text scoreGUI = scoreText.GetComponent<Text> ();
  49.  
  50.         shieldText.transform.localScale = GameSystem.Instance.scale/2;
  51.         shieldText = Instantiate (shieldText, new Vector3 (0.0f,GameSystem.Instance.targetWidth.y,0.0f), Quaternion.identity) as GameObject;
  52.  
  53.         targetText.transform.localScale = GameSystem.Instance.scale/2;
  54.         targetText = Instantiate (targetText, new Vector3 (0.0f,GameSystem.Instance.targetWidth.y,0.0f), Quaternion.identity) as GameObject;
  55.  
  56.         slowText.transform.localScale = GameSystem.Instance.scale/2;
  57.         slowText = Instantiate (slowText, new Vector3 (0.0f,GameSystem.Instance.targetWidth.y,0.0f), Quaternion.identity) as GameObject;
  58.  
  59.         gameOverText.transform.localScale = GameSystem.Instance.scale/2;
  60.         gameOverText = Instantiate (gameOverText, new Vector3 (0.0f,GameSystem.Instance.targetWidth.y,0.0f), Quaternion.identity) as GameObject;
  61.  
  62.         restartBtn.transform.localScale = GameSystem.Instance.scale*2;
  63.         restartBtn = Instantiate (restartBtn, new Vector3 (0.0f,0.0f,0.0f), Quaternion.identity) as GameObject;
  64.        
  65.         tapToPlay.transform.localScale = GameSystem.Instance.scale;
  66.         tapToPlay = Instantiate (tapToPlay, new Vector3 (0.0f, -GameSystem.Instance.targetWidth.y+tapToPlay.renderer.bounds.extents.y*6, 0.0f), Quaternion.identity) as GameObject;
  67.        
  68.         startBtn.transform.localScale = GameSystem.Instance.scale*2;
  69.         startBtn = Instantiate (startBtn, new Vector3 (0.0f, GameSystem.Instance.player.transform.position.y-GameSystem.Instance.scaleSize, 0.0f), Quaternion.identity) as GameObject;
  70.  
  71.     }
  72.  
  73.     void CreateIntroMenu()
  74.     {
  75.         introMenu = new GameObject ();
  76.         introMenu.name = "IntroMenu";
  77.         startBtn.transform.parent = introMenu.transform;
  78.         tapToPlay.transform.parent = introMenu.transform;
  79.         introMenu.SetActive (false);
  80.     }
  81.  
  82.     void CreateRestartMenu()
  83.     {
  84.         restartMenu = new GameObject ();
  85.         restartMenu.name = "RestartMenu";
  86.         restartBtn.transform.parent = restartMenu.transform;
  87.         restartMenu.SetActive (false);
  88.     }
  89.     void Update()
  90.     {
  91.         scoreGUI.text = GameSystem.Instance.score.ToString ();
  92.     }
  93.  
  94. //  void OnGUI ()
  95. //  {
  96. // 
  97. //      GUI.skin = skin;
  98. //      GUI.skin.label.fontSize =  (int)(GameSystem.Instance.scaleSize*2.0f)*95;
  99. //
  100. //
  101. //      if (GameStateManager.GameState == GameState.Playing)
  102. //      //if (true)
  103. //      {
  104. //          float guiSpeed = (GameSystem.Instance.speed.y * -1);
  105. //          int fixSpeed = (int)guiSpeed - 7;
  106. //          GUI.Label (new Rect (GameSystem.Instance.scoreGUIPosition.x, Screen.height-GameSystem.Instance.scoreGUIPosition.y, Screen.width/2, GameSystem.Instance.scaleSize*4.5f*100), "SCORE\n"+ GameSystem.Instance.score.ToString ());
  107. //          GUI.Label (new Rect (GameSystem.Instance.speedGUIPosition.x, Screen.height - GameSystem.Instance.speedGUIPosition.y, Screen.width/2, GameSystem.Instance.scaleSize*4.5f*100), "SPEED\n"+((slowler == false)?fixSpeed.ToString ():"SLOW"));
  108. //
  109. //      }
  110. //      if (GameStateManager.GameState == GameState.Dead)
  111. //      {
  112. //          GUI.Label (new Rect (GameSystem.Instance.bestScorePosition.x, Screen.height - GameSystem.Instance.bestScorePosition.y, Screen.width, GameSystem.Instance.scaleSize*2.0f*100), "Best score:" + GameSystem.Instance.realMaxScore.ToString ());   
  113. //          GUI.Label (new Rect (GameSystem.Instance.nowScorePosition.x, Screen.height - GameSystem.Instance.nowScorePosition.y, Screen.width, GameSystem.Instance.scaleSize*2.0f*100), "Your score:" + GameSystem.Instance.score.ToString ());
  114. //      }
  115. //
  116. //  }
  117. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement