60 lines
1.6 KiB
C#
60 lines
1.6 KiB
C#
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class PlayerDataManager : MonoBehaviour
|
|
{
|
|
public static PlayerDataManager Instance { get; private set; }
|
|
|
|
[Header("玩家拥有的角色(临时写死)")]
|
|
public List<PlayerCharacterData> ownedCharacters = new List<PlayerCharacterData>();
|
|
|
|
[Header("当前卡组(临时写死)")]
|
|
public PlayerCharacterData[] currentDeck = new PlayerCharacterData[5];
|
|
|
|
private void Awake()
|
|
{
|
|
if (Instance != null && Instance != this)
|
|
{
|
|
Destroy(gameObject);
|
|
return;
|
|
}
|
|
Instance = this;
|
|
|
|
InitializeTempData();
|
|
}
|
|
|
|
private void InitializeTempData()
|
|
{
|
|
ownedCharacters.Clear();
|
|
|
|
ownedCharacters.Add(new PlayerCharacterData("human_soldier", 1, 0));
|
|
ownedCharacters.Add(new PlayerCharacterData("archer", 1, 0));
|
|
|
|
currentDeck[0] = ownedCharacters[0];
|
|
currentDeck[1] = ownedCharacters[1];
|
|
}
|
|
|
|
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++;
|
|
Debug.Log($"角色 {characterId} 升级到 {character.level} 级");
|
|
}
|
|
}
|
|
} |