From f39fb14de536385b76b8c258ea4039e728654a02 Mon Sep 17 00:00:00 2001 From: Fredrik Lillemoen Eiding Date: Sun, 1 Dec 2024 14:08:25 +0100 Subject: [PATCH] Add Boombardier SFX, crosshair, extenstion combos, add #739 - Add early detonation with fire extension - Add explosive barrel variant with enlarger extension - Add trashuplink detonation targeting - Remove crosshairs when spectating - Fix issue where decals could be placed on AiTargetPosition prefab - Add explosion screen shakes for closing #739 - Add new secret names and loading screen tips --- Assets/Audio/Augments/boomBardier.meta | 8 + .../Augments/boomBardier/BoomBardier.asset | 25 ++ .../boomBardier/BoomBardier.asset.meta | 8 + .../Augments/boomBardier/boomBardierShot.mp3 | Bin 0 -> 2755 bytes .../boomBardier/boomBardierShot.mp3.meta | 23 ++ .../Bullets/StickyDynamiteStick.prefab | 117 +++++++- Assets/Prefabs/GunParts/DynamiteBarrel.prefab | 115 +++++++- Assets/Prefabs/Input/AITargetPosition.prefab | 2 +- Assets/Prefabs/UI/LoadingScreen.prefab | 9 + .../SecretNamesStaticStorage.asset | 15 + .../AugmentImplementations/DynamiteBarrel.cs | 57 +++- .../Hat/MeshProjectileController.cs | 8 +- .../AugmentImplementations/SateliteUplink.cs | 11 +- .../AugmentImplementations/StickyDynamite.cs | 25 +- .../Augment/BulletModifiers/DecalModifier.cs | 2 + .../StickyProjectileModifier.cs | 17 +- Assets/Scripts/Augment/FiringSound.cs | 3 +- Assets/Scripts/Augment/GunStats.cs | 1 + Assets/Scripts/ExplosionController.cs | 22 +- Assets/Scripts/Gamestate/PlayerManager.cs | 20 +- Assets/Scripts/UI/PlayerHUDController.cs | 26 +- Assets/Scripts/Utils/SteamManager.cs | 6 + Assets/Shaders/Crosshairs.meta | 8 + .../Shaders/{ => Crosshairs}/CrossHair.hlsl | 0 .../{ => Crosshairs}/CrossHair.hlsl.meta | 0 .../Shaders/Crosshairs/CrossHairDynamite.hlsl | 76 ++++++ .../Crosshairs/CrossHairDynamite.hlsl.meta | 7 + .../{ => Crosshairs}/CrossHairHat.hlsl | 0 .../{ => Crosshairs}/CrossHairHat.hlsl.meta | 0 .../{ => Crosshairs}/CrossHairShotgun.hlsl | 0 .../CrossHairShotgun.hlsl.meta | 0 .../{ => Crosshairs}/Crosshair.shadergraph | 258 +++++++++++++++++- .../Crosshair.shadergraph.meta | 0 33 files changed, 832 insertions(+), 37 deletions(-) create mode 100644 Assets/Audio/Augments/boomBardier.meta create mode 100644 Assets/Audio/Augments/boomBardier/BoomBardier.asset create mode 100644 Assets/Audio/Augments/boomBardier/BoomBardier.asset.meta create mode 100644 Assets/Audio/Augments/boomBardier/boomBardierShot.mp3 create mode 100644 Assets/Audio/Augments/boomBardier/boomBardierShot.mp3.meta create mode 100644 Assets/Shaders/Crosshairs.meta rename Assets/Shaders/{ => Crosshairs}/CrossHair.hlsl (100%) rename Assets/Shaders/{ => Crosshairs}/CrossHair.hlsl.meta (100%) create mode 100644 Assets/Shaders/Crosshairs/CrossHairDynamite.hlsl create mode 100644 Assets/Shaders/Crosshairs/CrossHairDynamite.hlsl.meta rename Assets/Shaders/{ => Crosshairs}/CrossHairHat.hlsl (100%) rename Assets/Shaders/{ => Crosshairs}/CrossHairHat.hlsl.meta (100%) rename Assets/Shaders/{ => Crosshairs}/CrossHairShotgun.hlsl (100%) rename Assets/Shaders/{ => Crosshairs}/CrossHairShotgun.hlsl.meta (100%) rename Assets/Shaders/{ => Crosshairs}/Crosshair.shadergraph (91%) rename Assets/Shaders/{ => Crosshairs}/Crosshair.shadergraph.meta (100%) diff --git a/Assets/Audio/Augments/boomBardier.meta b/Assets/Audio/Augments/boomBardier.meta new file mode 100644 index 000000000..5012c84d5 --- /dev/null +++ b/Assets/Audio/Augments/boomBardier.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 3bcc4d4c12161e9469aef4133ef076a2 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Audio/Augments/boomBardier/BoomBardier.asset b/Assets/Audio/Augments/boomBardier/BoomBardier.asset new file mode 100644 index 000000000..5aa0d56ce --- /dev/null +++ b/Assets/Audio/Augments/boomBardier/BoomBardier.asset @@ -0,0 +1,25 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!114 &11400000 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: aa94d7cf98a253641a478b6ab78a05e3, type: 3} + m_Name: BoomBardier + m_EditorClassIdentifier: + sounds: + - {fileID: 8300000, guid: 25ffafe1977fbde459c8cd438086b78a, type: 3} + semitoneRange: + min: -5 + max: 0 + continuousPitchBend: 0 + volumeRange: + min: 0.8990219 + max: 1 + is3D: 1 + shouldPlayInSplitscreen: 1 diff --git a/Assets/Audio/Augments/boomBardier/BoomBardier.asset.meta b/Assets/Audio/Augments/boomBardier/BoomBardier.asset.meta new file mode 100644 index 000000000..083f12370 --- /dev/null +++ b/Assets/Audio/Augments/boomBardier/BoomBardier.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 83ebc3c9a2cdc6049822b4ea1e94340d +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 11400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Audio/Augments/boomBardier/boomBardierShot.mp3 b/Assets/Audio/Augments/boomBardier/boomBardierShot.mp3 new file mode 100644 index 0000000000000000000000000000000000000000..a00b82ce4fd4c9e66a71ea2ce3a46cadb54f38b5 GIT binary patch literal 2755 zcmeHJYgAL&6+R&$Bq2Z`7!r+`Ao3C=Bw=_=q=7^T5^Url1g(U3q0|Bc*3Puco0t$E zL4rJlGBbkmP!J4b5m7rvgCbAq0D^)}5LSI56F{c|Q*Lj%YJb-Mv-+)d?*8sMd*8k9 zclNpKMhH1*U_|gB>!E zAVM`L_!zE#4DiQ*yL7jNk*|nF*1{J&VWFV5PP*+U4mE;hPZx?g!BgItjGz=CB$fDlab z^z^h5A?7?i5JEQF+1dTO6b(|rVPv8hNxTAp9IzmU-(#XB&`+VlpzhK7Q<_)zJ%%o2 zirp0$J<;-EwWd~2?K(<@HVsD8<#e+mZiZlW&nG zk?csnx6KBZlJ)1Nq9^Prc25zXDv1|M)9g!e*kTcr(Z~z*#i;C2tZ7Hqx7)hQ+3Pz` zP)pI_dRJ{0w>-F|O*dCvb&YFpU79kvt@7rqFy~Svcf9M;6H$tf^Mj4Sqm+g3pVJx? z`K=D+GoIrg-s!d1#7w+*OKQo72^d}r>fbhV>YILg_OV-V`=RZ30qPo%|0v2&J* z0G*5ai-BfhvX_gCsirO^m%1mUqK+1@M{S{`sKQV3Bu-AdRo^9*4h-zD;LU{{xA)kb z3EfF|KgT6G`RJkG7wa&V=+72hstzuZ9fj5 zIdma-Z0en@)+oDL=$OyRX^#&Te&(oo7#keV*VLsS-JeyH z6CHTxNJ{vXR?6LM0I%wVEgHiu*9T_{jkv=4<4bRDqHIWI0fn6qv)#en_Nobk)`Qpe zQF08MC(P+)uy3v5B@`dna z5p6I#Zygh#-p=q5XJH<{q~F}JH(PS+KL~ zSuzpxOX-pmiVu<7?8OO|=(bR_+oA1MIhfSx2td_8bCF1unEMhG1|$4{ zDSK&u3{up=@Uh`w-(h!V0A3ur=QK$G!wbW|C`r{wmG`fn*e^lT18>1^ec&^_v&AHi zX!%@5Q@`34Y4XMCRFupZL$vIU#)V6^|6A;Gf{ z5ur_@>kx2GoTy1M`1P$ck8)x;NnV{^9mG9jHqE2{2ESLGUM&Vcfq(O53 zr4P>M%Rp^L;NXxweK<#w7)gaH1M6M1uxizt(z!+ znY2vZ`ormnx`>}J?^yIMk05AVUg65#xszNCdX=xmH+<&OHlSrWKtB can do a super slide by performing a leap directly into a pan skate! - Some barrels grant extra damage on headshots! + - Combining the BOOM-bardier barrel with the Fire + extension lets you detonate the dynamites before + they hit the ground! + - Combining the BOOM-bardier barrel with the Fire + extension lets you detonate the dynamites before + they hit the ground! + - Combining the BOOM-bardier barrel with the Enlarger + extension turns your dynamites into explosive + barrels. Trick your opponents by hiding them well! background: {fileID: 8814292908430132048} mandatoryDuration: 4 normalRotationSpeed: 60 diff --git a/Assets/ScriptableObjects/Items/SecretNames/SecretNamesStaticStorage.asset b/Assets/ScriptableObjects/Items/SecretNames/SecretNamesStaticStorage.asset index d0a051d79..45dbd8e5f 100644 --- a/Assets/ScriptableObjects/Items/SecretNames/SecretNamesStaticStorage.asset +++ b/Assets/ScriptableObjects/Items/SecretNames/SecretNamesStaticStorage.asset @@ -118,3 +118,18 @@ MonoBehaviour: Extension: {fileID: 11400000, guid: 6955edf1e31801642a2f47defb820d36, type: 2} Name: The Turbocharged Point&Click Adventure Achievement: 20 + - Body: {fileID: 11400000, guid: bdea3807a64796f4da3038c849234215, type: 2} + Barrel: {fileID: 11400000, guid: 42441b7c0dcc82c43a745456680f2693, type: 2} + Extension: {fileID: 11400000, guid: a0f539379f7384445bc1535317457198, type: 2} + Name: The Unpatient S'ploder + Achievement: 21 + - Body: {fileID: 11400000, guid: 63bf1979c291d114b8dfb8d01bb407a9, type: 2} + Barrel: {fileID: 11400000, guid: 42441b7c0dcc82c43a745456680f2693, type: 2} + Extension: {fileID: 11400000, guid: 1e8a76909fc7b284dae3c37ebcf4d7ce, type: 2} + Name: The Barrel Imposter + Achievement: 22 + - Body: {fileID: 11400000, guid: a99e4b806f963ac45a0635c34182107a, type: 2} + Barrel: {fileID: 11400000, guid: 42441b7c0dcc82c43a745456680f2693, type: 2} + Extension: {fileID: 11400000, guid: 87e98f42380f122a486cd5034ef1d278, type: 2} + Name: The Tactical Strike + Achievement: 23 diff --git a/Assets/Scripts/Augment/AugmentImplementations/DynamiteBarrel.cs b/Assets/Scripts/Augment/AugmentImplementations/DynamiteBarrel.cs index 5e6fba6bb..9290dd350 100644 --- a/Assets/Scripts/Augment/AugmentImplementations/DynamiteBarrel.cs +++ b/Assets/Scripts/Augment/AugmentImplementations/DynamiteBarrel.cs @@ -1,3 +1,4 @@ +using Mirror; using System.Collections; using System.Collections.Generic; using System.Linq; @@ -14,6 +15,9 @@ public class DynamiteBarrel : GunBarrel private bool isDetonatableEarly = false; [SerializeField] private MeshProjectileController meshProjectiles; + private SateliteUplink sateliteUplink; + + void Start() { gunController = transform.parent.GetComponent(); @@ -28,17 +32,20 @@ void Start() GetComponent().Vfx.SetMesh("Mesh", explodingBarrelMesh); // If fire extension, dynamites should be able to explode while in air - //if (gunController.GetComponentInChildren()) - // isDetonatableEarly = true; + if (gunController.GetComponentInChildren()) + isDetonatableEarly = true; + else + sateliteUplink = gunController.GetComponentInChildren(); if (gunController.Player is AIManager) { StartCoroutine(TryDetonating()); return; - } - + } + syncDirection = SyncDirection.ClientToServer; gunController.Player.GetComponent().ResetZoom(); - gunController.Player.inputManager.onZoomPerformed += OnZoom; + if (gunController.Player.inputManager) + gunController.Player.inputManager.onZoomPerformed += OnZoom; } private void AddDynamite(StuckObject stuckObject) @@ -47,6 +54,7 @@ private void AddDynamite(StuckObject stuckObject) return; var stuckDynamite = (StickyDynamite)stuckObject; activeDynamites.Add(stuckDynamite); + stuckDynamite.ResetDynamite(); if (Projectile.stats.ProjectileScale >= 3) stuckDynamite.SetBarrel(); @@ -66,12 +74,39 @@ private IEnumerator TryDetonating() private void OnZoom(InputAction.CallbackContext ctx) { + if (authority) + CmdDetonate(); + } + + [Command] + private void CmdDetonate() + { + RpcDetonate(); + } + + [ClientRpc] + private void RpcDetonate() + { + if (isDetonatableEarly) + { + var explosivePositions = meshProjectiles.ProjectilePositions; + explosivePositions.ToList().ForEach(position => + { + var dynamite = (StickyDynamite)stickyModifer.InstantiateManual(position); + dynamite.Explosion.Init(); + activeDynamites.Add(dynamite); + }); + meshProjectiles.ClearProjectiles(); + } + else if (sateliteUplink) + sateliteUplink.TargetManual(activeDynamites + .Select(dynamite => dynamite.transform.position)); + + if (authority && activeDynamites.Count > 0 && gunController.Player.HUDController) + gunController.Player.HUDController.CrossHairDetonationAnimation(); + activeDynamites.ForEach(dynamite => dynamite.Detonate(gunController.Player)); activeDynamites.Clear(); - if (!isDetonatableEarly) - return; - var explosivePositions = meshProjectiles.ProjectilePositions; - meshProjectiles.ClearProjectiles(); } private void OnDeath(PlayerManager killer, PlayerManager victim, DamageInfo info) @@ -84,7 +119,7 @@ private void OnDeath(PlayerManager killer, PlayerManager victim, DamageInfo info stickyModifer.OnStuckToTarget -= AddDynamite; - if (gunController.Player is not AIManager) + if (gunController.Player is not AIManager && gunController.Player.inputManager) gunController.Player.inputManager.onZoomPerformed -= OnZoom; } @@ -98,7 +133,7 @@ private void OnDestroy() stickyModifer.OnStuckToTarget -= AddDynamite; - if (gunController.Player is not AIManager) + if (gunController.Player is not AIManager && gunController.Player.inputManager) gunController.Player.inputManager.onZoomPerformed -= OnZoom; } } diff --git a/Assets/Scripts/Augment/AugmentImplementations/Hat/MeshProjectileController.cs b/Assets/Scripts/Augment/AugmentImplementations/Hat/MeshProjectileController.cs index c29b6208d..47909ebf1 100644 --- a/Assets/Scripts/Augment/AugmentImplementations/Hat/MeshProjectileController.cs +++ b/Assets/Scripts/Augment/AugmentImplementations/Hat/MeshProjectileController.cs @@ -34,7 +34,9 @@ public class MeshProjectileController : ProjectileController private ProjectileState[] projectiles; - public Vector3[] ProjectilePositions => projectiles.Select(p => p.position).ToArray(); + public Vector3[] ProjectilePositions => + projectiles.Where(p => p != null && p.active == true) + .Select(p => p.position).ToArray(); private ProjectileState loadedProjectile; @@ -106,7 +108,9 @@ private void FireProjectile() public void ClearProjectiles() { - projectiles.ToList().Clear(); + for (int i = 0; i < maxProjectiles; i++) + if (projectiles[i] != null) + projectiles[i].active = false; } [Command] diff --git a/Assets/Scripts/Augment/AugmentImplementations/SateliteUplink.cs b/Assets/Scripts/Augment/AugmentImplementations/SateliteUplink.cs index afdeb186e..458b47f4c 100644 --- a/Assets/Scripts/Augment/AugmentImplementations/SateliteUplink.cs +++ b/Assets/Scripts/Augment/AugmentImplementations/SateliteUplink.cs @@ -5,6 +5,7 @@ using TMPro; using UnityEngine; using Mirror; +using System.Linq; public class SateliteUplink : NetworkBehaviour, ProjectileModifier { @@ -123,7 +124,7 @@ public void Detach(ProjectileController projectile) { projectile.OnProjectileInit -= Track; projectile.OnColliderHit -= Target; - projectile.OnRicochet += Target; + projectile.OnRicochet -= Target; garbagePool.Flush(); garbagePool = null; targetingReticlePool.Flush(); @@ -155,6 +156,14 @@ private void Target(RaycastHit hit, ref ProjectileState state) Launch(hit.point); } + public void TargetManual(IEnumerable positions) + { + if (!isReady) + return; + positions.ToList().ForEach(position => Launch(position)); + RestartCooldown(); + } + private void Launch(Vector3 target) { if (!gunController) diff --git a/Assets/Scripts/Augment/AugmentImplementations/StickyDynamite.cs b/Assets/Scripts/Augment/AugmentImplementations/StickyDynamite.cs index a69ff2e67..1dcf6a28a 100644 --- a/Assets/Scripts/Augment/AugmentImplementations/StickyDynamite.cs +++ b/Assets/Scripts/Augment/AugmentImplementations/StickyDynamite.cs @@ -16,6 +16,23 @@ public class StickyDynamite : StuckObject private VisualEffect[] barrelSmoke; [SerializeField] private ExplosionController explosion; + public ExplosionController Explosion => explosion; + + private void OnEnable() + { + ResetDynamite(); + } + + public void ResetDynamite() + { + explosion.StopAllCoroutines(); + mesh.enabled = true; + smoke.enabled = true; + if (explosion.transform.parent) + explosion.transform.parent.gameObject.SetActive(true); + explosion.gameObject.SetActive(true); + explosion.Init(); + } public void SetBarrel() { @@ -31,7 +48,11 @@ public void Detonate(PlayerManager sourcePlayer) explosiveBarrel.enabled = false; smoke.enabled = false; barrelSmoke.ToList().ForEach(smoke => smoke.enabled = false); - explosion.Explode(sourcePlayer); - explosion.transform.parent.parent = null; + // Double check that dynamite hasn't been taken by the pool before exploding + if (explosion.gameObject.activeSelf) + { + explosion.Explode(sourcePlayer); + explosion.transform.parent.parent = null; + } } } diff --git a/Assets/Scripts/Augment/BulletModifiers/DecalModifier.cs b/Assets/Scripts/Augment/BulletModifiers/DecalModifier.cs index dd25b9a5f..bd66c33fc 100644 --- a/Assets/Scripts/Augment/BulletModifiers/DecalModifier.cs +++ b/Assets/Scripts/Augment/BulletModifiers/DecalModifier.cs @@ -94,6 +94,8 @@ private Quaternion DetermineRotation(Collider target, ProjectileState state) private void OnDestroy() { + if (decalPool == null) + return; decalPool.Flush(); decalPool = null; } diff --git a/Assets/Scripts/Augment/BulletModifiers/StickyProjectileModifier.cs b/Assets/Scripts/Augment/BulletModifiers/StickyProjectileModifier.cs index 7b215d4cc..e6f600196 100644 --- a/Assets/Scripts/Augment/BulletModifiers/StickyProjectileModifier.cs +++ b/Assets/Scripts/Augment/BulletModifiers/StickyProjectileModifier.cs @@ -15,6 +15,8 @@ public class StickyProjectileModifier : MonoBehaviour, ProjectileModifier private bool isDespawnedAfterTime = true; [SerializeField] private float stuckLifeTime = 5f; + [SerializeField] + private int maxObjects = 70; // Does stuck object trigger onHit? [SerializeField] private bool triggerOnHit = true; @@ -43,7 +45,7 @@ public Priority GetPriority() public void Attach(ProjectileController projectile) { - stuckObjects = new ObjectPool(stuckObject); + stuckObjects = new ObjectPool(stuckObject, maxObjects); projectile.OnColliderHit += StickToTarget; scale = stuckObject.transform.localScale * projectile.stats.ProjectileScale; source = projectile.player; @@ -64,7 +66,7 @@ public void StickToTarget(RaycastHit hit, ref ProjectileState state) var stuck = isDespawnedAfterTime ? stuckObjects.GetAndReturnLater(stuckLifeTime) - : stuckObjects.Get(); + : stuckObjects.Get(); stuck.transform.position = hit.ClosestPoint(state.oldPosition); stuck.transform.localScale = scale; @@ -76,6 +78,17 @@ public void StickToTarget(RaycastHit hit, ref ProjectileState state) continuousDamage.source = source; } + public StuckObject InstantiateManual(Vector3 position) + { + var stuck = isDespawnedAfterTime ? + stuckObjects.GetAndReturnLater(stuckLifeTime) + : stuckObjects.Get(); + + stuck.transform.position = position; + stuck.transform.localScale = scale; + return stuck; + } + private void OnDestroy() { if (stuckObjects == null) diff --git a/Assets/Scripts/Augment/FiringSound.cs b/Assets/Scripts/Augment/FiringSound.cs index dd6ad2272..100b2275b 100644 --- a/Assets/Scripts/Augment/FiringSound.cs +++ b/Assets/Scripts/Augment/FiringSound.cs @@ -18,7 +18,8 @@ private void Start() private void OnDestroy() { - projectile.OnProjectileInit -= PlaySound; + if (projectile != null) + projectile.OnProjectileInit -= PlaySound; } private void PlaySound(ref ProjectileState state, GunStats stats) diff --git a/Assets/Scripts/Augment/GunStats.cs b/Assets/Scripts/Augment/GunStats.cs index 536ea4d13..18e047de7 100644 --- a/Assets/Scripts/Augment/GunStats.cs +++ b/Assets/Scripts/Augment/GunStats.cs @@ -156,6 +156,7 @@ public enum CrossHairModes Default, Shotgun, Hat, + Dynamite, } public CrossHairModes CrossHairMode { get; set; } [SerializeField] diff --git a/Assets/Scripts/ExplosionController.cs b/Assets/Scripts/ExplosionController.cs index 52b9de526..f283e01b4 100644 --- a/Assets/Scripts/ExplosionController.cs +++ b/Assets/Scripts/ExplosionController.cs @@ -1,5 +1,7 @@ -using System.Collections.Generic; +using System.Collections; +using System.Collections.Generic; using System.Linq; +using System.Runtime.CompilerServices; using UnityEngine; using UnityEngine.VFX; @@ -73,10 +75,26 @@ public void OnDrawGizmos() if (shouldBeReturned) hits.Add((target, scaledDamage)); } - Destroy(gameObject, 4); + if (gameObject.activeSelf) + StartCoroutine(WaitAndDeactivate()); return hits; } + private IEnumerator WaitAndDeactivate() + { + yield return new WaitForSeconds(4); + if (transform.parent) + transform.parent.gameObject.SetActive(false); + else + gameObject.SetActive(false); + } + + private void OnDisable() + { + visualEffects.ForEach(vfx => vfx.enabled = false); + StopAllCoroutines(); + } + private void DealDamage(Collider target, PlayerManager sourcePlayer, out bool shouldBeReturned, out float scaledDamage) { scaledDamage = 0; diff --git a/Assets/Scripts/Gamestate/PlayerManager.cs b/Assets/Scripts/Gamestate/PlayerManager.cs index 1411823dd..40e82ac29 100644 --- a/Assets/Scripts/Gamestate/PlayerManager.cs +++ b/Assets/Scripts/Gamestate/PlayerManager.cs @@ -178,7 +178,11 @@ private void UpdateAimAngleRpc(float yAngle) private void OnDamageTaken(HealthController healthController, float damage, DamageInfo info) { if (hudController) - hudController.OnDamageTaken(damage, healthController.CurrentHealth, healthController.MaxHealth); + hudController.OnDamageTaken(healthController.CurrentHealth, healthController.MaxHealth); + + if (info.damageType == DamageType.Explosion) + ScreenShake(info.damage * 0.005f); + if (info.sourcePlayer != this) { lastPlayerThatHitMe = info.sourcePlayer; @@ -446,6 +450,20 @@ private void ScreenShake(GunStats stats) screenShakeTween = inputManager.PlayerCamera.gameObject.LeanMoveLocal(new Vector3(0.02f, 0.02f, 0f) * stats.ScreenShakeFactor, 0.1f).setEaseShake().id; } + private void ScreenShake(float amount) + { + if (!inputManager) + return; + if (LeanTween.isTweening(screenShakeTween)) + { + LeanTween.cancel(screenShakeTween); + inputManager.PlayerCamera.gameObject.transform.localPosition = Vector3.zero; + } + var viewDirection = inputManager.PlayerCamera.transform.up; + screenShakeTween = inputManager.PlayerCamera.gameObject + .LeanMoveLocal(viewDirection * amount, 0.2f).setEaseShake().id; + } + public virtual void SetLayer(int playerIndex) { layerIndex = playerIndex; diff --git a/Assets/Scripts/UI/PlayerHUDController.cs b/Assets/Scripts/UI/PlayerHUDController.cs index 6c2ccccea..d349d3c09 100644 --- a/Assets/Scripts/UI/PlayerHUDController.cs +++ b/Assets/Scripts/UI/PlayerHUDController.cs @@ -109,12 +109,14 @@ public class PlayerHUDController : MonoBehaviour // Dampen how much vertical velocity should influence center of speedlines private const float lineVelocityDampeningY = 0.1f; private float crosshairCrossScale = 1.0f; + private float initialCrosshairRadius; [SerializeField] private RectTransform scopeZoom; private int scopeTween; private int hitTween; private int hitMarkTween; + private int crosshairRadiusTween; private void Awake() { @@ -204,7 +206,7 @@ public void AnimateHudJump() .id; } - public void OnDamageTaken(float damage, float currentHealth, float maxHealth) + public void OnDamageTaken(float currentHealth, float maxHealth) { UpdateHealthBar(currentHealth, maxHealth); LeanTween.value(gameObject, UpdateDamageBorder, 0f, 1f, damageBorderFlashDuration); @@ -308,6 +310,8 @@ public void DisplayDeathScreen(PlayerIdentity killer) spectateHintText.gameObject.SetActive(false); ammoHud.parent.gameObject.SetActive(false); speedLines.gameObject.SetActive(false); + // Disable crosshair when spectating + crosshair.rectTransform.sizeDelta *= 0; } public void DisplaySpectateHint() @@ -373,9 +377,27 @@ private void SetHitmarkScale(float scale) crosshairMaterial.SetFloat("_HitMarkerRadius", scale); } + private void SetCrosshairRadius(float radius) + { + crosshairMaterial.SetFloat("_Radius", radius); + } + + public void CrossHairDetonationAnimation() + { + if (LeanTween.isTweening(crosshairRadiusTween)) + { + LeanTween.cancel(crosshairRadiusTween); + crosshairMaterial.SetFloat("_Radius", initialCrosshairRadius); + } + crosshairRadiusTween = LeanTween.value(crosshair.gameObject, SetCrosshairRadius, initialCrosshairRadius, 0f, 0.3f) + .setEaseOutQuint() + .setOnComplete(() => SetCrosshairRadius(initialCrosshairRadius)).id; + } + public void UpdateOnInitialize(GunStats stats) { - crosshairMaterial.SetFloat("_Radius", stats.CrosshairRadius.Value() == 0f ? 0f : 1f / stats.CrosshairRadius.Value()); + initialCrosshairRadius = stats.CrosshairRadius.Value() == 0f ? 0f : 1f / stats.CrosshairRadius.Value(); + crosshairMaterial.SetFloat("_Radius", initialCrosshairRadius); // Has to be done this way as enum keywords in reality are a set of boolean keywords... foreach (CrossHairModes mode in Enum.GetValues(typeof(CrossHairModes))) diff --git a/Assets/Scripts/Utils/SteamManager.cs b/Assets/Scripts/Utils/SteamManager.cs index 7d4f3893b..9944b66a8 100644 --- a/Assets/Scripts/Utils/SteamManager.cs +++ b/Assets/Scripts/Utils/SteamManager.cs @@ -27,6 +27,9 @@ public enum SecretCombinationType Nuke, MadHatter, PointNClick, + UnpatientSploder, + BarrelImposter, + TacticalStrike, } public enum AchievementType @@ -196,6 +199,9 @@ private void RequestStats() { SecretCombinationType.Nuke, "WEAPON_NUKE" }, { SecretCombinationType.MadHatter, "WEAPON_MAD_HATTER" }, { SecretCombinationType.PointNClick, "WEAPON_POINT_CLICK" }, + { SecretCombinationType.UnpatientSploder, "WEAPON_UNPATIENT_SPLODER" }, + { SecretCombinationType.BarrelImposter, "WEAPON_BARREL_IMPOSTER" }, + { SecretCombinationType.TacticalStrike, "WEAPON_TACTICAL_STRIKE" }, }; private readonly Dictionary achievementNames = new() diff --git a/Assets/Shaders/Crosshairs.meta b/Assets/Shaders/Crosshairs.meta new file mode 100644 index 000000000..2fe316897 --- /dev/null +++ b/Assets/Shaders/Crosshairs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 774c98b9c1a2a524297f952a43cbf856 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Shaders/CrossHair.hlsl b/Assets/Shaders/Crosshairs/CrossHair.hlsl similarity index 100% rename from Assets/Shaders/CrossHair.hlsl rename to Assets/Shaders/Crosshairs/CrossHair.hlsl diff --git a/Assets/Shaders/CrossHair.hlsl.meta b/Assets/Shaders/Crosshairs/CrossHair.hlsl.meta similarity index 100% rename from Assets/Shaders/CrossHair.hlsl.meta rename to Assets/Shaders/Crosshairs/CrossHair.hlsl.meta diff --git a/Assets/Shaders/Crosshairs/CrossHairDynamite.hlsl b/Assets/Shaders/Crosshairs/CrossHairDynamite.hlsl new file mode 100644 index 000000000..c778ef1d5 --- /dev/null +++ b/Assets/Shaders/Crosshairs/CrossHairDynamite.hlsl @@ -0,0 +1,76 @@ +float2 rotateUVDynamite_float(float2 position, float degrees) +{ + float sinX = sin(degrees); + float cosX = cos(degrees); + float sinY = sin(degrees); + float2x2 rotationMatrix = float2x2(cosX, -sinX, sinY, cosX); + return mul(position, rotationMatrix); +} + +float sphereSDFDynamite_float(float2 pos) +{ + return abs(length(pos) - 1.)-0.05; +} + +float sdCrossDynamite_float(in float2 p, in float2 b, float r) +{ + p = abs(p); p = (p.y>p.x) ? p.yx : p.xy; + float2 q = p - b; + float k = max(q.y,q.x); + float2 w = (k>0.0) ? q : float2(b.y-p.x,-k); + return sign(k)*length(max(w,0.0)) + r; +} + +float sdRoundedXDynamite_float(float2 p, float w, float r) +{ + p = abs(p); + return max(length(p-min(p.x+p.y,w)*0.5) - r, -1. * (length(p) - 0.5)); +} + +float crossSDFDynamite_float(float2 pos, float r) +{ + return abs(sdCrossDynamite_float(pos, float2(0.5 * r, 0.1 * r), 0.1 * r)) - 0.05 * r; +} + + +float sdBoxDynamite_float(float2 p, float2 b) +{ + float2 d = abs(p)-b; + return abs(length(max(d, 0.0)) + min(max(d.x, d.y), 0.0)) - 0.045; +} + +float sdStringDynamite_float(float2 p, float2 b) +{ + float2 d = abs(p) - b; + return length(max(d, 0.0)) + min(max(d.x, d.y), 0.0); +} + +float sdHexagonDynamite_float(float2 p, in float r) +{ + float3 k = float3(-0.866025404,0.5,0.577350269); + p = abs(p); + p -= 2.0*min(dot(k.xy,p),0.0)*k.xy; + p -= float2(clamp(p.x, -k.z*r, k.z*r), r); + return length(p)*sign(p.y); +} + +float sdArcDynamite_float(float2 p, float2 sc, in float ra, float rb) +{ + p.x = abs(p.x); + return ((sc.y*p.x>sc.x*p.y) ? length(p-sc*ra) : + abs(length(p)-ra)) - rb; +} + +float dynamite_float(float2 pos) +{ + float2 rotatedPos = rotateUVDynamite_float(pos, -0.1); + return min( + min(sphereSDFDynamite_float(pos), sdBoxDynamite_float(rotateUVDynamite_float(pos + float2(0.6, -1.), 0.5), 0.2)), + sdStringDynamite_float(float2(rotatedPos.x + sin((rotatedPos -0.15).y * 1.), (rotatedPos.y - 1.85) * 0.1) * 10.8, 0.8)); + +} + +void CrossHairDynamite_float(float2 UV, float crossSize, float circleRadius, float hitMarkerRadius, out float Distance) +{ + Distance = min(dynamite_float(UV * circleRadius * 1.8), crossSDFDynamite_float(UV * 2.8, crossSize)); +} diff --git a/Assets/Shaders/Crosshairs/CrossHairDynamite.hlsl.meta b/Assets/Shaders/Crosshairs/CrossHairDynamite.hlsl.meta new file mode 100644 index 000000000..8a738d80d --- /dev/null +++ b/Assets/Shaders/Crosshairs/CrossHairDynamite.hlsl.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: e685d5027224b4f4f9f7cebfd7e0e43e +ShaderIncludeImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Shaders/CrossHairHat.hlsl b/Assets/Shaders/Crosshairs/CrossHairHat.hlsl similarity index 100% rename from Assets/Shaders/CrossHairHat.hlsl rename to Assets/Shaders/Crosshairs/CrossHairHat.hlsl diff --git a/Assets/Shaders/CrossHairHat.hlsl.meta b/Assets/Shaders/Crosshairs/CrossHairHat.hlsl.meta similarity index 100% rename from Assets/Shaders/CrossHairHat.hlsl.meta rename to Assets/Shaders/Crosshairs/CrossHairHat.hlsl.meta diff --git a/Assets/Shaders/CrossHairShotgun.hlsl b/Assets/Shaders/Crosshairs/CrossHairShotgun.hlsl similarity index 100% rename from Assets/Shaders/CrossHairShotgun.hlsl rename to Assets/Shaders/Crosshairs/CrossHairShotgun.hlsl diff --git a/Assets/Shaders/CrossHairShotgun.hlsl.meta b/Assets/Shaders/Crosshairs/CrossHairShotgun.hlsl.meta similarity index 100% rename from Assets/Shaders/CrossHairShotgun.hlsl.meta rename to Assets/Shaders/Crosshairs/CrossHairShotgun.hlsl.meta diff --git a/Assets/Shaders/Crosshair.shadergraph b/Assets/Shaders/Crosshairs/Crosshair.shadergraph similarity index 91% rename from Assets/Shaders/Crosshair.shadergraph rename to Assets/Shaders/Crosshairs/Crosshair.shadergraph index 53c6ca5ee..9ada43bd1 100644 --- a/Assets/Shaders/Crosshair.shadergraph +++ b/Assets/Shaders/Crosshairs/Crosshair.shadergraph @@ -99,6 +99,9 @@ }, { "m_Id": "4d1bf82061c14550a5894919d00b5ec5" + }, + { + "m_Id": "5e14cbcb16ea4175822beec00dda6c67" } ], "m_GroupDatas": [], @@ -164,6 +167,20 @@ "m_SlotId": 1 } }, + { + "m_OutputSlot": { + "m_Node": { + "m_Id": "347bc1c64428488085911aea9ecd6920" + }, + "m_SlotId": 0 + }, + "m_InputSlot": { + "m_Node": { + "m_Id": "5e14cbcb16ea4175822beec00dda6c67" + }, + "m_SlotId": 1 + } + }, { "m_OutputSlot": { "m_Node": { @@ -234,6 +251,34 @@ "m_SlotId": 1 } }, + { + "m_OutputSlot": { + "m_Node": { + "m_Id": "5e14cbcb16ea4175822beec00dda6c67" + }, + "m_SlotId": 4 + }, + "m_InputSlot": { + "m_Node": { + "m_Id": "2b5cf5822378467c8ffa4e4037ea7b1f" + }, + "m_SlotId": 5 + } + }, + { + "m_OutputSlot": { + "m_Node": { + "m_Id": "69ee95579277414b976cc4f92ccee9b9" + }, + "m_SlotId": 0 + }, + "m_InputSlot": { + "m_Node": { + "m_Id": "5e14cbcb16ea4175822beec00dda6c67" + }, + "m_SlotId": 3 + } + }, { "m_OutputSlot": { "m_Node": { @@ -332,6 +377,20 @@ "m_SlotId": 2 } }, + { + "m_OutputSlot": { + "m_Node": { + "m_Id": "bd1450a953c049f0a08aab0a999ef74f" + }, + "m_SlotId": 0 + }, + "m_InputSlot": { + "m_Node": { + "m_Id": "5e14cbcb16ea4175822beec00dda6c67" + }, + "m_SlotId": 2 + } + }, { "m_OutputSlot": { "m_Node": { @@ -430,6 +489,20 @@ "m_SlotId": 3 } }, + { + "m_OutputSlot": { + "m_Node": { + "m_Id": "f36957f8bb334884ae1c5cfd6aa3f78c" + }, + "m_SlotId": 2 + }, + "m_InputSlot": { + "m_Node": { + "m_Id": "5e14cbcb16ea4175822beec00dda6c67" + }, + "m_SlotId": 0 + } + }, { "m_OutputSlot": { "m_Node": { @@ -682,6 +755,27 @@ } } +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.Vector2MaterialSlot", + "m_ObjectId": "0f96ecddfa594b16ab72b9972edb31f6", + "m_Id": 0, + "m_DisplayName": "UV", + "m_SlotType": 0, + "m_Hidden": false, + "m_ShaderOutputName": "UV", + "m_StageCapability": 3, + "m_Value": { + "x": 0.0, + "y": 0.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0 + }, + "m_Labels": [] +} + { "m_SGVersion": 0, "m_Type": "UnityEditor.ShaderGraph.TilingAndOffsetNode", @@ -748,6 +842,21 @@ "m_Labels": [] } +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.Vector1MaterialSlot", + "m_ObjectId": "1735833bcca8468f979a7c1aa400bb3b", + "m_Id": 1, + "m_DisplayName": "CrossSize", + "m_SlotType": 0, + "m_Hidden": false, + "m_ShaderOutputName": "CrossSize", + "m_StageCapability": 3, + "m_Value": 0.0, + "m_DefaultValue": 0.0, + "m_Labels": [] +} + { "m_SGVersion": 1, "m_Type": "UnityEditor.ShaderGraph.Internal.Vector1ShaderProperty", @@ -1053,6 +1162,9 @@ }, { "m_Id": "fffbf0a1a01b47c1aa24fb74af11cd4a" + }, + { + "m_Id": "34129ca3f8834325b4ac754d544521c6" } ], "synonyms": [], @@ -1126,6 +1238,30 @@ } } +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.DynamicVectorMaterialSlot", + "m_ObjectId": "34129ca3f8834325b4ac754d544521c6", + "m_Id": 5, + "m_DisplayName": "Dynamite", + "m_SlotType": 0, + "m_Hidden": false, + "m_ShaderOutputName": "DYNAMITE", + "m_StageCapability": 3, + "m_Value": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + } +} + { "m_SGVersion": 0, "m_Type": "UnityEditor.ShaderGraph.PropertyNode", @@ -1138,10 +1274,10 @@ "m_Expanded": true, "m_Position": { "serializedVersion": "2", - "x": -1232.800048828125, - "y": 451.20001220703127, - "width": 127.2000732421875, - "height": 33.5999755859375 + "x": -1296.800048828125, + "y": 432.7999572753906, + "width": 128.0, + "height": 33.600006103515628 } }, "m_Slots": [ @@ -1305,6 +1441,11 @@ "id": 4, "displayName": "Hat", "referenceName": "HAT" + }, + { + "id": 5, + "displayName": "Dynamite", + "referenceName": "DYNAMITE" } ], "m_Value": 0, @@ -1545,6 +1686,58 @@ "m_Labels": [] } +{ + "m_SGVersion": 1, + "m_Type": "UnityEditor.ShaderGraph.CustomFunctionNode", + "m_ObjectId": "5e14cbcb16ea4175822beec00dda6c67", + "m_Group": { + "m_Id": "" + }, + "m_Name": "CrossHairDynamite (Custom Function)", + "m_DrawState": { + "m_Expanded": true, + "m_Position": { + "serializedVersion": "2", + "x": -1008.0000610351563, + "y": 1716.800048828125, + "width": 208.0, + "height": 244.7999267578125 + } + }, + "m_Slots": [ + { + "m_Id": "0f96ecddfa594b16ab72b9972edb31f6" + }, + { + "m_Id": "1735833bcca8468f979a7c1aa400bb3b" + }, + { + "m_Id": "6224074fd0a144b280be3a5866500622" + }, + { + "m_Id": "dd500391bbf646e4998528385c7f24fa" + }, + { + "m_Id": "684f62bb860142a3867f929aaaa6ba37" + } + ], + "synonyms": [ + "code", + "HLSL" + ], + "m_Precision": 0, + "m_PreviewExpanded": true, + "m_DismissedVersion": 0, + "m_PreviewMode": 0, + "m_CustomColors": { + "m_SerializableColors": [] + }, + "m_SourceType": 0, + "m_FunctionName": "CrossHairDynamite", + "m_FunctionSource": "e685d5027224b4f4f9f7cebfd7e0e43e", + "m_FunctionBody": "Enter function body here..." +} + { "m_SGVersion": 1, "m_Type": "UnityEditor.ShaderGraph.Internal.Vector1ShaderProperty", @@ -1573,6 +1766,21 @@ } } +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.Vector1MaterialSlot", + "m_ObjectId": "6224074fd0a144b280be3a5866500622", + "m_Id": 2, + "m_DisplayName": "CircleRadius", + "m_SlotType": 0, + "m_Hidden": false, + "m_ShaderOutputName": "CircleRadius", + "m_StageCapability": 3, + "m_Value": 0.0, + "m_DefaultValue": 0.0, + "m_Labels": [] +} + { "m_SGVersion": 0, "m_Type": "UnityEditor.ShaderGraph.DynamicVectorMaterialSlot", @@ -1645,6 +1853,21 @@ } } +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.Vector1MaterialSlot", + "m_ObjectId": "684f62bb860142a3867f929aaaa6ba37", + "m_Id": 4, + "m_DisplayName": "Distance", + "m_SlotType": 1, + "m_Hidden": false, + "m_ShaderOutputName": "Distance", + "m_StageCapability": 3, + "m_Value": 0.0, + "m_DefaultValue": 0.0, + "m_Labels": [] +} + { "m_SGVersion": 0, "m_Type": "UnityEditor.ShaderGraph.PropertyNode", @@ -1657,9 +1880,9 @@ "m_Expanded": true, "m_Position": { "serializedVersion": "2", - "x": -1315.199951171875, - "y": 680.0, - "width": 162.39990234375, + "x": -1432.0, + "y": 752.7999877929688, + "width": 161.5999755859375, "height": 33.60003662109375 } }, @@ -2400,10 +2623,10 @@ "m_Expanded": true, "m_Position": { "serializedVersion": "2", - "x": -1288.0, - "y": 548.0, + "x": -1380.800048828125, + "y": 581.5999145507813, "width": 110.4000244140625, - "height": 33.5999755859375 + "height": 33.60003662109375 } }, "m_Slots": [ @@ -2775,6 +2998,21 @@ "m_Labels": [] } +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.Vector1MaterialSlot", + "m_ObjectId": "dd500391bbf646e4998528385c7f24fa", + "m_Id": 3, + "m_DisplayName": "HitMarkerRadius", + "m_SlotType": 0, + "m_Hidden": false, + "m_ShaderOutputName": "HitMarkerRadius", + "m_StageCapability": 3, + "m_Value": 0.0, + "m_DefaultValue": 0.0, + "m_Labels": [] +} + { "m_SGVersion": 0, "m_Type": "UnityEditor.ShaderGraph.Vector1MaterialSlot", diff --git a/Assets/Shaders/Crosshair.shadergraph.meta b/Assets/Shaders/Crosshairs/Crosshair.shadergraph.meta similarity index 100% rename from Assets/Shaders/Crosshair.shadergraph.meta rename to Assets/Shaders/Crosshairs/Crosshair.shadergraph.meta