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.

74 lines
1.8 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 TMPro.TextMeshProUGUI ScoreText;
  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. ScoreText.text = "Score: " + Client.RoundScore;
  30. OnClick_Show();
  31. }
  32. private void Update()
  33. {
  34. if (!isTimePaused)
  35. {
  36. TimeText.text = ((int)(Client.RoundTime - (Time.time - StartTime))).ToString();
  37. if (Time.time - StartTime > Client.RoundTime)
  38. OnClick_Play();
  39. }
  40. }
  41. public override void OnClick_Play()
  42. {
  43. OnClick_Hide();
  44. LogicProtocols.LogicMsg msg = new LogicProtocols.LogicMsg(reader.LogicChain.ToArray());
  45. Debug.Log("sending on " + LogicProtocols.SendLogicList);
  46. Client.client.SendByChannel(LogicProtocols.SendLogicList, msg, TransportConfigure.ReliableFragmented);
  47. UnityEngine.SceneManagement.SceneManager.LoadScene("WaitScene");
  48. }
  49. public void On_ClickPauseTime()
  50. {
  51. isTimePaused = !isTimePaused;
  52. if (isTimePaused)
  53. TimeText.color = Color.grey;
  54. else
  55. TimeText.color = Color.black;
  56. }
  57. }