Пример #1
0
    // Start is called before the first frame update
    void Start()
    {
        rb = GetComponent <Rigidbody>();
        PopulationBehavior popBehavior = population.GetComponent <PopulationBehavior>();

        boids = popBehavior.boids;
    }
Пример #2
0
    public void OnBehaviorComplete(GameObject animal)
    {
        if (!animalsToExecutionData.ContainsKey(animal))// Discriminate force exited callbacks from removing animals
        {
            return;
        }
        PopulationBehavior behavior = animalsToExecutionData[animal].NextBehavior(defaultBehaviors);

        if (behavior == null)
        {
            return;
        }
        behavior.EnterBehavior(animal);
    }
Пример #3
0
    public List <GameObject> GetVisibleBoids()
    {
        PopulationBehavior popBehavior = population.GetComponent <PopulationBehavior>();

        boids = popBehavior.boids;
        List <GameObject> ans = new List <GameObject>();

        foreach (GameObject boid in boids)
        {
            if (IsVisible(boid))
            {
                ans.Add(boid);
            }
        }
        return(ans);
    }
Пример #4
0
    // TODO determine better way to setup behaviors
    private List <PopulationBehavior> CopyBehaviors()
    {
        List <PopulationBehavior> copiedBehaviors = new List <PopulationBehavior>();

        // Have to copy behavior scriptable objects for them to work on multiple populations
        foreach (PopulationBehavior behavior in GenericBehaviors)
        {
            List <BehaviorPattern> patterns = new List <BehaviorPattern>();
            foreach (BehaviorPattern pattern in behavior.behaviorPatterns)
            {
                patterns.Add(Instantiate(pattern, BehaviorPatternUpdater.gameObject.transform));
            }
            PopulationBehavior newBehavior = Instantiate(behavior);
            newBehavior.behaviorPatterns = patterns;
            copiedBehaviors.Add(newBehavior);
        }
        return(copiedBehaviors);
    }