```
feat(card): 添加卡牌消耗数字图片显示功能 为卡牌系统添加了消耗数字的图片显示组件,包括CostNumberImage游戏对象、 RectTransform布局以及对应的精灵资源数组。同时禁用了一些不需要的UI元素, 完善了卡牌界面的数值展示逻辑。 ```
This commit is contained in:
1 parent
eee5c83cb3
commit
bf5f1ba95b
22 files changed
+1790
-9
No files matched your search
@@ -17,6 +17,10 @@ public class SummonCardButton : MonoBehaviour
|
||||
public Image cardIcon;
|
||||
public Text characterNameText;
|
||||
public Text manaCostText;
|
||||
public Image costNumberImage; // 费用数字图片
|
||||
|
||||
[Header("费用数字精灵")]
|
||||
public Sprite[] costNumberSprites; // 数字_0 到 数字_8,对应费用 1-9
|
||||
|
||||
private Button button;
|
||||
private MainCharacterCombat combat;
|
||||
@@ -168,5 +172,30 @@ public class SummonCardButton : MonoBehaviour
|
||||
{
|
||||
manaCostText.text = characterData.manaCost.ToString();
|
||||
}
|
||||
|
||||
// 更新费用数字精灵
|
||||
UpdateCostNumberSprite();
|
||||
}
|
||||
|
||||
private void UpdateCostNumberSprite()
|
||||
{
|
||||
if (costNumberImage == null || characterData == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int cost = characterData.manaCost;
|
||||
|
||||
// 费用范围 1-9,对应精灵索引 0-8
|
||||
if (cost >= 1 && cost <= 9 && costNumberSprites != null && costNumberSprites.Length >= cost)
|
||||
{
|
||||
costNumberImage.sprite = costNumberSprites[cost - 1];
|
||||
costNumberImage.enabled = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
// 超出范围或未配置精灵数组,隐藏图片
|
||||
costNumberImage.enabled = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user