Exemplo n.º 1
0
    // Called when someone shoots the barrel.
    public override void OnBodyEntered(PhysicsBody2D body)
    {
        if (body is BulletRigidBody2D bullet)
        {
            FXs fx = this.GetNode <FXs>("/root/EnvironNode2D/FX");

            fx.PlayMineExplosionAnimAndSound(this.Position);
            this.SpawnBullets();
            this.QueueFree();
        }

        if (body is PlayerKinematicBody2D player)
        {
            player.OverBarrel = this;
        }
    }
Exemplo n.º 2
0
    // Called when someone steps over the mine.
    public virtual void OnBodyEntered(PhysicsBody2D body)
    {
        if ((body is ZombieKinematicBody2D zombie) || (body is PlayerKinematicBody2D p))
        {
            // explode

            // note: TODO minor bug: if you set NumberOfBulletsGenerated to 4, you will see that the
            // mine does not distribute the bullets equal around

            // Reference FX script and play sound/animation.
            FXs fx = this.GetNode <FXs>("/root/EnvironNode2D/FX");

            fx.PlayMineExplosionAnimAndSound(this.Position);
            this.SpawnBullets();              // Explode, then free.
            this.QueueFree();
        }
    }