コード例 #1
0
        public override void PlaceVertex(MazePoint p, Direction d)
        {
            MazePoint finalPoint;

            if (_movementHelper.CanMove(p, d, Size, out finalPoint))
            {
                MazeCell cell;
                switch (d)
                {
                case Direction.Right:
                case Direction.Up:
                case Direction.Forward:
                    cell            = Maze[p.X, p.Y, p.Z];
                    cell.Directions = _flagParser.AddDirectionsToFlag(cell.Directions, d);
                    break;

                case Direction.Left:
                case Direction.Down:
                case Direction.Back:
                    cell            = Maze[finalPoint.X, finalPoint.Y, finalPoint.Z];
                    cell.Directions = _flagParser.AddDirectionsToFlag(cell.Directions,
                                                                      _flagParser.OppositeDirection(d));
                    break;

                default:
                    throw new ArgumentException(String.Format("Flag not supported: {0}", d));
                }
            }
        }
コード例 #2
0
 public bool TryJumpToPoint(MazePoint p)
 {
     if (CanJumpToPoint(p))
     {
         JumpToPoint(p);
         return(true);
     }
     return(false);
 }
コード例 #3
0
        public override Direction GetFlagFromPoint(MazePoint p)
        {
            var currentCell = Maze[p.X, p.Y, p.Z].Directions & (Direction.Right | Direction.Up | Direction.Forward);

            return(currentCell |
                   HasVertexInDirection(p, Direction.Left) |
                   HasVertexInDirection(p, Direction.Down) |
                   HasVertexInDirection(p, Direction.Back));
        }
コード例 #4
0
        public override Direction GetFlagFromPoint(MazePoint p)
        {
            MazeCell startCell;

            if (Maze.TryGetValue(p, out startCell))
            {
                return(startCell.Directions);
            }
            throw new CellNotFoundException();
        }
コード例 #5
0
        public bool HasDirections(MazePoint p, Direction d)
        {
            var baseResult = _model.HasDirections(p, d);

            if (baseResult)
            {
                return(!_flagParser.FlagHasDirections(GetPoint(p).Directions, d));
            }
            return(false);
        }
コード例 #6
0
        private Direction HasVertexInDirection(MazePoint p, Direction d)
        {
            MazePoint finalPoint;
            var       canMove = _movementHelper.CanMove(p, d, Size, out finalPoint);

            if (canMove)
            {
                return(Maze[finalPoint.X, finalPoint.Y, finalPoint.Z].Directions & _flagParser.OppositeDirection(d));
            }
            return(Direction.None);
        }
コード例 #7
0
        public override void RemoveVertex(MazePoint p, Direction d)
        {
            MazeCell  startCell;
            MazePoint final;
            MazeCell  finalCell;

            if (Maze.TryGetValue(p, out startCell) && _movementHelper.CanMove(p, d, Size, out final) && Maze.TryGetValue(final, out finalCell))
            {
                startCell.Directions = _flagParser.RemoveDirectionsFromFlag(startCell.Directions, d);
                finalCell.Directions = _flagParser.RemoveDirectionsFromFlag(finalCell.Directions,
                                                                            _flagParser.OppositeDirection(d));
            }
        }
コード例 #8
0
        public void RemoveVertex(MazePoint p, Direction d)
        {
            var       startCell = GetPoint(p);
            MazePoint finalPoint;

            if (_movementHelper.CanMove(p, d, Size, out finalPoint))
            {
                var finalCell = Maze[finalPoint.X, finalPoint.Y, finalPoint.Z];
                startCell.Directions = _flagParser.AddDirectionsToFlag(startCell.Directions, d);
                finalCell.Directions = _flagParser.AddDirectionsToFlag(finalCell.Directions,
                                                                       _flagParser.OppositeDirection(d));
            }
        }
