Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.UI;
- public class scorekeeper : MonoBehaviour {
- public Text bluescore;
- public Text redscore;
- public Text winnertext;
- public Text restarttext;
- bool activeRound = false;
- int b = 0;
- int r = 0;
- void Start () {
- winnertext.text = "";
- restarttext.text = "";
- }
- void Update () {
- bluescore.text = "" + b;
- redscore.text = "" + r;
- if (Input.GetKeyUp(KeyCode.S))
- {
- activeRound = true;
- winnertext.text = "";
- }
- if (activeRound == true)
- {
- if ((Input.GetKeyUp(KeyCode.Alpha1)) || (Input.GetKeyUp(KeyCode.Alpha2)))
- {
- if ((Input.GetKeyUp(KeyCode.Alpha1)) && (Input.GetKeyUp(KeyCode.Alpha2)))
- {
- winnertext.text = "Draw!";
- }
- else if (Input.GetKeyUp(KeyCode.Alpha1))
- {
- b = b + 1;
- }
- else if (Input.GetKeyUp(KeyCode.Alpha2))
- {
- r = r + 1;
- }
- activeRound = false;
- }
- if (r >= 3)
- {
- winnertext.text = "Red Wins!";
- restarttext.text = "Press 'R' to reset.";
- }
- else if (b >= 3)
- {
- winnertext.text = "Blue Wins!";
- restarttext.text = "Press 'R' to reset.";
- }
- }
- if (activeRound == false)
- {
- if (Input.GetKeyUp(KeyCode.R))
- {
- winnertext.text = "";
- restarttext.text = "";
- b = 0;
- r = 0;
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment