Added basic lobby

This commit is contained in:
2026-05-20 21:03:54 +01:00
parent 48f8ae6c08
commit 6055fba959
15 changed files with 1019 additions and 6 deletions

View File

@@ -0,0 +1,19 @@
using PashaBibko.PenguinChase.Network;
using UnityEngine.UI;
using UnityEngine;
namespace PashaBibko.PenguinChase.Lobby
{
public class LobbyClientDisplay : MonoBehaviour
{
[Header("References")]
[SerializeField] private Text PlayerCountDisplay;
[SerializeField] private Text PlayerNameDisplay;
public void SetText(GameNetworkClient client)
{
PlayerCountDisplay.text = $"[{client.LocalPlayerCount}]";
PlayerNameDisplay.text = client.PlayerName;
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 9f49201e34d24522b93e78c7c24206ee
timeCreated: 1779304359

View File

@@ -0,0 +1,36 @@
using PashaBibko.PenguinChase.Network;
using UnityEngine;
namespace PashaBibko.PenguinChase.Lobby
{
public class LobbyClientDisplayManager : MonoBehaviour
{
[Header("References")]
[SerializeField] private GameObject ClientDisplayPrefab;
[SerializeField] private GameObject ClientDisplayParent;
private int mCachedClientCount = -1; // Forces a refresh on initial load
private void Update()
{
// Checks if the client count has changed since last update
if (mCachedClientCount != GameNetworkClient.ConnectedClientCount)
{
// Clears all old client displays
foreach (Transform child in ClientDisplayParent.transform)
{
Destroy(child.gameObject);
}
// Creates new objects for each client
GameNetworkClient[] clients = GameNetworkClient.ConnectedClients;
foreach (GameNetworkClient client in clients)
{
GameObject go = Instantiate(ClientDisplayPrefab, ClientDisplayParent.transform);
LobbyClientDisplay display = go.GetComponent<LobbyClientDisplay>();
display.SetText(client);
}
}
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 3dbc4cc72e209e84aa134a24a54c818f