void Update() { for (int i = 0; i < emitters.Count; i++) { EmitterClass emit = emitters[i]; EmissionSettings settings = emit.settings; float travDist = (emit.lastEmissionPos - emit.emitterTransform.position).magnitude; int innerLoop = Mathf.FloorToInt(travDist); if (settings.interpolateEmission && innerLoop > 0) { for (int j = 0; j < innerLoop; j++) { Vector3 randomVelo = DarkRef.RandomVector3(settings.emitVelocity[0], settings.emitVelocity[1]); float randomSize = Random.Range(settings.emitSize.x, settings.emitSize.y); float randomLife = Random.Range(settings.emitLifetime.x, settings.emitLifetime.y); Color randomColor = Color.Lerp(settings.emitColors[0], settings.emitColors[1], Random.value); thisSystem.Emit(Vector3.Lerp(emit.lastEmissionPos, emit.emitterTransform.position, (1f / innerLoop) * j) + (Random.insideUnitSphere * settings.emissionRadius), randomVelo, randomSize, randomLife, randomColor); } } else if (travDist >= emit.settings.emissionDistance) { Vector3 randomVelo = DarkRef.RandomVector3(settings.emitVelocity[0], settings.emitVelocity[1]); float randomSize = Random.Range(settings.emitSize.x, settings.emitSize.y); float randomLife = Random.Range(settings.emitLifetime.x, settings.emitLifetime.y); Color randomColor = Color.Lerp(settings.emitColors[0], settings.emitColors[1], Random.value); thisSystem.Emit(emit.emitterTransform.position + (Random.insideUnitSphere * settings.emissionRadius), randomVelo, randomSize, randomLife, randomColor); } emit.lastEmissionPos = emit.emitterTransform.position; } }
public void HitIndicator(Vector3 hitFromPos) { if (dead) { return; } if (pe.hasEMP) { hitFromPos += DarkRef.RandomVector3(-Vector3.one, Vector3.one) * (hitFromPos - transform.position).magnitude * 0.75f; } hitFromPos.y = 0f; for (int i = 0; i < hitIndicators.Count; i++) { if (Time.time - lastHitIndicate < 0.05f && (hitIndicators[i].hitFromPosition - hitFromPos).sqrMagnitude < 0.01f) { hitIndicators[i].initTime = Time.time; return; } } GameObject newInstance = (GameObject)Instantiate(hitIndicatorPrefab); newInstance.transform.parent = GeneralVariables.uiController.hitIndicatorRoot; newInstance.transform.localPosition = Vector3.zero; newInstance.transform.localScale = Vector3.one; Vector3 rot = newInstance.transform.localEulerAngles; rot.z = Mathf.Round(-CalculateIndicatorRotation(hitFromPos - transform.position) / hitIndicatorRotRound) * hitIndicatorRotRound; newInstance.transform.localRotation = Quaternion.Euler(rot); HitIndicatorInfo hii = new HitIndicatorInfo(); hii.instance = newInstance; hii.lifetime = 0.3f; hii.hitFromPosition = hitFromPos; hii.initTime = Time.time; hii.impulseTarget = 1.5f; hii.instance.transform.GetChild(0).localPosition = new Vector3(-1.5f, uic.crosshairs.hitIndicatorOffset + 40f, 0f); hitIndicators.Add(hii); lastHitIndicate = Time.time; }
void NetworkShoot(float x, float y, Vector3 pos) { if (currentGC == null) { Debug.Log("Proxy gun is null"); return; } if (Time.time - lastFireTime >= targetFireRate * 0.2f) { currentGC.firePos.GetComponent <AudioSource>().PlayOneShot(currentGC.fireSound); lastFireTime = Time.time; } GameObject poolProjectile = PoolManager.Instance.RequestInstantiate(currentGC.bulletInfo.poolIndex, pos, Quaternion.Euler(x * 360f, y * 360f, 0f), false); if (currentGC.bulletInfo.bulletType == BulletInfo.BulletType.Bullet) { Bullet bTracer = poolProjectile.GetComponent <Bullet>(); bTracer.BulletInfo(currentGC.bulletInfo, -1, true); bTracer.InstantiateStart(); } else if (currentGC.bulletInfo.bulletType == BulletInfo.BulletType.Rocket) { Rocket vRocket = poolProjectile.GetComponent <Rocket>(); vRocket.RocketInfo(currentGC.bulletInfo, -1, true); vRocket.InstantiateStart(); } if (renderV.isVisible && currentGC.ejectionEnabled && currentGC.ejectionPos != null) { Rigidbody bShell = PoolManager.Instance.RequestInstantiate(currentGC.bulletShellIndex, currentGC.ejectionPos.position, currentGC.ejectionPos.rotation).GetComponent <Rigidbody>(); Vector3 randomForce = DarkRef.RandomVector3(currentGC.ejectionMinForce, currentGC.ejectionMaxForce); bShell.velocity = msP.velocity + transform.TransformDirection(randomForce); bShell.angularVelocity = Random.rotation.eulerAngles * currentGC.ejectionRotation; } if (currentVisuals.muzzleFlash != null && currentVisuals.muzzleGlow != null && currentVisuals.muzzleSpark != null) { StartCoroutine(MuzzleControl()); } }
void Update() { int retrievedMaxHealth = AntiHackSystem.RetrieveInt("maxHealth"); int retrievedMaxShield = AntiHackSystem.RetrieveInt("maxShield"); if (GameManager.boundarySettings != null) { bool inMapBounds = GameManager.boundarySettings.mapBounds.Contains(transform.position); if (!inMapBounds) { ApplyDamageMain((curHealth + curShield) * 2, false); } } if (Input.GetKey(KeyCode.X)) { if (Input.GetKeyDown(KeyCode.B)) { ApplyDamageMain(Random.Range(10, 15), true); HitIndicator(transform.position + DarkRef.RandomVector3(Vector3.one * -5f, Vector3.one * 5f)); } else if (Input.GetKeyDown(KeyCode.K)) { ApplyDamageMain(retrievedMaxHealth + retrievedMaxShield + 1, false); } } AdjustGUISize(); ManageIndicatorGUI(); if (recovering && curHealth < retrievedMaxHealth) { timer += Time.deltaTime; } if (shRecovering) { if (curShield < retrievedMaxShield) { shTimer += Time.deltaTime; } shieldAlarmSource.volume = 0f; if (!shGlowRecover) { shieldTexture.color = shieldTexture.defaultColor; shieldAlpha = 0.21f; shGlowRecover = true; } } else { shGlowRecover = false; if (retrievedMaxShield > 0f) { if (pe.hasEMP) { shieldAlarmSource.volume = 0f; } else { shieldAlarmSource.volume = Mathf.Clamp01(0.5f - shPercent) * 0.12f; } } } if (Time.time - lastDamage > 0.3f) { Color lerpHurtColor = Color.Lerp(hurtColor, Color.white, Mathf.Clamp01((percent - 0.2f) * 3.5f)); healthText.color = Color.Lerp(healthText.color, lerpHurtColor, Time.unscaledDeltaTime * 5f); Color lerpShieldColor = Color.Lerp(new Color(0.8f, 0.8f, 0.8f, 1f), Color.white, Mathf.Clamp01(shPercent * 5f)); shieldText.color = Color.Lerp(shieldText.color, lerpShieldColor, Time.unscaledDeltaTime * 5f); } curShield = Mathf.Clamp(curShield, 0, retrievedMaxShield); float fallDmgMod = (fallDamageTotal > 0) ? 0.8f : 1f; if (retrievedMaxShield > 0) { shPercent = (float)curShield / (float)retrievedMaxShield; float shRecoverRate = (shieldRecoverySpeed * fallDmgMod); if (shTimer >= shRecoverRate && (curShield < retrievedMaxShield)) { curShield += shieldRecoverAmount; if (fallDamageTotal > 0) { fallDamageTotal--; } shTimer -= shRecoverRate; } } else { shPercent = 0f; } curHealth = Mathf.Clamp(curHealth, 0, retrievedMaxHealth); maxHealth = retrievedMaxHealth; maxShield = retrievedMaxShield; curStamina = Mathf.Clamp(curStamina, 0, 100); float recoverRate = (healthRecoverySpeed * (1f + (percent * healthRecoverInfluence)) * fallDmgMod); if (timer >= recoverRate && (curHealth < retrievedMaxHealth)) { curHealth += healthRecoverAmount; if (fallDamageTotal > 0) { fallDamageTotal--; } timer -= recoverRate; } if (!dead) { if (startRecoveryTimer) { rTimer += Time.deltaTime; } if (startShRecoveryTimer) { shrTimer += Time.deltaTime; } } if (rTimer >= healthRecoverDelay && !dead) { startRecoveryTimer = false; rTimer = 0f; recovering = true; } if (maxShield > 0 && shrTimer >= shieldRecoverDelay && !dead) { startShRecoveryTimer = false; shrTimer = 0f; shRecovering = true; fallDamageSource.GetComponent <TimeScaleSound>().pitchMod = 1f; fallDamageSource.PlayOneShot(shieldRegen, 0.1f); } float steepSlopeFactor = (pm.grounded) ? Mathf.Clamp01(pm.controller.velocity.normalized.y) : 0f; if (pm.grounded && (pm.sprinting || pm.sprintReloadBoost > 1f) && pm.xyVelocity >= 0.75f) { rattleTSS.pitchMod = 1f; equipmentRattleSource.volume = Mathf.Lerp(equipmentRattleSource.volume, rattleVolumeSprint, Time.deltaTime * 9f); dTimer += Time.deltaTime * (pm.controllerVeloMagn / pm.movement.sprintSpeed); float requirement = staminaDepletionRate * (1f - (wc.weightPercentage * 0.8f)) * (1f - (steepSlopeFactor * 0.22f)); if (dTimer >= requirement && curStamina > 0f) { curStamina -= 1 + Mathf.RoundToInt((1f / requirement) * Time.deltaTime); dTimer = 0f; } } else { float velocityFactor = Mathf.Clamp01(pm.xyVelocity / pm.movement.runSpeed); if (jumpRattleEquip) { rattleTimer += Time.deltaTime; if (pm.xyVelocity < 0.75f) { rattleTSS.pitchMod = 1f; equipmentRattleSource.volume = Mathf.Lerp(equipmentRattleSource.volume, Mathf.Lerp(rattleVolumeNormal, rattleVolumeSprint, 0.5f), Time.deltaTime * 11f); } if (rattleTimer >= 0.4f) { rattleTimer = 0f; jumpRattleEquip = false; } } else { if (pm.grounded) { if (pm.xyVelocity >= 0.75f) { rattleTSS.pitchMod = (pm.crouching) ? 0.8f : 0.96f; equipmentRattleSource.volume = Mathf.Lerp(equipmentRattleSource.volume, rattleVolumeNormal * velocityFactor, Time.deltaTime * 9f); } else { equipmentRattleSource.volume = Mathf.Lerp(equipmentRattleSource.volume, 0f, Time.deltaTime * 9f); } } else { equipmentRattleSource.volume = Mathf.Lerp(equipmentRattleSource.volume, 0f, Time.deltaTime * 9f); } } sTimer += Time.deltaTime; float requirement = (staminaRecoverySpeed * (2f - Mathf.Clamp(Time.time - lastDe, 0f, 1f)) * (1f + Mathf.Clamp01((pm.xyVelocity * 0.17f) / pm.movement.runSpeed)) + (steepSlopeFactor * 0.16f)); if (sTimer >= requirement && curStamina < 100 && !staminaCooldown) { curStamina += 1 + Mathf.RoundToInt((1f / requirement) * Time.deltaTime); sTimer = 0f; } } curStamina = Mathf.Clamp(curStamina, 0, 100); if (curStamina <= 1f && canSprint) { StartCoroutine(CalmingStage()); } shieldAlpha = Mathf.Clamp(shieldAlpha, 0f, 0.35f); shieldAlpha = Mathf.MoveTowards(shieldAlpha, 0f, Time.deltaTime * 0.6f); finalShAlpha = Mathf.Lerp(finalShAlpha, shieldAlpha, Time.deltaTime * 8.5f); shieldTexture.alpha = finalShAlpha * ((shGlowRecover) ? 1f : (0.3f + (Mathf.PerlinNoise(Mathf.PingPong(Time.time * 22f, 250f), 0f) * 0.7f))); damageEffect = Mathf.Lerp(damageEffect, 0f, (Time.time - lastDe) * 5f); chromAbb = Mathf.Lerp(chromAbb, Mathf.Clamp(damageEffect, 0f, 30f) + ((0.3f - Mathf.Min(percent, 0.3f)) * 25f), Time.deltaTime * 5f); bloodEffect = Mathf.Clamp01(Mathf.Lerp(bloodEffect, 0f, Time.deltaTime * 0.068f)); uic.gManager.damageBlur = Mathf.Clamp(Mathf.Lerp(uic.gManager.damageBlur, 0f, Time.deltaTime * dmgBlurRestore) + ((percent <= 0.2f) ? 0.001f : 0f), 0f, 0.85f); foreach (FlickeringGUI fg in flickeringGUI) { if (pe.hasEMP) { fg.dimAlpha = Random.Range(0.1f, 1f); fg.updateFrequency = 0.03f; fg.flickerFrequency = 0.8f; } else { fg.dimAlpha = Mathf.Clamp01(0.3f + flickerIntensity * 2f); fg.updateFrequency = 0.05f; fg.flickerFrequency = 0.85f; } } float stPercent = Mathf.Clamp01((float)curStamina / 100f); float hbVolume = Mathf.Clamp(0.5f - percent, 0f, 0.5f) * 0.3f; heartbeatSound.volume = hbVolume + ((1f - stPercent) * 0.05f); float nVolume = Mathf.Clamp(0.25f - percent, 0f, 0.25f) / 0.25f; noiseSource.volume = nVolume * 0.2f; if (Time.time - lastHeartTime >= 1f) { hbEffectTarget = 3.1f; lastHeartTime = Time.time; } if (pe.hasEMP) { grainEMP = Mathf.Lerp(grainEMP, 0.035f, Time.deltaTime * 1.3f); distortEMP = Mathf.Lerp(distortEMP, 0.15f, Time.deltaTime * 1.3f); } else { grainEMP = Mathf.Lerp(grainEMP, 0f, Time.deltaTime * 3f); distortEMP = Mathf.Lerp(distortEMP, 0f, Time.deltaTime * 3f); } vignetteEMP = Mathf.Lerp(vignetteEMP, 0f, Time.deltaTime * 4f); ne.empEffect = grainEMP; hbEffectTarget = Mathf.MoveTowards(hbEffectTarget, 0f, Time.deltaTime * 4.3f); heartbeatEffect = Mathf.Lerp(heartbeatEffect, hbEffectTarget + 0.05f, Time.deltaTime * 11f); percent = curHealth / (float)retrievedMaxHealth; flickerIntensity = Mathf.Lerp(flickerIntensity, percent, Time.deltaTime * 0.5f * Mathf.Clamp((Time.time - initTime) * 0.5f, 0f, 4f)); hearingPenalty = Mathf.Lerp(hearingPenalty, 1f, Time.deltaTime * 0.2f); if (percent <= 0.25f) { standardFreq = Mathf.Lerp(standardFreq, (pe.hasEMP) ? empMuffle : Mathf.Lerp(muffleRange.x, muffleRange.y, Mathf.Clamp01(percent * 4f)), Time.deltaTime * 9f); ne.grainIntensity = Mathf.Lerp(0f, 0.0075f, 1f - Mathf.Clamp01(percent * 4f)); } else { standardFreq = Mathf.Lerp(standardFreq, (pe.hasEMP) ? empMuffle : 20000f, Time.deltaTime * ((pe.hasEMP) ? 3.5f : 0.7f)); ne.grainIntensity = Mathf.Lerp(ne.grainIntensity, 0f, Time.deltaTime * 5f); } healthLowPass.cutoffFrequency = standardFreq * hearingPenalty; ne.enabled = (ne.grainIntensity + grainEMP > 0f); disE.enabled = (ne.enabled || distortEMP > 0f); disE.baseIntensity = (ne.grainIntensity * 4f) + distortEMP; disE.splitOffset = (pe.hasEMP) ? 0.05f : 0f; if (staminaBlinking) { sBlinkTimer += Time.deltaTime * 6.75f; sBlinkValue = Mathf.Sin(sBlinkTimer); Color redCol = defStaminaBGCol; redCol.r *= 3f; staminaBackground.color = Color.Lerp(defStaminaBGCol, redCol, sBlinkValue); } else { sBlinkTimer = 0f; sBlinkValue = 0f; staminaBackground.color = defStaminaBGCol; } damageBreathBoost = Mathf.Clamp(Mathf.MoveTowards(damageBreathBoost, 0f, Time.deltaTime * 0.05f), 0f, 0.42f); dBreath = Mathf.Lerp(dBreath, damageBreathBoost, Time.deltaTime * 7f); breathingSound.volume = (0.05f + (hbVolume * 0.11f) + (0.148f * (1f - stPercent)) + dBreath) * breathFactor; breathingSound.GetComponent <TimeScaleSound>().pitchMod = 1f + (hbVolume * 0.03f) + (0.145f * (1f - stPercent)); imageEffect = Mathf.Lerp(imageEffect, Mathf.Clamp01(1f - (percent + 0.45f)) * effectIntensity, Time.deltaTime * 3f); vignetting.intensity = imageEffect + vignetteEMP + (heartbeatEffect * Mathf.Clamp01(1f - (percent * 2f))); vignetting.blur = (imageEffect * 0.2f) + aimEffect; vignetting.blurSpread = aimEffect * 0.5f; vignetting.heartbeatBlur = heartbeatEffect * Mathf.Clamp01(1f - (percent * 2f)) * 0.45f; vignetting.chromaticAberration = chromAbb * (1f + ((1 - percent) * 0.3f)); float saturation = Mathf.Clamp01(0.45f + (percent * 0.88f)); sa.saturationAmount = Mathf.Lerp(sa.saturationAmount, (pe.hasEMP) ? Random.value * Random.value : saturation, Time.deltaTime * 4f); sa.colorTint = Vector4.Lerp(new Vector4(1.1f, 0.95f, 0.95f, 1f), Vector4.one, Mathf.Clamp01(percent * 2.5f)); if (!dead) { alpha = Mathf.Lerp(alpha, bloodEffect + ((1 - percent) * 0.15f), Time.deltaTime * 8f); bloodyScreen.material.color = DarkRef.SetAlpha(bloodyScreen.material.color, alpha * 0.82f); } healthBar.value = Mathf.Lerp(healthBar.value, (pe.hasEMP) ? Random.value : percent, Time.unscaledDeltaTime * 7.5f); shieldBar.value = Mathf.Lerp(shieldBar.value, (pe.hasEMP) ? Random.value : shPercent, Time.unscaledDeltaTime * 7.5f); if (pe.hasEMP) { if (Time.time - lastUpdateTime >= 0.1f) { healthText.text = (dead) ? "INACTIVE" : (Random.Range(0, 999) + "/" + Random.Range(0, 999)); lastUpdateTime = Time.time; } } else { healthText.text = (dead) ? "INACTIVE" : (curHealth + "/" + retrievedMaxHealth); } if (shrTimer < 0f || maxShield <= 0) { shieldText.color = new Color(1f, 0.4f, 0.2f); shieldText.text = "DISABLED"; } else { shieldText.color = shieldText.defaultColor; shieldText.text = curShield + "/" + retrievedMaxShield; } staminaBar.value = Mathf.Lerp(staminaBar.value, (pe.hasEMP) ? Random.value : stPercent, Time.deltaTime * 8f); }
private IEnumerator EjectShell() { yield return(new WaitForSeconds(ejectionDelay)); Rigidbody shell = PoolManager.Instance.RequestInstantiate(bulletShellIndex, ejectionPos.position, ejectionPos.rotation).GetComponent <Rigidbody>(); shell.velocity = (pm.controller.velocity * 0.7f) + pm.transform.TransformDirection(DarkRef.RandomVector3(ejectionMinForce, ejectionMaxForce)); shell.angularVelocity = Random.rotation.eulerAngles * ejectionRotation; }
private void Shoot(float cwm, float vf, float af) { for (int i = 0; i < bulletsPerShot; i++) { Vector2 randomTargetPoint = Random.insideUnitCircle * ((bsna * cwm * asm * af) + vf); Vector3 randomDir = new Vector3(randomTargetPoint.x, randomTargetPoint.y, 0f); Quaternion randomRot = Quaternion.Euler(firePos.eulerAngles) * Quaternion.Euler(randomDir); GameObject proj = PoolManager.Instance.RequestInstantiate(bulletInfo.poolIndex, firePos.position, randomRot, false); if (bulletInfo.bulletType == BulletInfo.BulletType.Bullet) { Bullet projBul = proj.GetComponent <Bullet>(); projBul.BulletInfo(bulletInfo, weaponID, false, true, -1); projBul.noWhizSound = true; projBul.InstantiateStart(); } else if (bulletInfo.bulletType == BulletInfo.BulletType.Rocket) { Rocket projRoc = proj.GetComponent <Rocket>(); projRoc.RocketInfo(bulletInfo, weaponID, false, true, -1); projRoc.InstantiateStart(); } if (Topan.Network.isConnected && wm.rootNetView) { Vector3 fwdRot = Quaternion.LookRotation(randomRot * Vector3.forward).eulerAngles; wm.rootNetView.UnreliableRPC(Topan.RPCMode.Others, "NetworkShoot", (TopanFloat)(fwdRot.x / 360f), (TopanFloat)(fwdRot.y / 360f), firePos.position); } } bsna += spreadSpeed * spreadAimFactor; if (countsAsOneBullet) { AntiHackSystem.ProtectInt("currentAmmo", currentAmmo - 1); } else { AntiHackSystem.ProtectInt("currentAmmo", currentAmmo - bulletsPerShot); } fireCount++; StopCoroutine("MuzzleControl"); StartCoroutine(MuzzleControl()); if (ejectionEnabled) { if (ejectionDelay > 0f) { StartCoroutine(EjectShell()); } else { Rigidbody shell = PoolManager.Instance.RequestInstantiate(bulletShellIndex, ejectionPos.position, ejectionPos.rotation).GetComponent <Rigidbody>(); shell.velocity = (pm.controller.velocity * 0.7f) + pm.transform.TransformDirection(DarkRef.RandomVector3(ejectionMinForce, ejectionMaxForce)); shell.angularVelocity = Random.rotation.eulerAngles * ejectionRotation; } } tss.pitchMod = Random.Range(0.95f, 1f); tss.GetComponent <AudioSource>().PlayOneShot(fireSound); if (pa != null) { pa.startAnimation = true; } float aimMod = (ac.isAiming) ? aimUpkickModifier : 1f; float crouchMod = (pm.crouching) ? crouchUpkickModifier : 1f; float extraMod = (fireCount > extraRecoilThreshold) ? 1f + Mathf.Clamp((fireCount - extraRecoilThreshold) * extraRecoilAmount, 0f, maxExtraRecoil) : 1f; pl.Recoil(recoilAmount * ((ac.isAiming) ? 0.56f : 1.0f), upKickAmount * aimMod * crouchMod * extraMod, sideKickAmount * aimMod * crouchMod * extraMod, kickInfluence, kickCameraTilt, camShakeAnim, autoReturn); dm.Kickback(kickBackAmount * 0.04f, kickSpeedFactor, kickGunTilt); shootImpulseGUI += 0.1f; ammoBar.value += 0.01f; crosshair.JoltAnimation(spreadSpeed); timeSinceLastFire = Time.time; if (currentFireMode != FireMode.BurstFire) { timer += 1f; } }