public void JoinRoom(RoomInfo aRoomInfo) { int minLevel = 0; int maxLevel = 50; int playerLevel = BrainCloudStats.Instance.GetStats()[0].m_statValue; if (aRoomInfo.CustomProperties["roomMinLevel"] != null) { minLevel = (int)aRoomInfo.CustomProperties["roomMinLevel"]; } if (aRoomInfo.CustomProperties["roomMaxLevel"] != null) { maxLevel = (int)aRoomInfo.CustomProperties["roomMaxLevel"]; } if (playerLevel < minLevel || playerLevel > maxLevel) { m_dialogDisplay.DisplayDialog("You're not in that room's\nlevel range!"); } else if (aRoomInfo.PlayerCount < aRoomInfo.MaxPlayers) { m_state = eMatchmakingState.GAME_STATE_JOIN_ROOM; if (!PhotonNetwork.JoinRoom(aRoomInfo.Name)) { m_state = eMatchmakingState.GAME_STATE_SHOW_ROOMS; m_dialogDisplay.DisplayDialog("Could not join room!"); } } else { m_dialogDisplay.DisplayDialog("That room is full!"); } }
public void OnMatchJoined(JoinMatchResponse aMatchResponse) { if (aMatchResponse.success) { try { NetworkManager.singleton.OnMatchJoined(aMatchResponse); } catch (ArgumentException e) { m_state = eMatchmakingState.GAME_STATE_SHOW_ROOMS; GameObject.Find("Version Text").transform.SetParent(GameObject.Find("Canvas").transform); GameObject.Find("FullScreen").transform.SetParent(GameObject.Find("Canvas").transform); GameObject.Find("DialogDisplay").GetComponent <DialogDisplay>().DisplayDialog("You just left that room!"); Debug.Log("caught ArgumentException " + e); } catch (Exception e) { m_state = eMatchmakingState.GAME_STATE_SHOW_ROOMS; GameObject.Find("Version Text").transform.SetParent(GameObject.Find("Canvas").transform); GameObject.Find("FullScreen").transform.SetParent(GameObject.Find("Canvas").transform); GameObject.Find("DialogDisplay").GetComponent <DialogDisplay>().DisplayDialog("Error joining room! Try restarting."); Debug.Log("caught Exception " + e); } } else { m_state = eMatchmakingState.GAME_STATE_SHOW_ROOMS; GameObject.Find("Version Text").transform.SetParent(GameObject.Find("Canvas").transform); GameObject.Find("FullScreen").transform.SetParent(GameObject.Find("Canvas").transform); GameObject.Find("DialogDisplay").GetComponent <DialogDisplay>().DisplayDialog("Could not join room!"); Debug.LogError("Join match failed"); } }
public void JoinRoom(RoomInfo aRoomInfo) { int minLevel = 0; int maxLevel = 50; int playerLevel = GameObject.Find("BrainCloudStats").GetComponent <BrainCloudStats>().GetStats()[0].m_statValue; if (aRoomInfo.customProperties["roomMinLevel"] != null) { minLevel = (int)aRoomInfo.customProperties["roomMinLevel"]; } if (aRoomInfo.customProperties["roomMaxLevel"] != null) { maxLevel = (int)aRoomInfo.customProperties["roomMaxLevel"]; } if (playerLevel < minLevel || playerLevel > maxLevel) { GameObject.Find("DialogDisplay").GetComponent <DialogDisplay>().DisplayDialog("You're not in that room's\nlevel range!"); } else if (aRoomInfo.playerCount < aRoomInfo.maxPlayers) { m_state = eMatchmakingState.GAME_STATE_JOIN_ROOM; if (!PhotonNetwork.JoinRoom(aRoomInfo.name)) { m_state = eMatchmakingState.GAME_STATE_SHOW_ROOMS; GameObject.Find("DialogDisplay").GetComponent <DialogDisplay>().DisplayDialog("Could not join room!"); } } else { GameObject.Find("DialogDisplay").GetComponent <DialogDisplay>().DisplayDialog("That room is full!"); } }
public void JoinRoom(MatchDesc aRoomInfo) { GameObject.Find("Version Text").transform.SetParent(null); GameObject.Find("FullScreen").transform.SetParent(null); int minLevel = 0; int maxLevel = 50; int playerLevel = GameObject.Find("BrainCloudStats").GetComponent <BrainCloudStats>().GetStats()[0].m_statValue; if (playerLevel < minLevel || playerLevel > maxLevel) { GameObject.Find("DialogDisplay").GetComponent <DialogDisplay>().DisplayDialog("You're not in that room's\nlevel range!"); GameObject.Find("Version Text").transform.SetParent(GameObject.Find("Canvas").transform); GameObject.Find("FullScreen").transform.SetParent(GameObject.Find("Canvas").transform); } else { m_state = eMatchmakingState.GAME_STATE_JOIN_ROOM; try { BombersNetworkManager.singleton.matchMaker.JoinMatch(aRoomInfo.networkId, "", OnMatchJoined); } catch (ArgumentException e) { m_state = eMatchmakingState.GAME_STATE_SHOW_ROOMS; GameObject.Find("Version Text").transform.SetParent(GameObject.Find("Canvas").transform); GameObject.Find("FullScreen").transform.SetParent(GameObject.Find("Canvas").transform); GameObject.Find("DialogDisplay").GetComponent <DialogDisplay>().DisplayDialog("You just left that room!"); Debug.Log("caught ArgumentException " + e); } catch (Exception e) { m_state = eMatchmakingState.GAME_STATE_SHOW_ROOMS; GameObject.Find("Version Text").transform.SetParent(GameObject.Find("Canvas").transform); GameObject.Find("FullScreen").transform.SetParent(GameObject.Find("Canvas").transform); GameObject.Find("DialogDisplay").GetComponent <DialogDisplay>().DisplayDialog("Error joining room! Try restarting."); Debug.Log("caught Exception " + e); } } }
void OnPhotonJoinRoomFailed() { m_state = eMatchmakingState.GAME_STATE_SHOW_ROOMS; m_dialogDisplay.DisplayDialog("Could not join room!"); }
public void OnMatchJoined(JoinMatchResponse aMatchResponse) { if (aMatchResponse.success) { try { NetworkManager.singleton.OnMatchJoined(aMatchResponse); } catch (ArgumentException e) { m_state = eMatchmakingState.GAME_STATE_SHOW_ROOMS; GameObject.Find("Version Text").transform.SetParent(GameObject.Find("Canvas").transform); GameObject.Find("FullScreen").transform.SetParent(GameObject.Find("Canvas").transform); GameObject.Find("DialogDisplay").GetComponent<DialogDisplay>().DisplayDialog("You just left that room!"); Debug.Log("caught ArgumentException " + e); } catch (Exception e) { m_state = eMatchmakingState.GAME_STATE_SHOW_ROOMS; GameObject.Find("Version Text").transform.SetParent(GameObject.Find("Canvas").transform); GameObject.Find("FullScreen").transform.SetParent(GameObject.Find("Canvas").transform); GameObject.Find("DialogDisplay").GetComponent<DialogDisplay>().DisplayDialog("Error joining room! Try restarting."); Debug.Log("caught Exception " + e); } } else { m_state = eMatchmakingState.GAME_STATE_SHOW_ROOMS; GameObject.Find("Version Text").transform.SetParent(GameObject.Find("Canvas").transform); GameObject.Find("FullScreen").transform.SetParent(GameObject.Find("Canvas").transform); GameObject.Find("DialogDisplay").GetComponent<DialogDisplay>().DisplayDialog("Could not join room!"); Debug.LogError("Join match failed"); } }
void CreateNewRoom(string aName, RoomOptions aOptions) { RoomInfo[] rooms = PhotonNetwork.GetRoomList(); bool roomExists = false; if (aName == "") { aName = PhotonNetwork.player.name + "'s Room"; } for (int i = 0; i < rooms.Length; i++) { if (rooms[i].name == aName) { roomExists = true; } } if (roomExists) { GameObject.Find("DialogDisplay").GetComponent<DialogDisplay>().DisplayDialog("There's already a room named " + aName + "!"); m_roomName = ""; return; } int playerLevel = GameObject.Find("BrainCloudStats").GetComponent<BrainCloudStats>().GetStats()[0].m_statValue; if (m_roomLevelRangeMin < 0) { m_roomLevelRangeMin = 0; } else if (m_roomLevelRangeMin > playerLevel) { m_roomLevelRangeMin = playerLevel; } if (m_roomLevelRangeMax > 50) { m_roomLevelRangeMax = 50; } if (m_roomLevelRangeMax < m_roomLevelRangeMin) { m_roomLevelRangeMax = m_roomLevelRangeMin; } if (aOptions.maxPlayers > 8) { aOptions.maxPlayers = 8; } else if (aOptions.maxPlayers < 1) { aOptions.maxPlayers = 1; } GameObject.Find("Version Text").transform.SetParent(null); GameObject.Find("FullScreen").transform.SetParent(null); ExitGames.Client.Photon.Hashtable customProperties = new ExitGames.Client.Photon.Hashtable(); customProperties["roomMinLevel"] = m_roomLevelRangeMin; customProperties["roomMaxLevel"] = m_roomLevelRangeMax; customProperties["StartGameTime"] = 10 * 60; customProperties["Team1Score"] = 0; customProperties["Team2Score"] = 0; customProperties["IsPlaying"] = 0; customProperties["MapLayout"] = m_presetListSelection; customProperties["MapSize"] = m_sizeListSelection; aOptions.customRoomProperties = customProperties; aOptions.customRoomPropertiesForLobby = new string[] { "roomMinLevel", "roomMaxLevel", "IsPlaying" }; BrainCloudWrapper.GetBC().EntityService.UpdateSingleton("gameName", "{\"gameName\": \"" + aName + "\"}", null, -1, null, null,null); GameObject.Find("BrainCloudStats").GetComponent<BrainCloudStats>().ReadStatistics(); m_state = eMatchmakingState.GAME_STATE_CREATE_NEW_ROOM; PhotonNetwork.CreateRoom(aName, aOptions, TypedLobby.Default); }
public void HideControls() { m_state = eMatchmakingState.GAME_STATE_SHOW_ROOMS; }
public void ShowControls() { m_state = eMatchmakingState.GAME_STATE_SHOW_CONTROLS; }
public void CancelCreateGame() { CloseDropDowns(); m_state = eMatchmakingState.GAME_STATE_SHOW_ROOMS; RefreshRoomsList(); }
public void ShowLeaderboard() { m_state = eMatchmakingState.GAME_STATE_SHOW_LEADERBOARDS; m_leaderboardReady = false; GameObject.Find("BrainCloudStats").GetComponent <BrainCloudStats>().GetLeaderboard(m_currentLeaderboardID); }
void OnJoinRoomFailed() { m_state = eMatchmakingState.GAME_STATE_SHOW_ROOMS; GameObject.Find("DialogDisplay").GetComponent<DialogDisplay>().DisplayDialog("Could not join room!"); }
void CreateNewRoom(string aName, RoomOptions aOptions) { RoomInfo[] rooms = PhotonNetwork.GetRoomList(); bool roomExists = false; if (aName == "") { aName = PhotonNetwork.player.name + "'s Room"; } for (int i = 0; i < rooms.Length; i++) { if (rooms[i].name == aName) { roomExists = true; } } if (roomExists) { GameObject.Find("DialogDisplay").GetComponent <DialogDisplay>().DisplayDialog("There's already a room named " + aName + "!"); m_roomName = ""; return; } int playerLevel = GameObject.Find("BrainCloudStats").GetComponent <BrainCloudStats>().GetStats()[0].m_statValue; if (m_roomLevelRangeMin < 0) { m_roomLevelRangeMin = 0; } else if (m_roomLevelRangeMin > playerLevel) { m_roomLevelRangeMin = playerLevel; } if (m_roomLevelRangeMax > 50) { m_roomLevelRangeMax = 50; } if (m_roomLevelRangeMax < m_roomLevelRangeMin) { m_roomLevelRangeMax = m_roomLevelRangeMin; } if (aOptions.maxPlayers > 8) { aOptions.maxPlayers = 8; } else if (aOptions.maxPlayers < 1) { aOptions.maxPlayers = 1; } ExitGames.Client.Photon.Hashtable customProperties = new ExitGames.Client.Photon.Hashtable(); customProperties["roomMinLevel"] = m_roomLevelRangeMin; customProperties["roomMaxLevel"] = m_roomLevelRangeMax; customProperties["StartGameTime"] = 10 * 60; customProperties["Team1Score"] = 0; customProperties["Team2Score"] = 0; customProperties["IsPlaying"] = 0; customProperties["MapLayout"] = m_presetListSelection; customProperties["MapSize"] = m_sizeListSelection; aOptions.customRoomProperties = customProperties; aOptions.customRoomPropertiesForLobby = new string[] { "roomMinLevel", "roomMaxLevel", "IsPlaying" }; BrainCloudWrapper.GetBC().EntityService.UpdateSingleton("gameName", "{\"gameName\": \"" + aName + "\"}", null, -1, null, null, null); GameObject.Find("BrainCloudStats").GetComponent <BrainCloudStats>().ReadStatistics(); m_state = eMatchmakingState.GAME_STATE_CREATE_NEW_ROOM; PhotonNetwork.CreateRoom(aName, aOptions, TypedLobby.Default); }
public void HideControls() { m_state = eMatchmakingState.GAME_STATE_SHOW_ROOMS; RefreshRoomsList(); }
public void CloseLeaderboard() { m_state = eMatchmakingState.GAME_STATE_SHOW_ROOMS; RefreshRoomsList(); }
public void ShowLeaderboard() { m_state = eMatchmakingState.GAME_STATE_SHOW_LEADERBOARDS; m_leaderboardReady = false; GameObject.Find("BrainCloudStats").GetComponent<BrainCloudStats>().GetLeaderboard(m_currentLeaderboardID); }
public void JoinRoom(MatchDesc aRoomInfo) { GameObject.Find("Version Text").transform.SetParent(null); GameObject.Find("FullScreen").transform.SetParent(null); int minLevel = 0; int maxLevel = 50; int playerLevel = GameObject.Find("BrainCloudStats").GetComponent<BrainCloudStats>().GetStats()[0].m_statValue; if (playerLevel < minLevel || playerLevel > maxLevel) { GameObject.Find("DialogDisplay").GetComponent<DialogDisplay>().DisplayDialog("You're not in that room's\nlevel range!"); GameObject.Find("Version Text").transform.SetParent(GameObject.Find("Canvas").transform); GameObject.Find("FullScreen").transform.SetParent(GameObject.Find("Canvas").transform); } else { m_state = eMatchmakingState.GAME_STATE_JOIN_ROOM; try { BombersNetworkManager.singleton.matchMaker.JoinMatch(aRoomInfo.networkId, "", OnMatchJoined); } catch (ArgumentException e) { m_state = eMatchmakingState.GAME_STATE_SHOW_ROOMS; GameObject.Find("Version Text").transform.SetParent(GameObject.Find("Canvas").transform); GameObject.Find("FullScreen").transform.SetParent(GameObject.Find("Canvas").transform); GameObject.Find("DialogDisplay").GetComponent<DialogDisplay>().DisplayDialog("You just left that room!"); Debug.Log("caught ArgumentException " + e); } catch (Exception e) { m_state = eMatchmakingState.GAME_STATE_SHOW_ROOMS; GameObject.Find("Version Text").transform.SetParent(GameObject.Find("Canvas").transform); GameObject.Find("FullScreen").transform.SetParent(GameObject.Find("Canvas").transform); GameObject.Find("DialogDisplay").GetComponent<DialogDisplay>().DisplayDialog("Error joining room! Try restarting."); Debug.Log("caught Exception " + e); } } }
public void ShowAchievements() { m_state = eMatchmakingState.GAME_STATE_SHOW_ACHIEVEMENTS; }
public void CreateGame() { m_state = eMatchmakingState.GAME_STATE_NEW_ROOM_OPTIONS; m_createGameWindow.transform.FindChild("Room Name").GetComponent<InputField>().text = GameObject.Find("BrainCloudStats").GetComponent<BrainCloudStats>().m_previousGameName; }
void CreateNewRoom(string aName, CreateMatchRequest aOptions) { List<MatchDesc> rooms = BombersNetworkManager.singleton.matches; bool roomExists = false; string roomName = aName; if (aName == "") { roomName = GameObject.Find("BrainCloudStats").GetComponent<BrainCloudStats>().m_playerName + "'s Room"; } if (rooms != null) { for (int i = 0; i < rooms.Count; i++) { if (rooms[i].name == aName) { roomExists = true; } } } if (roomExists) { GameObject.Find("DialogDisplay").GetComponent<DialogDisplay>().DisplayDialog("There's already a room named " + aName + "!"); return; } int playerLevel = GameObject.Find("BrainCloudStats").GetComponent<BrainCloudStats>().GetStats()[0].m_statValue; if (m_roomLevelRangeMin < 0) { m_roomLevelRangeMin = 0; } else if (m_roomLevelRangeMin > playerLevel) { m_roomLevelRangeMin = playerLevel; } if (m_roomLevelRangeMax > 50) { m_roomLevelRangeMax = 50; } if (m_roomLevelRangeMax < m_roomLevelRangeMin) { m_roomLevelRangeMax = m_roomLevelRangeMin; } if (aOptions.size > 8) { aOptions.size = 8; } else if (aOptions.size < 2) { aOptions.size = 2; } GameObject.Find("Version Text").transform.SetParent(null); GameObject.Find("FullScreen").transform.SetParent(null); CreateMatchRequest options = new CreateMatchRequest(); options.name = aName; options.size = aOptions.size; options.advertise = true; options.password = ""; options.matchAttributes = new Dictionary<string, long>(); options.matchAttributes.Add("minLevel", m_roomLevelRangeMin); options.matchAttributes.Add("maxLevel", m_roomLevelRangeMax); options.matchAttributes.Add("StartGameTime", 600); options.matchAttributes.Add("IsPlaying", 0); options.matchAttributes.Add("MapLayout", m_presetListSelection); options.matchAttributes.Add("MapSize", m_sizeListSelection); BrainCloudWrapper.GetBC().EntityService.UpdateSingleton("gameName", "{\"gameName\": \"" + roomName + "\"}", null, -1, null, null, null); GameObject.Find("BrainCloudStats").GetComponent<BrainCloudStats>().ReadStatistics(); m_state = eMatchmakingState.GAME_STATE_CREATE_NEW_ROOM; Dictionary<string, string> matchOptions = new Dictionary<string, string>(); matchOptions.Add("gameTime", 600.ToString()); matchOptions.Add("isPlaying", 0.ToString()); matchOptions.Add("mapLayout", m_presetListSelection.ToString()); matchOptions.Add("mapSize", m_sizeListSelection.ToString()); matchOptions.Add("gameName", roomName); matchOptions.Add("maxPlayers", aOptions.size.ToString()); matchOptions.Add("lightPosition", 0.ToString()); BombersNetworkManager.m_matchOptions = matchOptions; BombersNetworkManager.singleton.matchMaker.CreateMatch(options, OnMatchCreate); }
void OnJoinRoomFailed() { m_state = eMatchmakingState.GAME_STATE_SHOW_ROOMS; GameObject.Find("DialogDisplay").GetComponent <DialogDisplay>().DisplayDialog("Could not join room!"); }
public void CreateGame() { m_state = eMatchmakingState.GAME_STATE_NEW_ROOM_OPTIONS; m_createGameWindow.transform.FindChild("Room Name").GetComponent <InputField>().text = GameObject.Find("BrainCloudStats").GetComponent <BrainCloudStats>().m_previousGameName; }
public void ShowLeaderboard() { m_state = eMatchmakingState.GAME_STATE_SHOW_LEADERBOARDS; m_leaderboardReady = false; BrainCloudStats.Instance.GetLeaderboard(m_currentLeaderboardID); }
public void CloseLeaderboard() { m_state = eMatchmakingState.GAME_STATE_SHOW_ROOMS; }
void CreateNewRoom(string aName, CreateMatchRequest aOptions) { List <MatchDesc> rooms = BombersNetworkManager.singleton.matches; bool roomExists = false; string roomName = aName; if (aName == "") { roomName = GameObject.Find("BrainCloudStats").GetComponent <BrainCloudStats>().m_playerName + "'s Room"; } if (rooms != null) { for (int i = 0; i < rooms.Count; i++) { if (rooms[i].name == aName) { roomExists = true; } } } if (roomExists) { GameObject.Find("DialogDisplay").GetComponent <DialogDisplay>().DisplayDialog("There's already a room named " + aName + "!"); return; } int playerLevel = GameObject.Find("BrainCloudStats").GetComponent <BrainCloudStats>().GetStats()[0].m_statValue; if (m_roomLevelRangeMin < 0) { m_roomLevelRangeMin = 0; } else if (m_roomLevelRangeMin > playerLevel) { m_roomLevelRangeMin = playerLevel; } if (m_roomLevelRangeMax > 50) { m_roomLevelRangeMax = 50; } if (m_roomLevelRangeMax < m_roomLevelRangeMin) { m_roomLevelRangeMax = m_roomLevelRangeMin; } if (aOptions.size > 8) { aOptions.size = 8; } else if (aOptions.size < 2) { aOptions.size = 2; } GameObject.Find("Version Text").transform.SetParent(null); GameObject.Find("FullScreen").transform.SetParent(null); CreateMatchRequest options = new CreateMatchRequest(); options.name = aName; options.size = aOptions.size; options.advertise = true; options.password = ""; options.matchAttributes = new Dictionary <string, long>(); options.matchAttributes.Add("minLevel", m_roomLevelRangeMin); options.matchAttributes.Add("maxLevel", m_roomLevelRangeMax); options.matchAttributes.Add("StartGameTime", 600); options.matchAttributes.Add("IsPlaying", 0); options.matchAttributes.Add("MapLayout", m_presetListSelection); options.matchAttributes.Add("MapSize", m_sizeListSelection); BrainCloudWrapper.GetBC().EntityService.UpdateSingleton("gameName", "{\"gameName\": \"" + roomName + "\"}", null, -1, null, null, null); GameObject.Find("BrainCloudStats").GetComponent <BrainCloudStats>().ReadStatistics(); m_state = eMatchmakingState.GAME_STATE_CREATE_NEW_ROOM; Dictionary <string, string> matchOptions = new Dictionary <string, string>(); matchOptions.Add("gameTime", 600.ToString()); matchOptions.Add("isPlaying", 0.ToString()); matchOptions.Add("mapLayout", m_presetListSelection.ToString()); matchOptions.Add("mapSize", m_sizeListSelection.ToString()); matchOptions.Add("gameName", roomName); matchOptions.Add("maxPlayers", aOptions.size.ToString()); matchOptions.Add("lightPosition", 0.ToString()); BombersNetworkManager.m_matchOptions = matchOptions; BombersNetworkManager.singleton.matchMaker.CreateMatch(options, OnMatchCreate); }
public void JoinRoom(RoomInfo aRoomInfo) { GameObject.Find("Version Text").transform.SetParent(null); GameObject.Find("FullScreen").transform.SetParent(null); int minLevel = 0; int maxLevel = 50; int playerLevel = GameObject.Find("BrainCloudStats").GetComponent<BrainCloudStats>().GetStats()[0].m_statValue; if (aRoomInfo.customProperties["roomMinLevel"] != null) { minLevel = (int)aRoomInfo.customProperties["roomMinLevel"]; } if (aRoomInfo.customProperties["roomMaxLevel"] != null) { maxLevel = (int)aRoomInfo.customProperties["roomMaxLevel"]; } if (playerLevel < minLevel || playerLevel > maxLevel) { GameObject.Find("DialogDisplay").GetComponent<DialogDisplay>().DisplayDialog("You're not in that room's\nlevel range!"); GameObject.Find("Version Text").transform.SetParent(GameObject.Find("Canvas").transform); GameObject.Find("FullScreen").transform.SetParent(GameObject.Find("Canvas").transform); } else if (aRoomInfo.playerCount < aRoomInfo.maxPlayers) { m_state = eMatchmakingState.GAME_STATE_JOIN_ROOM; if (!PhotonNetwork.JoinRoom(aRoomInfo.name)) { m_state = eMatchmakingState.GAME_STATE_SHOW_ROOMS; GameObject.Find("Version Text").transform.SetParent(GameObject.Find("Canvas").transform); GameObject.Find("FullScreen").transform.SetParent(GameObject.Find("Canvas").transform); GameObject.Find("DialogDisplay").GetComponent<DialogDisplay>().DisplayDialog("Could not join room!"); } } else { GameObject.Find("DialogDisplay").GetComponent<DialogDisplay>().DisplayDialog("That room is full!"); GameObject.Find("Version Text").transform.SetParent(GameObject.Find("Canvas").transform); GameObject.Find("FullScreen").transform.SetParent(GameObject.Find("Canvas").transform); } }