public override void _Ready()
        {
            var size = GetViewportRect().Size;
            var path = new SimplePath();

            path.Points.Add(new Vector2(0, size.y / 2));
            path.Points.Add(new Vector2(size.x / 8, size.y * 3 / 4));
            path.Points.Add(new Vector2(size.x / 2, (size.y / 2) - 50));
            path.Points.Add(new Vector2(size.x, size.y / 2));
            AddChild(path);

            const int boidsCount = 50;
            var       spawner    = new SimpleTouchSpawner()
            {
                SpawnFunction = (pos) =>
                {
                    var boid = new SimpleBoid()
                    {
                        VehicleGroupList = boids,
                        Position         = pos,
                        TargetPath       = path
                    };
                    boids.Add(boid);
                    return(boid);
                }
            };

            AddChild(spawner);

            for (int i = 0; i < boidsCount; ++i)
            {
                spawner.SpawnBody(MathUtils.RandVector2(0, size.x, 0, size.y));
            }
        }
Example #2
0
        public override void _Ready()
        {
            const int boidsCount = 50;
            var       size       = GetViewportRect().Size;
            var       spawner    = new SimpleTouchSpawner()
            {
                SpawnFunction = (pos) =>
                {
                    var boid = new SimpleBoid()
                    {
                        VehicleGroupList = boids,
                        Position         = pos
                    };
                    boids.Add(boid);
                    return(boid);
                }
            };

            AddChild(spawner);

            for (int i = 0; i < boidsCount; ++i)
            {
                spawner.SpawnBody(MathUtils.RandVector2(0, size.x, 0, size.y));
            }
        }