コード例 #1
0
        /// <summary>
        /// Async method to instant weapon switch.
        /// </summary>
        /// <param name="weaponNumber">Weapon number to switch to.</param>
        /// <returns>IEnumerator for use with StartCoroutine.</returns>
        /// /// <summary>
        public IEnumerator _InstantWeaponSwitch(int weaponNumber)
        {
            Debug.Log("_InstantWeaponSwitch:" + weaponNumber);
            rpgCharacterController.SetAnimatorTrigger(AnimatorTrigger.InstantSwitchTrigger);
            rpgCharacterController.SetIKOff();

            // 2Handed.
            if (AnimationData.Is2HandedWeapon(weaponNumber))
            {
                animator.SetInteger("Weapon", weaponNumber);
                rpgCharacterController.rightWeapon = 0;
                rpgCharacterController.leftWeapon  = 0;
                animator.SetInteger("LeftWeapon", 0);
                animator.SetInteger("RightWeapon", 0);
                StartCoroutine(_HideAllWeapons(false, false));
                StartCoroutine(_WeaponVisibility(weaponNumber, true, false));
                if (AnimationData.IsIKWeapon(weaponNumber))
                {
                    rpgCharacterController.SetIKOn();
                }
            }
            // Switching to Unarmed or Relax.
            else
            {
                animator.SetInteger("Weapon", weaponNumber);
                rpgCharacterController.rightWeapon = 0;
                rpgCharacterController.leftWeapon  = 0;
                animator.SetInteger("LeftWeapon", 0);
                animator.SetInteger("RightWeapon", 0);
                animator.SetInteger("LeftRight", 0);
                StartCoroutine(_HideAllWeapons(false, false));
            }
            yield return(null);
        }