示例#1
0
        public Unload(IPlayerContext playerContext, IDrone drone, DateTime startedAt)
        {
            var item = playerContext.GetMap().Factories.FirstOrDefault(
                itm => drone.CurrentPosition.IsNear(itm.Position)
                );

            if (item == null)
            {
                throw new InvalidInstructionException("No factory near the drone");
            }
            Drone     = drone;
            StartedAt = startedAt;
            Resource  = drone.Storage;
            AbortedAt = null;
        }
示例#2
0
        public Collect(IPlayerContext playerContext, IDrone drone, DateTime startedAt)
        {
            var item = playerContext.GetMap().Mines.FirstOrDefault(
                itm => drone.CurrentPosition.IsNear(itm.Position)
                );

            if (item == null)
            {
                throw new InvalidInstructionException("No mine near the drone");
            }
            var mine = item as Mine;

            Drone     = drone;
            StartedAt = startedAt;
            Mine      = mine;
        }
示例#3
0
 public MoveTo(IPlayerContext playerContext, IDrone drone, DateTime startedAt, ICoordinate source, ICoordinate destination)
 {
     if (destination == null)
     {
         throw new ArgumentException("missing destination for MoveTo instruction");
     }
     if (source == null)
     {
         throw new ArgumentException("missing destination for MoveTo instruction");
     }
     if (source.IsNear(destination))
     {
         throw new InvalidInstructionException("The drone is already at destination");
     }
     if (!playerContext.GetMap().IsInside(destination))
     {
         throw new InvalidInstructionException("Destination is outside of the map.");
     }
     Drone         = drone;
     StartedAt     = startedAt;
     StartPosition = source;
     Destination   = destination;
 }