Пример #1
0
        private static void onPushJoiningGameSubStateFindLobbyLoaded(BaseState in_state)
        {
            GStateManager stateMgr = GStateManager.Instance;

            if (in_state as JoiningGameSubState)
            {
                stateMgr.OnInitializeDelegate -= onPushJoiningGameSubStateFindLobbyLoaded;

                BombersNetworkManager networkMgr = BombersNetworkManager.singleton as BombersNetworkManager;
                networkMgr.FindLobby(gmatchOptions);
            }
        }
Пример #2
0
        public void ConfirmJoinGameWithOther()
        {
            // send event to confirm
            Dictionary <string, object> jsonData = new Dictionary <string, object>();

            jsonData[BrainCloudConsts.JSON_LAST_CONNECTION_ID] = GCore.Wrapper.Client.RTTConnectionID;
            jsonData[BrainCloudConsts.JSON_PROFILE_ID]         = GCore.Wrapper.Client.ProfileId;
            jsonData[BrainCloudConsts.JSON_USER_NAME]          = GPlayerMgr.Instance.PlayerData.PlayerName;

            // send event to other person
            GCore.Wrapper.Client.EventService.SendEvent(m_offeredByProfileId, "CONFIRM_JOIN_LOBBY",
                                                        BrainCloud.JsonFx.Json.JsonWriter.Serialize(jsonData));

            BombersNetworkManager.WaitOnLobbyJoin();
            ExitSubState();
        }
Пример #3
0
        void CreateNewRoom(string aName, uint size, Dictionary <string, object> matchAttributes)
        {
            BombersNetworkManager networkMgr = BombersNetworkManager.singleton as BombersNetworkManager;
            //List<MatchInfoSnapshot> rooms = null;// networkMgr.matches;
            bool   roomExists = false;
            string roomName   = aName;

            if (aName == "")
            {
                roomName = GPlayerMgr.Instance.PlayerData.PlayerName + "'s Room";
            }
            if (roomExists)
            {
                //m_dialogueDisplay.DisplayDialog("There's already a room named " + aName + "!");
                return;
            }

            int playerLevel = BrainCloudStats.Instance.GetStats()[0].Value;

            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 (size > 8)
            {
                size = 8;
            }
            else if (size < 2)
            {
                size = 2;
            }

            matchAttributes["minLevel"]      = m_roomLevelRangeMin;
            matchAttributes["maxLevel"]      = m_roomLevelRangeMax;
            matchAttributes["StartGameTime"] = m_gameDurations[m_gameDurationListSelection].Duration;
            matchAttributes["IsPlaying"]     = 0;
            matchAttributes["MapLayout"]     = m_layoutListSelection;
            matchAttributes["MapSize"]       = m_sizeListSelection;

            GCore.Wrapper.Client.EntityService.UpdateSingleton("gameName", "{\"gameName\": \"" + roomName + "\"}", null, -1, null, null, null);
            BrainCloudStats.Instance.ReadStatistics();

            Dictionary <string, object> matchOptions = new Dictionary <string, object>();

            matchOptions.Add("gameTime", matchAttributes["StartGameTime"]);
            matchOptions.Add("gameTimeSel", m_gameDurationListSelection);
            matchOptions.Add("isPlaying", 0);
            matchOptions.Add("mapLayout", m_layoutListSelection);
            matchOptions.Add("mapSize", m_sizeListSelection);
            matchOptions.Add("gameName", roomName);
            matchOptions.Add("maxPlayers", size);
            matchOptions.Add("lightPosition", 0);

            matchOptions.Add("minLevel", m_roomLevelRangeMin);
            matchOptions.Add("maxLevel", m_roomLevelRangeMax);

            switch (m_state)
            {
            case eCreateGameState.NEW_ROOM:
            default:
            {
                // Make sure that the JoiningGameSubState is loaded before calling CreateLobby
                GStateManager stateMgr = GStateManager.Instance;
                stateMgr.OnInitializeDelegate += onPushJoiningGameSubStateCreateLobbyLoaded;
                gmatchOptions = matchOptions;
                stateMgr.PushSubState(JoiningGameSubState.STATE_NAME);
            }
            break;

            case eCreateGameState.QUICK_PLAY:
            case eCreateGameState.FIND_ROOM:
            {
                // Make sure that the JoiningGameSubState is loaded before calling FindLobby
                GStateManager stateMgr = GStateManager.Instance;
                stateMgr.OnInitializeDelegate += onPushJoiningGameSubStateFindLobbyLoaded;
                gmatchOptions = matchOptions;
                stateMgr.PushSubState(JoiningGameSubState.STATE_NAME);
            }
            break;
            }
        }