public Node(Tile type, int x, int y) { this.Type = type; this.Passable = false; this.Location = new CoOrdinates(x, y); this.MovementCost = Int32.MaxValue; }
public List<Node> GetShortestCompleteRouteToLocation(CoOrdinates closestChest) { var result = new List<Node>(); var node = _defaultMapBuilderBuilder.NodeMap[closestChest.X, closestChest.Y]; int depth; Node target = node; do { result.Add(target); depth = target.MovementCost; target = target.Parents.Where(n => n.Type != Tile.GOLD_MINE_1 && n.MovementCost > 0).OrderBy(n => n.MovementCost).First(); // no route to anything protection.. just wait if (result.Count > 100) { return null; } } while (depth > 1); // 0 is the hero result = result.OrderBy(n => n.MovementCost).ToList(); return result; }
public string GetDirection(CoOrdinates currentLocation, CoOrdinates moveTo) { var direction = "Stay"; if (moveTo == null) { return direction; } if (moveTo.X > currentLocation.X) { direction = "East"; } else if (moveTo.X < currentLocation.X) { direction = "West"; } else if (moveTo.Y > currentLocation.Y) { direction = "South"; } else if (moveTo.Y < currentLocation.Y) { direction = "North"; } return direction; }