OnlineGameScript.cs 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.UI;
  5. public class OnlineGameScript : MonoBehaviour {
  6. // Status color Pending, not your turn, your turn, declined
  7. 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) };
  8. public Text gameStatusText;
  9. public Text gameTitleText;
  10. public enum Status {
  11. PENDING,
  12. OTHERS_TURN,
  13. YOUR_TURN,
  14. DECLINED
  15. }
  16. // Start is called before the first frame update
  17. void Start() {
  18. }
  19. // Update is called once per frame
  20. void Update() {
  21. }
  22. public void SetStatusColor(Status status) {
  23. if (status.Equals(Status.PENDING)) {
  24. this.GetComponent<Image>().color = statusColors[0];
  25. } else if (status.Equals(Status.OTHERS_TURN)) {
  26. this.GetComponent<Image>().color = statusColors[1];
  27. } else if (status.Equals(Status.YOUR_TURN)) {
  28. this.GetComponent<Image>().color = statusColors[2];
  29. } else if (status.Equals(Status.DECLINED)) {
  30. this.GetComponent<Image>().color = statusColors[3];
  31. }
  32. }
  33. public void SetTitleText(string text) {
  34. gameTitleText.text = text;
  35. }
  36. public void SetGameStatusText(string text) {
  37. gameStatusText.text = text;
  38. }
  39. }