Esempio n. 1
0
 /// <summary>
 /// Creates an exploration unit that is responsible for exploring the provided location.
 ///
 /// This explorer is set as part of the provided team.
 /// </summary>
 /// <param name="crew">The team of explorers this explorer will belong to.</param>
 protected Explorer(ExplorationTeam crew)
 {
     ExplorationUnit     = crew ?? throw new ArgumentNullException(nameof(crew), "Exploration unit cannot be null.");
     DeploymentZoneChart = crew.DeploymentZoneChart;
 }
Esempio n. 2
0
 /// <summary>
 /// A specific kind of explorer that can navigate around many different deployment zones that humans otherwise
 /// could not.
 /// </summary>
 /// <param name="crew">The team this rover is assigned to.</param>
 public Rover(ExplorationTeam crew) :
     base(crew)
 {
     _roverMovementActions = new Dictionary <Movement, Action> {
         { Movement.Left, () => _roverRotateLeftActions[Heading].Invoke() },
         { Movement.Right, () => _roverRotateRightActions[Heading].Invoke() },
         { Movement.Forward, () => _roverMoveForwardActions[Heading].Invoke() }
     };
     _roverRotateLeftActions = new Dictionary <Heading, Action> {
         { Heading.North, () => Heading = Heading.West },
         { Heading.South, () => Heading = Heading.East },
         { Heading.East, () => Heading = Heading.North },
         { Heading.West, () => Heading = Heading.South }
     };
     _roverRotateRightActions = new Dictionary <Heading, Action> {
         { Heading.North, () => Heading = Heading.East },
         { Heading.South, () => Heading = Heading.West },
         { Heading.East, () => Heading = Heading.South },
         { Heading.West, () => Heading = Heading.North }
     };
     _roverMoveForwardActions = new Dictionary <Heading, Action> {
         {
             Heading.North, () => {
                 var nextPosition = new Position(Position.X, Position.Y + 1);
                 if (IsPositionAvailable(nextPosition))
                 {
                     Position = nextPosition;
                 }
                 else
                 {
                     Console.WriteLine("The position " + nextPosition + " is not avaiable. " +
                                       "Skipping movement action.");
                 }
             }
         }, {
             Heading.South, () => {
                 var nextPosition = new Position(Position.X, Position.Y - 1);
                 if (IsPositionAvailable(nextPosition))
                 {
                     Position = nextPosition;
                 }
                 else
                 {
                     Console.WriteLine("The position " + nextPosition + " is not avaiable. " +
                                       "Skipping movement action.");
                 }
             }
         }, {
             Heading.East, () => {
                 var nextPosition = new Position(Position.X + 1, Position.Y);
                 if (IsPositionAvailable(nextPosition))
                 {
                     Position = nextPosition;
                 }
                 else
                 {
                     Console.WriteLine("The position " + nextPosition + " is not avaiable. " +
                                       "Skipping movement action.");
                 }
             }
         }, {
             Heading.West, () => {
                 var nextPosition = new Position(Position.X - 1, Position.Y);
                 if (IsPositionAvailable(nextPosition))
                 {
                     Position = nextPosition;
                 }
                 else
                 {
                     Console.WriteLine("The position " + nextPosition + " is not avaiable. " +
                                       "Skipping movement action.");
                 }
             }
         }
     };
 }