public void MoveForward(ISentientEntity TheWarrior, Room TheRoom) { var oldCoordinates = TheRoom.GetCoordinatesOf(TheWarrior); var newCoordinates = oldCoordinates.Compute(TheWarrior.CurrentDirection, 1); if (!(TheRoom.GetEntityAtCoordinate(newCoordinates) is Wall)) { TheRoom.MoveEntity(oldCoordinates, newCoordinates); } }
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(); }
/// <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 void MoveForward(ISentientEntity TheWarrior, Room TheRoom) { var oldCoordinates = TheRoom.GetCoordinatesOf(TheWarrior); var newCoordinates = oldCoordinates.Compute(TheWarrior.CurrentDirection, 1); if(!(TheRoom.GetEntityAtCoordinate(newCoordinates) is Wall)) TheRoom.MoveEntity(oldCoordinates, newCoordinates); }
/// <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)); }