/// <summary>
        /// Creates a lobby for a deathmatch game with 10 players
        /// </summary>
        /// <param name="plugin"></param>
        /// <param name="properties"></param>
        /// <returns></returns>
        public static ILobby Deathmatch(LobbiesPlugin plugin, 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(plugin.GenerateLobbyId(),
                                      new[] { team }, plugin, 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 game lobby for 1 vs 1 game
        /// </summary>
        /// <param name="plugin"></param>
        /// <param name="properties"></param>
        /// <returns></returns>
        public static ILobby OneVsOne(LobbiesPlugin plugin, Dictionary <string, string> properties, IPeer creator)
        {
            // Create the teams
            var teamA = new LobbyTeam("Team Blue")
            {
                MaxPlayers = 1,
                MinPlayers = 1
            };
            var teamB = new LobbyTeam("Team Red")
            {
                MaxPlayers = 1,
                MinPlayers = 1
            };

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

            var config = new LobbyConfig();

            // Create the lobby
            var lobby = new BaseLobby(plugin.GenerateLobbyId(),
                                      new[] { teamA, teamB }, plugin, 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);
        }
        public LobbyView(BaseLobby lobby)
        {
            this.lobby = lobby;
            InitializeComponent();
            ChatListBox.ItemsSource = lobby.ChatMessages;

            if (lobby.Type == LobbyType.Host)
            {
                ForceJumpsCheck.IsEnabled  = true;
                ForceJumpsCheck.Visibility = Visibility.Visible;
                MiddleManAPI.UpdateLobbyStatus(LobbyStatus.InLobby);
                (lobby as HostLobby).StartEnabled += () => Dispatcher?.Invoke(() => { StartButton.IsEnabled = true; StartButton.Visibility = Visibility.Visible; });
            }

            lobby.PeerDisconnected += Lobby_PeerDisconnected;
        }
        public GameView(BaseLobby lobby)
        {
            InitializeComponent();

            Lobby = lobby;
            ChatBox.ItemsSource     = lobby.ChatMessages;
            lobby.NextTurn         += Lobby_NextTurn;
            lobby.PieceSelected    += Lobby_PieceSelected;
            lobby.TileSelected     += Lobby_TileSelected;
            lobby.GameEnd          += Lobby_GameEnd;
            lobby.PeerDisconnected += Lobby_PeerDisconnected;

            if (lobby.Type == LobbyType.Host)
            {
                MiddleManAPI.UpdateLobbyStatus(LobbyStatus.InLobby);
            }
        }
Example #5
0
 public void Init()
 {
     Lobby = new BaseLobby();
 }