예제 #1
0
    public void RemoveABird(GameObject bird)
    {
        BirdAI ba = bird.GetComponent <BirdAI>();

        //find the tree this bird is on
        GrownTree gt = GrownTrees.Concat(OccupiedTrees).ToList().Find(t => t.tree == ba.TargetTree.tree);

        gt.RemoveBird(bird);

        if (OccupiedTrees.Contains(gt))
        {
            OccupiedTrees.Remove(gt);
            GrownTrees.Add(gt);
        }
    }
예제 #2
0
    public void RemoveGrownTree(TreeControl tc)
    {
        //find the tree and remove form either list
        GrownTree gt = GrownTrees.Concat(OccupiedTrees).ToList().Find(t => t.tree == tc.gameObject);

        //make each bird on that tree fly away
        GameObject[] tempBirds = new GameObject[gt.birds.Count];
        gt.birds.CopyTo(tempBirds);
        foreach (GameObject bird in tempBirds)
        {
            gt.RemoveBird(bird);
            bird.GetComponent <BirdAI>().FlyAway();
        }

        //remove the tree
        GrownTrees.Remove(gt);
        OccupiedTrees.Remove(gt);
    }