示例#1
0
        private void DoWeaponSwitch(int weaponSwitch, int weaponVisibility, int weaponNumber, int leftRight, bool sheath)
        {
            Debug.Log("DoWeaponSwitch:" + weaponSwitch + "   WeaponVisibility:" + weaponVisibility + "   WeaponNumber:" + weaponNumber + "   LeftRight:" + leftRight + "   Sheath:" + sheath);

            // Lock character for switch unless has moving sheath/unsheath anims.
            if (weaponSwitch < 1)
            {
                if (AnimationData.Is2HandedWeapon(weaponNumber))
                {
                    rpgCharacterController.Lock(true, true, true, 0f, 1f);
                }
            }
            else if (AnimationData.Is1HandedWeapon(weaponSwitch))
            {
                rpgCharacterController.Lock(true, true, true, 0f, 1f);
            }
            // Set weaponSwitch if applicable.
            if (weaponSwitch != -2)
            {
                animator.SetInteger("WeaponSwitch", weaponSwitch);
            }

            animator.SetInteger("Weapon", weaponNumber);

            // Set leftRight if applicable.
            if (leftRight != -1)
            {
                animator.SetInteger("LeftRight", leftRight);
            }
            // Set animator trigger.
            if (sheath)
            {
                rpgCharacterController.SetAnimatorTrigger(AnimatorTrigger.WeaponSheathTrigger);
                StartCoroutine(_WeaponVisibility(weaponVisibility, false, false));

                // If using IKHands, trigger IK blend.
                if (rpgCharacterController.ikHands != null)
                {
                    rpgCharacterController.ikHands.BlendIK(false, 0f, 0.2f);
                }
            }
            else
            {
                rpgCharacterController.SetAnimatorTrigger(AnimatorTrigger.WeaponUnsheathTrigger);
                StartCoroutine(_WeaponVisibility(weaponVisibility, true, false));

                // If using IKHands, trigger IK blend.
                if (rpgCharacterController.ikHands != null)
                {
                    rpgCharacterController.ikHands.BlendIK(true, 0.75f, 1);
                }
            }
        }