示例#1
0
        // turn Warehouse into pathfinder object
        public Pathfinder GetPathfinderFromWarehouse(Warehouse warehouse)
        {
            _pathfinder = new Pathfinder();
            List <GraphNode> GraphNodes = new List <GraphNode>();

            // add start graphnode
            GraphNodes.Add(warehouse.StartNode);

            // loop through districts and add all graphnodes
            foreach (District district in warehouse.Districts)
            {
                GraphNodes.Add(district.StartGraphNode);
                GraphNodes.Add(district.EndGraphNode);
            }

            // loop through all graphnodes and add a path if there is one
            foreach (GraphNode gn in GraphNodes)
            {
                Position start = new Position {
                    X = gn.X, Y = gn.Y
                };
                foreach (Edge edge in gn.Edges)
                {
                    _pathfinder.AddPath(start, new Position {
                        X = edge.EndGraphNode.X, Y = edge.EndGraphNode.Y
                    });
                }
            }

            return(_pathfinder);
        }
示例#2
0
 void AddPath()
 {
     Pathfinder.AddPath(SelectedUnit, SelectedUnit.Tile, currentTile);
 }