TheKingsRace/Assets/Scripts/UI/PostGame/PostGameUI.cs
Julia Butenhoff ca48a8516b PostGame Transitions To and From Successfully
- End of timer goes to PostGame
- Timer on PostGame returns to Lobby
- Resets PlayerData on return to Lobby
2021-12-01 13:34:53 -06:00

37 lines
1017 B
C#

using MLAPI;
using MLAPI.Messaging;
using TMPro;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PostGameUI : NetworkBehaviour {
[SerializeField] private TMP_Text ReturnToLobbyText;
[SerializeField] private int ReturnToLobbyTimer;
void Start() {
ReturnToLobbyText.text = "Returning to the lobby in " + ReturnToLobbyTimer + " seconds...";
StartCoroutine(BeginCountdown());
//todo: do logic to determine and update who won the round
}
IEnumerator BeginCountdown() {
for (int i = ReturnToLobbyTimer; i >= 0; i--) {
ReturnToLobbyText.text = "Returning to the lobby in " + i + " seconds...";
yield return new WaitForSecondsRealtime(1f);
}
// Have the host return everyone to the lobby
if (IsHost) {
ReturnToLobbyServerRPC();
}
}
[ServerRpc]
private void ReturnToLobbyServerRPC() {
ServerGameNetPortal.Instance.EndRound();
}
}