Example #1
0
 public void CreateGame(CreateRoomSettings createRoomSettings)
 {
     _photonClient.CreateRoom(createRoomSettings.Name,
                              createRoomSettings.MaxPlayers,
                              createRoomSettings.CustomPropertiesToHashtable(),
                              createRoomSettings.CustomRoomPropertiesForLobby);
 }
Example #2
0
        public void QuickMatch()
        {
            var roomSettings = new CreateRoomSettings {
                Name           = $"QUICK-{Guid.NewGuid().ToString().Substring(0, 4)}",
                MinPlayers     = SelectedScenario.MinPlayerCount,
                MaxPlayers     = SelectedScenario.MaxPlayerCount,
                CloseOnStarted = true,
                OpenOnEnded    = true,
                GameScenario   = SelectedScenario.Key
            };
            var rooms = _photonClient.ListRooms(ListRoomsFilters.Open);

            rooms = rooms.Where(r => (string)r.customProperties[CustomRoomSettingKeys.GameScenario] == roomSettings.GameScenario).ToArray();
            rooms = rooms.Where(r => r.maxPlayers != r.playerCount).ToArray();
            if (0 < rooms.Length)
            {
                _photonClient.JoinRandomRoom(roomSettings.CustomPropertiesToHashtable());
            }
            else
            {
                _createGameController.CreateGame(roomSettings);
            }
        }