예제 #1
0
 public CoronavirusController(IMemoryCache memoryCache, CoronaContext coronaContext)
 {
     _authenticationManager = new AuthenticationManager(memoryCache, coronaContext);
     _infectionManager      = new InfectionManager(coronaContext);
     _locationRepository    = new LocationRepository(coronaContext);
     _userRepository        = new UserRepository(coronaContext);
 }
예제 #2
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;
        }
예제 #3
0
 public TestController(CoronaContext coronaContext)
 {
     _coronaContext      = coronaContext;
     _infectionManager   = new InfectionManager(_coronaContext);
     _cubeRepository     = new CubeRepository(_coronaContext);
     _locationRepository = new LocationRepository(_coronaContext);
     _userRepository     = new UserRepository(_coronaContext);
 }
예제 #4
0
        public Game(IDataAccess dataAccess, IList<string> playerNames, Difficulty difficulty)
        {
            OutbreakCounter = new OutbreakCounter();

            Diseases = dataAccess.GetDiseases();
            Nodes = dataAccess.GetNodes();
            Players = PlayerFactory.GetPlayers(playerNames);

            NodeCounters = GetNodeDiseaseCounter(Nodes, Diseases, OutbreakCounter);
            DiseaseCounters = GetDiseaseCounters(Diseases, NodeCounters, OutbreakCounter);

            SubscribeNodesToMovers();
            SubscribeToPlayerCounters();

            InfectionRateCounter = new InfectionRateCounter();
            ResearchStationCounter = new ResearchStationCounter();

            cityCards = GetCityCards(Nodes);
            infectionCards = GetInfectionCards(NodeCounters);

            infectionDeck = new InfectionDeck(infectionCards.ToList());

            ActionCardManager = new ActionCardManager(Nodes, Players, ResearchStationCounter, infectionDeck);

            playerDeck = new PlayerDeck(new List<Card>(cityCards), new List<Card>() { ActionCardManager.GovernmentGrant, ActionCardManager.Airlift });

            epidemicCards = GetEpidemicCards(InfectionRateCounter, infectionDeck);

            StartGame((int)difficulty);

            playerQueue = new PlayerQueue(Players.ToList());
            Players = Players.OrderBy(i => i.TurnOrder);

            ActionManager = new ActionManager();
            DrawManager = new DrawManager(playerDeck);
            DrawManager.DrawPhaseCompleted += DrawPhaseComplete;
            InfectionManager = new InfectionManager(InfectionRateCounter, infectionDeck);
            InfectionManager.InfectionPhaseCompleted += InfectionPhaseCompleted;

            //game over
            OutbreakCounter.GameOver += GameOverNotified;
            playerDeck.GameOver += GameOverNotified;

            foreach (DiseaseCounter dc in DiseaseCounters)
            {
                dc.GameOver += GameOverNotified;
            }

            //game won
            CureTracker = new CureTracker(Diseases);
            CureTracker.GameWon += GameWonNotified;

            NextPlayer();
        }
예제 #5
0
 private void Awake()
 {
     if (Instance == null)
     {
         Instance = this;
     }
     else
     {
         Destroy(this.gameObject);
     }
 }
예제 #6
0
    private void Awake()
    {
        if (instance == null)
        {
            instance = this;
        }

        else if (instance != this)
        {
            Debug.LogError("Tried to create another instance of " + GetType() + ". Destroying.");
            Destroy(gameObject);
        }
    }
        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;
        }