diff --git a/Assets/Scripts/SkyWalker/Skywalker_GameManager.cs b/Assets/Scripts/SkyWalker/Skywalker_GameManager.cs index d6381ff..9a51015 100644 --- a/Assets/Scripts/SkyWalker/Skywalker_GameManager.cs +++ b/Assets/Scripts/SkyWalker/Skywalker_GameManager.cs @@ -15,8 +15,8 @@ public class Skywalker_GameManager : MonoBehaviour [Header("Heaven Tween")] public float heavenHeight = 4f; // ascent height - public float ascendDuration = 2.5f; // ascent time - public float fadeDelay = 2.0f; // wait before fade (2–3s) + public float ascendDuration = 2.5f; // ascent time + public float fadeDelay = 2.0f; // wait before fade (2–3s) public float fadeDuration = 0.5f; // fade to 1 [Header("Material (AllIn1SpriteShader)")] @@ -27,23 +27,26 @@ public class Skywalker_GameManager : MonoBehaviour // AllIn1SpriteShader property IDs static readonly int ID_FadeAmount = Shader.PropertyToID("_FadeAmount"); static readonly int ID_FadeBurnWidth = Shader.PropertyToID("_FadeBurnWidth"); + static readonly int ID_GreyscaleBlend = Shader.PropertyToID("_GreyscaleBlend"); // <-- added + static readonly int ID_GhostBlend = Shader.PropertyToID("_GhostBlend"); // <-- added - // AllIn1SpriteShader keywords + // AllIn1SpriteShader keywords (kept; safe even if features are enabled on the asset) const string KW_FADE = "FADE_ON"; const string KW_GREYSCALE = "GREYSCALE_ON"; const string KW_GHOST = "GHOST_ON"; const string KW_OVERLAY = "OVERLAY_ON"; - const string KW_OVERLAYMULT = "OVERLAYMULT_ON"; // we'll keep this OFF unless you want multiply overlay + const string KW_OVERLAYMULT = "OVERLAYMULT_ON"; // store original keyword states so we can restore on disable bool origFade, origGrey, origGhost, origOverlay, origOverlayMult; Sequence deathSeq; + // --- Blueberry Glow Pulse (AllIn1SpriteShader) --- [Header("Blueberry Glow Pulse")] public Material glowMaterial; // optional: defaults to playerMaterial if null [Tooltip("Shader float property for glow intensity (AllIn1SpriteShader).")] - public string glowIntensityProp = "_GlowIntensity"; // change to your exact prop name if different + public string glowIntensityProp = "_Glow"; // <-- default corrected to _Glow public float glowBase = 1.75f; public float glowPeak = 7.75f; public float glowPulseDuration = 0.6f; // total time (up + down) @@ -51,6 +54,7 @@ public class Skywalker_GameManager : MonoBehaviour private Sequence glowSeq; private int _ID_GlowIntensity; private string _lastGlowPropName; + static readonly int ID_OverlayBlend = Shader.PropertyToID("_OverlayBlend"); void Awake() { @@ -62,6 +66,7 @@ public class Skywalker_GameManager : MonoBehaviour if (!glowMaterial) glowMaterial = playerMaterial; _ID_GlowIntensity = Shader.PropertyToID(glowIntensityProp); _lastGlowPropName = glowIntensityProp; + CacheOriginalKeywordStates(); } @@ -122,9 +127,11 @@ public class Skywalker_GameManager : MonoBehaviour rb.useGravity = false; rb.isKinematic = true; } + public void PulseBlueberryGlow() { if (!glowMaterial) return; + // Refresh property ID if you change the prop name in the Inspector if (_lastGlowPropName != glowIntensityProp || _ID_GlowIntensity == 0) { @@ -141,14 +148,8 @@ public class Skywalker_GameManager : MonoBehaviour float half = Mathf.Max(0.01f, glowPulseDuration * 0.5f); glowSeq = DOTween.Sequence().SetId("BlueberryGlow") - .Append(glowMaterial - .DOFloat(glowPeak, _ID_GlowIntensity, half) - .SetEase(Ease.OutQuad) - .SetId("BlueberryGlow")) - .Append(glowMaterial - .DOFloat(glowBase, _ID_GlowIntensity, half) - .SetEase(Ease.InQuad) - .SetId("BlueberryGlow")); + .Append(glowMaterial.DOFloat(glowPeak, _ID_GlowIntensity, half).SetEase(Ease.OutQuad).SetId("BlueberryGlow")) + .Append(glowMaterial.DOFloat(glowBase, _ID_GlowIntensity, half).SetEase(Ease.InQuad).SetId("BlueberryGlow")); glowSeq.Play(); } @@ -166,7 +167,7 @@ public class Skywalker_GameManager : MonoBehaviour BeginHeavenSequence(laserStyle: true); } - public void GameoverInvoker(int duration=5) + public void GameoverInvoker(int duration = 5) { CancelInvoke(nameof(GameoverPanelEnabler)); Invoke(nameof(GameoverPanelEnabler), duration); @@ -177,38 +178,41 @@ public class Skywalker_GameManager : MonoBehaviour if (gameOverPanel) gameOverPanel.SetActive(true); } - // -------- Tweens + Shader toggles -------- + // -------- Tweens + Shader toggles / values -------- void BeginHeavenSequence(bool laserStyle) { if (deathSeq != null && deathSeq.IsActive()) deathSeq.Kill(); if (playerMaterial) DOTween.Kill(playerMaterial); - // Enable FADE keyword for both styles if (playerMaterial) { playerMaterial.EnableKeyword(KW_FADE); - // Style-specific keywords if (laserStyle) { // Laser: Overlay + Ghost, NO Greyscale playerMaterial.DisableKeyword(KW_GREYSCALE); playerMaterial.EnableKeyword(KW_OVERLAY); - playerMaterial.DisableKeyword(KW_OVERLAYMULT); // keep overlay in normal blend; enable if you prefer multiply + playerMaterial.DisableKeyword(KW_OVERLAYMULT); playerMaterial.EnableKeyword(KW_GHOST); } else { - // Spikes: Greyscale + Ghost, NO Overlay + // Spikes: Greyscale + Ghost, NO Overlay (+ make sure OVERLAYMULT is OFF) playerMaterial.EnableKeyword(KW_GREYSCALE); playerMaterial.DisableKeyword(KW_OVERLAY); playerMaterial.DisableKeyword(KW_OVERLAYMULT); playerMaterial.EnableKeyword(KW_GHOST); } - // Make sure we start visible before fade + // Ensure visible before fade playerMaterial.SetFloat(ID_FadeAmount, -0.1f); if (!laserStyle) playerMaterial.SetFloat(ID_FadeBurnWidth, 0f); + + // Start blends from zero so tweens are visible + playerMaterial.SetFloat(ID_GreyscaleBlend, 0f); + playerMaterial.SetFloat(ID_GhostBlend, 0f); + playerMaterial.SetFloat(ID_OverlayBlend, 0f); } Vector3 endPos = player.transform.position + Vector3.up * heavenHeight; @@ -217,19 +221,42 @@ public class Skywalker_GameManager : MonoBehaviour if (laserStyle && playerMaterial) { - // Laser: widen burn first - deathSeq.Append(playerMaterial.DOFloat(1f, ID_FadeBurnWidth, 0.5f)); + // Start ALL laser visuals together: + // - BurnWidth widens (0.5s) + // - Ghost 0 -> 0.65 (0.35s) + // - Overlay 0 -> 1.0 (0.35s) + deathSeq.Append(playerMaterial.DOFloat(1f, ID_FadeBurnWidth, 0.5f)); // append first + deathSeq.Join(playerMaterial.DOFloat(0.65f, ID_GhostBlend, 0.35f).SetEase(Ease.OutQuad)); + deathSeq.Join(playerMaterial.DOFloat(1.0f, ID_OverlayBlend, 0.35f).SetEase(Ease.OutQuad)); + } + else if (playerMaterial) + { + // Spikes: Greyscale 0 -> 0.7, Ghost 0 -> 0.65 together + deathSeq.Join(playerMaterial.DOFloat(0.7f, ID_GreyscaleBlend, 0.35f).SetEase(Ease.OutQuad)); + deathSeq.Join(playerMaterial.DOFloat(0.65f, ID_GhostBlend, 0.35f).SetEase(Ease.OutQuad)); } // Float up like an angel deathSeq.Append(player.transform.DOMoveY(endPos.y, ascendDuration).SetEase(Ease.OutSine)); + // Wait before final fade deathSeq.AppendInterval(fadeDelay); // Final fade to 1 if (playerMaterial) - deathSeq.Append(playerMaterial.DOFloat(1f, ID_FadeAmount, fadeDuration)); - + { + if (laserStyle) + { + // Laser: fade out AND shrink burn width back to 0 at the same time + deathSeq.Append(playerMaterial.DOFloat(1f, ID_FadeAmount, fadeDuration)); + deathSeq.Join(playerMaterial.DOFloat(0f, ID_FadeBurnWidth, fadeDuration)); // <- new + } + else + { + // Spikes: just fade out + deathSeq.Append(playerMaterial.DOFloat(1f, ID_FadeAmount, fadeDuration)); + } + } deathSeq.Play(); } @@ -238,12 +265,15 @@ public class Skywalker_GameManager : MonoBehaviour { if (deathSeq != null && deathSeq.IsActive()) deathSeq.Kill(); DOTween.Kill(playerMaterial); - + playerMaterial.SetFloat(ID_OverlayBlend, 0f); if (playerMaterial) { // revert fade values playerMaterial.SetFloat(ID_FadeAmount, 0f); playerMaterial.SetFloat(ID_FadeBurnWidth, 0f); + // revert blends + playerMaterial.SetFloat(ID_GreyscaleBlend, 0f); + playerMaterial.SetFloat(ID_GhostBlend, 0f); // restore original keywords SetKeyword(playerMaterial, KW_FADE, origFade); @@ -256,7 +286,6 @@ public class Skywalker_GameManager : MonoBehaviour if (glowSeq != null && glowSeq.IsActive()) glowSeq.Kill(); DOTween.Kill("BlueberryGlow"); if (glowMaterial) glowMaterial.SetFloat(_ID_GlowIntensity, glowBase); - } static void SetKeyword(Material m, string keyword, bool enabled) diff --git a/Assets/Testable Assets/m_Zibu.mat b/Assets/Testable Assets/m_Zibu.mat index add1640..97af60e 100644 --- a/Assets/Testable Assets/m_Zibu.mat +++ b/Assets/Testable Assets/m_Zibu.mat @@ -13,9 +13,12 @@ Material: m_ModifiedSerializedProperties: 0 m_ValidKeywords: - FADE_ON + - GHOST_ON - GLOWTEX_ON - GLOW_ON - GREYSCALEOUTLINE_ON + - GREYSCALE_ON + - OVERLAY_ON m_InvalidKeywords: - _GREYSCALEOUTLINE_ON m_LightmapFlags: 4 @@ -149,14 +152,14 @@ Material: - _DstBlend: 0 - _EditorDrawers: 6 - _FadeAmount: 0 - - _FadeBurnGlow: 3 + - _FadeBurnGlow: 1 - _FadeBurnTransition: 0.01 - _FadeBurnWidth: 0 - _FishEyeUvAmount: 0.35 - _FlickerAlpha: 0 - _FlickerFreq: 0.2 - _FlickerPercent: 0.05 - - _GhostBlend: 0.524 + - _GhostBlend: 0 - _GhostColorBoost: 5 - _GhostTransparency: 1 - _GlitchAmount: 3 @@ -175,8 +178,8 @@ Material: - _GrassRadialBend: 0.1 - _GrassSpeed: 2 - _GrassWind: 20 - - _GreyscaleBlend: 1 - - _GreyscaleLuminosity: 1 + - _GreyscaleBlend: 0 + - _GreyscaleLuminosity: 0.7 - _GreyscaleOutline: 1 - _HandDrawnAmount: 10 - _HandDrawnSpeed: 5 @@ -219,8 +222,8 @@ Material: - _OutlineTexXSpeed: 10 - _OutlineTexYSpeed: 0 - _OutlineWidth: 0.004 - - _OverlayBlend: 1 - - _OverlayGlow: 5.8 + - _OverlayBlend: 0 + - _OverlayGlow: 3.9 - _Parallax: 0.02 - _PinchUvAmount: 0.35 - _PixelateSize: 32 diff --git a/ProjectSettings/ProjectSettings.asset b/ProjectSettings/ProjectSettings.asset index 5e6b032..fa84002 100644 --- a/ProjectSettings/ProjectSettings.asset +++ b/ProjectSettings/ProjectSettings.asset @@ -47,7 +47,7 @@ PlayerSettings: defaultScreenWidthWeb: 960 defaultScreenHeightWeb: 600 m_StereoRenderingPath: 0 - m_ActiveColorSpace: 1 + m_ActiveColorSpace: 0 unsupportedMSAAFallback: 0 m_SpriteBatchVertexThreshold: 300 m_MTRendering: 1 @@ -536,7 +536,7 @@ PlayerSettings: m_Automatic: 1 - m_BuildTarget: WebGLSupport m_APIs: 0b000000 - m_Automatic: 1 + m_Automatic: 0 m_BuildTargetVRSettings: - m_BuildTarget: Standalone m_Enabled: 0 @@ -828,7 +828,7 @@ PlayerSettings: webGLWasmArithmeticExceptions: 0 webGLLinkerTarget: 1 webGLThreadsSupport: 0 - webGLDecompressionFallback: 0 + webGLDecompressionFallback: 1 webGLInitialMemorySize: 32 webGLMaximumMemorySize: 2048 webGLMemoryGrowthMode: 2