This commit is contained in:
2024-02-16 01:00:03 +05:30
parent 74d86ce2fe
commit 84a4c88435
10 changed files with 1313 additions and 446 deletions

View File

@@ -68,6 +68,10 @@ public class MainMenu : MonoBehaviourPunCallbacks, IOnEventCallback
base.OnJoinedRoom();
Debug.Log("Connected to new room : " + PhotonNetwork.CurrentRoom.Name);
if(PhotonNetwork.CurrentRoom.PlayerCount >3 ){
Debug.Log("NO room for me!");
JoinAnotherRoom(myRoomname);
}
loadingPanel.SetActive(false);
UpdateLobbyPlayers();
@@ -136,10 +140,10 @@ public class MainMenu : MonoBehaviourPunCallbacks, IOnEventCallback
if(val.ToLower()== "tdm"){gameMode = GameModes.TeamDeathmatch;}
if(val.ToLower() == "br"){gameMode = GameModes.BattleRoyale;}
btnPlay.interactable = gameMode != GameModes.BattleRoyale;
Debug.Log("Set game mode to : " + gameMode.ToString() + $" ({val})");
GameManager.desiredGameMode = gameMode.ToString();
UpdatePlayBtnInteractability();
}
void OnInvitesUpdated(){
@@ -154,7 +158,7 @@ public class MainMenu : MonoBehaviourPunCallbacks, IOnEventCallback
GameObject newInviteItem = Instantiate(InviteListItemPrefab, InviteListParent);
newInviteItem.transform.GetChild(0).GetComponent<TMP_Text>().text = $"Lobby Invite from <color=green>{invite.host}";
newInviteItem.transform.GetChild(1).GetComponent<Button>().onClick.AddListener(()=>{ JoinFriendsLobby(invite.host, invite.host_id,invite.id); });
newInviteItem.transform.GetChild(1).GetComponent<Button>().onClick.AddListener(()=>{ JoinFriendsLobby(invite.host, invite.lobby,invite.id); });
newInviteItem.transform.GetChild(2).GetComponent<Button>().onClick.AddListener(()=>{ StartCoroutine(CoroutineDeleteInvite(invite.id)); });
}
}
@@ -172,12 +176,10 @@ public class MainMenu : MonoBehaviourPunCallbacks, IOnEventCallback
void JoinFriendsLobby(string hostname, int hostid, int inviteid){
void JoinFriendsLobby(string hostname, string lobby, int inviteid){
StartCoroutine(CoroutineDeleteInvite(inviteid));
string roomName = hostname+"#"+hostid;
JoinAnotherRoom(roomName);
JoinAnotherRoom(lobby);
}
public void JoinAnotherRoom(string roomname){
if(PhotonNetwork.InRoom){
@@ -192,7 +194,7 @@ public class MainMenu : MonoBehaviourPunCallbacks, IOnEventCallback
void JoinQueuedRoom(){
loadingPanel.SetActive(true);
if(queuedRoomname.Length >0){
PhotonNetwork.JoinOrCreateRoom(queuedRoomname, new RoomOptions(){IsOpen=true, IsVisible=true}, TypedLobby.Default);
PhotonNetwork.JoinOrCreateRoom(queuedRoomname, new RoomOptions(){IsOpen=true, IsVisible=true, MaxPlayers = 8}, TypedLobby.Default);
}
queuedRoomname="";
@@ -234,8 +236,14 @@ public class MainMenu : MonoBehaviourPunCallbacks, IOnEventCallback
//Uodate cotrols
btnPlay.interactable=PhotonNetwork.IsMasterClient;
UpdatePlayBtnInteractability();
GameModeSelector.SetInteractable(PhotonNetwork.IsMasterClient);
FriendsManager.instance.OnPlayersChanged();
}
void UpdatePlayBtnInteractability(){
btnPlay.interactable = PhotonNetwork.IsMasterClient && GameManager.desiredGameMode != GameModes.BattleRoyale.ToString();
}
IEnumerator CoroutineDeleteInvite(int inviteId){
@@ -316,6 +324,7 @@ public class MainMenu : MonoBehaviourPunCallbacks, IOnEventCallback
bool foundRoom =false;
List<string> suitableRooms = new List<string>();
foreach(RoomInfo room in RoomList){
Debug.Log($"roomname : {room.Name}, players: {room.PlayerCount}" );
if(room.Name.Contains(roomnameBase)){
//Suitable Room
suitableRooms.Add(room.Name);