private void HandleGameChanged(MultiplayerGame game)
        {
            _gameSubscriptions.CleanUp();
            _game = game;

            if (game != null)
            {
                HandleState(game, MultiplayerGameState.BeginningRound,
                            () => PublishGameEvent(Flatlings.GameEvents.Waiting));
                HandleState(game, MultiplayerGameState.PlayingRoundBeginningPuzzle,
                            () => PublishGameEvent(Flatlings.GameEvents.Countdown));
                HandleState(game, MultiplayerGameState.PlayingRoundWonPuzzle,
                            () => PublishGameEvent(Flatlings.GameEvents.Won));
                HandleState(game, MultiplayerGameState.PlayingRoundLostPuzzle,
                            () => PublishGameEvent(Flatlings.GameEvents.Lost));
                HandleState(game, MultiplayerGameState.PlayingRoundSolvingPuzzle,
                            () =>
                {
                    _notifiedOfCompletion = false;
                    PublishGameEvent(Flatlings.GameEvents.StartingNewGame);
                });
                HandleState(game, MultiplayerGameState.RoundFinished,
                            () => Messenger.Send(new TransitionToScreenMessage()
                {
                    ScreenName = "Scoreboard"
                }));
            }
        }
        private void HandleState(MultiplayerGame game, MultiplayerGameState multiplayerGameState, Action action)
        {
            var subscription = game.GameStateObservable.Where(state => state == multiplayerGameState)
                               .Subscribe(state => action());

            _gameSubscriptions.AddResourceRequiringCleanup(subscription);
        }
Ejemplo n.º 3
0
        public void StartNewGame(string gameName)
        {
            AbandonAnyPreviousGame();

            _client.StartGame(gameName, _currentPlayer)
            .Subscribe(gameResource =>
            {
                if (gameResource != null)
                {
                    CurrentGame = new MultiplayerGame(gameResource.Name, gameResource.Id, GameRole.Initiator, _client, _currentPlayer);
                }
            });
        }
Ejemplo n.º 4
0
        public void JoinGame(string gameId)
        {
            CurrentGame = null;

            _client.GetGame(gameId)
            .Subscribe(game =>
            {
                if (game != null)
                {
                    CurrentGame = new MultiplayerGame(game.Name, game.Id, GameRole.Player, _client, _currentPlayer);
                    _client.JoinGame(gameId, _currentPlayer);
                }
            });
        }
        private void HandleGameChanged(MultiplayerGame game)
        {
            if (!Enabled || game == null)
            {
                return;
            }

            _playerListView.ItemsSource = game.Players;
            _gameNameLabel.Text         = game.Name;

            var subscription = game.GameStateObservable
                               .Where(state => state == MultiplayerGameState.BeginningRound)
                               .Subscribe(state => Messenger.Send(new StartingMultiplayerGameMessage()));

            _resourceCleaner.AddResourceRequiringCleanup(subscription);
        }
Ejemplo n.º 6
0
 public AbandonedGame(MultiplayerGame parent) : base(parent)
 {
 }
Ejemplo n.º 7
0
 public RoundEndedState(MultiplayerGame parent)
     : base(parent)
 {
 }
Ejemplo n.º 8
0
 public SolvingPuzzleState(MultiplayerGame parent) : base(parent)
 {
 }
Ejemplo n.º 9
0
 public PuzzleStartingState(MultiplayerGame parent) : base(parent)
 {
 }
Ejemplo n.º 10
0
 public WaitingForPlayersState(MultiplayerGame parent) : base(parent)
 {
 }
Ejemplo n.º 11
0
 public StateHandler(MultiplayerGame parent)
 {
     _parent = parent;
 }