Пример #1
0
 public DroneData(Drone src)
 {
     _source = src;
     UID     = ++Count;
     completedJobs.ItemAdded += (obj) => AllCompleteJobs.Add(obj.UID, obj);
     completedJobs.ItemAdded += (obj) => packageWeight += ((Job)obj).PackageWeight;
     movement         = DroneMovement.Idle;
     state            = FlightStatus.Idle;
     collisionOn      = false;
     inHub            = true;
     previousPosition = CurrentPosition;
 }
Пример #2
0
 private void SetUpCollectionEvents()
 {
     batteries.ItemAdded += delegate(Battery bat)
     {
         AllBatteries.Add(bat.UID, bat);
         bat.AssignHub(_source);
     };
     batteries.ItemRemoved += delegate(Battery bat)
     {
         BatteriesWithNoDrones.Remove(bat.UID);
         AllBatteries.Remove(bat.UID);
     };
     drones.ItemAdded += delegate(IDataSource drone)
     {
         ((Drone)drone).AssignHub(_source);
         AllDrones.Add(drone.UID, drone);
         DronesWithNoJobs.Add(drone.UID, (Drone)drone);
     };
     drones.ItemRemoved += delegate(IDataSource drone)
     {
         AllDrones.Remove(drone);
         DronesWithNoJobs.Remove((Drone)drone);
     };
     DronesWithNoJobs.ItemAdded += (drone) =>
     {
         drone.transform.SetParent(_source.transform);
     };
     DronesWithNoJobs.ItemRemoved += (drone) =>
     {
         drone.transform.SetParent(Drone.ActiveDrones);
     };
     completedJobs.ItemAdded += delegate(IDataSource job)
     {
         incompleteJobs.Remove(job);
         AllCompleteJobs.Add(job.UID, job);
     };
     completedJobs.ItemRemoved += (job) => AllCompleteJobs.Remove(job);
     incompleteJobs.ItemAdded  += delegate(IDataSource job)
     {
         AllJobs.Add(job.UID, (Job)job);
         AllIncompleteJobs.Add(job.UID, job);
     };
     incompleteJobs.ItemRemoved += (job) => AllIncompleteJobs.Remove(job);
 }