Example #1
0
    public void UpdateP()
    {
        if (!m_bInvincible && !m_bDethFlag && !m_bClear)
        {
            hori = Input.GetAxisRaw("GamePad1_LeftStick_H");

            if (hori < 0)
            {
                //animator.SetBool("WarkFlag", false);
                transform.rotation = Quaternion.Slerp(transform.rotation,
                                                      Quaternion.AngleAxis(180f, new Vector3(0, 1, 0)), 0.6f);
                if (wallcheck && walldis == 1)
                {
                    hori = 0;
                }
            }
            else if (hori > 0)
            {
                // animator.SetBool("WarkFlag", false);
                transform.rotation = Quaternion.Slerp(transform.rotation,
                                                      Quaternion.AngleAxis(0f, new Vector3(0, 1, 0)), 0.6f);
                if (wallcheck && walldis == -1)
                {
                    hori = 0;
                }
            }
            if (!m_bIsJump)
            {
                if (hori == 0)
                {
                    State = PlayerState.Idle;
                }
                else
                {
                    State = PlayerState.Walk;
                }
            }
            else
            {
                hori *= 0.5f;
            }


            if (Input.GetButtonDown("GamePad1_buttonB") && !m_bIsJump && !m_bJumpIn)
            {
                m_bJumpIn = true;
                State     = PlayerState.Jump;
                soundManager.GetComponent <SoundManager>().jumpSE();
            }

            if (Input.GetButtonDown("GamePad1_buttonX") && !m_bIsJump)
            {
                State = PlayerState.Change;
                lightManager.ChageLight(Playernum);
                soundManager.GetComponent <SoundManager>().changelightSE();
            }
        }
        else if (m_bClear)
        {
            rb.isKinematic = true;
            State          = PlayerState.Clear;
        }

        if (Input.GetKeyDown(KeyCode.L))
        {
            RaycastHit hit;
            if (Physics.SphereCast(CapCol.transform.position + CapCol.center,
                                   CapCol.radius * 0.99f,
                                   Vector3.down,
                                   out hit,
                                   10,
                                   Physics.AllLayers))
            {
                Debug.Log("IsCast" + hit.distance);
                Debug.Log(hit.point);
                Debug.Log(CapCol.height * 0.5f - CapCol.radius * 0.99f + 0.01f);
            }
            //damage(1f);
            ReSet();
            InvincibleEnd();
        }

        if (State != PlayerState.Jump && m_bIsJump)
        {
            Debug.Log("Error" + Playernum);
        }

        animator.SetInteger("State", (int)State);
    }