Пример #1
0
        /// <summary>
        ///     Creates a lobby for a deathmatch game with 10 players
        /// </summary>
        /// <param name="module"></param>
        /// <param name="properties"></param>
        /// <returns></returns>
        public static ILobby Deathmatch(LobbiesModule module, Dictionary <string, string> properties, IPeer creator)
        {
            // Create the teams
            var team = new LobbyTeam("")
            {
                MaxPlayers = 10,
                MinPlayers = 1
            };

            var config = new LobbyConfig();

            // Create the lobby
            var lobby = new BaseLobby(module.GenerateLobbyId(),
                                      new[] { team }, module, config)
            {
                Name = ExtractLobbyName(properties)
            };

            // Override properties with what user provided
            lobby.SetLobbyProperties(properties);

            // Add control for the game speed
            lobby.AddControl(new LobbyPropertyData {
                Label   = "Game Speed",
                Options = new List <string> {
                    "1x", "2x", "3x"
                },
                PropertyKey = "speed"
            }, "2x"); // Default option

            return(lobby);
        }
        /// <summary>
        /// Creates a 3 vs 3 lobby, instead of the regular <see cref="GameLobby"/>,
        /// it uses the <see cref="GameLobbyAuto"/>, which demonstrates how you
        /// can extend game lobby functionality
        /// </summary>
        /// <param name="module"></param>
        /// <param name="properties"></param>
        /// <returns></returns>
        public static ILobby ThreeVsThreeQueue(LobbiesModule module, Dictionary <string, string> properties, IPeer creator)
        {
            // Create the teams
            var teamA = new LobbyTeam("Team Blue")
            {
                MaxPlayers = 3,
                MinPlayers = 1
            };
            var teamB = new LobbyTeam("Team Red")
            {
                MaxPlayers = 3,
                MinPlayers = 1
            };

            // Set their colors
            teamA.SetProperty("color", "0000FF");
            teamB.SetProperty("color", "FF0000");

            var config = new LobbyConfig()
            {
                EnableReadySystem = false,
                EnableManualStart = false
            };

            // Create the lobby
            var lobby = new BaseLobbyAuto(module.GenerateLobbyId(),
                                          new[] { teamA, teamB }, module, config)
            {
                Name = ExtractLobbyName(properties)
            };

            // Override properties with what user provided
            lobby.SetLobbyProperties(properties);

            // Add control for the game speed
            lobby.AddControl(new LobbyPropertyData()
            {
                Label   = "Game Speed",
                Options = new List <string>()
                {
                    "1x", "2x", "3x"
                },
                PropertyKey = "speed"
            }, "2x"); // Default option

            // Add control to enable/disable gravity
            lobby.AddControl(new LobbyPropertyData()
            {
                Label   = "Gravity",
                Options = new List <string>()
                {
                    "On", "Off"
                },
                PropertyKey = "gravity",
            });

            lobby.StartAutomation();

            return(lobby);
        }
Пример #3
0
 public BaseLobbyAuto(int lobbyId, IEnumerable <LobbyTeam> teams, LobbiesModule module, LobbyConfig config) :
     base(lobbyId, teams, module, config)
 {
     config.EnableManualStart = true;
     config.PlayAgainEnabled  = false;
     config.EnableGameMasters = false;
 }
Пример #4
0
        /// <summary>
        ///     Creates a game for two vs two vs four. This example shows
        ///     how you can setup different size teams, and add them different constraints.
        /// </summary>
        /// <param name="module"></param>
        /// <param name="properties"></param>
        /// <returns></returns>
        public static ILobby TwoVsTwoVsFour(LobbiesModule module, Dictionary <string, string> properties,
                                            IPeer creator)
        {
            // Create the teams
            var teamA = new LobbyTeam("Team Blue")
            {
                MaxPlayers = 2,
                MinPlayers = 1
            };
            var teamB = new LobbyTeam("Team Red")
            {
                MaxPlayers = 2,
                MinPlayers = 1
            };

            var teamC = new LobbyTeam("N00bs")
            {
                MaxPlayers = 4,
                MinPlayers = 0
            };

            // Set their colors
            teamA.SetProperty("color", "0000FF");
            teamB.SetProperty("color", "FF0000");
            teamC.SetProperty("color", "00FF00");

            var config = new LobbyConfig();

            // Create the lobby
            var lobby = new BaseLobby(module.GenerateLobbyId(),
                                      new[] { teamA, teamB, teamC }, module, config)
            {
                Name = ExtractLobbyName(properties)
            };

            // Override properties with what user provided
            lobby.SetLobbyProperties(properties);

            // Add control for the game speed
            lobby.AddControl(new LobbyPropertyData {
                Label   = "Game Speed",
                Options = new List <string> {
                    "1x", "2x", "3x"
                },
                PropertyKey = "speed"
            }, "2x"); // Default option

            // Add control to enable/disable gravity
            lobby.AddControl(new LobbyPropertyData {
                Label   = "Gravity",
                Options = new List <string> {
                    "On", "Off"
                },
                PropertyKey = "gravity"
            });

            return(lobby);
        }
Пример #5
0
        public BaseLobby(int lobbyId, IEnumerable <LobbyTeam> teams,
                         LobbiesModule module, LobbyConfig config)
        {
            Id       = lobbyId;
            Module   = module;
            GameIp   = "";
            GamePort = -1;

            Config = config;

            Controls        = new List <LobbyPropertyData>();
            Members         = new Dictionary <string, LobbyMember>();
            MembersByPeerId = new Dictionary <int, LobbyMember>();
            Properties      = new Dictionary <string, string>();
            Teams           = teams.ToDictionary(t => t.Name, t => t);
            Subscribers     = new HashSet <IPeer>();

            MaxPlayers = Teams.Values.Sum(t => t.MaxPlayers);
            MinPlayers = Teams.Values.Sum(t => t.MinPlayers);
        }
Пример #6
0
        public BaseLobby(int lobbyId, IEnumerable <LobbyTeam> teams, LobbiesModule module, LobbyConfig config)
        {
            Logger = Msf.Create.Logger(typeof(BaseLobby).Name);

            Id       = lobbyId;
            Module   = module;
            GameIp   = "";
            GamePort = -1;

            Config = config;

            controls            = new List <LobbyPropertyData>();
            membersList         = new Dictionary <string, LobbyMember>();
            membersByPeerIdList = new Dictionary <int, LobbyMember>();
            propertiesList      = new DictionaryOptions();
            teamsList           = teams.ToDictionary(t => t.Name, t => t);
            subscribersList     = new HashSet <IPeer>();

            MaxPlayers = teamsList.Values.Sum(t => t.MaxPlayers);
            MinPlayers = teamsList.Values.Sum(t => t.MinPlayers);
        }
Пример #7
0
 public LobbyFactoryAnonymous(string id, LobbiesModule module, LobbyCreationFactory factory)
 {
     Id       = id;
     _factory = factory;
     _module  = module;
 }