private bool _WillMoveToDifferentUnit(ISentientEntity entity, ISentientEntity unit, List <WorldRequest> proposedRequests) { WorldRequest unitRequest = GetEntityRequest(unit, proposedRequests); WorldRequest entityRequest = GetEntityRequest(entity, proposedRequests); if (unitRequest == null) { return(false); } //if(_PredictOutcome(unitRequest) == _PredictOutcome(entityRequest)) //{ // return true; //} // Will other entity walk onto this entity var entityPossibility = _GetEntityAt(_TheRoom, _GetCurrentLocation(unit, _TheRoom), unit.CurrentDirection, 1); if (entityPossibility == entity) { return(false); } //Should be false when entity tries to move thru another. return(true); }
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 WorldRequest GetEntityRequest(ISentientEntity entity, List <WorldRequest> proposedRequests) { WorldRequest unitRequest = null; foreach (var request in proposedRequests) { if (request.Entity == entity) { unitRequest = request; break; } } return(unitRequest); }
internal void PlaceAtEntryPoint(ISentientEntity TheWarrior) { foreach (var heightUnits in _FloorPlan) { foreach (var roomUnit in heightUnits) { if (roomUnit is EntryPoint) { roomUnit.Entity = TheWarrior; return; } } } throw new GeneralGameException("No entry point could be found. Every room must have an entry point."); }
public void EnterRoom(ISentientEntity entity, Room room, WorldCoordinates coordinates) { entity.CurrentDirection = AbsoluteDirections.North; room.Place(entity, coordinates); }
public void EnterRoom(ISentientEntity entity, Room TheRoom) { entity.CurrentDirection = AbsoluteDirections.North; TheRoom.PlaceAtEntryPoint(entity); }
private bool _WillMoveToDifferentUnit(ISentientEntity entity, ISentientEntity unit, List<WorldRequest> proposedRequests) { WorldRequest unitRequest = GetEntityRequest(unit, proposedRequests); WorldRequest entityRequest = GetEntityRequest(entity, proposedRequests); if(unitRequest == null) return false; //if(_PredictOutcome(unitRequest) == _PredictOutcome(entityRequest)) //{ // return true; //} // Will other entity walk onto this entity var entityPossibility = _GetEntityAt(_TheRoom, _GetCurrentLocation(unit, _TheRoom), unit.CurrentDirection, 1); if( entityPossibility == entity) { return false; } //Should be false when entity tries to move thru another. return true; }
/// <summary> /// Can compute the direction you get by starting at an absolute direction (ie. North) /// using a relative direction (ie. left) and can compute the absolute direction /// that results (ie. West) /// </summary> /// <param name="entity"></param> /// <param name="relativeDirection"></param> /// <returns></returns> private AbsoluteDirections _ComputeAbsoluteDirection(ISentientEntity entity, RelativeDirections relativeDirection) { var warriorDirection = FindDirectionFacing(entity); switch (warriorDirection) { case AbsoluteDirections.North: switch (relativeDirection) { case RelativeDirections.InFront: return AbsoluteDirections.North; case RelativeDirections.ToTheLeftSide: return AbsoluteDirections.West; case RelativeDirections.Behind: return AbsoluteDirections.South; case RelativeDirections.ToTheRightSide: return AbsoluteDirections.East; } break; case AbsoluteDirections.West: switch (relativeDirection) { case RelativeDirections.InFront: return AbsoluteDirections.West; case RelativeDirections.ToTheLeftSide: return AbsoluteDirections.South; case RelativeDirections.Behind: return AbsoluteDirections.East; case RelativeDirections.ToTheRightSide: return AbsoluteDirections.North; } break; case AbsoluteDirections.South: switch (relativeDirection) { case RelativeDirections.InFront: return AbsoluteDirections.South; case RelativeDirections.ToTheLeftSide: return AbsoluteDirections.East; case RelativeDirections.Behind: return AbsoluteDirections.North; case RelativeDirections.ToTheRightSide: return AbsoluteDirections.West; } break; case AbsoluteDirections.East: switch (relativeDirection) { case RelativeDirections.InFront: return AbsoluteDirections.East; case RelativeDirections.ToTheLeftSide: return AbsoluteDirections.North; case RelativeDirections.Behind: return AbsoluteDirections.West; case RelativeDirections.ToTheRightSide: return AbsoluteDirections.South; } break; } throw new GeneralGameException("The direction could not be computed. This makes no sense at all."); }
private WorldRequest GetEntityRequest(ISentientEntity entity, List<WorldRequest> proposedRequests) { WorldRequest unitRequest = null; foreach(var request in proposedRequests) { if(request.Entity == entity) { unitRequest = request; break; } } return unitRequest; }
public void Turn(ISentientEntity TheWarrior, RelativeDirections relativeDirections) { TheWarrior.CurrentDirection = _ComputeAbsoluteDirection(TheWarrior, relativeDirections); }
internal void PlaceAtEntryPoint(ISentientEntity TheWarrior) { foreach (var heightUnits in _FloorPlan) { foreach (var roomUnit in heightUnits) { if (roomUnit is EntryPoint) { roomUnit.Entity = TheWarrior; return; } } } throw new GeneralGameException("No entry point could be found. Every room must have an entry point."); }
public AbsoluteDirections FindDirectionFacing(ISentientEntity entity) { return entity.CurrentDirection; }
public AbsoluteDirections FindDirectionFacing(ISentientEntity entity) { return(entity.CurrentDirection); }
public void EnterRoom(ISentientEntity entity, Room room, WorldCoordinates coordinates) { entity.CurrentDirection = AbsoluteDirections.North; room.Place(entity, coordinates); }
public void EnterRoom(ISentientEntity entity, Room TheRoom) { entity.CurrentDirection = AbsoluteDirections.North; TheRoom.PlaceAtEntryPoint(entity); }
public void Place(ISentientEntity entity, WorldCoordinates coordinates) { _FloorPlan[coordinates.Longitude][coordinates.Latitude].Entity = entity; }
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); }
public void Turn(ISentientEntity TheWarrior, RelativeDirections relativeDirections) { TheWarrior.CurrentDirection = _ComputeAbsoluteDirection(TheWarrior, relativeDirections); }
public void Place(ISentientEntity entity, WorldCoordinates coordinates) { _FloorPlan[coordinates.Longitude][coordinates.Latitude].Entity = entity; }
/// <summary> /// Can compute the direction you get by starting at an absolute direction (ie. North) /// using a relative direction (ie. left) and can compute the absolute direction /// that results (ie. West) /// </summary> /// <param name="entity"></param> /// <param name="relativeDirection"></param> /// <returns></returns> private AbsoluteDirections _ComputeAbsoluteDirection(ISentientEntity entity, RelativeDirections relativeDirection) { var warriorDirection = FindDirectionFacing(entity); switch (warriorDirection) { case AbsoluteDirections.North: switch (relativeDirection) { case RelativeDirections.InFront: return(AbsoluteDirections.North); case RelativeDirections.ToTheLeftSide: return(AbsoluteDirections.West); case RelativeDirections.Behind: return(AbsoluteDirections.South); case RelativeDirections.ToTheRightSide: return(AbsoluteDirections.East); } break; case AbsoluteDirections.West: switch (relativeDirection) { case RelativeDirections.InFront: return(AbsoluteDirections.West); case RelativeDirections.ToTheLeftSide: return(AbsoluteDirections.South); case RelativeDirections.Behind: return(AbsoluteDirections.East); case RelativeDirections.ToTheRightSide: return(AbsoluteDirections.North); } break; case AbsoluteDirections.South: switch (relativeDirection) { case RelativeDirections.InFront: return(AbsoluteDirections.South); case RelativeDirections.ToTheLeftSide: return(AbsoluteDirections.East); case RelativeDirections.Behind: return(AbsoluteDirections.North); case RelativeDirections.ToTheRightSide: return(AbsoluteDirections.West); } break; case AbsoluteDirections.East: switch (relativeDirection) { case RelativeDirections.InFront: return(AbsoluteDirections.East); case RelativeDirections.ToTheLeftSide: return(AbsoluteDirections.North); case RelativeDirections.Behind: return(AbsoluteDirections.West); case RelativeDirections.ToTheRightSide: return(AbsoluteDirections.South); } break; } throw new GeneralGameException("The direction could not be computed. This makes no sense at all."); }