コード例 #1
0
    public Loot InstanceLoot(Vector2 globalPosition, Random rand, int ammount)
    {
        Loot loot = InstanceResource <Loot>("res://objects/Loot.tscn");

        loot.GlobalPosition = globalPosition;
        loot.Ammount        = ammount;

        gameplayScreen.CallDeferred("AddProjectile", loot);

        loot.Inertia = (float)rand.NextDouble() * 500;

        float fx = (float)(100 * (1 - 2 * rand.NextDouble()));
        float fy = 400 + (float)(100 * (1 - 2 * rand.NextDouble()));

        loot.ApplyImpulse(new Vector2(12, 12), new Vector2(fx, -fy));

        return(loot);
    }