feat: 移除自适应性能相关配置并调整动画控制器 移除了Unity自适应性能(Adaptive Performance)的相关配置文件, 包括Adaptive Performance文件夹及其子目录中的所有配置文件, 同时移除了移动通知(NotificationSettings)相关配置, 以及第一章第一关(level_chapter1_level1)的关卡配置文件, 还删除了多个材质文件如AdjustableGlowOrb、AdjustableGlowOrbHalo 和Arena相关材质。另外微调了base-人类士兵.controller中状态机 的位置坐标,将x坐标从320调整为330。 ```
106 lines
3.4 KiB
C#
106 lines
3.4 KiB
C#
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
[System.Serializable]
|
|
public class PlayerOwnedCharacterJson
|
|
{
|
|
public string characterId;
|
|
public int level = 1;
|
|
public int starLevel = 0;
|
|
}
|
|
|
|
[System.Serializable]
|
|
public class PlayerSaveJson
|
|
{
|
|
public string playerId = "local_player";
|
|
public PlayerOwnedCharacterJson[] unlockedCharacters = new PlayerOwnedCharacterJson[0];
|
|
public string[] currentDeck = new string[0];
|
|
}
|
|
|
|
public class PlayerDataManager : MonoBehaviour
|
|
{
|
|
public static PlayerDataManager Instance { get; private set; }
|
|
|
|
[Header("本地玩家 JSON(正式版替换为服务器响应)")]
|
|
public TextAsset localPlayerJson;
|
|
|
|
public List<PlayerCharacterData> ownedCharacters = new List<PlayerCharacterData>();
|
|
public PlayerCharacterData[] currentDeck = new PlayerCharacterData[5];
|
|
|
|
private void Awake()
|
|
{
|
|
if (Instance != null && Instance != this)
|
|
{
|
|
Destroy(gameObject);
|
|
return;
|
|
}
|
|
Instance = this;
|
|
InitializeFromJsonOrFallback();
|
|
}
|
|
|
|
private void InitializeFromJsonOrFallback()
|
|
{
|
|
TextAsset json = localPlayerJson != null
|
|
? localPlayerJson
|
|
: Resources.Load<TextAsset>("PlayerData");
|
|
|
|
if (json != null)
|
|
{
|
|
try
|
|
{
|
|
var save = JsonUtility.FromJson<PlayerSaveJson>(json.text);
|
|
if (save != null && save.unlockedCharacters != null)
|
|
{
|
|
ownedCharacters.Clear();
|
|
foreach (var entry in save.unlockedCharacters)
|
|
{
|
|
if (entry == null || string.IsNullOrEmpty(entry.characterId)) continue;
|
|
ownedCharacters.Add(new PlayerCharacterData(entry.characterId, Mathf.Max(1, entry.level), Mathf.Max(0, entry.starLevel)));
|
|
}
|
|
|
|
currentDeck = new PlayerCharacterData[5];
|
|
for (int i = 0; i < save.currentDeck.Length && i < currentDeck.Length; i++)
|
|
currentDeck[i] = GetCharacterData(save.currentDeck[i]);
|
|
return;
|
|
}
|
|
}
|
|
catch (System.Exception e)
|
|
{
|
|
Debug.LogError("玩家 JSON 解析失败:" + e.Message);
|
|
}
|
|
}
|
|
|
|
InitializeTempData();
|
|
}
|
|
|
|
private void InitializeTempData()
|
|
{
|
|
ownedCharacters.Clear();
|
|
ownedCharacters.Add(new PlayerCharacterData("human_soldier", 1, 0));
|
|
ownedCharacters.Add(new PlayerCharacterData("archer", 1, 0));
|
|
ownedCharacters.Add(new PlayerCharacterData("shield_guard", 1, 0));
|
|
ownedCharacters.Add(new PlayerCharacterData("mage", 1, 0));
|
|
ownedCharacters.Add(new PlayerCharacterData("elite_soldier", 1, 0));
|
|
|
|
currentDeck = new PlayerCharacterData[5];
|
|
for (int i = 0; i < currentDeck.Length && i < ownedCharacters.Count; i++)
|
|
currentDeck[i] = ownedCharacters[i];
|
|
}
|
|
|
|
public PlayerCharacterData GetCharacterData(string characterId)
|
|
{
|
|
return ownedCharacters.Find(c => c.characterId == characterId);
|
|
}
|
|
|
|
public PlayerCharacterData GetDeckCharacter(int slot)
|
|
{
|
|
if (slot < 0 || slot >= currentDeck.Length) return null;
|
|
return currentDeck[slot];
|
|
}
|
|
|
|
public void UpgradeCharacter(string characterId)
|
|
{
|
|
var character = GetCharacterData(characterId);
|
|
if (character != null) character.level++;
|
|
}
|
|
} |