Ejemplo n.º 1
0
    static IEnumerator <float> StartJumping(Vector3 TargetPosition, Action callback, Objects.IUseable useable = null, float CustomSpeed = 0)
    {
        TargetPosition = new Vector3(TargetPosition.x, TargetPosition.y, 1);
        var StartPosition = GameLibOfMethods.player.transform.position;

        GameLibOfMethods.canInteract    = false;
        GameLibOfMethods.cantMove       = true;
        GameLibOfMethods.doingSomething = true;

        Physics2D.IgnoreLayerCollision(GameLibOfMethods.player.layer, 10, true);

        Player.rb.velocity = Vector2.zero;
        Player.anim.SetBool("Walking", false);
        Player.anim.SetBool("Jumping", true);

        float T      = 0;
        float _speed = CustomSpeed > 0 ? CustomSpeed : DefaultJumpSpeed;


        while (true)
        {
            T += _speed * GameTime.Time.deltaTime;

            Player.transform.position   = Vector3.Lerp(StartPosition, TargetPosition, T);
            Player.transform.localScale = new Vector3(jumpCurve.Evaluate(T), jumpCurve.Evaluate(T));

            // if our value has reached the total, break out of the loop
            if (T >= 1)
            {
                break;
            }

            yield return(0f);
        }

        Player.anim.SetBool("Jumping", false);
        //PlayerAnimationHelper.ResetPlayer();
        callback?.Invoke();
        LastPositionBeforeJump = StartPosition;
    }
Ejemplo n.º 2
0
    public static void JumpTo(Objects.IUseable useable, Action callback = null)
    {
        var action = callback ?? (() => useable.BeginUsing());

        StartJumping(useable.useableFunctionality.PlayerStandPosition, action, useable, useable.useableFunctionality.CustomSpeedToPosition).Start();
    }
Ejemplo n.º 3
0
    public static void MoveTo(Objects.IUseable useable, Action callback = null)
    {
        Action action = callback ?? (() => useable.BeginUsing());

        StartWalking(useable.useableFunctionality.PlayerStandPosition, action).Start();
    }