Inheritance: MonoBehaviour
    void Start()
    {
        for (int i = 0; i < flockSize; i++)
        {
            BoidFlocking boid = Instantiate(boidprefab, transform.position, transform.rotation) as BoidFlocking;
            boid.transform.parent        = transform;
            boid.transform.localPosition = new Vector3(
                Random.value * GetComponent <Collider>().bounds.size.x, Random.value * GetComponent <Collider>().bounds.size.y,
                Random.value * GetComponent <Collider>().bounds.size.z) - GetComponent <Collider>().bounds.extents;

            boid.controller = this;
            boids.Add(boid);
        }
    }
示例#2
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;
    }
示例#3
0
    public void StartATL(ThirdPersonUserControl player, CurvySpline spline, Crosshair crosshair)
    {
        _boids = new List <BoidFlocking>();

        for (int i = 0; i < flockSize; i++)
        {
            Vector3 position = new Vector3(
                Random.value * 10.0f,
                Random.value * 10.0f,
                Random.value * 10.0f
                );

            BoidFlocking boid = Instantiate(prefab, transform.position, transform.rotation) as BoidFlocking;

            boid.transform.parent        = transform;
            boid.transform.localPosition = position;
            boid.GetComponent <BoidFlocking> ().StartATL(i, this, player, spline, crosshair);
            _boids.Add(boid);
        }
    }
示例#4
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);
        }
    }
示例#5
0
    void Start()
    {
        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.rigidbody.velocity = new Vector3(
                Random.value * maxSpeed,
                Random.value * maxSpeed,
                Random.value * maxSpeed);
            boid.rigidbody.velocity *= 0.8f;

            boid.target            = new Vector3(collider.bounds.center.x, collider.bounds.center.y, collider.bounds.center.z);
            boid.mTargetAttraction = targetAttraction;
            boids.Add(boid);
        }
    }
示例#6
0
 public void RemoveBoid(BoidFlocking boid)
 {
     _boids.Remove(boid);
     Destroy(boid.gameObject);
 }
示例#7
0
 public void TargetBy(BoidFlocking boid)
 {
     boids.Add(boid);
     boid.SetTarget(transform);
 }
示例#8
0
 public void Release(BoidFlocking boid)
 {
     boid.landingPt = null;
     boids.Remove(boid);
 }
示例#9
0
 public void Release(BoidFlocking boid)
 {
     Debug.Assert(boid == this.boid);
     boid.landingPt = null;
     this.boid      = null;
 }
示例#10
0
 public void TargetBy(BoidFlocking boid)
 {
     boid.SetTarget(transform);
     this.boid = boid;
 }
示例#11
0
 public void RemoveBoid(BoidFlocking _b)
 {
     boids.Remove(_b);
     GameObject.Destroy(_b.gameObject);
     flockSize = boids.Count;
 }