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; }
public PlayerViewModel(Player player, Notifier notifier) { this.player = player; notifier.SubscribeToViewModel(this); Icons icons = new Icons(); switch (player.Role) { case "Dispatcher": pawn = icons["pawnPurple"]; break; case "Medic": pawn = icons["pawnOrange"]; break; case "Scientist": pawn = icons["pawnWhite"]; break; case "Quarantine Specialist": pawn = icons["pawnDarkGreen"]; break; case "Researcher": pawn = icons["pawnBrown"]; break; case "Operations Expert": pawn = icons["pawnGreen"]; break; } }
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; }
public CommandsViewModel(ActionManager actionManager, IContext<Player> selectedPlayer, IBoardViewModel boardViewModel, Notifier notifier) { if (actionManager == null) throw new ArgumentNullException(); this.actionManager = actionManager; this.selectedPlayer = selectedPlayer; this.boardViewModel = boardViewModel; notifier.SubscribeToViewModel(this); }
public GameStatusViewModel(OutbreakCounter outbreakCounter, InfectionRateCounter infectionRateCounter, ResearchStationCounter researchStationCounter, IEnumerable<IDiseaseCounterViewModel> diseaseCounterViewModels, Notifier notifier) { if (diseaseCounterViewModels == null) throw new ArgumentNullException("DiseaseCounterViewModels"); this.outbreakCounter = outbreakCounter; this.infectionRateCounter = infectionRateCounter; this.researchStationCounter = researchStationCounter; this.diseaseCounterViewModels = diseaseCounterViewModels; notifier.SubscribeToViewModel(this); }
public AnchorViewModel(Node node, IEnumerable<NodeDiseaseCounter> diseaseCounters, IBoardViewModel boardViewModel, Notifier notifier) { this.node = node; this.nodeDiseaseCounters = diseaseCounters; this.boardViewModel = boardViewModel; foreach (NodeDiseaseCounter ndc in diseaseCounters) { ndc.Infected += Ndc_Infected; ndc.Treated += Ndc_Treated; } notifier.SubscribeToViewModel(this); opacityTimer = new DispatcherTimer(DispatcherPriority.Render) { Interval = TimeSpan.FromMilliseconds(1) }; opacityTimer.Tick += opacityTimer_Tick; GetAlertColors(); }
public InfectionViewModel(InfectionManager infectionManager, IEnumerable<NodeDiseaseCounter> nodeCounters, IBoardViewModel boardViewModel, Notifier notifier) { this.boardViewModel = boardViewModel; this.infectionManager = infectionManager; notifier.SubscribeToViewModel(this); foreach (NodeDiseaseCounter ndc in nodeCounters) { ndc.Infected += Ndc_Infected; } timer = new DispatcherTimer(); timer.Interval = TimeSpan.FromSeconds(2); timer.Tick += Timer_Tick; animationTimer = new DispatcherTimer(); animationTimer.Interval = TimeSpan.FromMilliseconds(1); animationTimer.Tick += TranslateTimer_Tick; }
public DiseaseCounterViewModel(DiseaseCounter counter, Notifier notifier) { this.counter = counter; notifier.SubscribeToViewModel(this); }
public NodeDiseaseCounterViewModel(NodeDiseaseCounter nodeDiseaseCounter, Notifier notifier) { this.nodeDiseaseCounter = nodeDiseaseCounter; notifier.SubscribeToViewModel(this); }
public NextTurnViewModel(Game game, IContext<Player> currentPlayer, Notifier notifier) { this.game = game; this.currentPlayer = currentPlayer; notifier.SubscribeToViewModel(this); }
public PlayersViewModel(IContext<Player> currentPlayer, IEnumerable<IPlayerViewModel> playerViewModels, Notifier notifier) { this.currentPlayer = currentPlayer; this.playerViewModels = playerViewModels; notifier.SubscribeToViewModel(this); }
public DrawViewModel(DrawManager drawManager, Notifier notifier) { this.drawManager = drawManager; notifier.SubscribeToViewModel(this); }
private IEnumerable<IAnchorViewModel> CreateAnchorViewModels(IEnumerable<Node> nodes, IEnumerable<NodeDiseaseCounter> diseaseCounters, Notifier notifier) { Icons icons = new Icons(); List<AnchorViewModel> anchorViewModels = new List<AnchorViewModel>(); foreach (Node node in nodes) { switch(node.City.Name) { case "Atlanta": anchorViewModels.Add(new AnchorViewModel(node, diseaseCounters.Where(i => i.Node == node), this, notifier) { Left = 1400, Top = 1400, Background = Brushes.Blue, ContentForeground = Brushes.White, Fill = Brushes.White }); break; case "Montreal": anchorViewModels.Add(new AnchorViewModel(node, diseaseCounters.Where(i => i.Node == node), this, notifier) { Left = 1625, Top = 1175, Background = Brushes.Blue, ContentForeground = Brushes.White, Fill = Brushes.White }); break; case "Chicago": anchorViewModels.Add(new AnchorViewModel(node, diseaseCounters.Where(i => i.Node == node), this, notifier) { Left = 1325, Top = 1125, Background = Brushes.Blue, ContentForeground = Brushes.White, Fill = Brushes.White }); break; case "San Francisco": anchorViewModels.Add(new AnchorViewModel(node, diseaseCounters.Where(i => i.Node == node), this, notifier) { Left = 800, Top = 1200, Background = Brushes.Blue, ContentForeground = Brushes.White, Fill = Brushes.White }); break; case "New York": anchorViewModels.Add(new AnchorViewModel(node, diseaseCounters.Where(i => i.Node == node), this, notifier) { Left = 1950, Top = 1200, Background = Brushes.Blue, ContentForeground = Brushes.White, Fill = Brushes.White }); break; case "Washington": anchorViewModels.Add(new AnchorViewModel(node, diseaseCounters.Where(i => i.Node == node), this, notifier) { Left = 1800, Top = 1350, Background = Brushes.Blue, ContentForeground = Brushes.White, NameplateFontSize = 13, Fill = Brushes.White }); break; case "London": anchorViewModels.Add(new AnchorViewModel(node, diseaseCounters.Where(i => i.Node == node), this, notifier) { Left = 2625, Top = 1025, Background = Brushes.Blue, ContentForeground = Brushes.White, Fill = Brushes.White }); break; case "Madrid": anchorViewModels.Add(new AnchorViewModel(node, diseaseCounters.Where(i => i.Node == node), this, notifier) { Left = 2600, Top = 1300, Background = Brushes.Blue, ContentForeground = Brushes.White, Fill = Brushes.White }); break; case "Paris": anchorViewModels.Add(new AnchorViewModel(node, diseaseCounters.Where(i => i.Node == node), this, notifier) { Left = 2900, Top = 1175, Background = Brushes.Blue, ContentForeground = Brushes.White, Fill = Brushes.White }); break; case "Milan": anchorViewModels.Add(new AnchorViewModel(node, diseaseCounters.Where(i => i.Node == node), this, notifier) { Left = 3150, Top = 1125, Background = Brushes.Blue, ContentForeground = Brushes.White, Fill = Brushes.White }); break; case "St. Petersburg": anchorViewModels.Add(new AnchorViewModel(node, diseaseCounters.Where(i => i.Node == node), this, notifier) { Left = 3325, Top = 900, Background = Brushes.Blue, ContentForeground = Brushes.White, NameplateFontSize = 12, Fill = Brushes.White }); break; case "Essen": anchorViewModels.Add(new AnchorViewModel(node, diseaseCounters.Where(i => i.Node == node), this, notifier) { Left = 2975, Top = 975, Background = Brushes.Blue, ContentForeground = Brushes.White, Fill = Brushes.White }); break; case "Miami": anchorViewModels.Add(new AnchorViewModel(node, diseaseCounters.Where(i => i.Node == node), this, notifier) { Left = 1600, Top = 1575, Background = Brushes.Yellow, ContentForeground = Brushes.Black, Fill = Brushes.Black }); break; case "Los Angeles": anchorViewModels.Add(new AnchorViewModel(node, diseaseCounters.Where(i => i.Node == node), this, notifier) { Left = 800, Top = 1525, Background = Brushes.Yellow, ContentForeground = Brushes.Black, Fill = Brushes.Black }); break; case "Mexico City": anchorViewModels.Add(new AnchorViewModel(node, diseaseCounters.Where(i => i.Node == node), this, notifier) { Left = 1100, Top = 1600, Background = Brushes.Yellow, ContentForeground = Brushes.Black, Fill = Brushes.Black }); break; case "Lima": anchorViewModels.Add(new AnchorViewModel(node, diseaseCounters.Where(i => i.Node == node), this, notifier) { Left = 1450, Top = 2300, Background = Brushes.Yellow, ContentForeground = Brushes.Black, Fill = Brushes.Black }); break; case "Santiago": anchorViewModels.Add(new AnchorViewModel(node, diseaseCounters.Where(i => i.Node == node), this, notifier) { Left = 1525, Top = 2600, Background = Brushes.Yellow, ContentForeground = Brushes.Black, Fill = Brushes.Black }); break; case "Bogota": anchorViewModels.Add(new AnchorViewModel(node, diseaseCounters.Where(i => i.Node == node), this, notifier) { Left = 1600, Top = 1900, Background = Brushes.Yellow, ContentForeground = Brushes.Black, Fill = Brushes.Black }); break; case "Sao Paulo": anchorViewModels.Add(new AnchorViewModel(node, diseaseCounters.Where(i => i.Node == node), this, notifier) { Left = 2125, Top = 2275, Background = Brushes.Yellow, ContentForeground = Brushes.Black, Fill = Brushes.Black }); break; case "Buenos Aires": anchorViewModels.Add(new AnchorViewModel(node, diseaseCounters.Where(i => i.Node == node), this, notifier) { Left = 1900, Top = 2525, Background = Brushes.Yellow, ContentForeground = Brushes.Black, Fill = Brushes.Black }); break; case "Lagos": anchorViewModels.Add(new AnchorViewModel(node, diseaseCounters.Where(i => i.Node == node), this, notifier) { Left = 2800, Top = 1875, Background = Brushes.Yellow, ContentForeground = Brushes.Black, Fill = Brushes.Black }); break; case "Khartoum": anchorViewModels.Add(new AnchorViewModel(node, diseaseCounters.Where(i => i.Node == node), this, notifier) { Left = 3300, Top = 1825, Background = Brushes.Yellow, ContentForeground = Brushes.Black, NameplateFontSize = 14, Fill = Brushes.Black }); break; case "Kinshasa": anchorViewModels.Add(new AnchorViewModel(node, diseaseCounters.Where(i => i.Node == node), this, notifier) { Left = 3100, Top = 2100, Background = Brushes.Yellow, ContentForeground = Brushes.Black, Fill = Brushes.Black }); break; case "Johannesburg": anchorViewModels.Add(new AnchorViewModel(node, diseaseCounters.Where(i => i.Node == node), this, notifier) { Left = 3350, Top = 2375, Background = Brushes.Yellow, ContentForeground = Brushes.Black, NameplateFontSize = 11, Fill = Brushes.Black }); break; case "Algiers": anchorViewModels.Add(new AnchorViewModel(node, diseaseCounters.Where(i => i.Node == node), this, notifier) { Left = 2900, Top = 1450, Background = Brushes.Black, ContentForeground = Brushes.White, Fill = Brushes.White }); break; case "Cairo": anchorViewModels.Add(new AnchorViewModel(node, diseaseCounters.Where(i => i.Node == node), this, notifier) { Left = 3300, Top = 1550, Background = Brushes.Black, ContentForeground = Brushes.White, Fill = Brushes.White }); break; case "Moscow": anchorViewModels.Add(new AnchorViewModel(node, diseaseCounters.Where(i => i.Node == node), this, notifier) { Left = 3550, Top = 1100, Background = Brushes.Black, ContentForeground = Brushes.White, Fill = Brushes.White }); break; case "Istanbul": anchorViewModels.Add(new AnchorViewModel(node, diseaseCounters.Where(i => i.Node == node), this, notifier) { Left = 3300, Top = 1275, Background = Brushes.Black, ContentForeground = Brushes.White, Fill = Brushes.White }); break; case "Baghdad": anchorViewModels.Add(new AnchorViewModel(node, diseaseCounters.Where(i => i.Node == node), this, notifier) { Left = 3550, Top = 1400, Background = Brushes.Black, ContentForeground = Brushes.White, Fill = Brushes.White }); break; case "Tehran": anchorViewModels.Add(new AnchorViewModel(node, diseaseCounters.Where(i => i.Node == node), this, notifier) { Left = 3900, Top = 1250, Background = Brushes.Black, ContentForeground = Brushes.White, Fill = Brushes.White }); break; case "Karachi": anchorViewModels.Add(new AnchorViewModel(node, diseaseCounters.Where(i => i.Node == node), this, notifier) { Left = 4000, Top = 1550, Background = Brushes.Black, ContentForeground = Brushes.White, Fill = Brushes.White }); break; case "Delhi": anchorViewModels.Add(new AnchorViewModel(node, diseaseCounters.Where(i => i.Node == node), this, notifier) { Left = 4200, Top = 1400, Background = Brushes.Black, ContentForeground = Brushes.White, Fill = Brushes.White }); break; case "Riyadh": anchorViewModels.Add(new AnchorViewModel(node, diseaseCounters.Where(i => i.Node == node), this, notifier) { Left = 3625, Top = 1675, Background = Brushes.Black, ContentForeground = Brushes.White, Fill = Brushes.White }); break; case "Mumbai": anchorViewModels.Add(new AnchorViewModel(node, diseaseCounters.Where(i => i.Node == node), this, notifier) { Left = 4075, Top = 1750, Background = Brushes.Black, ContentForeground = Brushes.White, Fill = Brushes.White }); break; case "Chennai": anchorViewModels.Add(new AnchorViewModel(node, diseaseCounters.Where(i => i.Node == node), this, notifier) { Left = 4300, Top = 1875, Background = Brushes.Black, ContentForeground = Brushes.White, Fill = Brushes.White }); break; case "Kolkata": anchorViewModels.Add(new AnchorViewModel(node, diseaseCounters.Where(i => i.Node == node), this, notifier) { Left = 4525, Top = 1500, Background = Brushes.Black, ContentForeground = Brushes.White, Fill = Brushes.White }); break; case "Shanghai": anchorViewModels.Add(new AnchorViewModel(node, diseaseCounters.Where(i => i.Node == node), this, notifier) { Left = 4725, Top = 1275, Background = Brushes.Red, ContentForeground = Brushes.White, Fill = Brushes.White }); break; case "Beijing": anchorViewModels.Add(new AnchorViewModel(node, diseaseCounters.Where(i => i.Node == node), this, notifier) { Left = 4750, Top = 1000, Background = Brushes.Red, ContentForeground = Brushes.White, Fill = Brushes.White }); break; case "Seoul": anchorViewModels.Add(new AnchorViewModel(node, diseaseCounters.Where(i => i.Node == node), this, notifier) { Left = 5000, Top = 1050, Background = Brushes.Red, ContentForeground = Brushes.White, Fill = Brushes.White }); break; case "Tokyo": anchorViewModels.Add(new AnchorViewModel(node, diseaseCounters.Where(i => i.Node == node), this, notifier) { Left = 5250, Top = 1200, Background = Brushes.Red, ContentForeground = Brushes.White, Fill = Brushes.White }); break; case "Hong Kong": anchorViewModels.Add(new AnchorViewModel(node, diseaseCounters.Where(i => i.Node == node), this, notifier) { Left = 4775, Top = 1600, Background = Brushes.Red, ContentForeground = Brushes.White, Fill = Brushes.White }); break; case "Bangkok": anchorViewModels.Add(new AnchorViewModel(node, diseaseCounters.Where(i => i.Node == node), this, notifier) { Left = 4575, Top = 1750, Background = Brushes.Red, ContentForeground = Brushes.White, Fill = Brushes.White }); break; case "Taipei": anchorViewModels.Add(new AnchorViewModel(node, diseaseCounters.Where(i => i.Node == node), this, notifier) { Left = 5100, Top = 1600, Background = Brushes.Red, ContentForeground = Brushes.White, Fill = Brushes.White }); break; case "Osaka": anchorViewModels.Add(new AnchorViewModel(node, diseaseCounters.Where(i => i.Node == node), this, notifier) { Left = 5400, Top = 1475, Background = Brushes.Red, ContentForeground = Brushes.White, Fill = Brushes.White }); break; case "Ho Chi Minh City": anchorViewModels.Add(new AnchorViewModel(node, diseaseCounters.Where(i => i.Node == node), this, notifier) { Left = 4825, Top = 1925, Background = Brushes.Red, ContentForeground = Brushes.White, NameplateFontSize = 15, Fill = Brushes.White }); break; case "Manila": anchorViewModels.Add(new AnchorViewModel(node, diseaseCounters.Where(i => i.Node == node), this, notifier) { Left = 5175, Top = 1950, Background = Brushes.Red, ContentForeground = Brushes.White, Fill = Brushes.White }); break; case "Jakarta": anchorViewModels.Add(new AnchorViewModel(node, diseaseCounters.Where(i => i.Node == node), this, notifier) { Left = 4600, Top = 2125, Background = Brushes.Red, ContentForeground = Brushes.White, Fill = Brushes.White }); break; case "Sydney": anchorViewModels.Add(new AnchorViewModel(node, diseaseCounters.Where(i => i.Node == node), this, notifier) { Left = 5350, Top = 2600, Background = Brushes.Red, ContentForeground = Brushes.White, Fill = Brushes.White }); break; } } return anchorViewModels; }
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; }
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; }