Esempio n. 1
0
 public override void _PhysicsProcess(float delta)
 {
     base._PhysicsProcess(delta);
     if (state == State.Ready && Mathf.Abs(Juni.ApparentPosition.x - Center.x) < DISTANCE_TO_DROP)
     {
         state = State.Dropping;
         GetNode <AnimatedSprite>("AnimatedSprite").Play("launch");
         collisionShape.SetDeferred("disabled", false);
     }
     if (state == State.Dropping)
     {
         if (moveAndCollide(new Vector2(0, delta * dropSpeed)) != null)
         {
             state = State.Dropped;
             collisionShape.SetDeferred("disabled", true);
             GetNode <AudioStreamPlayer2D>("DropPlayer").Play();
         }
         // 14 * 50 * delta -- original formula
         // for some odd reasons original formula makes some enemies impossible to pass
         if (dropSpeed < 450)
         {
             dropSpeed += 10 * 50 * delta;
         }
     }
 }
Esempio n. 2
0
    public override void _PhysicsProcess(float delta)
    {
        base._PhysicsProcess(delta);
        bool juni_at_right = Juni.ApparentPosition.x > Center.x;

        value += (Juni.FacingRight && juni_at_right) || (!Juni.FacingRight && !juni_at_right) ?
                 -50 * delta : 50 * delta;
        value = Mathf.Max(Mathf.Min(128, value), 0);

        if (value > 120)
        {
            if (collisionShape.Disabled)
            {
                collisionShape.SetDeferred("disabled", false);
            }
            if (sprite.Animation != "angry")
            {
                sprite.Play("angry");
            }
        }
        else
        {
            if (!collisionShape.Disabled)
            {
                collisionShape.SetDeferred("disabled", true);
            }
            if (sprite.Animation != "default")
            {
                sprite.Play("default");
            }
        }
        sprite.FlipH    = !juni_at_right;
        sprite.Modulate = new Color(1, 1, 1, value / 128);
    }
Esempio n. 3
0
    private void Destroy()
    {
        SetProcess(false);
        SelfModulate = new Color(0, 0, 0, 0);
        collider.SetDeferred("disabled", true);
        timerDestroy.Start();

        explode.Visible = true;
        explode.GetNode <AnimationPlayer>("AnimationPlayer").Play("default");

        sfxExplode.Play();

        EmitSignal(nameof(Exploded));
    }
        public override void Die()
        {
            CharacterHurtBox.Disable();
            CharacterHitBox.Disable();

            CollisionShape2D.SetDeferred("disabled", true);
            AnimationPlayer.Play("Death");
        }
Esempio n. 5
0
 private void _on_SwitchTimer_timeout_ext()
 {
     is_on = !is_on;
     sprite.Play(is_on ? "on" : "off");
     collisionShape.SetDeferred("disabled", !is_on);
     if (GDArea.Selector.IsObjectSelected(this, by_type: true))
     {
         GetNode <AudioStreamPlayer2D>("SwitchPlayer").Play();
     }
 }
Esempio n. 6
0
    public void _on_StompDetector_body_entered(PhysicsBody2D body)
    {
        Area2D stompDetector = GetNode <Area2D>("StompDetector");
        bool   isBodyEntered = body.GlobalPosition.y < stompDetector.GlobalPosition.y;

        if (isBodyEntered)
        {
            CollisionShape2D enemyCollision = GetNode <CollisionShape2D>("CollisionShape2D");
            enemyCollision.SetDeferred("disabled", false);
            Die();
        }
        else
        {
            return;
        }
    }
Esempio n. 7
0
    private async void Damage(Laser laser)
    {
        health -= laser.damage;
        sfxHit.Play();
        await ChangeColor();

        if (health <= 0)
        {
            SetProcess(false);
            SelfModulate = new Color(0, 0, 0, 0);
            collider.SetDeferred("disabled", true);
            timerDestroy.Start();
            SpawnParticles();
            sfxExplode.Play();
            EmitSignal(nameof(Exploded));
        }
    }
Esempio n. 8
0
    private async void Damage(Laser laser)
    {
        sfxHit.Play();
        hp -= laser.damage;
        await ChangeColor();

        if (hp <= 0)
        {
            SetProcess(false);
            SelfModulate = new Color(0, 0, 0, 0);
            collider.SetDeferred("disabled", true);
            explode.Visible = true;
            explode.GetNode <AnimationPlayer>("AnimationPlayer").Play("default");
            timerDestroy.Start();
            sfxExplode.Play();
            EmitSignal("Exploded");
        }
    }
