Ejemplo n.º 1
0
        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 RandomVehicle()
                    {
                        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));
            }
        }
Ejemplo n.º 2
0
        public static Vehicle GetRandomVehicle()
        {
            var rand = new RandomVehicle();

            return(rand.GetRandomVehicle());
        }