选择封面初步提交

This commit is contained in:
YiHan0621
2025-10-09 14:20:54 +08:00
parent 1f6a1e9b22
commit 8a884db968
30 changed files with 2566 additions and 43 deletions

View File

@@ -1,21 +0,0 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace TcgEngine.UI
{
public class Cards : UIPanel
{
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
}
}

View File

@@ -0,0 +1,36 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;
namespace TcgEngine
{
public class ChangeCoverLine : MonoBehaviour
{
public Image cover;
public string coverName;
public UnityAction<ChangeCoverLine> OnChangeCover;
/// <summary>
/// 初始化封面显示
/// </summary>
public void SetCover(Sprite coverSprite, string name)
{
if (cover != null)
cover.sprite = coverSprite;
coverName = name;
}
/// <summary>
/// 点击选择封面
/// </summary>
public void OnClickCover()
{
OnChangeCover?.Invoke(this);
}
}
}

View File

@@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: 446c25b1fcbf5cf4a9de5f31c0bcadec
guid: 4d29921007c1de7438608141413c1e15
MonoImporter:
externalObjects: {}
serializedVersion: 2

View File

@@ -0,0 +1,67 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
namespace TcgEngine.UI
{
public class ChangeCoverPanel : UIPanel
{
public Text coverNameText;
public Transform content;
public GameObject coverPrefab;
private static ChangeCoverPanel instance;
protected override void Awake()
{
base.Awake();
instance = this;
for (int i = 0; i < content.childCount; i++)
Destroy(content.GetChild(i).gameObject);
}
protected override void Start()
{
base.Start();
GenerateCardCovers();
}
/// <summary>
/// 生成并排布所有卡片封面
/// </summary>
private void GenerateCardCovers()
{
Debug.Log("数据有"+CardCoverData.GetAll().Count);
foreach (CardCoverData cover in CardCoverData.GetAll())
{
GameObject cardCover = Instantiate(coverPrefab, content);
var line = cardCover.GetComponent<ChangeCoverLine>();
line.SetCover(cover.GetCardCover(), cover.name);
}
}
private void RefreshPanel()
{
}
public void OpenPanel(DeckLine line)
{
Show();
RefreshPanel();
coverNameText.text = line.title.text;
}
public override void Show(bool instant = false)
{
base.Show(instant);
}
public static ChangeCoverPanel Get()
{
return instance;
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 106854e63da26e140bd2386d24e75ad1
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -52,6 +52,9 @@ namespace TcgEngine.UI
public GridLayoutGroup deck_grid;
public IconButton[] hero_powers;
[Header("切换卡组面板")]
public UIPanel changeCover;
private TeamData filter_team = null;
public int filter_dropdown = 0;
private string filter_search = "";
@@ -88,6 +91,8 @@ namespace TcgEngine.UI
line.onClick += OnClickDeckLine;
foreach (DeckLine line in deck_lines)
line.onClickDelete += OnClickDeckDelete;
foreach (DeckLine line in deck_lines)
line.onChangeCover += OnChangeCover;
foreach (IconButton button in team_filters)
button.onClick += OnClickTeam;
@@ -221,6 +226,7 @@ namespace TcgEngine.UI
private void ShowDeckList()
{
deck_list_panel.Show();
changeCover.Hide();
card_list_panel.Hide();
editing_deck = false;
}
@@ -228,6 +234,7 @@ namespace TcgEngine.UI
private void ShowDeckCards()
{
deck_list_panel.Hide();
changeCover.Hide();
card_list_panel.Show();
}
@@ -757,6 +764,11 @@ namespace TcgEngine.UI
DeleteDeck(deck.tid);
}
}
public void OnChangeCover(DeckLine line)
{
ChangeCoverPanel.Get().OpenPanel(line);
}
// ---- Getters -----
@@ -830,7 +842,6 @@ namespace TcgEngine.UI
public override void Show(bool instant = false)
{
base.Show(instant);
Debug.Log("11111");
RefreshAll();
ShowDeckList();
}

View File

@@ -19,6 +19,7 @@ namespace TcgEngine.UI
public Text value;
public IconValue cost;
public UIPanel delete_btn;
public UIPanel changeCover_btn;
public AudioClip click_audio;
public Material disabled_mat;
public Material default_mat;
@@ -26,6 +27,7 @@ namespace TcgEngine.UI
public UnityAction<DeckLine> onClick;
public UnityAction<DeckLine> onClickRight;
public UnityAction<DeckLine> onClickDelete;
public UnityAction<DeckLine> onChangeCover;
private CardData card;
private VariantData variant;
@@ -45,6 +47,12 @@ namespace TcgEngine.UI
{
bool visi = hover || GameTool.IsMobile();
delete_btn.SetVisible(visi && !hidden && udeck != null);
}
if (changeCover_btn)
{
bool visi = hover || GameTool.IsMobile();
changeCover_btn.SetVisible(visi && !hidden && udeck != null);
}
}
@@ -170,6 +178,8 @@ namespace TcgEngine.UI
frame.enabled = false;
if (delete_btn != null)
delete_btn.SetVisible(false);
if (changeCover_btn!=null)
changeCover_btn.SetVisible(false);
gameObject.SetActive(false);
}
@@ -194,6 +204,7 @@ namespace TcgEngine.UI
if (image) image.enabled = false;
if (frame) frame.enabled = false;
if (delete_btn) delete_btn.SetVisible(false);
if (changeCover_btn) changeCover_btn.SetVisible(false);
gameObject.SetActive(false);
}
@@ -264,6 +275,12 @@ namespace TcgEngine.UI
AudioTool.Get().PlaySFX("ui", click_audio);
}
public void OnChangeCover()
{
onChangeCover?.Invoke(this);
Debug.Log(title.text);
}
public void OnPointerEnter(PointerEventData eventData)
{
hover = true;