示例#1
0
 private static Direction[,] GetAvailableDirections(StarshipObject[] walls)
 {
     var availableDirections = RemoveDirectionsContactingWithBorder(MapWidth / CellSize + 2, MapHeight / CellSize + 2);
     foreach (var wall in walls)
     {
         if (wall.Type.Contains("Vertical"))
         {
             availableDirections[wall.DiscreteCoordinate.X, wall.DiscreteCoordinate.Y] &= ~Direction.Left;
             availableDirections[wall.DiscreteCoordinate.X - 1, wall.DiscreteCoordinate.Y] &= ~Direction.Right;
         }
         else if (wall.Type.Contains("Horizontal"))
         {
             availableDirections[wall.DiscreteCoordinate.X, wall.DiscreteCoordinate.Y] &= ~Direction.Up;
             availableDirections[wall.DiscreteCoordinate.X, wall.DiscreteCoordinate.Y - 1] &= ~Direction.Down;
         }
     }
     return availableDirections;
 }
示例#2
0
 private int GetDistance(StarshipObject starshipObject)
 {
     var objCoordinates = starshipObject.DiscreteCoordinate;
     return Math.Abs(OurCoordinates.X - objCoordinates.X) + Math.Abs(OurCoordinates.Y - objCoordinates.Y);
 }