public static Rover CreateEquipedRover(float posX, float posY)
        {
            Random rnd      = new Random();
            Rover  newRover = new Rover(posX, posY, this);
            Motor  newMotor = new Motor(this, "VW Express V6");

            newMotor.Attatch(newRover);
            for (int i = rnd.Next(1, 5); i > 0; i--)
            {
                Battery newBattery = new Battery(rnd.Next(4, 9));
                newRover.AddBattery(newBattery);
            }
            SolarPanel newSolarPanel = new SolarPanel(this, "Electro pN5166");
            Radar      RDL           = new Radar(this, RadarType.Location, "Senzay Ping");
            Radar      RDS           = new Radar(this, RadarType.Size, "Senzay Mass");
            Radar      RDN           = new Radar(this, RadarType.Name, "Senzay Hoo");

            RDL.PutInRoverSpareParts(newRover);
            RDS.PutInRoverSpareParts(newRover);
            RDN.PutInRoverSpareParts(newRover);
            for (int i = rnd.Next(1, 3); i > 0; i--)
            {
                Drill newDrill = new Drill(rnd.Next(1, 4), this, DrillNames[i]);
                newDrill.PutInRoverSpareParts(newRover);
            }
            newSolarPanel.PutInRoverSpareParts(newRover);
            return(newRover);
        }
Пример #2
0
 public void RemoveDevice(Device toAttatch)
 {
     //switch statements don't work
     if (toAttatch is Drill && _drill == (Drill)toAttatch)
     {
         _drill = null;
     }
     else if (toAttatch is Motor && _motor == (Motor)toAttatch)
     {
         _motor = null;
     }
     else if (toAttatch is Radar && _radar == (Radar)toAttatch)
     {
         _radar = null;
     }
     else if (toAttatch is SolarPanel && _solarPanel == (SolarPanel)toAttatch)
     {
         _solarPanel = null;
     }
 }
Пример #3
0
 //Devices
 public void AttatchDevice(Device toAttatch)
 {
     //switch statements don't work
     if (toAttatch is Drill)
     {
         if (_drill != null)
         {
             _drill.DeConnectBattery();
             AddToSpareDevices(_drill);
         }
         _drill = (Drill)toAttatch;
     }
     else if (toAttatch is Motor)
     {
         if (_motor != null)
         {
             _motor.DeConnectBattery();
             AddToSpareDevices(_motor);
         }
         _motor = (Motor)toAttatch;
     }
     else if (toAttatch is Radar)
     {
         if (_radar != null)
         {
             _radar.DeConnectBattery();
             AddToSpareDevices(_radar);
         }
         _radar = (Radar)toAttatch;
     }
     else if (toAttatch is SolarPanel)
     {
         if (_solarPanel != null)
         {
             _solarPanel.DeConnectBattery();
             AddToSpareDevices(_solarPanel);
         }
         _solarPanel = (SolarPanel)toAttatch;
     }
 }