技能主要更新,修复卡顿并加入动画,以及各种其他更新。

This commit is contained in:
FloatGaming
2026-02-07 21:05:17 +08:00
parent abeca51be5
commit 1ac3cd0104
1349 changed files with 1526749 additions and 24850 deletions
@@ -5,33 +5,33 @@ public class Animation_GenerateJudgementSituationPrefab : MonoBehaviour
{
public static Animation_GenerateJudgementSituationPrefab Instance;
[Header("生成位置 (五个轨道)")]
[Header("λ ()")]
public GameObject redEffect;
public GameObject greenEffect;
public GameObject yellowEffect;
public GameObject purpleEffect;
public GameObject blueEffect;
[Header("判定飘字 Prefabs")]
[Header("жƮ Prefabs")]
public GameObject perfect_judge_prefab;
public GameObject great_judge_prefab;
public GameObject good_judge_prefab;
public GameObject miss_judge_prefab;
[Header("缩放与随机")]
[Header("")]
public float baseScale = 1.0f;
public bool useRandomScale = true;
public float minScaleMultiplier = 0.8f;
public float maxScaleMultiplier = 1.2f;
[Header("物理跳跃设置")]
public float jumpForce = 5.0f; // 向上弹起的初始速度
public float gravity = -12.0f; // 重力
[Header("Ծ")]
public float jumpForce = 5.0f; // ϵijʼٶ
public float gravity = -12.0f; //
[Header("时间与透明度控制 (秒)")]
public float fadeInTime = 0.1f; // 生成后多少秒完成渐显 (0->1)
public float fadeOutStartTime = 0.6f; // 生成后第几秒开始渐隐
public float fadeOutDuration = 0.3f; // 渐隐动画持续时长
[Header("ʱ͸ȿ ()")]
public float fadeInTime = 0.1f; // ɺɽ (0->1)
public float fadeOutStartTime = 0.6f; // ɺڼ뿪ʼ
public float fadeOutDuration = 0.3f; // ʱ
// Cache spawn transforms to avoid accessing destroyed GameObject references.
private Transform redSpawn;
@@ -48,8 +48,8 @@ public class Animation_GenerateJudgementSituationPrefab : MonoBehaviour
if (Instance == null)
{
Instance = this;
// 注意:仅当第一次创建时保留,允许重新加载
// DontDestroyOnLoad(gameObject); // ← 移除此行以允许场景重新加载时的清理
// עһδʱ¼
// DontDestroyOnLoad(gameObject); // Ƴ¼ʱ
}
else if (Instance != this)
{
@@ -73,7 +73,7 @@ public class Animation_GenerateJudgementSituationPrefab : MonoBehaviour
int currentSceneIndex = UnityEngine.SceneManagement.SceneManager.GetActiveScene().buildIndex;
if (currentSceneIndex != lastSceneIndex)
{
if (GameConfig.verboseLogs) Debug.Log($"[Animation_Generate] Scene changed detected (from {lastSceneIndex} to {currentSceneIndex}), refreshing spawn point cache");
if (JudgeManager.IsDebugEnabled) Debug.Log($"[Animation_Generate] Scene changed detected (from {lastSceneIndex} to {currentSceneIndex}), refreshing spawn point cache");
lastSceneIndex = currentSceneIndex;
CacheSpawnPoints();
}
@@ -111,7 +111,7 @@ public class Animation_GenerateJudgementSituationPrefab : MonoBehaviour
purpleSpawn = purpleEffect != null ? purpleEffect.transform : null;
blueSpawn = blueEffect != null ? blueEffect.transform : null;
if (GameConfig.verboseLogs)
if (JudgeManager.IsDebugEnabled)
{
Debug.Log($"[Animation_Generate] Cached spawn points: red={redSpawn!=null}, green={greenSpawn!=null}, yellow={yellowSpawn!=null}, purple={purpleSpawn!=null}, blue={blueSpawn!=null}");
}
@@ -145,17 +145,17 @@ public class Animation_GenerateJudgementSituationPrefab : MonoBehaviour
return;
}
if (GameConfig.verboseLogs) Debug.Log($"[Animation_Generate] Spawning judge prefab: color={color}, result={judgeResult}, prefab={prefabToUse.name}");
if (JudgeManager.IsDebugEnabled) Debug.Log($"[Animation_Generate] Spawning judge prefab: color={color}, result={judgeResult}, prefab={prefabToUse.name}");
GameObject instance = Instantiate(prefabToUse, spawnPoint);
instance.transform.localPosition = Vector3.zero;
// 处理缩放
//
float finalScale = baseScale;
if (useRandomScale) finalScale *= Random.Range(minScaleMultiplier, maxScaleMultiplier);
instance.transform.localScale = new Vector3(finalScale, finalScale, 1f);
// 开启运动逻辑
// ˶߼
StartCoroutine(AnimateSprite(instance));
}
@@ -168,10 +168,10 @@ public class Animation_GenerateJudgementSituationPrefab : MonoBehaviour
float vVelocity = jumpForce;
Vector3 currentLocalPos = Vector3.zero;
// 计算总生命周期:开始渐隐的时间 + 渐隐持续的时长
// ڣʼʱ + ʱ
float totalLifeTime = fadeOutStartTime + fadeOutDuration;
// 初始透明度
// ʼ͸
if (sr != null)
{
Color c = sr.color;
@@ -179,7 +179,7 @@ public class Animation_GenerateJudgementSituationPrefab : MonoBehaviour
sr.color = c;
}
// 只要没到总寿命,就持续执行
// ֻҪûͳִ
while (elapsed < totalLifeTime)
{
if (obj == null) yield break;
@@ -187,28 +187,28 @@ public class Animation_GenerateJudgementSituationPrefab : MonoBehaviour
float dt = Time.deltaTime;
elapsed += dt;
// --- 1. 物理位移 ---
// --- 1. λ ---
vVelocity += gravity * dt;
currentLocalPos.y += vVelocity * dt;
obj.transform.localPosition = currentLocalPos;
// --- 2. 透明度逻辑 (基于秒数) ---
// --- 2. ͸߼ () ---
if (sr != null)
{
float alpha;
// 渐显阶段:当前时间 < fadeInTime
// Խ׶Σǰʱ < fadeInTime
if (elapsed < fadeInTime)
{
alpha = Mathf.InverseLerp(0f, fadeInTime, elapsed);
}
// 渐隐阶段:当前时间 > fadeOutStartTime
// ׶Σǰʱ > fadeOutStartTime
else if (elapsed > fadeOutStartTime)
{
// fadeOutStartTime totalLifeTime 之间从 1 变到 0
// fadeOutStartTime totalLifeTime ֮ 1 0
alpha = Mathf.InverseLerp(totalLifeTime, fadeOutStartTime, elapsed);
}
// 中间完全显示阶段
// мȫʾ׶
else
{
alpha = 1f;
@@ -222,7 +222,7 @@ public class Animation_GenerateJudgementSituationPrefab : MonoBehaviour
yield return null;
}
// --- 确保最后一帧是完全透明的 ---
// --- ȷһ֡ȫ͸ ---
if (obj != null && sr != null)
{
Color c = sr.color;
@@ -230,7 +230,7 @@ public class Animation_GenerateJudgementSituationPrefab : MonoBehaviour
sr.color = c;
}
// 等待渲染完成,防止闪删
// ȴȾɣֹɾ
yield return new WaitForEndOfFrame();
if (obj != null) Destroy(obj);
@@ -240,7 +240,7 @@ public class Animation_GenerateJudgementSituationPrefab : MonoBehaviour
{
if (string.IsNullOrEmpty(color)) return null;
// 在每次调用时检查是否需要重新缓存
// ÿεʱǷҪ»
CacheSpawnPointsIfNeeded();
Transform point = null;