コード例 #9
0
        public override void RemoveVertex(MazePoint p, Direction d)
        {
            var       startCell = Maze[p.X, p.Y, p.Z];
            MazePoint finalPoint;

            if (_movementHelper.CanMove(p, d, Size, out finalPoint))
            {
                var finalCell = Maze[finalPoint.X, finalPoint.Y, finalPoint.Z];
                startCell.Directions = _flagParser.RemoveDirectionsFromFlag(startCell.Directions, d);
                finalCell.Directions = _flagParser.RemoveDirectionsFromFlag(finalCell.Directions,
                                                                            _flagParser.OppositeDirection(d));
            }
        }
コード例 #10
0
        public override bool HasDirections(MazePoint p, Direction d)
        {
            var directions = _flagParser.SplitDirectionsFromFlag(d);

            return(directions.All(x =>
            {
                if (IsRightUpForward(x))
                {
                    return _flagParser.FlagHasDirections(Maze[p.X, p.Y, p.Z].Directions, x);
                }
                if (IsLeftDownBack(x))
                {
                    return _flagParser.FlagHasDirections(HasVertexInDirection(p, x), x);
                }
                throw new ArgumentException(String.Format("Flag not supported: {0}", d));
            }));
        }
コード例 #11
0
        public override void RemoveVertex(MazePoint p, Direction d)
        {
            MazePoint finalPoint;

            if (_movementHelper.CanMove(p, d, Size, out finalPoint))
            {
                MazeCell cell;
                if (IsRightUpForward(d))
                {
                    cell            = Maze[p.X, p.Y, p.Z];
                    cell.Directions = _flagParser.RemoveDirectionsFromFlag(cell.Directions, d);
                }
                else if (IsLeftDownBack(d))
                {
                    cell            = Maze[finalPoint.X, finalPoint.Y, finalPoint.Z];
                    cell.Directions = _flagParser.RemoveDirectionsFromFlag(cell.Directions,
                                                                           _flagParser.OppositeDirection(d));
                }
                else
                {
                    throw new ArgumentException(String.Format("Flag not supported: {0}", d));
                }
            }
        }
コード例 #12
0
 public abstract bool HasDirections(MazePoint p, Direction d);
コード例 #13
0
 public void JumpToPoint(MazePoint p)
 {
     CurrentPoint = MovementHelper.Move(CurrentPoint, p, Size);
 }
コード例 #14
0
 public void PlaceVertex(MazePoint p, Direction d)
 {
     throw new ArgumentException("You cannot add vertexes to a DeadEndModel");
 }
コード例 #15
0
 public bool CanJumpToPoint(MazePoint p)
 {
     return(PointValidity.ValidPoint(p, Size));
 }
コード例 #16
0
 private MazeCell GetPoint(MazePoint p)
 {
     return(Maze[p.X, p.Y, p.Z]);
 }
コード例 #17
0
 public void Initialise(IModelsWrapper modelsWrapper, IDirectionsFlagParser directionsFlagParser, IMovementHelper movementHelper, IPointValidity pointValidity, IRandomPointGenerator randomPointGenerator, MazePoint startingPoint = null)
 {
     ModelsWrapper        = modelsWrapper;
     DirectionsFlagParser = directionsFlagParser;
     MovementHelper       = movementHelper;
     PointValidity        = pointValidity;
     RandomPointGenerator = randomPointGenerator;
     CurrentPoint         = startingPoint ?? randomPointGenerator.RandomPoint(Size);
 }
コード例 #18
0
 public abstract void PlaceVertex(MazePoint p, Direction d);
コード例 #19
0
 public Direction GetFlagFromPoint(MazePoint p)
 {
     return(_flagParser.RemoveDirectionsFromFlag(_model.GetFlagFromPoint(p), GetPoint(p).Directions));
 }
コード例 #20
0
 public override bool HasDirections(MazePoint p, Direction d)
 {
     return(_flagParser.FlagHasDirections(GetFlagFromPoint(p), d));
 }
コード例 #21
0
 public abstract void RemoveVertex(MazePoint p, Direction d);
コード例 #22
0
 public override Direction GetFlagFromPoint(MazePoint p)
 {
     return(Maze[p.X, p.Y, p.Z].Directions);
 }
コード例 #23
0
 public abstract Direction GetFlagFromPoint(MazePoint p);