コード例 #1
0
        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!");
            }
        }
コード例 #2
0
 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");
     }
 }
コード例 #3
0
ファイル: Matchmaking.cs プロジェクト: DAHPr0gram3r/bomber2
        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!");
            }
        }
コード例 #4
0
        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);
                }
            }
        }
コード例 #5
0
 void OnPhotonJoinRoomFailed()
 {
     m_state = eMatchmakingState.GAME_STATE_SHOW_ROOMS;
     m_dialogDisplay.DisplayDialog("Could not join room!");
 }
コード例 #6
0
        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");
            }
        }
コード例 #7
0
        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);
        }
コード例 #8
0
 public void HideControls()
 {
     m_state = eMatchmakingState.GAME_STATE_SHOW_ROOMS;
 }
コード例 #9
0
 public void ShowControls()
 {
     m_state = eMatchmakingState.GAME_STATE_SHOW_CONTROLS;
 }
コード例 #10
0
 public void CancelCreateGame()
 {
     CloseDropDowns();
     m_state = eMatchmakingState.GAME_STATE_SHOW_ROOMS;
     RefreshRoomsList();
 }
コード例 #11
0
 public void CancelCreateGame()
 {
     CloseDropDowns();
     m_state = eMatchmakingState.GAME_STATE_SHOW_ROOMS;
     RefreshRoomsList();
 }
コード例 #12
0
 public void ShowLeaderboard()
 {
     m_state            = eMatchmakingState.GAME_STATE_SHOW_LEADERBOARDS;
     m_leaderboardReady = false;
     GameObject.Find("BrainCloudStats").GetComponent <BrainCloudStats>().GetLeaderboard(m_currentLeaderboardID);
 }
コード例 #13
0
 void OnJoinRoomFailed()
 {
     m_state = eMatchmakingState.GAME_STATE_SHOW_ROOMS;
     GameObject.Find("DialogDisplay").GetComponent<DialogDisplay>().DisplayDialog("Could not join room!");
 }
コード例 #14
0
ファイル: Matchmaking.cs プロジェクト: DAHPr0gram3r/bomber2
        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);
        }
コード例 #15
0
 public void HideControls()
 {
     m_state = eMatchmakingState.GAME_STATE_SHOW_ROOMS;
     RefreshRoomsList();
 }
コード例 #16
0
 public void ShowControls()
 {
     m_state = eMatchmakingState.GAME_STATE_SHOW_CONTROLS;
 }
コード例 #17
0
 public void CloseLeaderboard()
 {
     m_state = eMatchmakingState.GAME_STATE_SHOW_ROOMS;
     RefreshRoomsList();
 }
コード例 #18
0
 public void ShowLeaderboard()
 {
     m_state = eMatchmakingState.GAME_STATE_SHOW_LEADERBOARDS;
     m_leaderboardReady = false;
     GameObject.Find("BrainCloudStats").GetComponent<BrainCloudStats>().GetLeaderboard(m_currentLeaderboardID);
 }
コード例 #19
0
        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);
                }
            }
        }
コード例 #20
0
 public void ShowAchievements()
 {
     m_state = eMatchmakingState.GAME_STATE_SHOW_ACHIEVEMENTS;
 }
コード例 #21
0
 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;
 }
コード例 #22
0
        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);
        }
コード例 #23
0
 void OnJoinRoomFailed()
 {
     m_state = eMatchmakingState.GAME_STATE_SHOW_ROOMS;
     GameObject.Find("DialogDisplay").GetComponent <DialogDisplay>().DisplayDialog("Could not join room!");
 }
コード例 #24
0
 public void CloseLeaderboard()
 {
     m_state = eMatchmakingState.GAME_STATE_SHOW_ROOMS;
     RefreshRoomsList();
 }
コード例 #25
0
 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;
 }
コード例 #26
0
 public void HideControls()
 {
     m_state = eMatchmakingState.GAME_STATE_SHOW_ROOMS;
     RefreshRoomsList();
 }
コード例 #27
0
 public void ShowAchievements()
 {
     m_state = eMatchmakingState.GAME_STATE_SHOW_ACHIEVEMENTS;
 }
コード例 #28
0
 public void ShowLeaderboard()
 {
     m_state            = eMatchmakingState.GAME_STATE_SHOW_LEADERBOARDS;
     m_leaderboardReady = false;
     BrainCloudStats.Instance.GetLeaderboard(m_currentLeaderboardID);
 }
コード例 #29
0
 public void CloseLeaderboard()
 {
     m_state = eMatchmakingState.GAME_STATE_SHOW_ROOMS;
 }
コード例 #30
0
        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);
        }
コード例 #31
0
        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);
            }
        }