mirror of
https://github.com/Leahnaya/TheKingsRace.git
synced 2026-03-30 21:54:44 -05:00
- End of timer goes to PostGame - Timer on PostGame returns to Lobby - Resets PlayerData on return to Lobby
37 lines
1017 B
C#
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();
|
|
}
|
|
}
|