예제 #1
0
 public void AddBoidToFlock()
 {
     population++;
     Boid boid = new Boid(pd);
     flock.Add(boid);
     if (population == 1) Demo.SelectedVehicle = boid;
 }
예제 #2
0
        public void RemoveBoidFromFlock()
        {
            if (population > 0)
            {
                // save a pointer to the last boid, then remove it from the flock
                population--;
                Boid boid = flock[population];
                flock.RemoveAt(population);

                // if it is Demo's selected vehicle, unselect it
                if (boid == Demo.SelectedVehicle)
                {
                    Demo.SelectedVehicle = null;
                }

                // delete the Boid
                boid = null;
            }
        }