예제 #1
0
        public MainViewModel()
        {
            data = new DataAccess.Data();
            game = new Game(data, new List<string> { "Jessica", "Jack", "John", "Jane" }, Difficulty.Introductory);
            notifier = new Notifier();

            actionCardManager = game.ActionCardManager;
            actionManager = game.ActionManager;
            drawManager = game.DrawManager;
            infectionManager = game.InfectionManager;

            currentPlayer = new ObjectContext<Player>();
            currentPlayer.Context = game.CurrentPlayer;

            selectedPlayer = new ObjectContext<Player>();

            messageContext = new ObjectContext<StringBuilder>();
            messageContext.Context = new StringBuilder();

            BoardViewModel = new BoardViewModel(game, currentPlayer, selectedPlayer, notifier);
            MessageViewModel = new MessageViewModel(messageContext, game.NodeCounters);

            foreach (Player player in game.Players)
            {
                player.Hand.DiscardManager.Block += DiscardManagerBlock;
                player.Hand.DiscardManager.Release += DiscardManagerRelease;
            }

            drawManager.EpidemicDrawn += EpidemicDrawn;

            game.GameOver += Game_GameOver;
            game.GameWon += Game_GameWon;
        }
예제 #2
0
        public BoardViewModel(Game game, IContext<Player> currentPlayer, IContext<Player> selectedPlayer, Notifier notifier)
        {
            this.currentPlayer = currentPlayer;
            this.selectedPlayer = selectedPlayer;

            this.selectedPlayer.ContextChanged += SelectedPlayer_ContextChanged;

            drawViewModel = new DrawViewModel(game.DrawManager, notifier);
            infectionViewModel = new InfectionViewModel(game.InfectionManager, game.NodeCounters, this, notifier);
            playerViewModels = CreatePlayerViewModels(game, notifier);
            playersViewModel = new PlayersViewModel(currentPlayer, playerViewModels, notifier);
            nextTurnViewModel = new NextTurnViewModel(game, currentPlayer, notifier);
            gameStatusViewModel = new GameStatusViewModel(game.OutbreakCounter, game.InfectionRateCounter, game.ResearchStationCounter, CreateDiseaseCounterViewModels(game, notifier), notifier);
            commandsViewModel = new CommandsViewModel(game.ActionManager, selectedPlayer, this, notifier);
            anchorViewModels = CreateAnchorViewModels(game.Nodes, game.NodeCounters, notifier);
            connectionViewModels = CreateConnectionViewModels(game.Nodes, AnchorViewModels);
            pathAnimationViewModel = new PathAnimationViewModel();
            pawnViewModel = new PawnViewModel(this, selectedPlayer);

            notifier.SubscribeToViewModel(this);

            nextTurnViewModel.TurnChanged += NextTurnViewModel_TurnChanged;

            selectedPlayer.Context = currentPlayer.Context;
        }
예제 #3
0
 private void Game_GameOver(object sender, EventArgs e)
 {
     game = null;
 }
 public NextTurnViewModel(Game game, IContext<Player> currentPlayer, Notifier notifier)
 {
     this.game = game;
     this.currentPlayer = currentPlayer;
     notifier.SubscribeToViewModel(this);
 }
예제 #5
0
 private static IEnumerable<IPlayerViewModel> CreatePlayerViewModels(Game game, Notifier notifier)
 {
     List<IPlayerViewModel> playerViewModels = new List<IPlayerViewModel>();
     foreach (Player player in game.Players)
     {
         PlayerViewModel pvm = new PlayerViewModel(player, notifier);
         playerViewModels.Add(pvm);
     }
     return playerViewModels;
 }
예제 #6
0
 private static IEnumerable<IDiseaseCounterViewModel> CreateDiseaseCounterViewModels(Game game, Notifier notifier)
 {
     List<IDiseaseCounterViewModel> diseaseCounterViewModels = new List<IDiseaseCounterViewModel>();
     foreach (DiseaseCounter disease in game.DiseaseCounters)
     {
         DiseaseCounterViewModel dcvm = new DiseaseCounterViewModel(disease, notifier);
         diseaseCounterViewModels.Add(dcvm);
     }
     return diseaseCounterViewModels;
 }