Esempio n. 1
0
 public MatchLobbyContext(
     TCPServer Server, ConnectionCache <Player> ConnectionCache, MatchLobby Lobby, Chat Chat)
     : base(Server, ConnectionCache)
 {
     this.Lobby = Lobby;
     this.Chat  = Chat;
 }
Esempio n. 2
0
        public MatchLobbyScreen(
            Vector2f WindowSize, bool Host, MatchLobby Lobby, Chat Chat, Player Player, IEnumerable <Scenario> Scenarios)
            : base(WindowSize)
        {
            _Host  = Host;
            _Lobby = Lobby;
            _Lobby.OnActionApplied += (sender, e) => _Dirty = true;
            _Player    = Player;
            _Scenarios = Scenarios.ToList();

            ChatView = new ChatView(
                Chat, "match-lobby-chat-display", "match-lobby-chat", "match-lobby-chat-message", "text-input");
            ChatView.Position = new Vector2f(_Display.Size.X + 16, 0);

            _LaunchButton.Position = new Vector2f(0, _Pane.Size.Y - _LaunchButton.Size.Y - 32);
            _LaunchButton.Enabled  = Host;
            _LaunchButton.OnClick += HandleLaunched;

            _ScenarioSelect.Enabled   = Host;
            _ScenarioSelect.OnChange += HandleScenarioSelected;

            _Pane.Position = .5f * (WindowSize - _Pane.Size);
            _Pane.Add(_Display);
            _Pane.Add(_LaunchButton);
            _Pane.Add(ChatView);
            DisplayPlayers();
        }
Esempio n. 3
0
        public MatchLobbyPlayerSection(Player Player, MatchLobby Lobby, bool Enabled)
            : base("match-lobby-player-section")
        {
            this.Player = Player;

            var header = new Button("match-lobby-player-section-header")
            {
                DisplayedString = Player.Name
            };
            var select = new Select <ArmyConfiguration>("match-lobby-player-section-select");
            var ready  = new Checkbox("match-lobby-player-section-checkbox");

            select.Add(new SelectionOption <ArmyConfiguration>("match-lobby-player-section-select-option")
            {
                DisplayedString = "Spectator",
                Value           = null
            });
            foreach (ArmyConfiguration a in Lobby.Scenario.ArmyConfigurations)
            {
                select.Add(new SelectionOption <ArmyConfiguration>("match-lobby-player-section-select-option")
                {
                    DisplayedString = a.Faction.Name,
                    Value           = a
                });
            }
            if (Enabled)
            {
                select.OnChange += HandleArmyConfigurationSelected;
            }
            select.Position = new Vector2f(0, header.Size.Y + 6);
            select.Enabled  = Enabled && !Lobby.GetPlayerReady(Player);
            select.SetValue(i => i.Value == Lobby.GetPlayerArmy(Player));

            if (Enabled)
            {
                ready.OnChange += HandlePlayerReadyStateChanged;
            }
            ready.Position = new Vector2f(Size.X - ready.Size.X - 16, 0);
            ready.Value    = Lobby.GetPlayerReady(Player);
            ready.Enabled  = Enabled;

            Add(header);
            Add(select);
            Add(ready);
        }
Esempio n. 4
0
        public MatchLobbyContext MakeLobbyContext()
        {
            if (IsHost)
            {
                var lobby = new MatchLobby(GameData.Scenarios.First());
                lobby.ApplyAction(new AddPlayerAction(Player));
                var chat = new Chat();

                Server.MessageAdapter = new NonMatchMessageSerializer();
                Server.RPCHandler     =
                    new RPCHandler().Install(
                        new LobbyServerLayer(lobby, ConnectionCache), new ChatServerLayer(chat, ConnectionCache));

                lobby.OnActionApplied += (sender, e) => Server.Broadcast(new ApplyLobbyActionRequest(e.Value));
                chat.OnActionApplied  += (sender, e) => Server.Broadcast(new ApplyChatActionRequest(e.Value));

                return(new MatchLobbyContext(Server, ConnectionCache, lobby, chat));
            }
            else
            {
                var chat = new Chat();
                Client.MessageAdapter = new NonMatchMessageSerializer();
                var lobbyLayer = new LobbyLayer();
                var handler    = new RPCHandler().Install(lobbyLayer, new ChatLayer(chat));
                Client.RPCHandler = handler;

                if (Client.Call(
                        new ApplyLobbyActionRequest(new AddPlayerAction(Player))).Get <BooleanResponse>().Value)
                {
                    MatchLobby lobby = Client.Call(new GetLobbyRequest()).Get <GetLobbyResponse>().Lobby;
                    lobbyLayer.Lobby = lobby;
                    return(new MatchLobbyContext(Client, lobby, chat));
                }
                return(null);
            }
        }
 public bool Apply(MatchLobby Lobby)
 {
     return(Lobby.SetScenario(Scenario));
 }
Esempio n. 6
0
 public bool Apply(MatchLobby Lobby)
 {
     return(Lobby.SetPlayerReady(Player, Ready));
 }
Esempio n. 7
0
 public MatchLobbyContext(TCPClient Client, MatchLobby Lobby, Chat Chat)
     : base(Client)
 {
     this.Lobby = Lobby;
     this.Chat  = Chat;
 }
 public bool Apply(MatchLobby Lobby)
 {
     return(Lobby.AddPlayer(Player));
 }
Esempio n. 9
0
 public LobbyServerLayer(MatchLobby Lobby, ConnectionCache <Player> PlayerConnections)
 {
     this.Lobby         = Lobby;
     _PlayerConnections = PlayerConnections;
 }
Esempio n. 10
0
 public LocalMatchLobbyAdapter(MatchLobby Lobby)
 {
     _Lobby = Lobby;
 }
 public bool Apply(MatchLobby Lobby)
 {
     return(Lobby.SetPlayerArmy(
                Player, Lobby.Scenario.ArmyConfigurations.FirstOrDefault(i => i.UniqueKey == ArmyConfigurationKey)));
 }
 public GetLobbyResponse(MatchLobby Lobby)
 {
     this.Lobby = Lobby;
 }
 public GetLobbyResponse(SerializationInputStream Stream)
     : base(Stream)
 {
     Lobby = new MatchLobby(Stream);
 }
Esempio n. 14
0
 public bool Apply(MatchLobby Lobby)
 {
     return(Lobby.Start(StaticScenario));
 }