gameplay所有基本功能都装了,加入了全局警告。加入飘字等各种东西。

This commit is contained in:
FloatGaming
2026-02-21 00:20:03 +08:00
parent 9f7c1c57b7
commit 14fb281d6f
254 changed files with 102927 additions and 9427 deletions
+175 -6
View File
@@ -2,6 +2,14 @@ using System;
using System.Collections.Generic;
using UnityEngine;
[Serializable]
public struct EnemyConfiguration
{
public int enemyID;
[Range(0, 100)]
public int hpPercentage;
}
[Serializable]
public class ChartFileEntry
{
@@ -12,6 +20,13 @@ public class ChartFileEntry
[Header("Inspector")]
public float enemyTotalHP_Multiplier;
[Header("Enemy Configuration")]
[Tooltip("List of enemy configurations for this difficulty (0-5 enemies)")]
public List<EnemyConfiguration> enemyConfigList = new List<EnemyConfiguration>();
// [Tooltip("List of enemy IDs for this difficulty (0-5 enemies)")]
// public List<int> enemyList = new List<int>(); // Deprecated
[Header("Inspector")]
public string difficultyName;
@@ -83,6 +98,8 @@ public class SongData : ScriptableObject
public List<ChartFileEntry> chartFiles = new List<ChartFileEntry>();
[NonSerialized] private Dictionary<int, List<long>> enemyConfigSignatureCache;
public int personalRecord;
public float current_levelProgress;
public bool _if_level_is_EASE;
@@ -98,16 +115,168 @@ public class SongData : ScriptableObject
[TextArea(3, 10)]
public string thisLevel_overallDescription;
[Header("Enemy Configuration")]
[Tooltip("List of enemy IDs for this song (0-5 enemies)")]
public List<int> enemyList = new List<int>();
// [Header("Enemy Configuration")]
// [Tooltip("DEPRECATED: Use enemyList in ChartFileEntry instead. List of enemy IDs for this song (0-5 enemies)")]
// public List<int> enemyList = new List<int>();
private void OnValidate()
{
if (enemyList != null && enemyList.Count > 5)
if (enemyConfigSignatureCache == null) enemyConfigSignatureCache = new Dictionary<int, List<long>>();
if (chartFiles != null)
{
enemyList.RemoveRange(5, enemyList.Count - 5);
Debug.LogWarning($"[SongData] {songName}: enemyList length restricted to a maximum of 5.");
foreach (var chart in chartFiles)
{
if (chart != null)
{
if (chart.enemyConfigList != null && chart.enemyConfigList.Count > 5)
{
chart.enemyConfigList.RemoveRange(5, chart.enemyConfigList.Count - 5);
Debug.LogWarning($"[SongData] {songName} (Difficulty {chart.difficulty}): enemyConfigList length restricted to a maximum of 5.");
}
if (chart.enemyConfigList != null && chart.enemyConfigList.Count > 0)
{
var activeIndices = new List<int>();
var currentSignature = new List<long>();
for (int i = 0; i < chart.enemyConfigList.Count; i++)
{
var c = chart.enemyConfigList[i];
if (c.enemyID == 0)
{
if (c.hpPercentage != 0)
{
c.hpPercentage = 0;
chart.enemyConfigList[i] = c;
}
currentSignature.Add(0L);
continue;
}
if (c.hpPercentage < 0) c.hpPercentage = 0;
if (c.hpPercentage > 100) c.hpPercentage = 100;
chart.enemyConfigList[i] = c;
activeIndices.Add(i);
currentSignature.Add(((long)c.enemyID << 32) | (uint)c.hpPercentage);
}
int activeCount = activeIndices.Count;
if (activeCount == 1)
{
int idx = activeIndices[0];
var c = chart.enemyConfigList[idx];
c.hpPercentage = 100;
chart.enemyConfigList[idx] = c;
}
else if (activeCount > 1)
{
int changedIndex = -1;
int changedEnemyID = 0;
if (enemyConfigSignatureCache.TryGetValue(chart.difficulty, out var oldSignature) &&
oldSignature != null &&
oldSignature.Count == currentSignature.Count)
{
for (int i = 0; i < currentSignature.Count; i++)
{
if (oldSignature[i] != currentSignature[i])
{
changedIndex = i;
changedEnemyID = chart.enemyConfigList[i].enemyID;
break;
}
}
}
int remainderIndex = activeIndices[activeIndices.Count - 1];
if (changedIndex >= 0)
{
int candidate = -1;
for (int i = activeIndices.Count - 1; i >= 0; i--)
{
int idx = activeIndices[i];
if (idx == changedIndex) continue;
if (chart.enemyConfigList[idx].enemyID != changedEnemyID) { candidate = idx; break; }
}
if (candidate == -1)
{
for (int i = activeIndices.Count - 1; i >= 0; i--)
{
int idx = activeIndices[i];
if (idx == changedIndex) continue;
candidate = idx;
break;
}
}
if (candidate != -1) remainderIndex = candidate;
}
int sumOthers = 0;
for (int i = 0; i < activeIndices.Count; i++)
{
int idx = activeIndices[i];
if (idx == remainderIndex) continue;
sumOthers += chart.enemyConfigList[idx].hpPercentage;
}
int overflow = sumOthers - 100;
if (overflow > 0)
{
for (int i = activeIndices.Count - 1; i >= 0 && overflow > 0; i--)
{
int idx = activeIndices[i];
if (idx == remainderIndex) continue;
if (idx == changedIndex) continue;
var c = chart.enemyConfigList[idx];
int reduce = Mathf.Min(overflow, c.hpPercentage);
if (reduce > 0)
{
c.hpPercentage -= reduce;
overflow -= reduce;
chart.enemyConfigList[idx] = c;
}
}
if (overflow > 0 && changedIndex >= 0 && changedIndex != remainderIndex)
{
var c = chart.enemyConfigList[changedIndex];
int reduce = Mathf.Min(overflow, c.hpPercentage);
if (reduce > 0)
{
c.hpPercentage -= reduce;
overflow -= reduce;
chart.enemyConfigList[changedIndex] = c;
}
}
}
sumOthers = 0;
for (int i = 0; i < activeIndices.Count; i++)
{
int idx = activeIndices[i];
if (idx == remainderIndex) continue;
sumOthers += chart.enemyConfigList[idx].hpPercentage;
}
int remainder = 100 - sumOthers;
if (remainder < 0) remainder = 0;
if (remainder > 100) remainder = 100;
var r = chart.enemyConfigList[remainderIndex];
r.hpPercentage = remainder;
chart.enemyConfigList[remainderIndex] = r;
}
currentSignature.Clear();
for (int i = 0; i < chart.enemyConfigList.Count; i++)
{
var c = chart.enemyConfigList[i];
if (c.enemyID == 0) currentSignature.Add(0L);
else currentSignature.Add(((long)c.enemyID << 32) | (uint)c.hpPercentage);
}
enemyConfigSignatureCache[chart.difficulty] = currentSignature;
}
}
}
}
}
+4 -4
View File
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using UnityEngine;
@@ -13,7 +13,7 @@ public class SongDataSerializable
public int max_comboRecord;
public int personalRecord;
public string dataHash; // 防篡改校验和
public List<int> enemyList = new List<int>();
// public List<int> enemyList = new List<int>(); // Deprecated and removed
// --- 字典映射表 (JsonUtility 不支持 Dictionary,需转为 List 存储) ---
[System.Serializable]
@@ -41,7 +41,7 @@ public class SongDataSerializable
this._if_level_is_EASE = source._if_level_is_EASE;
this.max_comboRecord = source.max_comboRecord;
this.personalRecord = source.personalRecord;
this.enemyList = new List<int>(source.enemyList);
// this.enemyList = new List<int>(source.enemyList); // Deprecated and removed
// 将字典转换为 List
this.difficultyNumberList = DictToList(source.difficultyNumberMap);
@@ -63,7 +63,7 @@ public class SongDataSerializable
target._if_level_is_EASE = this._if_level_is_EASE;
target.max_comboRecord = this.max_comboRecord;
target.personalRecord = this.personalRecord;
target.enemyList = new List<int>(this.enemyList);
// target.enemyList = new List<int>(this.enemyList); // Deprecated and removed
// 将 List 还原回字典
ListToDict(this.difficultyNumberList, target.difficultyNumberMap);