Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using UnityEngine.UI;
- using System.Collections;
- //[ExecuteInEditMode]
- public class GUIScript : MonoBehaviour {
- private static GUIScript instance = null;
- public static GUIScript Instance {
- get {
- return instance;
- }
- }
- public GUISkin skin;
- public GameObject restartBtn;
- public GameObject startBtn;
- public GameObject tapToPlay;
- public GameObject introMenu;
- public GameObject restartMenu;
- public GameObject shieldText;
- public GameObject targetText;
- public GameObject slowText;
- public GameObject gameOverText;
- public bool slowler;
- public GameObject scoreText;
- public Text scoreGUI;
- void Start () {
- if (instance != null && instance != this) {
- Destroy (this);
- return;
- }
- instance = this;
- slowler = false;
- LoadGUI ();
- CreateIntroMenu ();
- CreateRestartMenu ();
- }
- void LoadGUI()
- {
- Text scoreGUI = scoreText.GetComponent<Text> ();
- shieldText.transform.localScale = GameSystem.Instance.scale/2;
- shieldText = Instantiate (shieldText, new Vector3 (0.0f,GameSystem.Instance.targetWidth.y,0.0f), Quaternion.identity) as GameObject;
- targetText.transform.localScale = GameSystem.Instance.scale/2;
- targetText = Instantiate (targetText, new Vector3 (0.0f,GameSystem.Instance.targetWidth.y,0.0f), Quaternion.identity) as GameObject;
- slowText.transform.localScale = GameSystem.Instance.scale/2;
- slowText = Instantiate (slowText, new Vector3 (0.0f,GameSystem.Instance.targetWidth.y,0.0f), Quaternion.identity) as GameObject;
- gameOverText.transform.localScale = GameSystem.Instance.scale/2;
- gameOverText = Instantiate (gameOverText, new Vector3 (0.0f,GameSystem.Instance.targetWidth.y,0.0f), Quaternion.identity) as GameObject;
- restartBtn.transform.localScale = GameSystem.Instance.scale*2;
- restartBtn = Instantiate (restartBtn, new Vector3 (0.0f,0.0f,0.0f), Quaternion.identity) as GameObject;
- tapToPlay.transform.localScale = GameSystem.Instance.scale;
- tapToPlay = Instantiate (tapToPlay, new Vector3 (0.0f, -GameSystem.Instance.targetWidth.y+tapToPlay.renderer.bounds.extents.y*6, 0.0f), Quaternion.identity) as GameObject;
- startBtn.transform.localScale = GameSystem.Instance.scale*2;
- startBtn = Instantiate (startBtn, new Vector3 (0.0f, GameSystem.Instance.player.transform.position.y-GameSystem.Instance.scaleSize, 0.0f), Quaternion.identity) as GameObject;
- }
- void CreateIntroMenu()
- {
- introMenu = new GameObject ();
- introMenu.name = "IntroMenu";
- startBtn.transform.parent = introMenu.transform;
- tapToPlay.transform.parent = introMenu.transform;
- introMenu.SetActive (false);
- }
- void CreateRestartMenu()
- {
- restartMenu = new GameObject ();
- restartMenu.name = "RestartMenu";
- restartBtn.transform.parent = restartMenu.transform;
- restartMenu.SetActive (false);
- }
- void Update()
- {
- scoreGUI.text = GameSystem.Instance.score.ToString ();
- }
- // void OnGUI ()
- // {
- //
- // GUI.skin = skin;
- // GUI.skin.label.fontSize = (int)(GameSystem.Instance.scaleSize*2.0f)*95;
- //
- //
- // if (GameStateManager.GameState == GameState.Playing)
- // //if (true)
- // {
- // float guiSpeed = (GameSystem.Instance.speed.y * -1);
- // int fixSpeed = (int)guiSpeed - 7;
- // 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 ());
- // 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"));
- //
- // }
- // if (GameStateManager.GameState == GameState.Dead)
- // {
- // 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 ());
- // 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 ());
- // }
- //
- // }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement