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(); }
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]; }
internal IEntity GetEntityAtCoordinate(WorldCoordinates coordinateToCheck) { return GetEntityAtCoordinate(coordinateToCheck.Latitude, coordinateToCheck.Longitude); }
internal IEntity GetEntityAtCoordinate(WorldCoordinates coordinateToCheck) { return(GetEntityAtCoordinate(coordinateToCheck.Latitude, coordinateToCheck.Longitude)); }
internal RoomUnit GetUnitAt(WorldCoordinates currentCoordinates) { return(_FloorPlan[currentCoordinates.Longitude][currentCoordinates.Latitude]); }
public void EnterRoom(ISentientEntity entity, Room room, WorldCoordinates coordinates) { entity.CurrentDirection = AbsoluteDirections.North; room.Place(entity, coordinates); }
/// <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); }
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)); }