コード例 #1
0
    void Update()
    {
#if !TOTO
        var x = Input.H1();
        var y = Input.V1();

        var jump = Input.ADown();
        var dash = Input.XDown();
#else
        var x = UnityEngine.Input.GetAxis("Horizontal");
        var y = UnityEngine.Input.GetAxis("Vertical");


        var jump = UnityEngine.Input.GetButtonDown("Jump");
        var dash = UnityEngine.Input.GetButtonDown("Fire1");
#endif

        var dt = Time.deltaTime;
        DashingUpdate(dash, dt);
        JumpingUpdate(jump, dt);

        var isMoving = Mathf.Abs(x) > 0.01f || Mathf.Abs(y) > 0.01f || IsDashing;

        if (isMoving)
        {
            m_dirX = x;
            m_dirY = y;
        }


//		var isMoving = Mathf.Abs(x) > 0.001f || Mathf.Abs(y) > 0.001f;
//		var isJumping = false; // TODO
//		var isDashing = false; // TODO
//
//		if (Mathf.Abs(x) > 0.001f)
//		{
//			m_dirX = x;
//		}
//		if (Mathf.Abs(y) > 0.001f)
//		{
//			m_dirY = y;
//		}

        if (!IsDashing)
        {
            m_moveX = x;
            m_moveY = y;
        }

        if (IsDead)
        {
            m_animator.SetBool("dead", true);
        }
        else
        {
            m_animator.SetFloat("moveX", x);
            m_animator.SetFloat("moveY", y);
            m_animator.SetFloat("dirX", m_dirX);
            m_animator.SetFloat("dirY", m_dirY);

            m_animator.SetBool("isMoving", isMoving);
            m_animator.SetBool("isJumping", IsJumping);
            m_animator.SetBool("isDashing", IsDashing);
        }
    }