Example #1
0
        private static List <BoidAttributes> InitialFlock()
        {
            var init = new List <BoidAttributes>();

            for (int i = 0; i < NUM_BOIDS; i++)
            {
                init.Add(BoidAttributes.GenerateRandomBoid());
            }

            return(init);
        }
Example #2
0
    private void Awake()
    {
        boidData          = ScriptableObject.CreateInstance <BoidAttributes>();
        obstacleMaskIndex = LayerMask.NameToLayer("Obstacle");
        obstacleMaskIndex = ~obstacleMaskIndex;

        velocity = transform.forward;

        if (target)
        {
            flockTarget = GameObject.FindWithTag("Target").transform;
        }
    }
    private static BoidAttributes BreedBoid(BoidAttributes left, BoidAttributes right)
    {
        float size      = GenerateAttribute(left.Size, right.Size);
        float speed     = GenerateAttribute(left.Speed, right.Speed);
        float strength  = GenerateAttribute(left.Strength, right.Strength);
        float agility   = GenerateAttribute(left.TurnSpeed, right.TurnSpeed);
        float agression = GenerateAttribute(left.Agression, right.Agression);
        float mass      = GenerateAttribute(left.Mass, right.Mass);
        float fear      = GenerateAttribute(left.Fear, right.Fear);
        float bounce    = GenerateAttribute(left.Bounciness, right.Bounciness);

        return(new BoidAttributes(1, size, mass, speed, strength, agression, agility, bounce, fear));
    }
        public void Init(BoidAttributes attributes, float maxValue)
        {
            this.attributes = attributes;
            List <float> values = new List <float>()
            {
                attributes.Agression,
                attributes.Bounciness,
                attributes.Fear,
                attributes.Mass,
                attributes.Speed,
                attributes.Strength,
                attributes.TurnSpeed
            };

            gameObject.GetComponentInChildren <AttributeList>().Init(values, maxValue);
        }
Example #5
0
 public static void RemoveBoid(BoidAttributes boid)
 {
     boids.Remove(boid);
 }