예제 #1
0
    void UpdateInputs()
    {
        if (Input.GetKey(KeyCode.T))
        {
            transform.position = TP.position;
        }

        if (Input.GetKey(KeyCode.LeftShift))
        {
            animator.SetBool("Run", true);
            animator.SetBool("RifleRun", true);
        }
        else
        {
            animator.SetBool("Run", false);
            animator.SetBool("RifleRun", false);
        }
        animator.SetBool("Rifle", animator.GetBool("Rifle_Aim"));

        if (Input.GetKey(KeyCode.Mouse1) || AimingTestBool == true)
        {
            if (WM.CheckIfHoldingWeapon() == true)
            {
                animator.SetBool("Rifle_Aim", true);
                if (gameObject.GetComponent <AimIK>().solver.IKPositionWeight < 1)
                {
                    gameObject.GetComponent <AimIK>().solver.IKPositionWeight += AimTransitionSpeed * Time.deltaTime;
                }
                MainCamAcess.GetComponent <CameraCont>().Aiming = true;

                if (Input.GetKeyDown(KeyCode.Mouse2))
                {
                    MainCamAcess.GetComponent <CameraCont>().TrueAiming = !MainCamAcess.GetComponent <CameraCont>().TrueAiming;
                }
            }
            else
            {
                animator.SetBool("Rifle_Aim", false);
                if (gameObject.GetComponent <AimIK>().solver.IKPositionWeight > 0)
                {
                    gameObject.GetComponent <AimIK>().solver.IKPositionWeight -= AimTransitionSpeed * Time.deltaTime;
                }
                if (gameObject.GetComponent <AimIK>().solver.IKPositionWeight <= 0)
                {
                    MainCamAcess.GetComponent <CameraCont>().Aiming = false;
                }
            }
        }
        else
        {
            animator.SetBool("Rifle_Aim", false);
            if (gameObject.GetComponent <AimIK>().solver.IKPositionWeight > 0)
            {
                gameObject.GetComponent <AimIK>().solver.IKPositionWeight -= AimTransitionSpeed * Time.deltaTime;
            }
            if (gameObject.GetComponent <AimIK>().solver.IKPositionWeight <= 0)
            {
                MainCamAcess.GetComponent <CameraCont>().Aiming = false;
            }
        }
        if (Input.GetKey(KeyCode.Space))
        {
            if (gameObject.GetComponent <WeaponsManager>().BigWeapons == false)
            {
                animator.SetBool("Sprint", true);
            }
            else
            {
                animator.SetBool("Sprint", false);
            }
        }
        else
        {
            animator.SetBool("Sprint", false);
        }

        if (Input.GetKeyDown(KeyCode.Tab))
        {
            if (currentBaseState.nameHash == walkState || currentBaseState.nameHash == inventoryState)
            {
                gameObject.GetComponent <Stats>().inventoryOn = !gameObject.GetComponent <Stats>().inventoryOn;
            }
            gameObject.GetComponent <ActionPerform>().StopAction();
        }

        if (Input.GetKey(KeyCode.E))
        {
            InteractMode = true;
        }
        else
        {
            InteractMode = false;
        }
    }