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.

69 lines
1.7 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. [SerializeField]
  16. private float TotalTime;
  17. [Header("Debug")]
  18. [SerializeField]
  19. private bool isTimePaused;
  20. private float StartTime;
  21. private BlockReader reader;
  22. protected override void Awake()
  23. {
  24. base.Awake();
  25. reader = new BlockReader();
  26. TrayUI.SetBlockReader(reader);
  27. StartTime = Time.time;
  28. ShowPosition.y -= Title.rect.height;
  29. OnClick_Show();
  30. }
  31. private void Update()
  32. {
  33. if (!isTimePaused)
  34. {
  35. TimeText.text = ((int)(TotalTime - (Time.time - StartTime))).ToString();
  36. if (Time.time - StartTime > TotalTime)
  37. OnClick_Play();
  38. }
  39. }
  40. public override void OnClick_Play()
  41. {
  42. OnClick_Hide();
  43. LogicProtocols.LogicMsg msg = new LogicProtocols.LogicMsg(reader.LogicChain.ToArray());
  44. Debug.Log("sending on " + LogicProtocols.SendLogicList);
  45. Client.client.SendByChannel(LogicProtocols.SendLogicList, msg, TransportConfigure.ReliableFragmented);
  46. UnityEngine.SceneManagement.SceneManager.LoadScene("WaitScene");
  47. }
  48. public void On_ClickPauseTime()
  49. {
  50. isTimePaused = !isTimePaused;
  51. if (isTimePaused)
  52. TimeText.color = Color.grey;
  53. else
  54. TimeText.color = Color.black;
  55. }
  56. }