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);
        }
示例#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);
                }
            });
        }
示例#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);
        }
 public AbandonedGame(MultiplayerGame parent) : base(parent)
 {
 }
 public RoundEndedState(MultiplayerGame parent)
     : base(parent)
 {
 }
 public SolvingPuzzleState(MultiplayerGame parent) : base(parent)
 {
 }
 public PuzzleStartingState(MultiplayerGame parent) : base(parent)
 {
 }
示例#10
0
 public WaitingForPlayersState(MultiplayerGame parent) : base(parent)
 {
 }
示例#11
0
 public StateHandler(MultiplayerGame parent)
 {
     _parent = parent;
 }