コード例 #1
0
 public LaserMazeRunner(LaserMazeConfiguration config)
 {
     _mirrors            = config.Mirrors;
     _startingLaserPoint = config.LaserStartingPoint;
     _gridSize           = config.GridSize;
     Rooms = BuildRooms(_gridSize);
 }
コード例 #2
0
        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);
        }
コード例 #3
0
        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));
            }
        }
コード例 #4
0
        public LaserPoint GetLaserExitPoint()
        {
            _previousLaserPoint = _startingLaserPoint;

            while (!hasExited)
            {
                var nextPoint = GetNextLaserPoint(_previousLaserPoint);
                if (nextPoint == null)
                {
                    hasExited = true;
                }
            }

            return(_previousLaserPoint);
        }