private void WeaponGUI() { shootImpulseGUI = Mathf.Clamp(Mathf.Lerp(shootImpulseGUI, 1f, Time.unscaledDeltaTime * 5f), 1f, 1.11f); reloadImpulseGUI = Mathf.Clamp(Mathf.Lerp(reloadImpulseGUI, 1f, Time.unscaledDeltaTime * 5f), 1f, 1.11f); reloadSinAlpha = (reloading) ? Mathf.Abs(Mathf.Sin(Time.time * 5f)) * 0.4f : 0f; curAmmoDisplay.color = (percent <= 0.33f && !wm.pe.hasEMP) ? new Color(1f, 0.3f, 0.1f, 1f - reloadSinAlpha) : new Color(1f, 1f, 1f, 1f - reloadSinAlpha); curAmmoDisplay.cachedTrans.localScale = Vector3.one * shootImpulseGUI; curAmmoDisplay.text = wm.displayCurAmmo.ToString(); ammoLeftDisplay.cachedTrans.localScale = Vector3.one * reloadImpulseGUI; ammoLeftDisplay.text = wm.displayAmmoLeft.ToString(); if (!wm.pe.hasEMP) { ammoBar.value = DarkRef.LerpTowards(ammoBar.value, percent, Time.deltaTime * 8f, Time.deltaTime * 2f, 0.5f); } }
private IEnumerator WeaponNameTransition() { scramble = 0f; while (scramble < 0.99f) { scramble = DarkRef.LerpTowards(scramble, 1f, Time.deltaTime * 20f, Time.deltaTime, 0.2f); yield return(null); } scramble = 1f; while (scramble > 0.01f) { scramble = DarkRef.LerpTowards(scramble, 0f, Time.deltaTime * 20f, Time.deltaTime, 0.2f); yield return(null); } scramble = 0f; }
void Update() { if (Time.time - startTime < 0.15f) { switchRotX = dm.drawRot.x; switchRotY = -dm.drawRot.y; switchRotZ = dm.drawRot.z; } if (Time.timeScale <= 0f) { return; } if (wm.currentWeaponTransform != null && lastWepTrans != wm.currentWeaponTransform) { acv = wm.currentWeaponTransform.GetComponent <AntiClipVariables>(); lastWepTrans = wm.currentWeaponTransform; } RaycastHit hit1; RaycastHit hit2; Physics.Raycast(tr.position, Vector3.up, out hit2, 0f); antiClipPos = Vector3.zero; float lerpRotation = 0f; ac.antiClipVector = Vector3.Lerp(ac.antiClipVector, Vector3.zero, Time.deltaTime * 6.5f); if (Physics.Raycast(tr.position, tr.forward, out hit1, rayLength, layers.value) || Physics.Raycast(tr.position - (tr.right * 0.15f), tr.forward, out hit2, rayLength * 0.95f, layers.value)) { float distFromObj = Mathf.Max(hit1.distance, hit2.distance); if (rayLength - distFromObj < distThreshold) { clipping = false; float rDepth = rayLength - distFromObj; antiClipPos = -Vector3.forward * rDepth * distMultiplier; ac.antiClipVector = Vector3.Lerp(ac.antiClipVector, -Vector3.forward * rDepth * aimDistMultiplier, Time.deltaTime * 6.5f); mainRot = DarkRef.LerpTowards(mainRot, defaultRot, Time.deltaTime * smoothing, Time.deltaTime * 280f, 0.25f); } else { clipping = true; lerpRotation = Mathf.Clamp((Mathf.Max(0.55f - distFromObj) / 0.27f) + 0.7f, 0.7f, 1f); if (wm.currentWeaponTransform != null && acv != null && !pm.sprinting && !pm.onLadder) { mainRot = DarkRef.LerpTowards(mainRot, Vector3.Lerp(defaultRot, acv.antiClipRot, lerpRotation), Time.deltaTime * smoothing, Time.deltaTime * 280f, 0.25f); } } } else { clipping = false; mainRot = Vector3.Lerp(mainRot, defaultRot, Time.deltaTime * smoothing); } rotateWeaponTr = DarkRef.LerpTowards(rotateWeaponTr, (dm.rotateWeaponTransform || pm.onLadder) ? Vector3.zero : dm.curSprintRot, Time.deltaTime * ((ac.isAiming) ? 8.1f : 6.9f) * ((pm.wasSprinting) ? 0.8f : 1f), Time.deltaTime * dm.sprintRot.magnitude * 2.5f, 0.18f); switchRotX = Mathf.Lerp(switchRotX, dm.switchRot.x, Time.deltaTime * 7.3f); switchRotY = Mathf.Lerp(switchRotY, dm.switchRot.y, Time.deltaTime * 6.6f); switchRotZ = Mathf.Lerp(switchRotZ, dm.switchRot.z, Time.deltaTime * 6.7f); Vector3 realSwitchRot = new Vector3(switchRotX - (overshootCurve.Evaluate((1f - Mathf.Clamp01(Mathf.Abs(switchRotY) / Mathf.Abs(Mathf.Max(0.001f, dm.drawRot.y))))) * overshootMultiplier), switchRotY, switchRotZ); drawOffset = Vector3.Lerp(drawOffset, Vector3.up * dm.drawOffset, Time.deltaTime * 6.6f); acoTr.localPosition = drawOffset + Vector3.Lerp(acoTr.localPosition, antiClipPos + ((acv != null) ? Vector3.Lerp(defaultPos, acv.antiClipPos, lerpRotation) : defaultPos), Time.deltaTime * 6.5f); acoTr.localRotation = Quaternion.Euler(mainRot + realSwitchRot + rotateWeaponTr); }
void Update() { GameSettings sManager = GameSettings.settingsController; noisePos += Time.deltaTime * 0.58f; float perlinX = (Mathf.PerlinNoise(noisePos, 0f) - 0.5f); float perlinY = (Mathf.PerlinNoise(0f, noisePos) - 0.5f); idleX = Mathf.Lerp(idleX, perlinX * ((isAiming) ? 0.36f : 0.55f), Time.deltaTime * 12f); idleY = Mathf.Lerp(idleY, perlinY * ((isAiming) ? 0.36f : 0.55f), Time.deltaTime * 12f); idleZ = Mathf.Lerp(idleZ, (Mathf.PerlinNoise(noisePos * 0.4f, noisePos * 0.3f) - 0.5f) * ((isAiming) ? 0.3f : 0.45f), Time.deltaTime * 12f); shakeX = Mathf.PerlinNoise(Mathf.PingPong(Time.time * 19.5f, 750f), -501f) - 0.5f; shakeY = Mathf.PerlinNoise(32f, Mathf.PingPong(Time.time * 19.5f, 650f)) - 0.5f; gc = wm.currentGC; float spdFactor = 1f; if (!RestrictionManager.restricted) { if (gc != null && !wm.prepareToSwitch && !dm.animationIsPlaying && !pm.onLadder && !dm.terminalVelocity) { bool aimCheck = (!pm.sprinting && !pm.wasSprinting && !gc.reloading && !acs.clipping && !hasStartAiming && (Time.time - lastUnAim) > 0.25f); bool aimSettings = (sManager.aimToggle == "Hold (Press)"); bool aimMethod = (aimSettings) ? cInput.GetButton("Aim") : cInput.GetButtonDown("Aim"); if (aimMethod && aimCheck) { isAiming = true; hasStartAiming = true; pv.jumpRattleEquip = true; lastAim = Time.time; } bool unaimBool = (aimSettings ? !cInput.GetButton("Aim") : cInput.GetButtonDown("Aim")) && (hasStartAiming && (Time.time - lastAim) > 0.25f); if ((unaimBool && !pl.isBreathing) || gc.reloading) { isAiming = false; hasStartAiming = false; lastUnAim = Time.time; } if (unaimBool) { pv.jumpRattleEquip = true; } spdFactor = gc.aimSpeedFactor; } else { isAiming = false; hasStartAiming = false; aimEffect = false; } } bool wepEnableDof = false; if (gc != null && gc.dofBlurAmount > 0f) { wepEnableDof = true; dofBlurAmount = gc.dofBlurAmount; dofBlurDistance = gc.dofBlurDistance; dofBlurAperture = gc.dofBlurAperture; dofBlurFocalSize = gc.dofBlurFocalSize; dofBlendBlur = gc.dofBlendBlur; } if (aimEffect) { vc.sniperBlur = Mathf.Lerp(vc.sniperBlur, blur, Time.deltaTime * effectSmoothing); vc.sniperIntensity = Mathf.Lerp(vc.sniperIntensity, intensity, Time.deltaTime * effectSmoothing); } else { vc.sniperBlur = Mathf.Lerp(vc.sniperBlur, 0f, Time.deltaTime * effectSmoothing); vc.sniperIntensity = Mathf.Lerp(vc.sniperIntensity, 0f, Time.deltaTime * effectSmoothing); } fallAnim = Mathf.Lerp(fallAnim, (ia.impactY > 0f) ? ia.impactY : 0f, Time.deltaTime * 3f); float upwardKickAnim = (dm.kickPos.z < -0.0001f && !dm.isEmptyClick) ? (dm.kickPosReal.z / dm.kickPos.z) * 0.65f * pl.camAnimation : 0f; tilt = Mathf.Lerp(tilt, Mathf.Clamp(pl.xVelocity * 0.6f * 0.01f, -3f, 3f), Time.deltaTime * 4f); //Mouse shootShake = new Vector3((Mathf.PerlinNoise(noisePos * 25f, 0f) - 0.5f), (Mathf.PerlinNoise(0f, noisePos * 25f) - 0.5f), 0f) * (0.2f - Mathf.Clamp(Time.time - lastShake, 0f, 0.2f)) * 5f; cachedTr.localRotation = Quaternion.Euler((pl.shakePos * 160f) + (shootShake * 0.75f) + flinchRot + new Vector3(-fallAnim * 36f + idleX - Mathf.Pow(upwardKickAnim, 0.6f), idleY - (upwardKickAnim * ((Mathf.PerlinNoise(Mathf.PingPong(Time.time * 12f, 50f), 0f)) - 0.5f) * 2.5f), tilt + (idleZ * 2f) + (fallAnim * 12f) + (pl.recoilZ * 1.3f) - (cb.translateChangeX * 0.9f)) + new Vector3(shakeX, shakeY, 0f) * shakeIntensity * 0.6f * (Mathf.Clamp(ia.shakeTime - Time.time, 0f, 0.5f))); settingsFOV = (float)sManager.FOV; if ((isAiming || pl.isBreathing) && !acs.clipping) { lerpPos = DarkRef.LerpTowards(lerpPos, gc.aimPos, Time.deltaTime * 10f, Time.deltaTime * aimSpeed * 0.956f * spdFactor, 0.5f); GetComponent <Camera>().fieldOfView = Mathf.Lerp(GetComponent <Camera>().fieldOfView, settingsFOV - (aimFovBoost * (1f + (((settingsFOV - 60) / 30f) * 2.75f))) - ((gc != null) ? gc.addZoomFOV : 0f), Time.deltaTime * spdFactor * fovInterpolateSpeed); pv.aimEffect = Mathf.Lerp(pv.aimEffect, 2.5f, Time.deltaTime * 8f); DarkRef.ToggleComponent(wdof, sManager.wDepthOfField == 1 && wepEnableDof); wdof.maxBlurSize = dofBlurAmount; wdof.focalLength = dofBlurDistance; wdof.aperture = dofBlurAperture; wdof.focalSize = dofBlurFocalSize; wdof.foregroundOverlap = dofBlendBlur; } else { lerpPos = DarkRef.LerpTowards(lerpPos, Vector3.zero, Time.deltaTime * 10f, Time.deltaTime * aimSpeed * spdFactor, 0.5f); GetComponent <Camera>().fieldOfView = Mathf.Lerp(GetComponent <Camera>().fieldOfView, settingsFOV, Time.deltaTime * spdFactor * fovInterpolateSpeed); pv.aimEffect = Mathf.Lerp(pv.aimEffect, 0f, Time.deltaTime * 8f); DarkRef.ToggleComponent(wdof, false); } cachedTr.localPosition = (pl.shakePos * 0.3f) + (flinchPos * 0.75f) + antiClipVector; }