Ejemplo n.º 1
0
    public override void _PhysicsProcess(float delta)
    {
        if (Freeze.Frozen)
        {
            freezeTimer -= delta;
            if (freezeTimer <= 0)
            {
                Freeze.Frozen = false;
            }
        }
        else
        {
            this.UpdateMask();

            if (IsStunned())
            {
                stunTimer -= delta;
            }

            if (dash.IsDashing())
            {
                (GetNode("Hitbox").GetNode("CollisionShape2D") as CollisionShape2D).Disabled = true;
                var dashVelocity = new Vector2();
                if (!dash.verticalDash)
                {
                    dashVelocity.x = (int)currentOrientation * dash.GetSpeed();
                }
                else
                {
                    dashVelocity.x = (int)currentOrientation * dash.GetSpeed() * 0.4f;
                    dashVelocity.y = dash.GetSpeed();
                }

                horizontalVelocity = dashVelocity.x;
                velocity.y         = dashVelocity.y;

                finalVelocity = this.MoveAndSlide(dashVelocity, UpDirection);
            }
            else
            {
                (GetNode("Hitbox").GetNode("CollisionShape2D") as CollisionShape2D).Disabled = false;
                this.UpdatePowerState();

                this.UpdateVelocity(delta);

                finalVelocity = this.MoveAndSlide(velocity, UpDirection);
            }

            if (this.currentState == EntityState.Jumping && this.IsOnSomething())
            {
                this.UpdateState(EntityState.Idle);
            }
        }
    }