特效新内容。修复gameplay致命bug和分数保存bug

This commit is contained in:
2026-02-16 01:55:18 +08:00
parent 3a7a0b4669
commit 9f7c1c57b7
206 changed files with 112684 additions and 857 deletions
@@ -1,4 +1,4 @@
using System.IO;
using System.IO;
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
@@ -204,18 +204,18 @@ public class GameManager : MonoBehaviour
try
{
// Reset audio time to 0 before playing to ensure playback starts from the beginning
musicSource.time = 0f;
float startTime = 0f;
if (delaySeconds < 0f)
startTime = -delaySeconds;
if (delaySeconds > 0f)
{
// Use coroutine instead of PlayDelayed so pause state can interrupt it
playbackDelayCoroutine = StartCoroutine(DelayAndPlayMusic(delaySeconds));
}
else
{
// Immediate playback (no delay)
musicSource.time = 0f;
float clampedStartTime = ClampAudioStartTime(startTime);
musicSource.time = clampedStartTime;
musicSource.Play();
PlaybackStarted = true;
Debug.Log("GameManager.PlayMusicWithDelay: Music playback started immediately (no delay)");
@@ -226,7 +226,8 @@ public class GameManager : MonoBehaviour
Debug.LogWarning($"PlayMusicWithDelay failed: {ex}");
try
{
musicSource.time = 0f;
float clampedStartTime = ClampAudioStartTime(delaySeconds < 0f ? -delaySeconds : 0f);
musicSource.time = clampedStartTime;
musicSource.Play();
PlaybackStarted = true;
}
@@ -234,6 +235,14 @@ public class GameManager : MonoBehaviour
}
}
private float ClampAudioStartTime(float startTime)
{
if (musicSource == null || musicSource.clip == null)
return Mathf.Max(0f, startTime);
return Mathf.Clamp(startTime, 0f, musicSource.clip.length);
}
private IEnumerator DelayAndPlayMusic(float delaySeconds)
{
Debug.Log($"GameManager.DelayAndPlayMusic: waiting {delaySeconds} seconds before playing (respects pause state)");