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

            var spawner = new SimpleTouchSpawner()
            {
                SpawnFunction = (pos) =>
                {
                    var vehicle = new RoundVehicle()
                    {
                        VehicleGroupList  = vehicles,
                        SeparationEnabled = true,
                        Position          = pos
                    };
                    vehicles.Add(vehicle);
                    return(vehicle);
                }
            };

            AddChild(spawner);

            for (int i = 0; i < vehicleCount; ++i)
            {
                spawner.SpawnBody(MathUtils.RandVector2(0, size.x, 0, size.y));
            }
        }
        public override void _Ready()
        {
            var size = GetViewportRect().Size;
            var path = new SimplePath();

            path.Points.Add(new Vector2(size.x * 1 / 4, size.y * 1 / 4));
            path.Points.Add(new Vector2(size.x * 3 / 4, size.y * 1 / 4));
            path.Points.Add(new Vector2(size.x * 3 / 4, size.y * 3 / 4));
            path.Points.Add(new Vector2((size.x * 1 / 4) - 20, size.y * 3 / 4));
            path.Looping = true;
            AddChild(path);

            var spawner = new SimpleTouchSpawner()
            {
                SpawnFunction = (pos) =>
                {
                    var vehicle = new RoundVehicle()
                    {
                        VehicleGroupList  = vehicles,
                        Position          = pos,
                        TargetPath        = path,
                        SeparationEnabled = true
                    };
                    vehicles.Add(vehicle);
                    return(vehicle);
                }
            };

            AddChild(spawner);

            for (int i = 0; i < vehicleCount; ++i)
            {
                spawner.SpawnBody(MathUtils.RandVector2(0, size.x, 0, size.y));
            }
        }
Example #3
0
        public override void _Ready()
        {
            var size = GetViewportRect().Size;

            var spawner = new SimpleTouchSpawner()
            {
                SpawnFunction = (pos) =>
                {
                    var vehicle = new RoundVehicle()
                    {
                        VehicleGroupList  = vehicles,
                        SeparationEnabled = true,
                        Target            = targetMover,
                        Position          = pos,

                        // Scale forces
                        SeparationForceFactor = 1.5f,
                        SeekForceFactor       = 0.5f
                    };

                    vehicles.Add(vehicle);
                    return(vehicle);
                }
            };

            AddChild(spawner);

            // Create target
            targetMover = new SimpleMover()
            {
                Position = size / 2,
                Modulate = Colors.LightBlue.WithAlpha(128)
            };
            AddChild(targetMover);

            // Create initial bodies
            for (int i = 0; i < vehicleCount; ++i)
            {
                spawner.SpawnBody(MathUtils.RandVector2(0, size.x, 0, size.y));
            }
        }