超大量的更新 修复很多问题,gameplay特效初步
This commit is contained in:
@@ -1,107 +1,97 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
[Serializable]
|
||||
public class SongDataSerializable
|
||||
{
|
||||
public string usernameID;
|
||||
public string songName;
|
||||
public int songID;
|
||||
public int songLength_second;
|
||||
public string artistName;
|
||||
public string painter;
|
||||
public string level_creator;
|
||||
public string belongsTo_whichDLC;
|
||||
|
||||
public int bpm;
|
||||
public float songDuration;
|
||||
|
||||
// --- 动态变动数据 (需要存储) ---
|
||||
public int game_enterTimes;
|
||||
public float time_totalPlayingTime;
|
||||
public string uploadData;
|
||||
|
||||
public int difficultyID;
|
||||
public float current_levelProgress;
|
||||
public bool _if_level_is_EASE;
|
||||
public int max_comboRecord;
|
||||
public int personalRecord;
|
||||
public string dataHash; // 防篡改校验和
|
||||
public List<int> enemyList = new List<int>();
|
||||
|
||||
public int personalRecord; // �洢����߷� (���˷� + ż���)
|
||||
public Dictionary<int, int> difficultyNumberMap = new Dictionary<int, int>();
|
||||
public Dictionary<int, int> personalRecordMap = new Dictionary<int, int>();
|
||||
public Dictionary<int, int> idolRecordMap = new Dictionary<int, int>();
|
||||
public Dictionary<int, int> chartScoreMap = new Dictionary<int, int>();
|
||||
public Dictionary<int, string> chartFileMap = new Dictionary<int, string>();
|
||||
|
||||
public SongDataSerializable(SongData songData)
|
||||
// --- 字典映射表 (JsonUtility 不支持 Dictionary,需转为 List 存储) ---
|
||||
[System.Serializable]
|
||||
public struct IntIntEntry
|
||||
{
|
||||
usernameID = songData.usernameID;
|
||||
songName = songData.songName;
|
||||
songID = songData.songID;
|
||||
songLength_second = songData.songLength_second;
|
||||
artistName = songData.artistName;
|
||||
painter = songData.painter;
|
||||
level_creator = songData.level_creator;
|
||||
belongsTo_whichDLC = songData.belongsTo_whichDLC;
|
||||
|
||||
bpm = songData.bpm;
|
||||
songDuration = songData.songDuration;
|
||||
|
||||
game_enterTimes = songData.game_enterTimes;
|
||||
time_totalPlayingTime = songData.time_totalPlayingTime;
|
||||
uploadData = songData.uploadData.ToString();
|
||||
|
||||
difficultyID = songData.difficultyID;
|
||||
current_levelProgress = songData.current_levelProgress;
|
||||
_if_level_is_EASE = songData._if_level_is_EASE;
|
||||
max_comboRecord = songData.max_comboRecord;
|
||||
|
||||
difficultyNumberMap = songData.difficultyNumberMap;
|
||||
personalRecordMap = songData.personalRecordMap;
|
||||
idolRecordMap = songData.idolRecordMap;
|
||||
chartScoreMap = songData.chartScoreMap;
|
||||
personalRecord = songData.personalRecord; // �洢�ۺ���߷�
|
||||
|
||||
chartFileMap = new Dictionary<int, string>();
|
||||
/*foreach (var kvp in songData.chartFileMap)
|
||||
{
|
||||
if (songData.chartFileMap == null) return;
|
||||
chartFileMap[kvp.Key] = kvp.Value ? kvp.Value.name : "";
|
||||
}*/
|
||||
public int key;
|
||||
public int value;
|
||||
}
|
||||
|
||||
public void ApplyTo(SongData songData)
|
||||
public List<IntIntEntry> difficultyNumberList = new List<IntIntEntry>();
|
||||
public List<IntIntEntry> personalRecordList = new List<IntIntEntry>();
|
||||
public List<IntIntEntry> idolRecordList = new List<IntIntEntry>();
|
||||
public List<IntIntEntry> chartScoreList = new List<IntIntEntry>();
|
||||
|
||||
public SongDataSerializable() { }
|
||||
|
||||
public SongDataSerializable(SongData source)
|
||||
{
|
||||
songData.usernameID = usernameID;
|
||||
songData.songName = songName;
|
||||
songData.songID = songID;
|
||||
songData.songLength_second = songLength_second;
|
||||
songData.artistName = artistName;
|
||||
songData.painter = painter;
|
||||
songData.level_creator = level_creator;
|
||||
songData.belongsTo_whichDLC = belongsTo_whichDLC;
|
||||
if (source == null) return;
|
||||
|
||||
songData.bpm = bpm;
|
||||
songData.songDuration = songDuration;
|
||||
// 提取动态数据
|
||||
this.game_enterTimes = source.game_enterTimes;
|
||||
this.time_totalPlayingTime = source.time_totalPlayingTime;
|
||||
this.current_levelProgress = source.current_levelProgress;
|
||||
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);
|
||||
|
||||
songData.game_enterTimes = game_enterTimes;
|
||||
songData.time_totalPlayingTime = time_totalPlayingTime;
|
||||
songData.uploadData = DateTime.Parse(uploadData);
|
||||
// 将字典转换为 List
|
||||
this.difficultyNumberList = DictToList(source.difficultyNumberMap);
|
||||
this.personalRecordList = DictToList(source.personalRecordMap);
|
||||
this.idolRecordList = DictToList(source.idolRecordMap);
|
||||
this.chartScoreList = DictToList(source.chartScoreMap);
|
||||
}
|
||||
|
||||
songData.difficultyID = difficultyID;
|
||||
songData.current_levelProgress = current_levelProgress;
|
||||
songData._if_level_is_EASE = _if_level_is_EASE;
|
||||
songData.max_comboRecord = max_comboRecord;
|
||||
/// <summary>
|
||||
/// 将序列化的动态数据应用回 SongData SO。
|
||||
/// </summary>
|
||||
public void ApplyTo(SongData target)
|
||||
{
|
||||
if (target == null) return;
|
||||
|
||||
songData.difficultyNumberMap = difficultyNumberMap;
|
||||
songData.personalRecordMap = personalRecordMap;
|
||||
songData.idolRecordMap = idolRecordMap;
|
||||
songData.chartScoreMap = chartScoreMap;
|
||||
songData.personalRecord = personalRecord; // ��ֵ�ۺ���߷�
|
||||
target.game_enterTimes = this.game_enterTimes;
|
||||
target.time_totalPlayingTime = this.time_totalPlayingTime;
|
||||
target.current_levelProgress = this.current_levelProgress;
|
||||
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);
|
||||
|
||||
foreach (var kvp in chartFileMap)
|
||||
// 将 List 还原回字典
|
||||
ListToDict(this.difficultyNumberList, target.difficultyNumberMap);
|
||||
ListToDict(this.personalRecordList, target.personalRecordMap);
|
||||
ListToDict(this.idolRecordList, target.idolRecordMap);
|
||||
ListToDict(this.chartScoreList, target.chartScoreMap);
|
||||
}
|
||||
|
||||
private List<IntIntEntry> DictToList(Dictionary<int, int> dict)
|
||||
{
|
||||
List<IntIntEntry> list = new List<IntIntEntry>();
|
||||
if (dict != null)
|
||||
{
|
||||
songData.chartFileMap[kvp.Key] = Resources.Load<TextAsset>("Charts/" + kvp.Value);
|
||||
foreach (var kvp in dict)
|
||||
{
|
||||
list.Add(new IntIntEntry { key = kvp.Key, value = kvp.Value });
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
private void ListToDict(List<IntIntEntry> list, Dictionary<int, int> dict)
|
||||
{
|
||||
if (list == null || dict == null) return;
|
||||
dict.Clear();
|
||||
foreach (var entry in list)
|
||||
{
|
||||
dict[entry.key] = entry.value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user