Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- public class Score : MonoBehaviour {
- public static int Player1Score=0;
- public static int Player2Score=0;
- public static bool showText = false;
- public Rect textArea = new Rect(0,0,Screen.width, Screen.height);
- public static string Winner;
- // Use this for initialization
- void Start () {
- }
- // Update is called once per frame
- void Update () {
- }
- void OnGUI () {
- if (transform.tag == "player1score")
- GetComponent<GUIText> ().text = Player1Score.ToString ();
- else if (transform.tag == "player2score")
- GetComponent<GUIText> ().text = Player2Score.ToString ();
- if (showText) {
- GUI.Label (textArea, Winner + "is the victor!");
- }
- }
- public static void AnnounceWinner(){
- if(Player1Score>=10)
- Winner="Player 1";
- if(Player2Score>=10)
- Winner="Player 2";
- showText = true;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement