public LaserMazeRunner(LaserMazeConfiguration config) { _mirrors = config.Mirrors; _startingLaserPoint = config.LaserStartingPoint; _gridSize = config.GridSize; Rooms = BuildRooms(_gridSize); }
private static LaserPoint GetLaserStartingPoint(string laserConfigText) { var laserStartPoint = new LaserPoint(); var laserProps = Regex.Match(laserConfigText, @"(?<coords>\d+,\d+)(?<direction>V|H)").Groups; laserStartPoint.Coordinates = new GridCoordinates(laserProps["coords"].Value); laserStartPoint.Direction = GetLaserDirection(laserProps["direction"].Value, laserStartPoint.Coordinates); return(laserStartPoint); }
private LaserPoint GetNextLaserPoint(LaserPoint _currentLaserPoint) { var currentRoom = Rooms.Where(a => a.Coordinates.X == _currentLaserPoint.Coordinates.X && a.Coordinates.Y == _currentLaserPoint.Coordinates.Y).FirstOrDefault(); if (currentRoom == null) { return(null); } else { _previousLaserPoint = _currentLaserPoint; var nextPoint = currentRoom.GetNextLaserPosition(_currentLaserPoint.Direction); return(GetNextLaserPoint(nextPoint)); } }
public LaserPoint GetLaserExitPoint() { _previousLaserPoint = _startingLaserPoint; while (!hasExited) { var nextPoint = GetNextLaserPoint(_previousLaserPoint); if (nextPoint == null) { hasExited = true; } } return(_previousLaserPoint); }