Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2014
38
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class Score : MonoBehaviour {
  5.  
  6. public static int Player1Score=0;
  7. public static int Player2Score=0;
  8. public static bool showText = false;
  9. public Rect textArea = new Rect(0,0,Screen.width, Screen.height);
  10. public static string Winner;
  11. // Use this for initialization
  12. void Start () {
  13.  
  14. }
  15.  
  16. // Update is called once per frame
  17. void Update () {
  18.  
  19.  
  20. }
  21.  
  22. void OnGUI () {
  23. if (transform.tag == "player1score")
  24. GetComponent<GUIText> ().text = Player1Score.ToString ();
  25. else if (transform.tag == "player2score")
  26. GetComponent<GUIText> ().text = Player2Score.ToString ();
  27.  
  28.  
  29.  
  30. if (showText) {
  31.  
  32. GUI.Label (textArea, Winner + "is the victor!");
  33. }
  34. }
  35. public static void AnnounceWinner(){
  36.  
  37.  
  38. if(Player1Score>=10)
  39. Winner="Player 1";
  40. if(Player2Score>=10)
  41. Winner="Player 2";
  42. showText = true;
  43. }
  44.  
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement