Beispiel #1
0
 protected void DecoratedPickup(AbstractCargo cargo)
 {
     if (cargo.GetCompilerTimeType() == typeof(ToxicCargo) && this.robot.GetCompilerTimeType() == typeof(Cyborg))
     {
         this.toxicActions = this.toxicActionsCount;
         this.ReduceToxicActionPickUp();
     }
 }
Beispiel #2
0
 public override void PickupCargo(AbstractCargo cargo)
 {
     this.SpoilCargo();
     if (cargo.GetType() == typeof(SpoilableCargo))
     {
         this.cargoThatSpoils     = cargo;
         this.ActionsUntilSpoiled = 10;
     }
     this.robot.PickupCargo(cargo);
 }
Beispiel #3
0
        public Robot DecorateRobotIfNeeded(Robot robot, AbstractCargo cargo)
        {
            Robot res = null;

            if (cargo.GetType() != typeof(Cargo))
            {
                res = this.DecorateRobot(robot, cargo);
            }
            else
            {
                res = robot;
            }
            return(res);
        }
Beispiel #4
0
        private Robot DecorateRobot(Robot robot, AbstractCargo cargo)
        {
            if (cargo.GetType() == typeof(ProtectedCargo))
            {
                factory = new ProtectedDecoratorFactory();
            }
            else if (cargo.GetType() == typeof(SpoilableCargo))
            {
                factory = new SpoilingDecoratorFactory();
            }
            else if (cargo.GetType() == typeof(ToxicCargo))
            {
                factory = new ToxicDecoratorFactory();
            }

            return(factory.CreateDecorator(robot)
                   );
        }
Beispiel #5
0
        public override bool CanPickCargo(AbstractCargo cargo)
        {
            if (robot.CanPickCargo(cargo))
            {
                if (this.hasBeenCalled == true)
                {
                    return(true);
                }
                if (cargo.GetType() == typeof(ProtectedCargo))
                {
                    this.hasBeenCalled = true;
                    var rand  = new Random();
                    var integ = rand.Next(0, 100);

                    if (this.robot.GetCompilerTimeType() == typeof(BrightMind))
                    {
                        return(true);
                    }
                    else if (this.robot.GetCompilerTimeType() == typeof(Cyborg))
                    {
                        if (integ < 60)
                        {
                            return(true);
                        }
                        return(false);
                    }
                    else if (this.robot.GetCompilerTimeType() == typeof(Worker))
                    {
                        if (integ < 10)
                        {
                            return(true);
                        }
                        return(false);
                    }
                }
                return(true);
            }
            return(false);
        }
Beispiel #6
0
 public void SetCargoThatSpoils(AbstractCargo cargo)
 {
     this.cargoThatSpoils = cargo;
 }
Beispiel #7
0
 public override void PickupCargo(AbstractCargo cargo)
 {
     DecoratedPickup(cargo);
     this.robot.PickupCargo(cargo);
 }