コード例 #1
0
 public void LoadWeaponDamageCollider(bool isLeft)
 {
     if (isLeft)
     {
         if (leftHandWeapon != null)
         {
             leftHandDamageCollider = leftHandSlot.currentWeaponModel.GetComponentInChildren <DamageCollider>();
             leftHandDamageCollider.currentWeaponDamage = leftHandWeapon.baseDamage;
             leftHandDamageCollider.characterManager    = GetComponentInParent <CharacterManager>();
         }
     }
     else
     {
         if (rightHandWeapon != null)
         {
             rightHandDamageCollider = rightHandSlot.currentWeaponModel.GetComponentInChildren <DamageCollider>();
             rightHandDamageCollider.currentWeaponDamage = rightHandWeapon.baseDamage;
             rightHandDamageCollider.characterManager    = GetComponentInParent <CharacterManager>();
         }
         else if (bodypartCollider_1 != null)
         {
             bodypartCollider_1.currentWeaponDamage = leftHandWeapon.baseDamage;
         }
         else if (bodypartCollider_2 != null)
         {
             bodypartCollider_2.currentWeaponDamage = rightHandWeapon.baseDamage;
         }
     }
 }
コード例 #2
0
 private void LoadRightWeaponDamageCollider()
 {
     rightHandDamageCollider = rightHandSlot.currentWeaponModel.GetComponentInChildren <DamageCollider>();
     rightHandDamageCollider.currentWeaponDamage = playerInventory.rightWeapon.baseDamage;
 }
コード例 #3
0
        public void AttemptBackStabOrRiposte()
        {
            //Stamina dependency
            if (playerStats.CurrentStamina <= 0)
            {
                return;
            }

            RaycastHit hit;

            // start point - going out to transforms direction forward - out hit variable - distance 0.5f - scan on layer
            if (Physics.Raycast(inputHandler.criticalAttackRayCastStartPoint.position, transform.TransformDirection(Vector3.forward), out hit, 0.5f, backStabLayer))
            {
                #region Backstab
                CharacterManager enemyCharacterManager = hit.transform.gameObject.GetComponentInParent <CharacterManager>();
                DamageCollider   rightWeapon           = weaponSlotManager.rightHandDamageCollider;

                if (enemyCharacterManager != null)
                {
                    //check id ( so you cant stab ally )

                    //pull is into a transform behind the enemy so backstab looks clean
                    playerManager.transform.position = enemyCharacterManager.backStabCollider.deathblowsPosition.position;


                    //rotate us towards that transform

                    Vector3 rotationDirection = playerManager.transform.root.eulerAngles;
                    rotationDirection   = hit.transform.position - playerManager.transform.position;
                    rotationDirection.y = 0;
                    rotationDirection.Normalize();
                    Quaternion tr             = Quaternion.LookRotation(rotationDirection);
                    Quaternion targetRotation = Quaternion.Slerp(playerManager.transform.rotation, tr, 500 * Time.deltaTime);
                    playerManager.transform.rotation = targetRotation;


                    int criticalDamage = playerInventory.rightWeapon.criticalDamageMultiplier * rightWeapon.currentWeaponDamage;
                    enemyCharacterManager.pendingCriticalDamage = criticalDamage;

                    //play animation
                    animatorHandler.PlayTargetAnimation("Back Stab", true);
                    //make enemy play animation
                    enemyCharacterManager.GetComponentInChildren <AnimatorManager>().PlayTargetAnimation("Back Stabbed", true);

                    //do damage
                }
                #endregion
            }

            else if (Physics.Raycast(inputHandler.criticalAttackRayCastStartPoint.position, transform.TransformDirection(Vector3.forward), out hit, 0.7f, riposteLayer))
            {
                #region Riposte
                CharacterManager enemyCharacterManager = hit.transform.gameObject.GetComponentInParent <CharacterManager>();
                DamageCollider   rightWeapon           = weaponSlotManager.rightHandDamageCollider;

                if (enemyCharacterManager != null && enemyCharacterManager.canBeRiposted)
                {
                    playerManager.transform.position = enemyCharacterManager.riposteCollider.deathblowsPosition.position;

                    Vector3 rotationDirection = playerManager.transform.root.eulerAngles;
                    rotationDirection   = hit.transform.position - playerManager.transform.position;
                    rotationDirection.y = 0;
                    rotationDirection.Normalize();

                    Quaternion tr             = Quaternion.LookRotation(rotationDirection);
                    Quaternion targetRotation = Quaternion.Slerp(playerManager.transform.rotation, tr, 500 * Time.deltaTime);
                    playerManager.transform.rotation = targetRotation;



                    int criticalDamage = playerInventory.rightWeapon.criticalDamageMultiplier * rightWeapon.currentWeaponDamage;
                    enemyCharacterManager.pendingCriticalDamage = criticalDamage;

                    animatorHandler.PlayTargetAnimation("Riposte", true);
                    enemyCharacterManager.GetComponentInChildren <AnimatorManager>().PlayTargetAnimation("Riposted", true);
                }

                #endregion
            }
        }
コード例 #4
0
 private void LoadLeftWeaponDamageCollider()
 {
     leftHandDamageCollider = leftHandSlot.currentWeaponModel.GetComponentInChildren <DamageCollider>();
     leftHandDamageCollider.currentWeaponDamage = playerInventory.leftWeapon.baseDamage;
 }