超大量的更新 修复很多问题,gameplay特效初步

This commit is contained in:
FloatGaming
2026-02-14 23:46:20 +08:00
parent ef8eb67259
commit 3a7a0b4669
360 changed files with 85670 additions and 4144 deletions
+60 -44
View File
@@ -1,4 +1,4 @@
using System.Collections.Generic;
using System.Collections.Generic;
using UnityEngine;
using GamePlay; // for PoolItem
using System.Collections;
@@ -7,10 +7,10 @@ public class NotePool : MonoBehaviour
{
public static NotePool Instance { get; private set; }
public GameObject[] notePrefabs; // Ԥɫ
public GameObject[] holdNotePrefabs; // ƬԤ
public GameObject[] holdNoteEndPrefabs; // βרóԤѡ
public GameObject[] startNotePrefabs; // startƬԤ
public GameObject[] notePrefabs; // Documentation text normalized.
public GameObject[] holdNotePrefabs; // Documentation text normalized.
public GameObject[] holdNoteEndPrefabs; // Documentation text normalized.
public GameObject[] startNotePrefabs; // Documentation text normalized.
[Header("Pool Size")]
public int poolSize = 24;
@@ -20,20 +20,19 @@ public class NotePool : MonoBehaviour
[Tooltip("Multiplier for hold end pool size (per color).")]
public int holdEndPoolMultiplier = 8;
// ɫĿӳÿ switch
// Documentation text normalized.
private Dictionary<string, int> colorIndexMap;
private Dictionary<int, Stack<GameObject>> notePools; //
private Dictionary<int, Stack<GameObject>> holdNotePools; // Ƭζ
private Dictionary<int, Stack<GameObject>> holdNoteEndPools; // β
private Dictionary<int, Stack<GameObject>> startNotePools; // startƬζ
// ڲ㼶֯еĶ󣬱ڵԺ͹
private Dictionary<int, Stack<GameObject>> notePools; // Documentation text normalized.
private Dictionary<int, Stack<GameObject>> holdNotePools;
private Dictionary<int, Stack<GameObject>> holdNoteEndPools;
private Dictionary<int, Stack<GameObject>> startNotePools;
// Documentation text normalized.
private Transform notePoolContainer;
private Transform holdPoolContainer;
private Transform startPoolContainer;
// ƵĬϹر
[Header("Debug")]
public bool verboseLogging = false;
[Header("Prewarm Settings")]
@@ -61,7 +60,7 @@ public class NotePool : MonoBehaviour
return;
}
// ʼɫӳ
// Documentation text normalized.
colorIndexMap = new Dictionary<string, int>
{
{ "red", 0 },
@@ -71,7 +70,7 @@ public class NotePool : MonoBehaviour
{ "blue", 4 }
};
//
// Documentation text normalized.
notePoolContainer = new GameObject("_NotePool_Notes").transform;
notePoolContainer.SetParent(transform, false);
holdPoolContainer = new GameObject("_NotePool_HoldSegments").transform;
@@ -195,16 +194,15 @@ public class NotePool : MonoBehaviour
GameObject obj = pool.Pop();
if (obj == null)
{
// жѱ٣
obj = InstantiateAndPrepare(prefab);
// Documentation text normalized.
}
else
{
// Żʹ PoolItem ʶǷͬһ prefab
// Documentation text normalized.
GamePlay.PoolItem pi = obj.GetComponent<GamePlay.PoolItem>();
if (pi == null || prefab == null || pi.prefabName != prefab.name)
{
// ٴ͵Ķ滻Ϊȷ prefab ʵ
// Documentation text normalized.
if (pi == null && verboseLogging) Debug.LogWarning("PoolItem missing on pooled object, replacing.");
Destroy(obj);
obj = InstantiateAndPrepare(prefab);
@@ -215,13 +213,20 @@ public class NotePool : MonoBehaviour
// mark as taken from pool
GamePlay.PoolItem takenPi = obj.GetComponent<GamePlay.PoolItem>();
if (takenPi != null) takenPi.inPool = false;
if (takenPi != null)
{
takenPi.inPool = false;
if (takenPi.initialLocalScaleCaptured)
{
obj.transform.localScale = takenPi.initialLocalScale;
}
}
return obj;
}
else
{
// ؿʱֱʵ
// Documentation text normalized.
GameObject obj = InstantiateAndPrepare(prefab);
obj.SetActive(true);
return obj;
@@ -236,12 +241,17 @@ public class NotePool : MonoBehaviour
if (pi == null) pi = obj.AddComponent<GamePlay.PoolItem>();
pi.prefabName = prefab.name;
pi.inPool = false;
if (!pi.initialLocalScaleCaptured)
{
pi.initialLocalScale = obj.transform.localScale;
pi.initialLocalScaleCaptured = true;
}
return obj;
}
private void ReturnObjectToPool(Stack<GameObject> pool, GameObject obj, Transform container)
{
if (obj == null || pool == null) return; // ֹ
if (obj == null || pool == null) return; // Documentation text normalized.
// Defensive: unregister/unlock any TrackKeyManager state referencing this object to avoid stale queues/locks
try
@@ -271,21 +281,29 @@ public class NotePool : MonoBehaviour
}
catch { }
// ظڳڣֱӺ
// Documentation text normalized.
GamePlay.PoolItem pi = obj.GetComponent<GamePlay.PoolItem>();
if (pi == null)
{
pi = obj.AddComponent<GamePlay.PoolItem>();
}
if (!pi.initialLocalScaleCaptured)
{
pi.initialLocalScale = obj.transform.localScale;
pi.initialLocalScaleCaptured = true;
}
if (pi != null && pi.inPool) return;
// ƶñ任
// Documentation text normalized.
obj.transform.SetParent(container, false);
obj.transform.localPosition = Vector3.zero;
obj.transform.localRotation = Quaternion.identity;
obj.transform.localScale = Vector3.one;
obj.transform.localScale = pi.initialLocalScaleCaptured ? pi.initialLocalScale : obj.transform.localScale;
// ΪǼ״̬Ա㸴
// Documentation text normalized.
obj.SetActive(false);
// Ϊڳ
if (pi != null) pi.inPool = true;
// Documentation text normalized.
if (pool.Count < maxPoolSize)
{
@@ -293,7 +311,7 @@ public class NotePool : MonoBehaviour
}
else
{
// ٶԽʡڴ
// Documentation text normalized.
Destroy(obj);
}
}
@@ -308,6 +326,11 @@ public class NotePool : MonoBehaviour
GamePlay.PoolItem pi = obj.GetComponent<GamePlay.PoolItem>() ?? obj.AddComponent<GamePlay.PoolItem>();
pi.prefabName = prefab.name;
pi.inPool = true;
if (!pi.initialLocalScaleCaptured)
{
pi.initialLocalScale = obj.transform.localScale;
pi.initialLocalScaleCaptured = true;
}
obj.SetActive(false);
pool.Push(obj);
@@ -332,7 +355,6 @@ public class NotePool : MonoBehaviour
return GetObjectFromPool(holdNotePools[colorIndex], holdNotePrefabs[colorIndex], holdPoolContainer);
}
// βרóػȡβƬΣδβԤ򽵼ΪжΣ
public GameObject GetHoldNoteEndSegment(string color)
{
int colorIndex = GetColorIndexFromName(color);
@@ -359,7 +381,7 @@ public class NotePool : MonoBehaviour
if (startNote == null) return;
if (string.IsNullOrEmpty(color))
{
if (verboseLogging) Debug.LogWarning($" StartNote ʱ color Ϊգ: {startNote.name}");
if (verboseLogging) Debug.LogWarning($"归还 StartNote color 为空或无效: {startNote.name}");
Destroy(startNote);
return;
}
@@ -367,20 +389,20 @@ public class NotePool : MonoBehaviour
HoldNote holdNote = startNote.GetComponent<HoldNote>();
if (holdNote != null)
{
holdNote.ResetState(); // ȷ״̬
holdNote.ResetState(); // Documentation text normalized.
}
int idx = GetColorIndexFromName(color);
ReturnObjectToPool(startNotePools[idx], startNote, startPoolContainer);
}
// 黹βƬ
// Documentation text normalized.
public void ReturnHoldNoteEndSegment(GameObject holdNoteEnd, string color)
{
if (holdNoteEnd == null) return;
if (string.IsNullOrEmpty(color))
{
if (verboseLogging) Debug.LogWarning($" HoldNoteEndSegment ʱ color Ϊգ: {holdNoteEnd.name}");
if (verboseLogging) Debug.LogWarning($"归还 HoldNoteEndSegment color 为空或无效: {holdNoteEnd.name}");
Destroy(holdNoteEnd);
return;
}
@@ -388,7 +410,7 @@ public class NotePool : MonoBehaviour
HoldNote holdNoteScript = holdNoteEnd.GetComponent<HoldNote>();
if (holdNoteScript != null)
{
holdNoteScript.ResetState(); // ȷ״̬
holdNoteScript.ResetState(); // Documentation text normalized.
}
int idx = GetColorIndexFromName(color);
@@ -400,7 +422,7 @@ public class NotePool : MonoBehaviour
if (holdNote == null) return;
if (string.IsNullOrEmpty(color))
{
if (verboseLogging) Debug.LogWarning($" HoldNoteSegment ʱ color Ϊգ: {holdNote.name}");
if (verboseLogging) Debug.LogWarning($"归还 HoldNoteSegment color 为空或无效: {holdNote.name}");
Destroy(holdNote);
return;
}
@@ -408,7 +430,7 @@ public class NotePool : MonoBehaviour
HoldNote holdNoteScript = holdNote.GetComponent<HoldNote>();
if (holdNoteScript != null)
{
holdNoteScript.ResetState(); // ȷ״̬
holdNoteScript.ResetState(); // Documentation text normalized.
}
int idx = GetColorIndexFromName(color);
@@ -419,13 +441,7 @@ public class NotePool : MonoBehaviour
{
if (string.IsNullOrEmpty(colorName)) return 0;
if (colorIndexMap != null && colorIndexMap.TryGetValue(colorName, out int idx)) return idx;
if (verboseLogging) Debug.LogError($"δʶɫ: {colorName}Ĭʹúɫ");
if (verboseLogging) Debug.LogError($"未识别颜色名: {colorName},默认使用红色");
return 0;
}
}
public class PoolItem : MonoBehaviour
{
public string prefabName;
public bool inPool;
}