internal void MoveEntity(WorldCoordinates oldCoordinates, WorldCoordinates newCoordinates)
        {
            IEntity entityToMove;

            if (_FloorPlan[oldCoordinates.Longitude][oldCoordinates.Latitude].PreviousEntity != null)
            {
                entityToMove = _FloorPlan[oldCoordinates.Longitude][oldCoordinates.Latitude].PreviousEntity;
                _FloorPlan[oldCoordinates.Longitude][oldCoordinates.Latitude].PreviousEntity = null;
            }
            else
            {
                entityToMove = _FloorPlan[oldCoordinates.Longitude][oldCoordinates.Latitude].Entity;
                _FloorPlan[oldCoordinates.Longitude][oldCoordinates.Latitude].Entity = null;
            }

            var currentEntityInNewUnit = _FloorPlan[newCoordinates.Longitude][newCoordinates.Latitude].Entity;

            _FloorPlan[newCoordinates.Longitude][newCoordinates.Latitude].PreviousEntity = currentEntityInNewUnit;
            _FloorPlan[newCoordinates.Longitude][newCoordinates.Latitude].Entity         = entityToMove;
        }
        private WorldCoordinates _GetCurrentLocation(IEntity TheWarrior, Room TheRoom)
        {
            WorldCoordinates warriorsLocation;

            var width  = TheRoom.Width;
            var height = TheRoom.Height;

            for (var widthIndex = 0; widthIndex < width; widthIndex++)
            {
                for (var heightIndex = 0; heightIndex < height; heightIndex++)
                {
                    if (TheRoom.GetEntityAtCoordinate(widthIndex, heightIndex) == TheWarrior)
                    {
                        warriorsLocation = new WorldCoordinates(widthIndex, heightIndex);
                        return(warriorsLocation);
                    }
                }
            }

            throw new EntityNotFoundException();
        }
コード例 #3
0
 public void Place(ISentientEntity entity, WorldCoordinates coordinates)
 {
     _FloorPlan[coordinates.Longitude][coordinates.Latitude].Entity = entity;
 }
コード例 #4
0
        internal void MoveEntity(WorldCoordinates oldCoordinates, WorldCoordinates newCoordinates)
        {
            IEntity entityToMove;

            if (_FloorPlan[oldCoordinates.Longitude][oldCoordinates.Latitude].PreviousEntity != null)
            {
                entityToMove = _FloorPlan[oldCoordinates.Longitude][oldCoordinates.Latitude].PreviousEntity;
                _FloorPlan[oldCoordinates.Longitude][oldCoordinates.Latitude].PreviousEntity = null;
            }
            else
            {
                entityToMove = _FloorPlan[oldCoordinates.Longitude][oldCoordinates.Latitude].Entity;
                _FloorPlan[oldCoordinates.Longitude][oldCoordinates.Latitude].Entity = null;
            }

            var currentEntityInNewUnit = _FloorPlan[newCoordinates.Longitude][newCoordinates.Latitude].Entity;
            _FloorPlan[newCoordinates.Longitude][newCoordinates.Latitude].PreviousEntity = currentEntityInNewUnit;
            _FloorPlan[newCoordinates.Longitude][newCoordinates.Latitude].Entity = entityToMove;
        }
コード例 #5
0
 internal RoomUnit GetUnitAt(WorldCoordinates currentCoordinates)
 {
     return _FloorPlan[currentCoordinates.Longitude][currentCoordinates.Latitude];
 }
コード例 #6
0
 internal IEntity GetEntityAtCoordinate(WorldCoordinates coordinateToCheck)
 {
     return GetEntityAtCoordinate(coordinateToCheck.Latitude, coordinateToCheck.Longitude);
 }
 internal IEntity GetEntityAtCoordinate(WorldCoordinates coordinateToCheck)
 {
     return(GetEntityAtCoordinate(coordinateToCheck.Latitude, coordinateToCheck.Longitude));
 }
 public void Place(ISentientEntity entity, WorldCoordinates coordinates)
 {
     _FloorPlan[coordinates.Longitude][coordinates.Latitude].Entity = entity;
 }
 internal RoomUnit GetUnitAt(WorldCoordinates currentCoordinates)
 {
     return(_FloorPlan[currentCoordinates.Longitude][currentCoordinates.Latitude]);
 }
コード例 #10
0
 public void EnterRoom(ISentientEntity entity, Room room, WorldCoordinates coordinates)
 {
     entity.CurrentDirection = AbsoluteDirections.North;
     room.Place(entity, coordinates);
 }
コード例 #11
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="location"></param>
 /// <param name="direction"></param>
 /// <param name="unitDistance"></param>
 /// <returns></returns>
 private IEntity _GetEntityAt(Room theRoom, WorldCoordinates location, AbsoluteDirections direction, int unitDistance)
 {
     var coordinateToCheck = (WorldCoordinates)location.Compute(direction, unitDistance);
     return theRoom.GetEntityAtCoordinate(coordinateToCheck);
 }
コード例 #12
0
        private WorldCoordinates _GetCurrentLocation(IEntity TheWarrior, Room TheRoom)
        {
            WorldCoordinates warriorsLocation;

            var width = TheRoom.Width;
            var height = TheRoom.Height;

            for (var widthIndex = 0; widthIndex < width; widthIndex++)
            {
                for (var heightIndex = 0; heightIndex < height; heightIndex++)
                {
                    if (TheRoom.GetEntityAtCoordinate(widthIndex, heightIndex) == TheWarrior)
                    {
                        warriorsLocation = new WorldCoordinates(widthIndex, heightIndex);
                        return warriorsLocation;
                    }
                }
            }

            throw new EntityNotFoundException();
        }
 public override void Context()
 {
     TheWorld.MoveForward(TheWarrior, TheRoom);
     PreviousCoordinates = TheWorld.GetCoordinatesOf(TheWarrior, TheRoom);
 }
 public override void Context()
 {
     PreviousCoordinates = TheWorld.GetCoordinatesOf(TheWarrior, TheRoom);
     PreviousCoordinates.ShouldEqual(new WorldCoordinates(2, 2));
 }
        /// <summary>
        ///
        /// </summary>
        /// <param name="location"></param>
        /// <param name="direction"></param>
        /// <param name="unitDistance"></param>
        /// <returns></returns>
        private IEntity _GetEntityAt(Room theRoom, WorldCoordinates location, AbsoluteDirections direction, int unitDistance)
        {
            var coordinateToCheck = (WorldCoordinates)location.Compute(direction, unitDistance);

            return(theRoom.GetEntityAtCoordinate(coordinateToCheck));
        }
 public void EnterRoom(ISentientEntity entity, Room room, WorldCoordinates coordinates)
 {
     entity.CurrentDirection = AbsoluteDirections.North;
     room.Place(entity, coordinates);
 }