From 2fca6a67a524fa6a54cd42f7be1e9be4a1151ff5 Mon Sep 17 00:00:00 2001 From: RaffyTaffy14 Date: Sun, 7 Apr 2024 00:46:55 -0400 Subject: [PATCH] Stomp Camera Shake The way it is coded is not good at all, but the stomp shakes look *ok* when the game runs at triple digit tempos. --- Assets/Resources/Games/sumoBrothers.prefab | 4 + .../Prefabs/GameView/GameTex.renderTexture | 4 +- .../Prefabs/GameView/OverlayTex.renderTexture | 4 +- .../Sprites/Games/SumoBrothers/confetti.png | Bin 0 -> 126 bytes .../Games/SumoBrothers/confetti.png.meta | 167 ++++++++++++++++++ .../Games/SumoBrothers/SumoBrothers.cs | 43 +++++ 6 files changed, 218 insertions(+), 4 deletions(-) create mode 100644 Assets/Resources/Sprites/Games/SumoBrothers/confetti.png create mode 100644 Assets/Resources/Sprites/Games/SumoBrothers/confetti.png.meta diff --git a/Assets/Resources/Games/sumoBrothers.prefab b/Assets/Resources/Games/sumoBrothers.prefab index 05c52c549..e3d4e44dc 100644 --- a/Assets/Resources/Games/sumoBrothers.prefab +++ b/Assets/Resources/Games/sumoBrothers.prefab @@ -2227,6 +2227,10 @@ MonoBehaviour: dust: {fileID: 0} bgMove: {fileID: 907213061987012567} bgStatic: {fileID: 8786252013339787948} + camera: {fileID: 7621216590368296269} + cameraX: 0 + cameraXNew: 0 + stompShakeSpeed: 0.65 --- !u!1 &2594614983758801598 GameObject: m_ObjectHideFlags: 0 diff --git a/Assets/Resources/Prefabs/GameView/GameTex.renderTexture b/Assets/Resources/Prefabs/GameView/GameTex.renderTexture index 8c4b7c141..196a0b375 100644 --- a/Assets/Resources/Prefabs/GameView/GameTex.renderTexture +++ b/Assets/Resources/Prefabs/GameView/GameTex.renderTexture @@ -14,8 +14,8 @@ RenderTexture: m_DownscaleFallback: 0 m_IsAlphaChannelOptional: 0 serializedVersion: 5 - m_Width: 1057 - m_Height: 595 + m_Width: 579 + m_Height: 326 m_AntiAliasing: 2 m_MipCount: -1 m_DepthStencilFormat: 92 diff --git a/Assets/Resources/Prefabs/GameView/OverlayTex.renderTexture b/Assets/Resources/Prefabs/GameView/OverlayTex.renderTexture index 0adc9aee6..383352918 100644 --- a/Assets/Resources/Prefabs/GameView/OverlayTex.renderTexture +++ b/Assets/Resources/Prefabs/GameView/OverlayTex.renderTexture @@ -14,8 +14,8 @@ RenderTexture: m_DownscaleFallback: 0 m_IsAlphaChannelOptional: 0 serializedVersion: 5 - m_Width: 1585 - m_Height: 892 + m_Width: 868 + m_Height: 489 m_AntiAliasing: 1 m_MipCount: -1 m_DepthStencilFormat: 92 diff --git a/Assets/Resources/Sprites/Games/SumoBrothers/confetti.png b/Assets/Resources/Sprites/Games/SumoBrothers/confetti.png new file mode 100644 index 0000000000000000000000000000000000000000..15e8db7c56168f3e96cc03f25d51a0467fac961b GIT binary patch literal 126 zcmeAS@N?(olHy`uVBq!ia0vp^Od!m`1|*BN@u~nR#^NA%Cx&(BWL^R}Ea{HEjtmSN z`?>!lvI6;>1s;*b3=DjSL74G){)!Z!ps=TlV~9j}@*jQ{9-bbafCC2@7;HZ>|5pge R@C8aUc)I$ztaD0e0su5)9ZvuN literal 0 HcmV?d00001 diff --git a/Assets/Resources/Sprites/Games/SumoBrothers/confetti.png.meta b/Assets/Resources/Sprites/Games/SumoBrothers/confetti.png.meta new file mode 100644 index 000000000..a6a38f139 --- /dev/null +++ b/Assets/Resources/Sprites/Games/SumoBrothers/confetti.png.meta @@ -0,0 +1,167 @@ +fileFormatVersion: 2 +guid: e0dc0a4e87c7b2e45b72b9dcbf572333 +TextureImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 12 + mipmaps: + mipMapMode: 0 + enableMipMap: 0 + sRGBTexture: 1 + linearTexture: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapsPreserveCoverage: 0 + alphaTestReferenceValue: 0.5 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + streamingMipmaps: 0 + streamingMipmapsPriority: 0 + vTOnly: 0 + ignoreMasterTextureLimit: 0 + grayScaleToAlpha: 0 + generateCubemap: 6 + cubemapConvolution: 0 + seamlessCubemap: 0 + textureFormat: 1 + maxTextureSize: 2048 + textureSettings: + serializedVersion: 2 + filterMode: 0 + aniso: 1 + mipBias: 0 + wrapU: 1 + wrapV: 1 + wrapW: 1 + nPOTScale: 0 + lightmap: 0 + compressionQuality: 50 + spriteMode: 2 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spritePixelsToUnits: 100 + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spriteGenerateFallbackPhysicsShape: 1 + alphaUsage: 1 + alphaIsTransparency: 1 + spriteTessellationDetail: -1 + textureType: 8 + textureShape: 1 + singleChannelComponent: 0 + flipbookRows: 1 + flipbookColumns: 1 + maxTextureSizeSet: 0 + compressionQualitySet: 0 + textureFormatSet: 0 + ignorePngGamma: 0 + applyGammaDecoding: 0 + cookieLightType: 0 + platformSettings: + - serializedVersion: 3 + buildTarget: DefaultTexturePlatform + maxTextureSize: 32 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 2 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + - serializedVersion: 3 + buildTarget: Standalone + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + - serializedVersion: 3 + buildTarget: Server + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + spriteSheet: + serializedVersion: 2 + sprites: + - serializedVersion: 2 + name: white + rect: + serializedVersion: 2 + x: 0 + y: 1 + width: 1 + height: 1 + alignment: 0 + pivot: {x: 0, y: 0} + border: {x: 0, y: 0, z: 0, w: 0} + outline: [] + physicsShape: [] + tessellationDetail: 0 + bones: [] + spriteID: 7e4d1742bcf695d4e862bb35060d7320 + internalID: -700379706 + vertices: [] + indices: + edges: [] + weights: [] + - serializedVersion: 2 + name: yellow + rect: + serializedVersion: 2 + x: 1 + y: 1 + width: 1 + height: 1 + alignment: 0 + pivot: {x: 0, y: 0} + border: {x: 0, y: 0, z: 0, w: 0} + outline: [] + physicsShape: [] + tessellationDetail: 0 + bones: [] + spriteID: cb9f0e1e2a778fc488444d9b37f84053 + internalID: 632254773 + vertices: [] + indices: + edges: [] + weights: [] + outline: [] + physicsShape: [] + bones: [] + spriteID: 5e97eb03825dee720800000000000000 + internalID: 0 + vertices: [] + indices: + edges: [] + weights: [] + secondaryTextures: [] + nameFileIdTable: + white: -700379706 + yellow: 632254773 + spritePackingTag: + pSDRemoveMatte: 0 + pSDShowRemoveMatteOption: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Games/SumoBrothers/SumoBrothers.cs b/Assets/Scripts/Games/SumoBrothers/SumoBrothers.cs index 0ae1d0489..422c5c3bb 100644 --- a/Assets/Scripts/Games/SumoBrothers/SumoBrothers.cs +++ b/Assets/Scripts/Games/SumoBrothers/SumoBrothers.cs @@ -155,6 +155,13 @@ namespace HeavenStudio.Games public int poseBG; }*/ + [SerializeField] private Transform camera; + public float cameraX = 0f; + public float cameraXNew = 0f; + private double justStompBeat; + private double stompShakeLength; + public double stompShakeSpeed; + private bool goBopSumo; private bool goBopInu; @@ -294,6 +301,8 @@ namespace HeavenStudio.Games sumoBrotherPHead.DoScaledAnimationAsync("SumoPMiss"); } } + + StompShake(); } public override void OnGameSwitch(double beat) // stole code from manzai @@ -839,6 +848,8 @@ namespace HeavenStudio.Games void StompHit(PlayerActionEvent caller, float state) { + justStompBeat = Conductor.instance.songPositionInBeatsAsDouble; + if (state >= 1f || state <= -1f) { SoundByte.PlayOneShotGame("sumoBrothers/tink"); @@ -856,6 +867,24 @@ namespace HeavenStudio.Games } else { sumoBrotherP.DoScaledAnimationAsync("SumoStompR", 0.5f); } + + BeatAction.New(instance, new List() { + new BeatAction.Action(justStompBeat, delegate { stompShakeLength = 0.13; }), + new BeatAction.Action(justStompBeat, delegate { cameraXNew = -0.2f; }), + new BeatAction.Action(justStompBeat + 0.2, delegate { stompShakeLength = 0.25; }), + new BeatAction.Action(justStompBeat + 0.2, delegate { cameraX = cameraXNew; }), + new BeatAction.Action(justStompBeat + 0.2, delegate { cameraXNew = 0.2f; }), + new BeatAction.Action(justStompBeat + 0.4, delegate { stompShakeLength = 0.25; }), + new BeatAction.Action(justStompBeat + 0.4, delegate { cameraX = cameraXNew; }), + new BeatAction.Action(justStompBeat + 0.4, delegate { cameraXNew = -0.1f; }), + new BeatAction.Action(justStompBeat + 0.6, delegate { stompShakeLength = 0.25; }), + new BeatAction.Action(justStompBeat + 0.6, delegate { cameraX = cameraXNew; }), + new BeatAction.Action(justStompBeat + 0.6, delegate { cameraXNew = 0.05f; }), + new BeatAction.Action(justStompBeat + 0.8, delegate { stompShakeLength = 0.12; }), + new BeatAction.Action(justStompBeat + 0.8, delegate { cameraX = cameraXNew; }), + new BeatAction.Action(justStompBeat + 0.8, delegate { cameraXNew = 0f; }), + new BeatAction.Action(justStompBeat + 1, delegate { cameraX = cameraXNew; }), + }); /*BeatAction.New(instance, new List() { new BeatAction.Action(beat, delegate { allowBopInu = false; }), @@ -887,5 +916,19 @@ namespace HeavenStudio.Games void Nothing(PlayerActionEvent caller) { } + void StompShake() + { + float normalizedBeat = Conductor.instance.GetPositionFromBeat(justStompBeat, stompShakeSpeed); + + if (1.2f >= normalizedBeat) + { + EasingFunction.Function func = EasingFunction.GetEasingFunction(EasingFunction.Ease.EaseInOutQuad); + float newPosX = func(cameraX, cameraXNew, normalizedBeat); + camera.position = new Vector3(newPosX, 0, 0); + print("cX: " + cameraX + " cXN: " + cameraXNew + "nPX: " + newPosX + "sSL: " + stompShakeLength); + } + } + + } }