public override void PerformAction() { if (Parent.Position != Goal) { Map.GameMap map = (Map.GameMap)Parent.CurrentMap; GoRogue.Pathing.FastAStar pathing = new GoRogue.Pathing.FastAStar(map.GetWalkabilityMap(), GoRogue.Distance.EUCLIDEAN); GoRogue.Pathing.Path path = pathing.ShortestPath(Parent.Position, Goal); if (path != null) { GoRogue.Coord next = path.GetStepWithStart(1); GoRogue.Coord toMove = next - Parent.Position; Parent.Position += toMove; } } }
public void InitializeGame() { Map = new Map.GameMap(height, width); SnakeLength = initialSnakeLength; SnakeXPos = -1; SnakeYPos = -1; FoodXPos = -1; FoodYPos = -1; IsFoodPlaced = false; TotalMoves = 0; PlaceFood(); }
public override void PerformAction() { if (Goal == Parent.Position || Goal.X == -1) { GoRogue.Coord zero = new GoRogue.Coord(0, 0); int x; int y; do { x = rand.Next(0, Parent.CurrentMap.Width); y = rand.Next(0, Parent.CurrentMap.Height); Goal = new GoRogue.Coord(x, y); } while ((Goal - Parent.Position) == zero || !Parent.CurrentMap.GetWalkabilityMap()[x, y]); } Map.GameMap map = (Map.GameMap)Parent.CurrentMap; GoRogue.Pathing.FastAStar pathing = new GoRogue.Pathing.FastAStar(map.GetWalkabilityMap(), GoRogue.Distance.EUCLIDEAN); GoRogue.Pathing.Path path = pathing.ShortestPath(Parent.Position, Goal); if (path != null) { GoRogue.Coord next = path.GetStepWithStart(1); GoRogue.Coord toMove = next - Parent.Position; Parent.Position += toMove; } else { if (WaitTime > 10) { Goal = new GoRogue.Coord(-1, -1); WaitTime = 0; } else { WaitTime++; } } }
public Game(Windows.GameWindow window) { map = new Map.GameMap(window); player = new Player(); player.InitOutput(window, map); }