Example #1
0
    public void PutBoidsOnTree(PeachTreeLandingPtsCtrler peachTree)
    {
        boids.Clear();
        foreach (Landable landable in peachTree.landablePts)
        {
            Transform    landingPtTrans = landable.getTrans();
            BoidFlocking boid           = Instantiate(prefab, landingPtTrans.position, landingPtTrans.rotation) as BoidFlocking;
            boid.transform.parent = transform;

            boid.controller = this;
            landable.TargetBy(boid);

            boid.EnterState(BoidFlocking.State.perching);
            boids.Add(boid);
        }
        perchingTree = peachTree;
    }
Example #2
0
    public void RandomGenerateBoidInsideCollider(BoidFlocking.State initState)
    {
        Collider collider = GetComponent <Collider>();

        Debug.Assert(collider != null, "no collider on this gameObject");

        boids.Clear();
        for (int i = 0; i < flockSize; i++)
        {
            BoidFlocking boid = Instantiate(prefab, transform.position, transform.rotation) as BoidFlocking;
            boid.transform.parent        = transform;
            boid.transform.localPosition = new Vector3(
                Random.value * collider.bounds.size.x,
                Random.value * collider.bounds.size.y,
                Random.value * collider.bounds.size.z) - collider.bounds.extents;
            boid.controller = this;
            boid.EnterState(initState);
            boids.Add(boid);
        }
    }