Exemple #1
0
 void Cover()
 {
     if (!useAdvancedCover)
     {
         //Check to see if we should crouch, and if so, crouch.  We only crouch if we are in cover and not firing or being suppressed.
         if (myBaseScript.inCover && (!gunScript || !gunScript.IsFiring() || !myBaseScript.shouldFireFromCover) && Vector3.SqrMagnitude(myTransform.position - myBaseScript.GetCurrentCoverNodePos()) < minDistToCrouch && currentVelocityRatio < 0.3)
         {
             animator.SetBool(crouchingHash, true);
         }
         else
         {
             animator.SetBool(crouchingHash, false);
         }
     }
     else
     {
         if (myBaseScript.inCover)
         {
             if (!enteredCover && navi.ReachedDestination())
             {
                 if (!gunScript || !gunScript.IsFiring() || !myBaseScript.shouldFireFromCover)
                 {
                     animator.SetBool(coverHash, true);
                     enteredCover = true;
                 }
                 useCustomRotation = true;
                 directionToFace   = coverStandDirection;
             }
             if (enteredCover)
             {
                 if (!gunScript || !gunScript.IsFiring() || !myBaseScript.shouldFireFromCover)
                 {
                     rotateGunScript.stopForCover = true;
                     animator.SetBool(centerHash, false);
                     animator.SetBool(leftHash, false);
                     animator.SetBool(rightHash, false);
                     startedFireCycle = false;
                 }
                 else if (gunScript.IsFiring())
                 {
                     if (!startedFireCycle)
                     {
                         timeToAimRotate  = coverTransitionTime;
                         startedFireCycle = true;
                     }
                     timeToAimRotate -= Time.deltaTime;
                     if (timeToAimRotate < 0)
                     {
                         rotateGunScript.stopForCover = false;
                     }
                     if (coverFaceDirection == 0)
                     {
                         animator.SetBool(centerHash, true);
                     }
                     if (coverFaceDirection == 1)
                     {
                         animator.SetBool(rightHash, true);
                     }
                     if (coverFaceDirection == -1)
                     {
                         animator.SetBool(leftHash, true);
                     }
                 }
             }
         }
         else
         {
             animator.SetBool(coverHash, false);
             rotateGunScript.stopForCover = false;
         }
     }
 }