mirror of
https://github.com/Leahnaya/TheKingsRace.git
synced 2026-09-13 12:55:16 -05:00
PostGame Transitions To and From Successfully
- End of timer goes to PostGame - Timer on PostGame returns to Lobby - Resets PlayerData on return to Lobby
This commit is contained in:
@@ -46,6 +46,28 @@ public class LobbyUI : NetworkBehaviour {
|
||||
// Get/Set the ip of the host
|
||||
StartCoroutine(GetIPAddress());
|
||||
}
|
||||
|
||||
// Reset the variables for IsReady and IsKing
|
||||
if (IsHost) {
|
||||
for (int i = 0; i < lobbyPlayers.Count; i++) {
|
||||
// Update the lobby player cards states
|
||||
lobbyPlayers[i] = new LobbyPlayerState(
|
||||
lobbyPlayers[i].ClientId,
|
||||
lobbyPlayers[i].PlayerName,
|
||||
false,
|
||||
false
|
||||
);
|
||||
|
||||
// Update the server's player data as well
|
||||
if (ServerGameNetPortal.Instance.clientIdToGuid.TryGetValue(lobbyPlayers[i].ClientId, out string clientGuid)) {
|
||||
ServerGameNetPortal.Instance.clientData[clientGuid] = new PlayerData(
|
||||
ServerGameNetPortal.Instance.clientData[clientGuid].PlayerName,
|
||||
ServerGameNetPortal.Instance.clientData[clientGuid].ClientId,
|
||||
false
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
|
||||
@@ -1,23 +1,36 @@
|
||||
using MLAPI;
|
||||
using MLAPI.Messaging;
|
||||
using TMPro;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class PostGameUI : NetworkBehaviour
|
||||
{
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
public void OnReturnToLobbyClicked() {
|
||||
//TODO: Do it here
|
||||
[ServerRpc]
|
||||
private void ReturnToLobbyServerRPC() {
|
||||
ServerGameNetPortal.Instance.EndRound();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user