/// <summary>Updates the position by 1 unit in the diretion of the orientation.</summary> /// <returns>Bearing.</returns> public Bearing Move() { var newBearing = new Bearing( this.Position.X, this.Position.Y, this.Orientation); switch (this.Orientation) { case Orientation.North: newBearing.Position = new Position(this.Position.X, this.Position.Y + 1); break; case Orientation.South: newBearing.Position = new Position(this.Position.X, this.Position.Y - 1); break; case Orientation.East: newBearing.Position = new Position(this.Position.X + 1, this.Position.Y); break; case Orientation.West: newBearing.Position = new Position(this.Position.X - 1, this.Position.Y); break; } return(newBearing); }
/// <summary>Updates the orientation by 90° left or right.</summary> /// <param name="direction">The direction to update the orientation.</param> /// <returns>Bearing.</returns> public Bearing Turn(Direction direction) { var newBearing = new Bearing( this.Position.X, this.Position.Y, this.Orientation); switch (this.Orientation) { case Orientation.North: newBearing.Orientation = direction == Direction.Left ? Orientation.West : Orientation.East; break; case Orientation.South: newBearing.Orientation = direction == Direction.Left ? Orientation.East : Orientation.West; break; case Orientation.East: newBearing.Orientation = direction == Direction.Left ? Orientation.North : Orientation.South; break; case Orientation.West: newBearing.Orientation = direction == Direction.Left ? Orientation.South : Orientation.North; break; } return(newBearing); }
/// <summary>Updates the bearing of the Actor.</summary> /// <param name="bearing">The bearing.</param> public abstract void Place(Bearing bearing);