Esempio n. 1
0
    public override HeroState Update_(HeroMover hero, float deltatime)
    {
        hero.velocity.Y = 0;

        if (hero.IsOnGround)
        {
            fromNoGround = 0f;
        }
        else
        {
            fromNoGround += deltatime;
            if (fromNoGround >= hero.Parameters.RunParams.CoyoteTime)
            {
                return(new StateFall());
            }
        }

        if (hero.KeyDirection == 0)
        {
            return(new StateWait());
        }

        if (hero.KeyDirection == 1)
        {
            hero.velocity.X = Mathf.Min(
                hero.velocity.X + hero.Parameters.RunParams.ForceOnGround * deltatime,
                hero.Parameters.RunParams.GroundSpeedMax);
        }
        else if (hero.KeyDirection == -1)
        {
            hero.velocity.X = Mathf.Max(
                hero.velocity.X - hero.Parameters.RunParams.ForceOnGround * deltatime,
                -hero.Parameters.RunParams.GroundSpeedMax);
        }

        hero.ApplySakamichi();

        return(this);
    }