CellGUI.cs 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. using UnityEngine;
  2. using UnityEngine.UI;
  3. namespace Mirror.Examples.MultipleMatch
  4. {
  5. public class CellGUI : MonoBehaviour
  6. {
  7. public MatchController matchController;
  8. public CellValue cellValue;
  9. [Header("GUI References")]
  10. public Image image;
  11. public Button button;
  12. [Header("Diagnostics - Do Not Modify")]
  13. public NetworkIdentity playerIdentity;
  14. public void Awake()
  15. {
  16. matchController.MatchCells.Add(cellValue, this);
  17. }
  18. public void MakePlay()
  19. {
  20. if (matchController.currentPlayer.isLocalPlayer)
  21. matchController.CmdMakePlay(cellValue);
  22. }
  23. public void SetPlayer(NetworkIdentity playerIdentity)
  24. {
  25. if (playerIdentity != null)
  26. {
  27. this.playerIdentity = playerIdentity;
  28. image.color = this.playerIdentity.isLocalPlayer ? Color.blue : Color.red;
  29. button.interactable = false;
  30. }
  31. else
  32. {
  33. this.playerIdentity = null;
  34. image.color = Color.white;
  35. button.interactable = true;
  36. }
  37. }
  38. }
  39. }