Example #1
0
//  // Called every frame. 'delta' is the elapsed time since the previous frame.
    public override void _Process(float delta)
    {
        if (onSpot)
        {
            sprite.Animation = "ready";

            if (Input.IsActionJustPressed(keycode))
            {
                sprite.Animation = "right";
                targetBox.QueueFree();

                EmitSignal("Hit");
            }
        }

        else
        {
            sprite.Animation = "idle";

            if (Input.IsActionJustPressed(keycode))
            {
                sprite.Animation = "wrong";
                EmitSignal("Wrong");
            }
        }


        sprite.Play();
    }
Example #2
0
    public void OnPlayerBodyEntered(PhysicsBody2D body)
    {
        if (DeathSkips > 0)
        {
            DeathSkips--;
            body.QueueFree();
            return;
        }

        Hide();
        EmitSignal("Hit");
        GetNode <CollisionShape2D>("CollisionShape2D").SetDeferred("disabled", true);
    }
Example #3
0
        public void OnArea2DEntered(PhysicsBody2D body2D)
        {
            if (body2D.IsInGroup("Enemy"))
            {
                body2D.QueueFree();
                Health -= 1;
            }

            if (Health <= 0)
            {
                QueueFree();
            }
        }
Example #4
0
 void OnBodyEntered(PhysicsBody2D body)
 {
     if (body is Asteroid)
     {
         Asteroid asteroid = (Asteroid)body;
         if (asteroid.sprite.Modulate == this.actualColor)
         {
             EmitSignal("scoreUp");
             body.QueueFree();
         }
         else
         {
             EmitSignal("hit");
         }
     }
 }
Example #5
0
    private void _OnDetectCollide(PhysicsBody2D body)
    {
        if (!Freeze)
        {
            // Enemy
            if (body.GetCollisionLayerBit(1))
            {
                body.QueueFree();
                EmitSignal("EnemyKilled");
            }
            else if (body.GetCollisionLayerBit(0))
            {
                EmitSignal("PlayerKilled");
            }

            EmitSignal("Boom", this);
            QueueFree();
        }
    }
Example #6
0
    void OnTowerEntered(PhysicsBody2D body)
    {
        if (!body.IsInGroup("Enemy"))
        {
            return;
        }

        stats.TakeHealth(1);

        body.QueueFree();

        if (stats.Health <= 0)
        {
            gameOverMenuScoreLabel.Text = gameLocalScoreLabel.Text;

            GetNode <Game>("/root/Core/Game").Visible = false;
            GetNode <Game>("/root/Core/Game").SetProcess(false);

            GetNode <Control>("/root/Core/GameOverMenu").Visible = true;

            QueueFree();
        }
    }