35 lines
1.0 KiB
C#
35 lines
1.0 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Threading.Tasks;
|
|
using Continentis.MainGame.Card;
|
|
using SoulliesFramework.General;
|
|
using UnityEngine;
|
|
|
|
namespace Continentis
|
|
{
|
|
public class CardDatabase : Singleton<CardDatabase>
|
|
{
|
|
public Dictionary<string, CardData> cardDatabase;
|
|
|
|
protected override void Awake()
|
|
{
|
|
Initialize(true);
|
|
}
|
|
|
|
public async Task<IList<CardData>> CollectAllCardData()
|
|
{
|
|
IList<CardData> dataList = await AssetLoader.LoadAssetsWithLabelAsync<CardData>("CardData");
|
|
cardDatabase = new Dictionary<string, CardData>();
|
|
foreach (CardData data in dataList)
|
|
{
|
|
if (!cardDatabase.TryAdd(data.cardIdentifier, data))
|
|
{
|
|
Debug.LogWarning($"CardDatabase: Duplicate card ID found: {data.cardIdentifier}");
|
|
}
|
|
}
|
|
|
|
Debug.Log($"CardDatabase: Collected {cardDatabase.Count} cards.");
|
|
return dataList;
|
|
}
|
|
}
|
|
} |