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.
 
 
 
 
 
 

72 lines
2.0 KiB

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Networking;
using Networking;
using Networking.Client;
using UnityEngine.UI;
public class NetworkedUIManager : PlayerUIManager
{
[SerializeField]
private ClientObject Client;
[SerializeField]
private TMPro.TextMeshProUGUI TimeText;
[SerializeField]
private RectTransform Title;
[SerializeField]
private TMPro.TextMeshProUGUI LivesText;
[Header("Debug")]
[SerializeField]
private bool isTimePaused;
public Image backgroundColour;
public Image animalSprite;
private float StartTime;
private BlockReader reader;
protected override void Awake()
{
base.Awake();
reader = new BlockReader();
TrayUI.SetBlockReader(reader);
StartTime = Time.time;
ShowPosition.y -= Title.rect.height;
LivesText.text = "Lives: " + Client.RemainingLives;
backgroundColour.color = Client.PlayerColor;
animalSprite.sprite = Resources.Load<Sprite>(Client.PlayerAnimal.ToString());
OnClick_Show();
}
private void Update()
{
if (!isTimePaused)
{
TimeText.text = ((int)(Client.RoundTime - (Time.time - StartTime))).ToString();
if (Time.time - StartTime > Client.RoundTime)
OnClick_Play();
}
}
public override void OnClick_Play()
{
OnClick_Hide();
LogicProtocols.LogicMsg msg = new LogicProtocols.LogicMsg(reader.LogicChain.ToArray());
Debug.Log("sending on " + LogicProtocols.SendLogicList);
Client.client.SendByChannel(LogicProtocols.SendLogicList, msg, TransportConfigure.ReliableFragmented);
UnityEngine.SceneManagement.SceneManager.LoadScene("WaitScene");
}
public void On_ClickPauseTime()
{
isTimePaused = !isTimePaused;
if (isTimePaused)
TimeText.color = Color.grey;
else
TimeText.color = Color.black;
}
}