OnlineGameScript.cs 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using UnityEngine;
  5. using UnityEngine.UI;
  6. public class OnlineGameScript : MonoBehaviour {
  7. // Status color Pending, not your turn, your turn, declined
  8. List<Color32> statusColors = new List<Color32>() { new Color32(234, 164, 17, 100), new Color32(255, 255, 24, 175), new Color32(0, 255, 0, 100), new Color32(75, 50, 75, 100) };
  9. public Text gameStatusText;
  10. public Text gameTitleText;
  11. private int id;
  12. private int winNumber;
  13. private int answerTimer;
  14. private int roundTimeLimit;
  15. private string currentPlayer;
  16. private int round;
  17. private string startDate;
  18. private string LastPlayedDate;
  19. private string finishedDate;
  20. public int Id { get => id; set => id = value; }
  21. public int WinNumber { get => winNumber; set => winNumber = value; }
  22. public int AnswerTimer { get => answerTimer; set => answerTimer = value; }
  23. public int RoundTimeLimit { get => roundTimeLimit; set => roundTimeLimit = value; }
  24. public string CurrentPlayer { get => currentPlayer; set => currentPlayer = value; }
  25. public int Round { get => round; set => round = value; }
  26. public string StartDate { get => startDate; set => startDate = value; }
  27. public string LastPlayedDate1 { get => LastPlayedDate; set => LastPlayedDate = value; }
  28. public string FinishedDate { get => finishedDate; set => finishedDate = value; }
  29. public enum Status {
  30. PENDING,
  31. OTHERS_TURN,
  32. YOUR_TURN,
  33. DECLINED
  34. }
  35. // Start is called before the first frame update
  36. void Start() {
  37. }
  38. // Update is called once per frame
  39. void Update() {
  40. }
  41. public void SetStatusColor(Status status) {
  42. if (status.Equals(Status.PENDING)) {
  43. this.GetComponent<Image>().color = statusColors[0];
  44. } else if (status.Equals(Status.OTHERS_TURN)) {
  45. this.GetComponent<Image>().color = statusColors[1];
  46. } else if (status.Equals(Status.YOUR_TURN)) {
  47. this.GetComponent<Image>().color = statusColors[2];
  48. } else if (status.Equals(Status.DECLINED)) {
  49. this.GetComponent<Image>().color = statusColors[3];
  50. }
  51. }
  52. public void SetTitleText(string text) {
  53. gameTitleText.text = text;
  54. }
  55. public void SetGameStatusText(string text) {
  56. gameStatusText.text = text;
  57. }
  58. public void SetId(string id) {
  59. Int32.TryParse(id, out int intId);
  60. Id = intId;
  61. }
  62. public void SetWinNumber(string winNumber) {
  63. Int32.TryParse(winNumber, out int intWinNumber);
  64. WinNumber = intWinNumber;
  65. }
  66. public void SetAnswerTimer(string answerTimer) {
  67. Int32.TryParse(answerTimer, out int intAnswerTimer);
  68. AnswerTimer = intAnswerTimer;
  69. }
  70. public void SetRoundTimeLimit(string roundTimeLimit) {
  71. Int32.TryParse(roundTimeLimit, out int intRoundTimelimit);
  72. RoundTimeLimit = intRoundTimelimit;
  73. }
  74. public void SetRound(string round) {
  75. Int32.TryParse(round, out int intRound);
  76. Round = intRound;
  77. }
  78. }