Merge remote-tracking branch 'origin/main'

This commit is contained in:
YiHan0621
2025-09-14 20:22:00 +08:00
4 changed files with 58 additions and 35 deletions

View File

@@ -7088,7 +7088,7 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 1, y: 1}
m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: -247.39996, y: -65.84}
m_AnchoredPosition: {x: -247.39996, y: -65.839966}
m_SizeDelta: {x: 494.79, y: 131.69}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &1449244093741349574
@@ -14561,7 +14561,7 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 1, y: 0}
m_AnchorMax: {x: 1, y: 0}
m_AnchoredPosition: {x: -135.79999, y: 44.28}
m_AnchoredPosition: {x: -135.80005, y: 44.28003}
m_SizeDelta: {x: 210.96, y: 81.14}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &4201586067522883778
@@ -17028,6 +17028,16 @@ PrefabInstance:
propertyPath: card_angle
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5110355759202193847, guid: 4f5d06d57a8cd5f42b526a96b940dca7,
type: 3}
propertyPath: usePathMode
value: 1
objectReference: {fileID: 0}
- target: {fileID: 5110355759202193847, guid: 4f5d06d57a8cd5f42b526a96b940dca7,
type: 3}
propertyPath: cardback_path
value: Cardbacks/cardback_gold.png
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 4f5d06d57a8cd5f42b526a96b940dca7, type: 3}
--- !u!114 &5052310800691334680
@@ -21847,7 +21857,7 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 1, y: 0}
m_AnchorMax: {x: 1, y: 0}
m_AnchoredPosition: {x: -137.20001, y: 123.83002}
m_AnchoredPosition: {x: -137.19995, y: 123.83002}
m_SizeDelta: {x: 213.76, y: 77.96}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!1 &6512466294668775865
@@ -21983,7 +21993,7 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 1}
m_AnchorMax: {x: 0.5, y: 1}
m_AnchoredPosition: {x: 0, y: -140.16}
m_AnchoredPosition: {x: 0, y: -140.16003}
m_SizeDelta: {x: 794.78, y: 280.32}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!1 &6577887540008874255

View File

@@ -20,6 +20,7 @@ namespace TcgEngine.Client
public Text discard_value;
private bool hover = false;
private string prev_deck_path = null;
void Start()
{
@@ -43,28 +44,20 @@ namespace TcgEngine.Client
if (player == null)
return;
// 获取卡背数据,如果为空则使用默认路径
CardbackData cb = CardbackData.Get(player.cardback);
if (deck_render != null)
string targetDeckPath = cb != null && !string.IsNullOrEmpty(cb.deck_path) ? cb.deck_path : "Cardbacks/deck_silver.png";
if (deck_render != null && (deck_render.sprite == null || prev_deck_path != targetDeckPath))
{
if (cb != null)
Sprite sprite = SpriteLoader.Get()?.LoadSprite(targetDeckPath);
if (sprite != null)
{
deck_render.sprite = cb.GetDeck();
deck_render.sprite = sprite;
deck_render.gameObject.transform.localScale = Vector3.one * 0.5f;
prev_deck_path = targetDeckPath;
}
else
{
// 如果卡背数据为空,使用默认路径
Sprite defaultDeckSprite = SpriteLoader.Get()?.LoadSprite("Cardbacks/deck_silver.png");
if (defaultDeckSprite != null)
{
deck_render.sprite = defaultDeckSprite;
deck_render.transform.localScale = Vector3.one * 0.5f;
}
else
{
Debug.LogWarning($"[BoardDeck] {(opponent ? "" : "")} 默认牌组图片加载失败: Cardbacks/deck_silver.png");
}
Debug.LogWarning($"[BoardDeck] {(opponent ? "" : "")} 牌组图片加载失败: {targetDeckPath}");
}
}

View File

@@ -67,6 +67,8 @@ namespace TcgEngine.UI
/// </summary>
public void SetAvatarPath(string path)
{
if (avatar_path == path)
return;
avatar_path = path;
LoadAvatarSprite();
}

View File

@@ -68,17 +68,21 @@ namespace TcgEngine.UI
if (card == null)
return;
bool isSameCard = (this.card == card) && (this.variant == variant);
this.card = card;
this.variant = variant;
if(card_image != null)
card_image.sprite = card.GetFullArt(variant);
if (frame_image != null)
frame_image.sprite = variant.frame;
if (card_title != null)
card_title.text = card.GetTitle().ToUpper();
if (card_text != null)
card_text.text = card.GetText();
if (!isSameCard)
{
if(card_image != null)
card_image.sprite = card.GetFullArt(variant);
if (frame_image != null)
frame_image.sprite = (variant != null) ? variant.frame : frame_image.sprite;
if (card_title != null)
card_title.text = card.GetTitle().ToUpper();
if (card_text != null)
card_text.text = card.GetText();
}
if (attack_icon != null)
attack_icon.enabled = card.IsCharacter();
@@ -102,20 +106,34 @@ namespace TcgEngine.UI
if (hp != null)
hp.text = card.hp.ToString();
if (team_icon != null)
if (!isSameCard)
{
team_icon.sprite = card.team.icon;
team_icon.enabled = team_icon.sprite != null;
if (team_icon != null)
{
Sprite teamSprite = (card.team != null) ? card.team.icon : null;
team_icon.sprite = teamSprite;
team_icon.enabled = teamSprite != null;
}
}
if (rarity_icon != null)
if (!isSameCard)
{
rarity_icon.sprite = card.rarity.icon;
rarity_icon.enabled = rarity_icon.sprite != null && card.type != CardType.Hero;
if (rarity_icon != null)
{
Sprite raritySprite = (card.rarity != null) ? card.rarity.icon : null;
rarity_icon.sprite = raritySprite;
rarity_icon.enabled = raritySprite != null && card.type != CardType.Hero;
}
}
foreach (TraitUI stat in stats)
stat.SetCard(card);
if (stats != null)
{
foreach (TraitUI stat in stats)
{
if (stat != null)
stat.SetCard(card);
}
}
if (!gameObject.activeSelf)
gameObject.SetActive(true);