Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Assets/Scripts/Menus/CreateLobbyPopup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ private void OnCreateButtonClicked()
{
if (string.IsNullOrEmpty(lobbyNameInput.text)) return;

RoomOptions roomOptions = new RoomOptions { IsOpen = true, MaxPlayers = 4 };
RoomOptions roomOptions = new RoomOptions { IsVisible = !IsPrivate, IsOpen = true, MaxPlayers = 4 };
PhotonNetwork.CreateRoom(lobbyNameInput.text, roomOptions, TypedLobby.Default);
}

Expand Down
3 changes: 2 additions & 1 deletion Assets/Scripts/Menus/JoinPrivateLobbyPopup.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using Photon.Pun;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
Expand Down Expand Up @@ -33,7 +34,7 @@ private void OnEnterClicked()
if (string.IsNullOrEmpty(lobbyNameInput.text)) return;
LoadingGraphics.Enable();

// TODO: Join target room
PhotonNetwork.JoinRoom(lobbyNameInput.text);
}
}
}
28 changes: 26 additions & 2 deletions Assets/Scripts/Menus/PlayerLobbyEntry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public void Setup(Player entryPlayer)

if (IsLocalPlayer)
{
PlayerTeam = (player.ActorNumber - 1) % PhotonNetwork.CurrentRoom.MaxPlayers;
PlayerTeam = GetAvailableTeam(0);
}

playerName.text = player.NickName;
Expand Down Expand Up @@ -82,9 +82,33 @@ private void Start()
readyButton.gameObject.SetActive(false);
}

private int GetAvailableTeam(int desiredTeam)
{
while (true)
{
bool available = true;

foreach (var currentPlayer in PhotonNetwork.PlayerList)
{
if (currentPlayer == PhotonNetwork.LocalPlayer) continue;

int team = currentPlayer.CustomProperties.ContainsKey("Team") ?
(int) currentPlayer.CustomProperties["Team"] : 0;

if (team == desiredTeam)
{
available = false;
desiredTeam = (desiredTeam + 1) % PhotonNetwork.CurrentRoom.MaxPlayers;
}
}

if (available) return desiredTeam;
}
}

private void OnChangeTeamButtonClicked()
{
PlayerTeam = (PlayerTeam + 1) % PhotonNetwork.CurrentRoom.MaxPlayers;
PlayerTeam = GetAvailableTeam((PlayerTeam + 1) % PhotonNetwork.CurrentRoom.MaxPlayers);
}

private void OnReadyButtonClick(bool isReady)
Expand Down
4 changes: 2 additions & 2 deletions Assets/Scripts/Menus/SettingsController.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using Photon.Pun;
using TMPro;
using UnityEngine;
using UnityEngine.Audio;
Expand Down Expand Up @@ -56,8 +57,7 @@ private void OnCloseButtonClicked()
gameObject.SetActive(false);

PlayerPrefs.SetString("PlayerName", playerNameInput.text);

// TODO: Update photon local player nickname
PhotonNetwork.NickName = playerNameInput.text;
}

private void SetSound(string id, bool newValue, Button disabledButton, Button enabledButton)
Expand Down