You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

70 lines
1.6 KiB

  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.Networking;
  5. using Networking;
  6. using Networking.Client;
  7. public class NetworkedUIManager : PlayerUIManager
  8. {
  9. [SerializeField]
  10. private ClientObject Client;
  11. [SerializeField]
  12. private TMPro.TextMeshProUGUI TimeText;
  13. [SerializeField]
  14. private RectTransform Title;
  15. [Header("Debug")]
  16. [SerializeField]
  17. private bool isTimePaused;
  18. private float StartTime;
  19. private BlockReader reader;
  20. protected override void Awake()
  21. {
  22. base.Awake();
  23. reader = new BlockReader();
  24. TrayUI.SetBlockReader(reader);
  25. StartTime = Time.time;
  26. ShowPosition.y -= Title.rect.height;
  27. OnClick_Show();
  28. }
  29. private void Update()
  30. {
  31. if (!isTimePaused)
  32. {
  33. TimeText.text = ((int)(Client.RoundTime - (Time.time - StartTime))).ToString();
  34. if (Time.time - StartTime > Client.RoundTime)
  35. OnClick_Play();
  36. }
  37. }
  38. public override void OnClick_Play()
  39. {
  40. OnClick_Hide();
  41. LogicProtocols.LogicMsg msg = new LogicProtocols.LogicMsg(reader.LogicChain.ToArray());
  42. Debug.Log("sending on " + LogicProtocols.SendLogicList);
  43. Client.client.SendByChannel(LogicProtocols.SendLogicList, msg, TransportConfigure.ReliableFragmented);
  44. UnityEngine.SceneManagement.SceneManager.LoadScene("WaitScene");
  45. }
  46. public void On_ClickPauseTime()
  47. {
  48. isTimePaused = !isTimePaused;
  49. if (isTimePaused)
  50. TimeText.color = Color.grey;
  51. else
  52. TimeText.color = Color.black;
  53. }
  54. }