示例#1
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);
 }
示例#2
0
 private void SetUpCollectionEvents()
 {
     batteries.ItemAdded += delegate(Battery bat)
     {
         AllBatteries.Add(bat.UID, bat);
         bat.AssignHub(_source);
     };
     batteries.ItemRemoved += delegate(Battery bat)
     {
         chargingBatteries.Remove(bat.UID);
         freeBatteries.Remove(bat.UID);
         AllBatteries.Remove(bat);
     };
     chargingBatteries.ItemAdded += delegate(Battery bat)
     {
         bat.SetStatus(BatteryStatus.Charge);
         _source.StartCoroutine(bat.ChargeBattery());
     };
     chargingBatteries.ItemRemoved += delegate(Battery bat)
     {
         bat.SetStatus(BatteryStatus.Idle);
         _source.StopCoroutine(bat.ChargeBattery());
     };
     drones.ItemAdded += delegate(IDataSource drone)
     {
         ((Drone)drone).AssignHub(_source);
         AllDrones.Add(drone.UID, drone);
         freeDrones.Add(drone.UID, (Drone)drone);
     };
     drones.ItemRemoved += delegate(IDataSource drone)
     {
         AllDrones.Remove(drone);
         freeDrones.Remove((Drone)drone);
     };
     freeDrones.ItemAdded += (drone) =>
     {
         drone.transform.SetParent(_source.transform);
     };
     freeDrones.ItemRemoved += (drone) =>
     {
         drone.transform.SetParent(Drone.ActiveDrones);
     };
 }