Merge branch 'PausePitfallFix'

This commit is contained in:
Julia Butenhoff 2022-04-22 18:22:54 -05:00
commit 34601c58b2
3 changed files with 57 additions and 3 deletions

View File

@ -201,6 +201,18 @@ public class PlayerStats : MonoBehaviour
else if (GameObject.FindGameObjectWithTag("FogSystem").GetComponent<ParticleSystem>().isPlaying) {
SetWeather(Weather.Fog);
}
StartCoroutine(UnPause());
}
}
IEnumerator UnPause() {
yield return new WaitForSecondsRealtime(3f);
if (gameObject.transform.root.GetComponentInChildren<PlayerStats>().IsPaused) {
GameObject PauseMenu = GameObject.FindGameObjectWithTag("PauseMenu");
PauseMenu.GetComponent<PauseMenu>().setPlayerControlsStateServerRPC(true);
PauseMenu.GetComponent<PauseMenu>().TurnOffPanelServerRPC();
}
}

View File

@ -353,6 +353,7 @@ public class LobbyUI : NetworkBehaviour {
}
public void RefreshIPAddress() {
if (!IsServer) { return; }
StartCoroutine(GetIPAddress());
}

View File

@ -53,6 +53,27 @@ public class PauseMenu : NetworkBehaviour {
ControlsPanel.SetActive(false);
ConfirmationPanel.SetActive(false);
RespawnConfirmationPanel.SetActive(false);
InvokeRepeating("checkForPaused", 0f, 2f);
}
private void checkForPaused() {
GameObject[] players = GameObject.FindGameObjectsWithTag("Player");
foreach (GameObject player in players) {
if (player.GetComponent<NetworkObject>().IsLocalPlayer) {
if (player.GetComponentInChildren<PlayerStats>() != null)
{
if (!player.GetComponentInChildren<PlayerStats>().IsPaused)
{
PauseMenuPanel.SetActive(false);
ControlsPanel.SetActive(false);
ConfirmationPanel.SetActive(false);
RespawnConfirmationPanel.SetActive(false);
}
}
}
}
}
void Update() {
@ -89,8 +110,6 @@ public class PauseMenu : NetworkBehaviour {
// Turn off "Restart from Checkpoint" button for the king
RestartButton.interactable = false;
}
}
}
@ -98,7 +117,29 @@ public class PauseMenu : NetworkBehaviour {
}
[ServerRpc(RequireOwnership = false)]
private void setPlayerControlsStateServerRPC(bool newState, ServerRpcParams serverRpcParams = default) {
public void TurnOffPanelServerRPC(ServerRpcParams serverRpcParams = default) {
ClientRpcParams clientRpcParams = new ClientRpcParams
{
Send = new ClientRpcSendParams
{
TargetClientIds = new ulong[] { serverRpcParams.Receive.SenderClientId }
}
};
TurnOffPanelClientRPC(clientRpcParams);
}
[ClientRpc]
private void TurnOffPanelClientRPC(ClientRpcParams clientRpcParams)
{
PauseMenuPanel.SetActive(false);
ControlsPanel.SetActive(false);
ConfirmationPanel.SetActive(false);
RespawnConfirmationPanel.SetActive(false);
}
[ServerRpc(RequireOwnership = false)]
public void setPlayerControlsStateServerRPC(bool newState, ServerRpcParams serverRpcParams = default) {
ClientRpcParams clientRpcParams = new ClientRpcParams
{
Send = new ClientRpcSendParams