Skip to content

Commit

Permalink
Fix new players joining while game is running
Browse files Browse the repository at this point in the history
  • Loading branch information
devedse committed Oct 1, 2023
1 parent 65ea092 commit 47a55a3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 2 additions & 0 deletions UnityGame/Assets/Scripts/MinigameManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,8 @@ public void Start()

public void InitializeNewGame()
{
SignalR.LobbyHasStartedSoBlockNewPlayerJoins = true;

ScoreCanvas.SetActive(true);
DontDestroyOnLoad(ScoreCanvas);
foreach (var scscr in ScoreCanvas.GetComponentsInChildren<IngameScoreScreen>())
Expand Down
8 changes: 7 additions & 1 deletion UnityGame/Assets/Scripts/SignalRTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ public class SignalRTest : MonoBehaviour

private string DeveURL = "https://LD54_Server.Devedse.DuckDNS.org/UltraHub";

public bool LobbyHasStartedSoBlockNewPlayerJoins { get; set; } = false;

public PC GetPlayerByNumber(int playerNumber)
{
return Players.Values.FirstOrDefault(t => t.PlayerIndex == playerNumber);
Expand Down Expand Up @@ -139,7 +141,7 @@ public PC AddOrConnectClient(string name)
existingPc.IsConnected = true;
return existingPc;
}
else
else if (!LobbyHasStartedSoBlockNewPlayerJoins)
{
var player = Instantiate(PlayerPrefab, transform);
var pc = player.GetComponent<PC>();
Expand All @@ -152,6 +154,10 @@ public PC AddOrConnectClient(string name)

return pc;
}
else
{
return null;
}
}

public void HandleLeaveEvents()
Expand Down

0 comments on commit 47a55a3

Please sign in to comment.