出战卡组UI

This commit is contained in:
YiHan0621
2025-09-19 14:07:19 +08:00
parent f3199704b8
commit 6e3e6b59a5
137 changed files with 11050 additions and 751 deletions

View File

@@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: 2badac8a05537094caad9f78cb2e2e0b
guid: c1f91f8897412434fa053d9e9f255052
MonoImporter:
externalObjects: {}
serializedVersion: 2

View File

@@ -26,6 +26,9 @@ namespace TcgEngine.UI
}
/// <summary>
/// 设置卡组列表
/// </summary>
public void SetupUserDeckList()
{
deck_dropdown.ClearOptions();

View File

@@ -64,12 +64,18 @@ namespace TcgEngine.UI
}
}
/// <summary>
/// 设置
/// </summary>
public void SetValue(int index)
{
if (index >= 0 && index < dropdown.options.Count)
dropdown.value = index;
}
/// <summary>
/// 更改
/// </summary>
private void OnChangeValue(int selected_index)
{
if (selected_index >= 0 && selected_index < values.Count)
@@ -80,6 +86,10 @@ namespace TcgEngine.UI
}
}
/// <summary>
/// 获取选中项
/// </summary>
/// <returns></returns>
public DropdownValueItem GetSelected()
{
if (dropdown.value >= 0 && dropdown.value < values.Count)
@@ -90,6 +100,10 @@ namespace TcgEngine.UI
return null;
}
/// <summary>
/// 获取选定值
/// </summary>
/// <returns></returns>
public string GetSelectedValue()
{
DropdownValueItem item = GetSelected();
@@ -97,7 +111,10 @@ namespace TcgEngine.UI
return item.id;
return "";
}
/// <summary>
/// 获取选定文本
/// </summary>
/// <returns></returns>
public string GetSelectedText()
{
DropdownValueItem item = GetSelected();

View File

@@ -0,0 +1,109 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using TcgEngine;
using Unity.VisualScripting;
namespace TcgEngine.UI
{
public class PresetDeck : UIPanel
{
[Header("展示面板")]
public UIPanel preset_lineup;
public Button preset_lineup_button;
public UIPanel hide_panel;
public GameObject deck_lines_prefab;
public RectTransform deck_line_content;
[Header("预设面板")]
public DeckSelector deckSelector;
public DropdownValue dropdownValue;
public int currentSelect;
public Button selectDeckButton;
private Button hide_panel_button;
// 选择卡组面板
private Dictionary<int, DropdownValueItem> desk_lines = new Dictionary<int, DropdownValueItem>();
private static PresetDeck instance;
protected override void Awake()
{
base.Awake();
instance = this;
}
protected override void Start()
{
base.Start();
for (int i = 0; i < deck_line_content.transform.childCount; i++)
Destroy(deck_line_content.transform.GetChild(i).gameObject);
preset_lineup_button.onClick.AddListener(OnPresetLineupPanle);
hide_panel_button = hide_panel.GetComponent<Button>();
hide_panel_button.onClick.AddListener(OffPresetLineupPanle);
}
public void SetupUserDeckList()
{
desk_lines.Clear();
if (dropdownValue == null)
return;
int index = 0;
foreach (DropdownValueItem item in dropdownValue.Items)
{
desk_lines.Add(index,item);
index++;
}
if (desk_lines != null)
{
for (int i = 0; i < desk_lines.Count; i++)
{
GameObject deckLine = Instantiate(deck_lines_prefab, deck_line_content.transform);
var line = deckLine.GetComponent<DeckLine>();
line.title.text = desk_lines[i].text;
line.onClick += OnSelectDeck;
}
}
}
/// <summary>
/// 打开预设面板
/// </summary>
private void OnPresetLineupPanle()
{
preset_lineup.Show();
hide_panel.Show();
}
/// <summary>
/// 关闭预设面板
/// </summary>
private void OffPresetLineupPanle()
{
preset_lineup.Hide();
hide_panel.Hide();
}
private void OnSelectDeck(DeckLine line)
{
}
public override void Show(bool instant = false)
{
base.Show(instant);
SetupUserDeckList();
preset_lineup.Hide();
hide_panel.Hide();
}
public static PresetDeck Get()
{
return instance;
}
}
}

View File

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