internal void BuildResearchStation(Node node)
 {
     if (CanBuildResearchStation(node))
     {
         Count--;
         node.ResearchStation = true;
         if (ResearchStationConstructed != null) ResearchStationConstructed(this, new ResearchStationChangedEventArgs(node));
     }
 }
 internal void MoveResearchStation(Node deconstructionNode, Node constructionNode)
 {
     if (CanMoveResearchStation(deconstructionNode, constructionNode))
     {
         deconstructionNode.ResearchStation = false;
         constructionNode.ResearchStation = true;
         if (ResearchStationConstructed != null) ResearchStationConstructed(this, new ResearchStationChangedEventArgs(constructionNode));
         if (ResearchStationDestroyed != null) ResearchStationDestroyed(this, new ResearchStationChangedEventArgs(deconstructionNode));
     }
 }
Ejemplo n.º 3
0
        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();
        }
Ejemplo n.º 4
0
        public Data()
        {
            diseases = new List<Disease>()
            {
                new Disease("Yellow", DiseaseType.Yellow),
                new Disease("Red", DiseaseType.Red),
                new Disease("Blue", DiseaseType.Blue),
                new Disease("Black", DiseaseType.Black)
            };

            nodes = new List<Node>();

            connectionDictionary = new Dictionary<Node, IList<string>>();

            XDocument xmlCities = XDocument.Load("Cities.XML");
            foreach (XElement city in xmlCities.Descendants("City"))
            {
                string cityName = city.Element("Name").Value;
                string countryName = city.Element("Country").Value;
                int population = int.Parse(city.Element("Population").Value);
                string cityDisease = city.Element("Disease").Value;
                List<string> connectionNames = new List<string>();
                foreach (XElement con in city.Element("Connections").Descendants())
                {
                    connectionNames.Add(con.Value);
                }

                Node newNode = new Node(new City(cityName, countryName, population), diseases.Single(i => i.Type.ToString() == cityDisease));
                nodes.Add(newNode);
                connectionDictionary.Add(newNode, connectionNames);
            }

            foreach (Node node in nodes)
            {
                foreach (string cityName in ResolveCityConnections(node))
                {
                    node.Connect(nodes.Single(i => i.City.Name == cityName));
                }
            }
        }
 public ResearchStationChangedEventArgs(Node node)
 {
     Node = node;
 }
 internal NodeDiseaseCounter(Disease disease, Node node)
 {
     Disease = disease;
     Node = node;
     Count = 0;
 }
Ejemplo n.º 7
0
 internal void Move(Node node)
 {
     Node departedNode = Location;
     Location = node;
     if (Moved != null) Moved(this, new PlayerMovedEventArgs(departedNode, node));
 }
        public DispatchItem GetDispatchItem(Node node)
        {
            if (node == null || actionManager.DispatchDestinations == null)
                return null;

            return actionManager.DispatchDestinations.SingleOrDefault(i => i.DispatchDestination == node && i.Player == boardViewModel.SelectedPlayerViewModel.Player);
        }
        public DirectFlightItem GetDirectFlightItem(Node node)
        {
            if (node == null || actionManager.DirectFlightDestinations == null)
                return null;

            return actionManager.DirectFlightDestinations.SingleOrDefault(i => i.CityCard.Node == node);
        }
Ejemplo n.º 10
0
 private IList<string> ResolveCityConnections(Node node)
 {
     return connectionDictionary[node];
 }
Ejemplo n.º 11
0
        public DriveDestinationItem GetDriveDestinationItem(Node node)
        {
            if (node == null)
                return null;

            return actionManager.DriveDestinations.SingleOrDefault(i => i.Node == node);
        }
Ejemplo n.º 12
0
 public CityCard(Node node)
 {
     Node = node;
 }
 internal bool CanMoveResearchStation(Node deconstructionNode, Node constructionNode)
 {
     return Count == 0 && deconstructionNode != null && constructionNode != null && deconstructionNode.ResearchStation && !constructionNode.ResearchStation;
 }
 internal bool CanBuildResearchStation(Node node)
 {
     return Count > 0 && node != null && !node.ResearchStation;
 }
 public PlayerMovedEventArgs(Node departedCity, Node arrivedCity)
 {
     this.departedNode = departedCity;
     this.arrivedNode = arrivedCity;
 }
Ejemplo n.º 16
0
        public static Queue<Node> GetNodePath(Node startNode, Node endNode)
        {
            Queue<Node> path = new Queue<Node>();
            Queue<Node> Q = new Queue<Node>();
            Dictionary<Node, int> Depth = new Dictionary<Node, int>();

            Q.Enqueue(startNode);
            int i = 1;
            Depth.Add(startNode, i);

            bool found = false;

            while (Q.Count > 0 && !found)
            {
                i++;
                Node n = Q.Dequeue();
                path.Enqueue(n);

                foreach (Node connection in n.Connections)
                {
                    if(!Depth.Keys.Contains(connection))
                    {
                        if (connection == endNode)
                        {
                            path.Enqueue(connection);
                            Depth.Add(connection, i);
                            found = true;
                        }

                        if (found)
                            break;

                        Q.Enqueue(connection);
                        Depth.Add(connection, i);
                    }
                }
            }

            Node hit = endNode;
            List<Node> smallestPath = new List<Node>();
            smallestPath.Add(endNode);
            int layer = Depth[endNode];
            while (layer > 1)
            {
                foreach (Node node in Depth.Keys)
                {
                    if (hit.Connections.Contains(node))
                    {
                        layer = Depth[node];
                        smallestPath.Add(node);
                        hit = node;
                        break;
                    }
                }
            }

            Queue<Node> link = new Queue<Node>();
            smallestPath.Reverse();
            foreach (Node node in smallestPath)
            {
                link.Enqueue(node);
            }

            return link;
        }
Ejemplo n.º 17
0
 public void Connect(Node node)
 {
     connections.Add(node);
 }
Ejemplo n.º 18
0
 private bool CanDrive(Node node)
 {
     if (node == null)
         return false;
     else
     {
         DriveDestinationItem ddi = actionManager.DriveDestinations.SingleOrDefault(i => i.Node == node);
         return actionManager.CanDrive(ddi);
     }
 }
 public PreventionEventArgs(Player player, Disease disease, Node node)
 {
     Player = player;
     Disease = disease;
     Node = node;
 }
Ejemplo n.º 20
0
 private void Drive(Node node)
 {
     DriveDestinationItem ddi = actionManager.DriveDestinations.SingleOrDefault(i => i.Node == node);
     actionManager.Drive(ddi);
     RaiseChangeNotificationRequested(null);
     boardViewModel.PawnViewModel.AnimateDrive(boardViewModel.PathAnimationViewModel.Data);
 }