예제 #1
0
 private void AddVehicleToJob(VehicleModel data, JobType type)
 {
     if (type == JobType.Dustman)
     {
         DustmanVehicle vehicle = new DustmanVehicle(data);
         if (Jobs.First(x => x is DustmanJob) is DustmanJob job)
         {
             job.Vehicles.Add(vehicle);
             JsonHelper.AddJsonObject(vehicle.DbModel, job.JsonDirectory);
             vehicle.Spawn();
         }
     }
     else if (type == JobType.Greenkeeper)
     {
         GreenkeeperVehicle vehicle = new GreenkeeperVehicle(data);
         if (Jobs.First(x => x is GreenkeeperJob) is GreenkeeperJob job)
         {
             job.Vehicles.Add(vehicle);
             JsonHelper.AddJsonObject(vehicle.DbModel, job.JsonDirectory);
             vehicle.Spawn();
         }
     }
     else if (type == JobType.Courier)
     {
         CourierVehicle vehicle = new CourierVehicle(data);
         if (Jobs.First(x => x is CourierJob) is CourierJob job)
         {
             job.Vehicles.Add(vehicle);
             JsonHelper.AddJsonObject(vehicle.DbModel, job.JsonDirectory);
             vehicle.Spawn();
         }
     }
 }