Exemplo n.º 1
0
    public void FlyToTree(PeachTreeLandingPtsCtrler peachTree, bool scattered = true)
    {
        if (peachTree == perchingTree)
        {
            return;
        }

        foreach (Landable landable in perchingTree.landablePts)
        {
            landable.ReleaseAll();
        }

        perchingTree = peachTree;

        if (scattered)
        {
            cohesionFactor = -Mathf.Abs(cohesionFactor);
        }
        else
        {
            cohesionFactor = Mathf.Abs(cohesionFactor);
        }

        foreach (BoidFlocking boid in boids)
        {
            Landable landable = peachTree.GetOneLandablePt();
            if (landable == null)
            {
                Debug.Log("not enough landing pts QAQ");
                break;
            }
            landable.TargetBy(boid);
            boid.EnterState(BoidFlocking.State.flocking);
        }

        if (cohesionFactor < 0)
        {
            Invoke("RecoverCoherent", 1);
        }
    }