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));
                }
            }
        }
 public bool TryJumpToPoint(MazePoint p)
 {
     if (CanJumpToPoint(p))
     {
         JumpToPoint(p);
         return(true);
     }
     return(false);
 }
        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));
        }
Example #4
0
        public override Direction GetFlagFromPoint(MazePoint p)
        {
            MazeCell startCell;

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

            if (baseResult)
            {
                return(!_flagParser.FlagHasDirections(GetPoint(p).Directions, d));
            }
            return(false);
        }
        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);
        }
Example #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));
            }
        }
        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));
            }
        }
        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));
            }
        }
        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));
            }));
        }
        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));
                }
            }
        }
 public abstract bool HasDirections(MazePoint p, Direction d);
 public void JumpToPoint(MazePoint p)
 {
     CurrentPoint = MovementHelper.Move(CurrentPoint, p, Size);
 }
 public void PlaceVertex(MazePoint p, Direction d)
 {
     throw new ArgumentException("You cannot add vertexes to a DeadEndModel");
 }
 public bool CanJumpToPoint(MazePoint p)
 {
     return(PointValidity.ValidPoint(p, Size));
 }
 private MazeCell GetPoint(MazePoint p)
 {
     return(Maze[p.X, p.Y, p.Z]);
 }
Example #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);
 }
 public abstract void PlaceVertex(MazePoint p, Direction d);
 public Direction GetFlagFromPoint(MazePoint p)
 {
     return(_flagParser.RemoveDirectionsFromFlag(_model.GetFlagFromPoint(p), GetPoint(p).Directions));
 }
 public override bool HasDirections(MazePoint p, Direction d)
 {
     return(_flagParser.FlagHasDirections(GetFlagFromPoint(p), d));
 }
 public abstract void RemoveVertex(MazePoint p, Direction d);
 public override Direction GetFlagFromPoint(MazePoint p)
 {
     return(Maze[p.X, p.Y, p.Z].Directions);
 }
 public abstract Direction GetFlagFromPoint(MazePoint p);