new env int

This commit is contained in:
2024-02-11 23:23:12 +05:30
parent dfc221d77e
commit 36da1f016f
483 changed files with 203139 additions and 46804 deletions

View File

@@ -48,8 +48,6 @@ public class GameManager : MonoBehaviourPunCallbacks, IOnEventCallback
{
SpawnPositions[i] = SpawnPositionsParent.GetChild(i);
}
desiredGameMode = GameModes.Deathmatch.ToString();
}
//Statics
@@ -57,7 +55,7 @@ public class GameManager : MonoBehaviourPunCallbacks, IOnEventCallback
public static string partyId;
public static string RoomName;
public static bool isInit =false;
public static string desiredGameMode = GameModes.TeamDeathmatch.ToString();
public static string desiredGameMode;
public static GameManager instance;
public static PlayerController localPlayer;

View File

@@ -16,6 +16,7 @@ public class MainMenu : MonoBehaviourPunCallbacks, IOnEventCallback
public const byte MatchmadeEventCode = 1;
public const byte StartMatchmakeEventCode = 2;
public const byte StopMatchmakeEventCode = 3;
public const byte ChangeGameModeEventCode= 4;
#region overrides
@@ -42,6 +43,7 @@ public class MainMenu : MonoBehaviourPunCallbacks, IOnEventCallback
PhotonNetwork.LocalPlayer.NickName = UserDataManager.instance.Username;
if(queuedRoomname == "GAME_READY"){
Debug.Log($"Loading new match, roomname:{GameManager.RoomName}, mode:{GameManager.desiredGameMode}");
SceneManager.LoadScene("SampleScene");
return;
}
@@ -122,11 +124,19 @@ public class MainMenu : MonoBehaviourPunCallbacks, IOnEventCallback
}
public string gameModeSelection => GameModeSelector.SelectedOption.ToLower();
void OnSelectedGameModeChanged(){
GameModes gameMode = GameModes.Deathmatch;
if(gameModeSelection == "dm"){gameMode = GameModes.Deathmatch;}
if(gameModeSelection== "tdm"){gameMode = GameModes.TeamDeathmatch;}
if(gameModeSelection == "br"){gameMode = GameModes.BattleRoyale;}
UpdateGameMode(gameModeSelection);
if(PhotonNetwork.IsMasterClient){
PhotonNetwork.RaiseEvent(ChangeGameModeEventCode, gameModeSelection, EveryoneRaiseEventOptions, new SendOptions());
}
}
void UpdateGameMode(string val){
GameModes gameMode = GameModes.Deathmatch;
if(val.ToLower() == "dm"){gameMode = GameModes.Deathmatch;}
if(val.ToLower()== "tdm"){gameMode = GameModes.TeamDeathmatch;}
if(val.ToLower() == "br"){gameMode = GameModes.BattleRoyale;}
Debug.Log("Set game mode to : " + gameMode.ToString() + $" ({val})");
GameManager.desiredGameMode = gameMode.ToString();
}
@@ -204,6 +214,7 @@ public class MainMenu : MonoBehaviourPunCallbacks, IOnEventCallback
void UpdateLobbyPlayers(){
if(PhotonNetwork.CurrentRoom.PlayerCount <= 1 && PhotonNetwork.CurrentRoom.Name != myRoomname){
Debug.Log("everyone left, Im going back home");
if(queuedRoomname=="GAME_READY"){Debug.Log("Holddd! We going to war!"); return;}
JoinAnotherRoom(myRoomname);
return;
}
@@ -283,7 +294,6 @@ public class MainMenu : MonoBehaviourPunCallbacks, IOnEventCallback
float matchmakingTimer = 0;
RaiseEventOptions EveryoneRaiseEventOptions =new RaiseEventOptions(){Receivers = ReceiverGroup.All};
RaiseEventOptions OthersRaiseEventOptions =new RaiseEventOptions(){Receivers = ReceiverGroup.All};
Coroutine MathcmakeOperation;
public void StartMatchmaking(){
@@ -348,29 +358,6 @@ public class MainMenu : MonoBehaviourPunCallbacks, IOnEventCallback
StopCoroutine(MathcmakeOperation);
}
public void Play()
{
GameManager.desiredGameMode = GameModes.Deathmatch.ToString();
SceneManager.LoadScene("SampleScene");
}
public void PlayDM(){
string roomName = "";
for(int i=0; i < RoomList.Count; i++){
if(RoomList[i].IsOpen){
roomName = RoomList[i].Name;
break;
}
}
if(roomName == ""){roomName="Deathmatch#" + RoomList.Count;}
Debug.Log("Room name is " + roomName);
queuedRoomname = "GAME_READY";
PhotonNetwork.LeaveRoom();
GameManager.RoomName = roomName;
}
void LoadGame(string newRoomname){
queuedRoomname = "GAME_READY";
PhotonNetwork.LeaveRoom();
@@ -399,6 +386,12 @@ public class MainMenu : MonoBehaviourPunCallbacks, IOnEventCallback
StartMatchmaking();
}else if(eventCode == StopMatchmakeEventCode){
CancelMatchmaking();
}else if(eventCode == ChangeGameModeEventCode){
if(!PhotonNetwork.IsMasterClient){
GameModeSelector.SetValue((string)photonEvent.CustomData);
UpdateGameMode((string)photonEvent.CustomData);
}
}
}
}