void Start()
 {
     registry = transform.parent.gameObject.GetComponent <BoidRegister>();
     registry.register(this);
     rb             = GetComponent <Rigidbody>();
     chlorine       = registry.maxChlorine;
     power          = registry.maxPower;
     algaeCluster   = registry.algaeCluster;
     chlorineClouds = registry.chlorineClouds;
     boids          = new HashSet <BoidController>();
     cluster        = new HashSet <AlgaeController>();
     clouds         = new HashSet <ChlorineController>();
     closestChunk   = Vector3.zero;
 }
Example #2
0
 public void spawnBoids()
 {
     register = GetComponent <BoidRegister>();
     register.purge();
     for (int i = 0; i < x; i++)
     {
         for (int j = 0; j < y; j++)
         {
             Vector3    position = new Vector3(i * separation, 0, j * separation);
             GameObject boid     = (GameObject)Instantiate(prefab, position, Quaternion.identity);
             int        index    = (i * y + j);
             boid.name = "Boid " + index;
             boid.GetComponent <BoidController>().id          = index;
             boid.GetComponent <BoidController>().headingHome = false;
             boid.transform.parent = transform;
         }
     }
 }