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; } } }
public void CheckToSeeIfWeShouldDodge() { //Make sure we're out of cover, not dodging already, and environment allows for a dodge (ie: make sure we won't dodge into a wall.) if (shouldTryAndDodge && myTransform && targetTransform && !inCover && !isDodging && !isSprinting && !isStaggered && !Physics.Linecast(myTransform.position, targetTransform.position, layerMask) && Vector3.Distance(myTransform.position, targetTransform.position) > minDistToDodge && !gunScript.IsFiring()) { if (canOverrideBehaviour) { SetOverrideBehaviour(GetNewBehaviour(AIBehaviour.Dodging), true); StartCoroutine(WaitBetweenDodges()); } } }