Guest User

Untitled

a guest
Mar 18th, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.77 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.UI;
  5.  
  6. public class scorekeeper : MonoBehaviour {
  7.  
  8. public Text bluescore;
  9. public Text redscore;
  10. public Text winnertext;
  11. public Text restarttext;
  12. bool activeRound = false;
  13. int b = 0;
  14. int r = 0;
  15.  
  16. void Start () {
  17. winnertext.text = "";
  18. restarttext.text = "";
  19. }
  20.  
  21. void Update () {
  22. bluescore.text = "" + b;
  23. redscore.text = "" + r;
  24.  
  25. if (Input.GetKeyUp(KeyCode.S))
  26. {
  27. activeRound = true;
  28. winnertext.text = "";
  29. }
  30.  
  31. if (activeRound == true)
  32. {
  33. if ((Input.GetKeyUp(KeyCode.Alpha1)) || (Input.GetKeyUp(KeyCode.Alpha2)))
  34. {
  35. if ((Input.GetKeyUp(KeyCode.Alpha1)) && (Input.GetKeyUp(KeyCode.Alpha2)))
  36. {
  37. winnertext.text = "Draw!";
  38. }
  39. else if (Input.GetKeyUp(KeyCode.Alpha1))
  40. {
  41. b = b + 1;
  42. }
  43. else if (Input.GetKeyUp(KeyCode.Alpha2))
  44. {
  45. r = r + 1;
  46. }
  47. activeRound = false;
  48. }
  49.  
  50. if (r >= 3)
  51. {
  52. winnertext.text = "Red Wins!";
  53. restarttext.text = "Press 'R' to reset.";
  54. }
  55. else if (b >= 3)
  56. {
  57. winnertext.text = "Blue Wins!";
  58. restarttext.text = "Press 'R' to reset.";
  59. }
  60. }
  61.  
  62. if (activeRound == false)
  63. {
  64. if (Input.GetKeyUp(KeyCode.R))
  65. {
  66. winnertext.text = "";
  67. restarttext.text = "";
  68. b = 0;
  69. r = 0;
  70. }
  71. }
  72. }
  73. }
Add Comment
Please, Sign In to add comment