Esempio n. 9
0
 private void onClockItemBodyEntered(PhysicsBody body)
 {
     if (body.IsInGroup("player"))
     {
         picked = true;
         Global.MainScene.TimeLeft += ExtraTime;
         particles.Emitting         = true;
         collision.SetDeferred("disabled", true);
         Tween t = new Tween();
         t.InterpolateProperty(sprite, "modulate", sprite.Modulate, Colors.Transparent, 1F);
         extraTimeLabel.Text = $"+{ExtraTime:0.0}";
         Debug.Log($"Extratime: {ExtraTime}");
         extraTimeLabel.Visible = true;
         t.InterpolateProperty(extraTimeLabel, "rect_position", extraTimeLabel.RectPosition, extraTimeLabel.RectPosition + (Vector2.Up * 40F), 2F);
         AddChild(t);
         t.Connect("tween_all_completed", this, nameof(destroy));
         t.Start();
     }
 }
Esempio n. 10
0
    public void Acquire()
    {
        sfxAcquire.Play();
        switch (type)
        {
        case "AttackUp":
            EmitSignal(nameof(AttackUpAcquired));
            break;

        case "FireRateUp":
            EmitSignal(nameof(FireRateUpAcquired));
            break;

        case "SpeedUp":
            EmitSignal(nameof(SpeedUpAcquired));
            break;
        }

        Visible = false;
        collider.SetDeferred("disabled", true);
    }
Esempio n. 11
0
    public override void _Ready()
    {
        sprite         = GetNode <AnimatedSprite>("AnimatedSprite");
        collisionShape = GetNode <CollisionShape2D>("Area2D/CollisionShape2D");

        int index = ObjectID.y - 7;

        if (horizontal[index])
        {
            GetNode <Area2D>("Area2D").RotationDegrees = 90;
            sprite.RotationDegrees = 90;
        }

        is_on = onAtStart[index] || alwaysOn[index];
        sprite.Play(is_on ? "on" : "off");
        collisionShape.SetDeferred("disabled", !is_on);
        if (!alwaysOn[index])
        {
            GetNode <TimerExt>("SwitchTimer").RunTimer();
            GDArea.Selector.Register(this, by_type: true);
        }
    }
Esempio n. 12
0
 public void _on_Hurtbox_invincibiltyStarted()
 {
     collisionShape.SetDeferred("disabled", true);
 }
Esempio n. 13
0
    public override void _PhysicsProcess(float delta)
    {
        if (!Enabled)
        {
            return;
        }
        // Workaround to make sure that Translate was made before actual enabling
        // Without this, player can move with a particle and re-enter an area that has been left!
        if (collisionShape.Disabled && --_enable_countdown <= 0)
        {
            collisionShape.SetDeferred("disabled", false);
        }

        _velocity_x -= _deceleration_x * delta * DecelerationCorrectionX;
        if (_deceleration_x > 0 && _velocity_x < 0)
        {
            _velocity_x = 0;
        }
        if (_deceleration_x < 0 && _velocity_x > 0)
        {
            _velocity_x = 0;
        }

        if (_velocity_y > 0)
        {
            _velocity_y -= _deceleration_y * delta * DecelerationCorrectionDown;
            if (_gravity == 0 && _velocity_y < 0)
            {
                _velocity_y = 0;
            }
        }
        else if (_velocity_y < 0)
        {
            _velocity_y += _deceleration_y * delta * DecelerationCorrectionUp;
            if (_gravity == 0 && _velocity_y > 0)
            {
                _velocity_y = 0;
            }
        }

        if (DisappearWhenStopped && _gravity == 0 && _velocity_x == 0 && _velocity_y == 0)
        {
            disappear(collide: false);
        }

        _velocity_y += _gravity * delta;

        if (EnableRotation)
        {
            Rotation = Mathf.Atan2(-_velocity_y, -_velocity_x);
        }

        var collision = MoveAndCollide(new Vector2(delta * _velocity_x, delta * _velocity_y));

        if (!GDArea.isIn(GlobalPosition, x_border: 2, y_border: 2))
        {
            disappear(collide: false);
        }
        else if (collision != null)
        {
            if (collision.Collider is Juni juni)
            {
                juni.die();
            }
            // TODO: turn off collisions for Juni's soul if a bullet should go through her (like in original game)
            disappear(!(collision.Collider is Juni));
        }
    }
Esempio n. 14
0
 public void Disable()
 {
     CollisionShape2D.SetDeferred("disabled", true);
 }
Esempio n. 15
0
 void OpenGate(string label)
 {
     collision.SetDeferred("disabled", true);
     animator.Play();
 }
Esempio n. 16
0
 private void _on_DistanceMod_EnterEvent()
 {
     // TODO: rock particles
     shape.SetDeferred("disabled", false);
     GetNode <RawAudioPlayer2D>("OpenPlayer").Play();
 }
Esempio n. 17
0
 private void _toggleShield(Boolean toggle)
 {
     _collisionShape2D.SetDeferred("disabled", !toggle);
     _effect.Visible = toggle;
     _smoke.Visible  = !toggle;
 }