feat():大改前的提交,这个版本保存了所有冗余的代码
This commit is contained in:
31
Assets/Script/Gameplay/Card/Utils/CardLoader.cs
Normal file
31
Assets/Script/Gameplay/Card/Utils/CardLoader.cs
Normal file
@@ -0,0 +1,31 @@
|
||||
using UnityEngine;
|
||||
namespace Gameplay
|
||||
{
|
||||
// 用来加载卡牌数据的静态类
|
||||
public static class CardLoader
|
||||
{
|
||||
public static CardData GetCardDataByID(int cardID)
|
||||
{
|
||||
CardData[] allCards = Resources.LoadAll<CardData>("Configs/Card");
|
||||
foreach (var card in allCards)
|
||||
{
|
||||
if (card.CardID == cardID)
|
||||
{
|
||||
return card;
|
||||
}
|
||||
}
|
||||
Debug.LogError($"Card with ID {cardID} not found!");
|
||||
return null;
|
||||
}
|
||||
|
||||
public static Card GetCardByID(int cardID)
|
||||
{
|
||||
CardData cardData = GetCardDataByID(cardID);
|
||||
if (cardData != null)
|
||||
{
|
||||
return new Card(cardData);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user