卡组数据删减
This commit is contained in:
58
Assets/TcgEngine/Scripts/Data/CardCoverData.cs
Normal file
58
Assets/TcgEngine/Scripts/Data/CardCoverData.cs
Normal file
@@ -0,0 +1,58 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace TcgEngine
|
||||
{
|
||||
[CreateAssetMenu(fileName = "CardCover", menuName = "TcgEngine/CardCover", order = 10)]
|
||||
public class CardCoverData : ScriptableObject
|
||||
{
|
||||
public string id;
|
||||
public string name;
|
||||
public string cardCoverPath;
|
||||
|
||||
private static List<CardCoverData> _cardCoverList = new List<CardCoverData>();
|
||||
|
||||
public static void Load(string folder = "")
|
||||
{
|
||||
if (_cardCoverList.Count==0)
|
||||
_cardCoverList.AddRange(Resources.LoadAll<CardCoverData>(folder));
|
||||
}
|
||||
|
||||
public Sprite GetCardCover()
|
||||
{
|
||||
if (_cardCoverList.Count == 0)
|
||||
Load();
|
||||
|
||||
if (!string.IsNullOrEmpty(cardCoverPath))
|
||||
{
|
||||
Sprite dynamicSprite = SpriteLoader.Get()?.LoadSprite(cardCoverPath);
|
||||
if (dynamicSprite != null)
|
||||
return dynamicSprite;
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogWarning("卡组封面地址为空!");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static CardCoverData Get(string id)
|
||||
{
|
||||
foreach (CardCoverData cardCover in GetAll())
|
||||
{
|
||||
if (cardCover.id == id)
|
||||
{
|
||||
return cardCover;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static List<CardCoverData> GetAll()
|
||||
{
|
||||
return _cardCoverList;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
3
Assets/TcgEngine/Scripts/Data/CardCoverData.cs.meta
Normal file
3
Assets/TcgEngine/Scripts/Data/CardCoverData.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fc3f18e9386843beb552310c5c14f280
|
||||
timeCreated: 1759135868
|
||||
@@ -52,6 +52,7 @@ namespace TcgEngine
|
||||
public int mana;
|
||||
public int attack;
|
||||
public int hp;
|
||||
public bool isOnline = true;// 判断排序和可点击性
|
||||
|
||||
[Header("Traits")]
|
||||
public TraitData[] traits;
|
||||
|
||||
@@ -44,9 +44,13 @@ namespace TcgEngine
|
||||
AvatarData.Load();
|
||||
CardbackData.Load();
|
||||
RewardData.Load();
|
||||
|
||||
|
||||
Debug.Log("[拦截] 目前卡: " + DeckData.GetAll().Count);
|
||||
Debug.Log("[拦截] 目前卡牌数量: " + CardData.GetAll().Count);
|
||||
|
||||
Debug.Log("[拦截] PackData 数量: " + PackData.GetAll().Count);
|
||||
foreach (var p in PackData.GetAll()) Debug.Log(p.id);
|
||||
|
||||
CheckCardData();
|
||||
CheckAbilityData();
|
||||
CheckDeckData();
|
||||
|
||||
Reference in New Issue
Block a user