Beispiel #1
0
        public IEnumerator _SheathWeapon(int weaponNumber, int weaponTo)
        {
            //Debug.Log("Sheath Weapon: " + weaponNumber + " - Weapon To: " + weaponTo);
            //Reset for animation events.
            isWeaponSwitching = true;
            //Use Dual switch.
            if (dualSwitch)
            {
                StartCoroutine(_DualSheath(weaponNumber, weaponTo));
                yield break;
            }
            //Set LeftRight hand for 1handed switching.
            if (IsLeftWeapon(weaponNumber))
            {
                animator.SetInteger("LeftRight", 1);
            }
            else if (IsRightWeapon(weaponNumber))
            {
                animator.SetInteger("LeftRight", 2);
            }
            //Switching to Unarmed or Relaxed.
            if (weaponTo < 1)
            {
                //Have at least 1 weapon.
                if (rightWeapon != 0 || leftWeapon != 0)
                {
                    //Sheath 1handed weapon.
                    if (Is1HandedWeapon(weaponNumber))
                    {
                        //If sheathing both weapons, go to Armed first.
                        if (rightWeapon != 0 && leftWeapon != 0)
                        {
                            DoWeaponSwitch(7, weaponNumber, 7, -1, true);
                        }
                        else
                        {
                            DoWeaponSwitch(weaponTo, weaponNumber, 7, -1, true);
                        }
                        yield return(new WaitForSeconds(0.5f));

                        if (IsLeftWeapon(weaponNumber))
                        {
                            animator.SetInteger("LeftWeapon", 0);
                            SetAnimator(weaponTo, -2, 0, -1, -1);
                        }
                        else if (IsRightWeapon(weaponNumber))
                        {
                            animator.SetInteger("RightWeapon", 0);
                            SetAnimator(weaponTo, -2, -1, 0, -1);
                        }
                        animator.SetBool("Shield", false);
                    }
                    //Sheath 2handed weapon.
                    else if (Is2HandedWeapon(weaponNumber))
                    {
                        DoWeaponSwitch(weaponTo, weaponNumber, animator.GetInteger("Weapon"), -1, true);
                        yield return(new WaitForSeconds(0.5f));

                        SetAnimator(weaponTo, -2, 0, 0, -1);
                    }
                }
                //Unarmed, switching to Relax.
                else if (rightWeapon == 0 && leftWeapon == 0)
                {
                    DoWeaponSwitch(weaponTo, weaponNumber, animator.GetInteger("Weapon"), 0, true);
                    yield return(new WaitForSeconds(0.5f));

                    SetAnimator(weaponTo, -2, 0, 0, -1);
                }
            }
            //Switching to 2handed weapon.
            else if (Is2HandedWeapon(weaponTo))
            {
                //Switching from 1handed weapons.
                if (animator.GetInteger("Weapon") == 7)
                {
                    //Dual weilding, switch to Armed if first switch.
                    if (leftWeapon != 0 && rightWeapon != 0)
                    {
                        DoWeaponSwitch(7, weaponNumber, 7, -1, true);
                        if (IsLeftWeapon(weaponNumber))
                        {
                            SetAnimator(7, -2, 0, -1, -1);
                        }
                        else if (IsRightWeapon(weaponNumber))
                        {
                            SetAnimator(7, -2, -1, 0, -1);
                        }
                    }
                    else
                    {
                        DoWeaponSwitch(0, weaponNumber, 7, -1, true);
                        yield return(new WaitForSeconds(0.5f));

                        SetAnimator(0, -2, 0, 0, -1);
                    }
                }
                //Switching from 2handed weapons.
                else
                {
                    DoWeaponSwitch(0, weaponNumber, animator.GetInteger("Weapon"), -1, true);
                    yield return(new WaitForSeconds(0.5f));

                    SetAnimator(weaponNumber, -2, weaponNumber, 0, -1);
                }
            }
            //Switching to 1handed weapons.
            else
            {
                //Switching from 2handed weapons, go to Unarmed before next switch.
                if (Is2HandedWeapon(animator.GetInteger("Weapon")))
                {
                    DoWeaponSwitch(0, weaponNumber, animator.GetInteger("Weapon"), 0, true);
                    yield return(new WaitForSeconds(0.5f));

                    SetAnimator(0, -2, 0, 0, 0);
                }
                //Switching from 1handed weapon(s), go to Armed before next switch.
                else if (Is1HandedWeapon(animator.GetInteger("Weapon")))
                {
                    if (IsRightWeapon(weaponNumber))
                    {
                        animator.SetBool("Shield", false);
                    }
                    DoWeaponSwitch(7, weaponNumber, 7, -1, true);
                    yield return(new WaitForSeconds(0.1f));

                    if (weaponNumber == 7)
                    {
                        animator.SetBool("Shield", false);
                    }
                    if (IsLeftWeapon(weaponNumber))
                    {
                        SetAnimator(7, 7, 0, -1, 0);
                    }
                    else
                    {
                        SetAnimator(7, 7, -1, 0, 0);
                    }
                }
            }
            rpgCharacterController.SetWeaponState(weaponTo);
            yield return(null);
        }