Ejemplo n.º 1
0
 private void Jumping()
 {
     t += Time.deltaTime * speed;
     if (startCurve)
     {
         Vector3 center = (startPos + endPos) * 0.5f;
         center.y          += jumpHeight;
         transform.position = Util.Math.GetBezierCurve(startPos, center, endPos, t);
     }
     else
     {
         var p = Util.Math.GetLinearCurve(startPos, endPos, t);
         transform.position = p;
     }
     if (t >= 0.5f)
     {
         var a = (Input.GetKeyDown(KeyCode.A));
         var d = (Input.GetKeyDown(KeyCode.D));
         if (a || d)
         {
             isDJumping = true;
             startPos   = transform.position;
             j_dir      = (a) ? JumpDirection.LEFT : JumpDirection.RIGHT;
             t          = 0.0f;
         }
     }
     if (t > 1.0f)
     {
         t = 0.0f;
         if (startCurve == false)
         {
             playerRenderer.flipY = true;
             startCurve           = true;
         }
         isJumping = false;
         animControl.Play(PlayerAnim.Animation.Run_2);
         startPos = transform.position;
     }
 }