横竖版展示逻辑
This commit is contained in:
@@ -40,6 +40,9 @@ namespace TcgEngine
|
||||
[Header("Dynamic Art Paths")]
|
||||
public string art_full_path;
|
||||
public string art_board_path;
|
||||
public string art_horizontal_path;
|
||||
public string art_vertical_path;
|
||||
|
||||
|
||||
[Header("Stats")]
|
||||
public CardType type;
|
||||
@@ -127,6 +130,48 @@ namespace TcgEngine
|
||||
return null;
|
||||
}
|
||||
|
||||
public Sprite GetHorizontalArt()
|
||||
{
|
||||
if (!string.IsNullOrEmpty(art_horizontal_path))
|
||||
{
|
||||
Sprite dynamicSprite = SpriteLoader.Get()?.LoadSprite(art_horizontal_path);
|
||||
if (dynamicSprite != null)
|
||||
{
|
||||
return dynamicSprite;
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogWarning($"卡牌{id} 图片加载失败: {art_horizontal_path}");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogWarning($"卡牌{id} art_horizontal_path为空");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public Sprite GetVerticalArt()
|
||||
{
|
||||
if (!string.IsNullOrEmpty(art_vertical_path))
|
||||
{
|
||||
Sprite dynamicSprite = SpriteLoader.Get()?.LoadSprite(art_vertical_path);
|
||||
if (dynamicSprite != null)
|
||||
{
|
||||
return dynamicSprite;
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogWarning($"卡牌{id} 图片加载失败: {art_vertical_path}");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogWarning($"卡牌{id} art_vertical_path为空");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public string GetTitle()
|
||||
{
|
||||
return title;
|
||||
|
||||
@@ -128,16 +128,6 @@ namespace TcgEngine.UI
|
||||
gameObject.SetActive(true);
|
||||
}
|
||||
|
||||
public void SetLine(CardData card, UserData udata, UserDeckData deck)
|
||||
{
|
||||
this.card = null;
|
||||
this.deck = null;
|
||||
this.udeck = deck;
|
||||
hidden = false;
|
||||
if(this.title!=null)
|
||||
this.title.text = deck.title;
|
||||
}
|
||||
|
||||
public void SetLine(string title)
|
||||
{
|
||||
this.card = null;
|
||||
|
||||
@@ -74,8 +74,11 @@ namespace TcgEngine.UI
|
||||
|
||||
if (!isSameCard)
|
||||
{
|
||||
if(card_image != null)
|
||||
if (card_image != null)
|
||||
{
|
||||
card_image.enabled = true;
|
||||
card_image.sprite = card.GetFullArt(variant);
|
||||
}
|
||||
if (frame_image != null)
|
||||
frame_image.sprite = (variant != null) ? variant.frame : frame_image.sprite;
|
||||
if (card_title != null)
|
||||
@@ -139,6 +142,31 @@ namespace TcgEngine.UI
|
||||
gameObject.SetActive(true);
|
||||
}
|
||||
|
||||
public void SetCard(CardData card)
|
||||
{
|
||||
if (card == null)
|
||||
return;
|
||||
|
||||
bool isSameCard = (this.card == card);
|
||||
|
||||
this.card = card;
|
||||
|
||||
if (!isSameCard)
|
||||
{
|
||||
if (card_image != null)
|
||||
{
|
||||
card_image.enabled = true;
|
||||
card_image.sprite = card.GetVerticalArt();
|
||||
}
|
||||
if (team_icon != null)
|
||||
{
|
||||
Sprite teamSprite = (card.team != null) ? card.team.icon : null;
|
||||
team_icon.sprite = teamSprite;
|
||||
team_icon.enabled = teamSprite != null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void SetHP(int hp_value)
|
||||
{
|
||||
if (hp != null)
|
||||
@@ -190,7 +218,31 @@ namespace TcgEngine.UI
|
||||
if (card_text != null)
|
||||
card_text.color = new Color(card_text.color.r, card_text.color.g, card_text.color.b, opacity);
|
||||
}
|
||||
#region ================== 对象池友好接口 ==================
|
||||
|
||||
/// <summary>
|
||||
/// 重置数据并隐藏
|
||||
/// </summary>
|
||||
public void ResetLine()
|
||||
{
|
||||
card = null;
|
||||
variant = null;
|
||||
|
||||
if (card_image) card_image.enabled = false;
|
||||
if (frame_image) frame_image.enabled = false;
|
||||
if (team_icon) team_icon.enabled = false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 展开用户卡组信息
|
||||
/// </summary>
|
||||
public void Refresh(CardData card, VariantData variant)
|
||||
{
|
||||
SetCard(card);
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
public void Hide()
|
||||
{
|
||||
if (gameObject.activeSelf)
|
||||
|
||||
@@ -35,8 +35,8 @@ namespace TcgEngine.UI
|
||||
|
||||
// 卡组展示管理
|
||||
public int card_lines_size = 12;
|
||||
public List<DeckLine> card_pool = new List<DeckLine>();
|
||||
public List<DeckLine> card_lines = new List<DeckLine>();
|
||||
public List<CardUI> card_pool = new List<CardUI>();
|
||||
public List<CardUI> card_lines = new List<CardUI>();
|
||||
|
||||
|
||||
private UserData lastUserData;
|
||||
@@ -65,7 +65,7 @@ namespace TcgEngine.UI
|
||||
for (int i = 0; i < card_lines_size; i++)
|
||||
{
|
||||
GameObject card = Instantiate(card_lines_prefab, deck_display_grid.transform);
|
||||
DeckLine line = card.GetComponent<DeckLine>();
|
||||
CardUI line = card.GetComponent<CardUI>();
|
||||
line.gameObject.SetActive(false);
|
||||
card_pool.Add(line);
|
||||
}
|
||||
@@ -165,12 +165,12 @@ namespace TcgEngine.UI
|
||||
for (int i = 0; i < udeck.cards.Length; i++)
|
||||
{
|
||||
UserCardData ucard = udeck.cards[i];
|
||||
DeckLine line = card_pool[i];
|
||||
CardUI line = card_pool[i];
|
||||
|
||||
CardData cdata = CardData.Get(ucard.tid);
|
||||
VariantData variant = VariantData.Get(ucard.variant);
|
||||
|
||||
line.Refresh(cdata, variant, ucard.quantity);
|
||||
line.Refresh(cdata, variant);
|
||||
line.gameObject.SetActive(true);
|
||||
card_lines.Add(line);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user