예제 #1
0
    // アニメーション再生コルーチン。
    // ジャンプ中の着地アニメーション開始を調整して、
    // time に合わせた時間だけジャンプアニメーションを再生する。
    private IEnumerator JumpAnimation(float time)
    {
        animatorCtrl.Jump(true);
        yield return(new WaitForSeconds(time + preJumpTime - jumpEndTime)); // 着地アニメ開始まで待つ

        animatorCtrl.Jump(false);
        yield return(new WaitForSeconds(jumpEndTime));
    }
    void Update()
    {
        movement.x = Input.GetAxis("Horizontal");
        mousePos   = Camera.main.ScreenToWorldPoint(Input.mousePosition);

        if (Input.GetMouseButtonDown(1))
        {
            currWeap = 1;
        }
        else if (Input.GetMouseButtonUp(1))
        {
            currWeap = 0;
        }

        if (currWeap != 0)
        {
            if (transform.position.x > mousePos.x && isFacingRight || transform.position.x < mousePos.x && !isFacingRight)
            {
                Flip();
            }
        }
        else
        {
            if (movement.x > 0 && !isFacingRight || movement.x < 0 && isFacingRight)
            {
                Flip();
            }
        }

        if (canMove == true)
        {
            if (Input.GetButtonDown("Jump") && isGrounded == true)
            {
                GetComponent <Rigidbody2D>().velocity = Vector2.up * jumpVelocity;
                playerAnimator.Jump(true);
            }
        }

        //Just for test, when we have a proper death mechanic change it. Right now it is just to show player death.
        if (Input.GetKeyDown(KeyCode.H))
        {
            playerAnimator.Death();
        }
    }
예제 #3
0
    void ChangeRail()
    {
        int idx = currentRailIndex == 0 ? 1 : 0;

        currentRail      = rails[idx];
        currentRailIndex = idx;
        NextWaypoint(true);
        animController.Jump();
        audioSource.Play();
    }
예제 #4
0
 void Update()
 {
     if (Input.GetKeyDown(KeyCode.Space) && canJump)
     {
         canJump = false;
         Jump();
         playerAnimator.Jump();
     }
     BetterFall();
     ClampYVelocity();
 }
예제 #5
0
 private void Jump()
 {
     _animator.Jump();
     _rb.velocity = new Vector3(0, Input.GetAxis("Jump") * JumpForce, 0);
     JumpingSound.Play();
 }
예제 #6
0
 public void Stop()
 {
     animatorCtrl.Run(false);
     animatorCtrl.Jump(false);
     runner.StopAgent();
 }