CellGUI.cs 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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. [ClientCallback]
  19. public void MakePlay()
  20. {
  21. if (matchController.currentPlayer.isLocalPlayer)
  22. matchController.CmdMakePlay(cellValue);
  23. }
  24. [ClientCallback]
  25. public void SetPlayer(NetworkIdentity playerIdentity)
  26. {
  27. if (playerIdentity != null)
  28. {
  29. this.playerIdentity = playerIdentity;
  30. image.color = this.playerIdentity.isLocalPlayer ? Color.blue : Color.red;
  31. button.interactable = false;
  32. }
  33. else
  34. {
  35. this.playerIdentity = null;
  36. image.color = Color.white;
  37. button.interactable = true;
  38. }
  39. }
  40. }
  41. }