修改默认卡组&卡背图片
This commit is contained in:
@@ -13,7 +13,7 @@ MonoBehaviour:
|
||||
m_Name: fire_deck
|
||||
m_EditorClassIdentifier:
|
||||
id: fire_deck
|
||||
title: 火焰
|
||||
title: "\u706B\u7130"
|
||||
hero: {fileID: 11400000, guid: cf170aea7ffb041428f37608f1561058, type: 2}
|
||||
cards:
|
||||
- {fileID: 11400000, guid: 99081d84b6aa6264aa1c68c6defbe31d, type: 2}
|
||||
@@ -24,3 +24,7 @@ MonoBehaviour:
|
||||
- {fileID: 11400000, guid: 90322744d448d6a46b8c2361a222d9a6, type: 2}
|
||||
- {fileID: 11400000, guid: 90322744d448d6a46b8c2361a222d9a6, type: 2}
|
||||
- {fileID: 11400000, guid: faacda797c4448a4bbbcbca76c6fefc0, type: 2}
|
||||
- {fileID: 11400000, guid: 83692bb780503404b92feed04c7d222b, type: 2}
|
||||
- {fileID: 11400000, guid: d3e866161f45f03498b4098dbd8d968d, type: 2}
|
||||
- {fileID: 11400000, guid: 979b326ecf73d0a4791dc37a6f13c24a, type: 2}
|
||||
- {fileID: 11400000, guid: 900d0aa6de59c1349ab5c08a481c2a38, type: 2}
|
||||
|
||||
@@ -13,7 +13,7 @@ MonoBehaviour:
|
||||
m_Name: forest_deck
|
||||
m_EditorClassIdentifier:
|
||||
id: forest_deck
|
||||
title: 森林
|
||||
title: "\u68EE\u6797"
|
||||
hero: {fileID: 11400000, guid: 04fd0777e8f567b48ad05e6bdaf97c1d, type: 2}
|
||||
cards:
|
||||
- {fileID: 11400000, guid: 1e22d4647e903814d96f63a729e1f820, type: 2}
|
||||
@@ -24,3 +24,7 @@ MonoBehaviour:
|
||||
- {fileID: 11400000, guid: 4a0f93237a2ae53468e29927c1b7c1ec, type: 2}
|
||||
- {fileID: 11400000, guid: 2302f11d23015254dbb067255d70e738, type: 2}
|
||||
- {fileID: 11400000, guid: 4fc52d01f2883134ea1e6ea0d9ba82f2, type: 2}
|
||||
- {fileID: 11400000, guid: 4fc52d01f2883134ea1e6ea0d9ba82f2, type: 2}
|
||||
- {fileID: 11400000, guid: fa7053162e690c948a100b6cbcde7266, type: 2}
|
||||
- {fileID: 11400000, guid: fa7053162e690c948a100b6cbcde7266, type: 2}
|
||||
- {fileID: 11400000, guid: 9f363479388a0c347b8a455c4f32a659, type: 2}
|
||||
|
||||
@@ -13,7 +13,7 @@ MonoBehaviour:
|
||||
m_Name: water_deck
|
||||
m_EditorClassIdentifier:
|
||||
id: water_deck
|
||||
title: 臻冰
|
||||
title: "\u81FB\u51B0"
|
||||
hero: {fileID: 11400000, guid: 111d60b13ae137f4597da2789d94ecce, type: 2}
|
||||
cards:
|
||||
- {fileID: 11400000, guid: 89f3d73097f233148896600d94d482c0, type: 2}
|
||||
@@ -22,5 +22,9 @@ MonoBehaviour:
|
||||
- {fileID: 11400000, guid: 3eb5d82b098a31640981aa400ef099f0, type: 2}
|
||||
- {fileID: 11400000, guid: 3eb5d82b098a31640981aa400ef099f0, type: 2}
|
||||
- {fileID: 11400000, guid: 7522cb2b475fdca45aae97664d79e53c, type: 2}
|
||||
- {fileID: 11400000, guid: fced434c254f6a94e8377864595757c8, type: 2}
|
||||
- {fileID: 11400000, guid: fced434c254f6a94e8377864595757c8, type: 2}
|
||||
- {fileID: 11400000, guid: 89f3d73097f233148896600d94d482c0, type: 2}
|
||||
- {fileID: 11400000, guid: 6d25f87d5e8912e4aae6b2e8cdb51378, type: 2}
|
||||
- {fileID: 11400000, guid: e777946125cd2eb49a3b2ac17bea169a, type: 2}
|
||||
- {fileID: 11400000, guid: 3eb5d82b098a31640981aa400ef099f0, type: 2}
|
||||
- {fileID: 11400000, guid: 74ffbe8087a7ec64696352b9013d5d21, type: 2}
|
||||
- {fileID: 11400000, guid: ee0eb5f42cd646d4c92cc5bae97f8512, type: 2}
|
||||
|
||||
@@ -2393,6 +2393,16 @@ PrefabInstance:
|
||||
propertyPath: m_Name
|
||||
value: HandsArea
|
||||
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!1001 &5509868164999168658
|
||||
|
||||
@@ -13,6 +13,9 @@ namespace TcgEngine.Client
|
||||
{
|
||||
public Image card_sprite;
|
||||
|
||||
[Header("Dynamic Art Path")]
|
||||
[SerializeField] private string cardback_path;
|
||||
|
||||
private RectTransform rect;
|
||||
|
||||
private static List<HandCardBack> card_list = new List<HandCardBack>();
|
||||
@@ -21,7 +24,16 @@ namespace TcgEngine.Client
|
||||
{
|
||||
card_list.Add(this);
|
||||
rect = GetComponent<RectTransform>();
|
||||
SetCardback(null);
|
||||
|
||||
// 如果有设置路径,自动加载
|
||||
if (!string.IsNullOrEmpty(cardback_path))
|
||||
{
|
||||
LoadCardbackSprite();
|
||||
}
|
||||
else
|
||||
{
|
||||
SetCardback(null);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
@@ -29,12 +41,63 @@ namespace TcgEngine.Client
|
||||
card_list.Remove(this);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 在 Inspector 中修改值时自动重新加载
|
||||
/// </summary>
|
||||
private void OnValidate()
|
||||
{
|
||||
if (Application.isPlaying && !string.IsNullOrEmpty(cardback_path))
|
||||
{
|
||||
LoadCardbackSprite();
|
||||
}
|
||||
}
|
||||
|
||||
public void SetCardback(CardbackData cb)
|
||||
{
|
||||
if (cb != null)
|
||||
card_sprite.sprite = cb.GetCardback();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置卡背图片,使用本地图片路径
|
||||
/// </summary>
|
||||
public void SetCardbackPath(string path)
|
||||
{
|
||||
cardback_path = path;
|
||||
LoadCardbackSprite();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取当前卡背路径
|
||||
/// </summary>
|
||||
public string GetCardbackPath()
|
||||
{
|
||||
return cardback_path;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 加载卡背图片
|
||||
/// </summary>
|
||||
private void LoadCardbackSprite()
|
||||
{
|
||||
if (!string.IsNullOrEmpty(cardback_path))
|
||||
{
|
||||
Sprite dynamicSprite = SpriteLoader.Get()?.LoadSprite(cardback_path);
|
||||
if (dynamicSprite != null)
|
||||
{
|
||||
card_sprite.sprite = dynamicSprite;
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogWarning($"HandCardBack 卡背图片加载失败: {cardback_path}");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogWarning($"HandCardBack cardback_path为空");
|
||||
}
|
||||
}
|
||||
|
||||
public RectTransform GetRect()
|
||||
{
|
||||
if (rect == null)
|
||||
|
||||
@@ -18,6 +18,12 @@ namespace TcgEngine.Client
|
||||
public float card_angle = 10f;
|
||||
public float card_offset_y = 10f;
|
||||
|
||||
[Header("Cardback Settings")]
|
||||
[Tooltip("是否使用路径方式加载卡背图片")]
|
||||
public bool usePathMode = false;
|
||||
[Tooltip("卡背图片路径,仅在 usePathMode 为 true 时使用")]
|
||||
public string cardback_path = "";
|
||||
|
||||
private List<HandCardBack> cards = new List<HandCardBack>();
|
||||
|
||||
void Start()
|
||||
@@ -37,8 +43,20 @@ namespace TcgEngine.Client
|
||||
{
|
||||
GameObject new_card = Instantiate(card_prefab, card_area);
|
||||
HandCardBack hand_card = new_card.GetComponent<HandCardBack>();
|
||||
CardbackData cbdata = CardbackData.Get(player.cardback);
|
||||
hand_card.SetCardback(cbdata);
|
||||
|
||||
// 根据设置选择加载方式
|
||||
if (usePathMode && !string.IsNullOrEmpty(cardback_path))
|
||||
{
|
||||
// 使用路径方式
|
||||
hand_card.SetCardbackPath(cardback_path);
|
||||
}
|
||||
else
|
||||
{
|
||||
// 使用传统的 CardbackData 方式
|
||||
CardbackData cbdata = CardbackData.Get(player.cardback);
|
||||
hand_card.SetCardback(cbdata);
|
||||
}
|
||||
|
||||
RectTransform card_rect = new_card.GetComponent<RectTransform>();
|
||||
card_rect.anchoredPosition = new Vector2(0f, 100f);
|
||||
cards.Add(hand_card);
|
||||
|
||||
Reference in New Issue
Block a user