修复开始游戏无法点击和UI增加
This commit is contained in:
@@ -248,6 +248,7 @@ namespace TcgEngine
|
||||
{
|
||||
udata = ApiTool.JsonToObject<UserData>(res.data);
|
||||
Debug.Log($"获取玩家数据:{res.data}");
|
||||
Debug.Log($"lastWinDeck{udata.lastWinDeck}");
|
||||
}
|
||||
return udata;
|
||||
}
|
||||
|
||||
@@ -36,6 +36,7 @@ namespace TcgEngine
|
||||
public UserCardData[] cards;
|
||||
public UserCardData[] packs;
|
||||
public UserDeckData[] decks;
|
||||
public UserDeckData lastWinDeck;
|
||||
public string[] rewards;
|
||||
public string[] avatars;
|
||||
public string[] cardbacks;
|
||||
|
||||
@@ -42,6 +42,27 @@ namespace TcgEngine.UI
|
||||
RankMedalData.Load();
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
viewCardButton.onClick.AddListener(OnViewCard);
|
||||
|
||||
}
|
||||
|
||||
private async void OnViewCard()
|
||||
{
|
||||
UserData udata = null;
|
||||
udata = await ApiClient.Get().LoadUserData(id);
|
||||
if (udata.lastWinDeck.title != null)
|
||||
{
|
||||
Debug.Log($"找到{udata.lastWinDeck.title}");
|
||||
PresetDeck.Get().SetupUserCardList(udata.lastWinDeck, username);
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Log($"没有udata.lastWinDeck");
|
||||
}
|
||||
}
|
||||
|
||||
public void SetLine(LadderLeaderboardEntry udata, int ranking, Sprite avatar,
|
||||
int rankId, int rankScore, int stars, bool highlight)
|
||||
{
|
||||
|
||||
@@ -54,12 +54,12 @@ namespace TcgEngine
|
||||
return null;
|
||||
}
|
||||
|
||||
Debug.Log($"[SpriteLoader] Loading sprite: {relativePath}");
|
||||
// Debug.Log($"[SpriteLoader] Loading sprite: {relativePath}");
|
||||
|
||||
// 检查缓存
|
||||
if (spriteCache.ContainsKey(relativePath))
|
||||
{
|
||||
Debug.Log($"[SpriteLoader] Found in cache: {relativePath}");
|
||||
// Debug.Log($"[SpriteLoader] Found in cache: {relativePath}");
|
||||
return spriteCache[relativePath];
|
||||
}
|
||||
|
||||
|
||||
@@ -227,7 +227,7 @@ namespace TcgEngine.UI
|
||||
{
|
||||
card = null;
|
||||
variant = null;
|
||||
|
||||
Hide();
|
||||
if (card_image) card_image.enabled = false;
|
||||
if (frame_image) frame_image.enabled = false;
|
||||
if (team_icon) team_icon.enabled = false;
|
||||
|
||||
@@ -10,7 +10,10 @@ namespace TcgEngine.UI
|
||||
{
|
||||
public class PresetDeck : UIPanel
|
||||
{
|
||||
[Header("展示面板")]
|
||||
public Button start_game_button;
|
||||
public TabButton close;
|
||||
|
||||
[Header("卡组面板")]
|
||||
public UIPanel preset_lineup;
|
||||
public Button preset_lineup_button;
|
||||
public UIPanel hide_panel;
|
||||
@@ -24,7 +27,6 @@ namespace TcgEngine.UI
|
||||
[Header("预设面板")]
|
||||
public Button deleteDeckButton;
|
||||
public DeckSelector deckSelector;
|
||||
public DropdownValue dropdownValue;
|
||||
|
||||
private Button hide_panel_button;
|
||||
|
||||
@@ -35,9 +37,10 @@ namespace TcgEngine.UI
|
||||
|
||||
// 卡组展示管理
|
||||
public int card_lines_size = 12;
|
||||
public List<CardUI> card_pool = new List<CardUI>();
|
||||
public List<CardUI> card_lines = new List<CardUI>();
|
||||
|
||||
private List<CardUI> card_pool = new List<CardUI>();
|
||||
private List<CardUI> card_lines = new List<CardUI>();
|
||||
|
||||
private bool _isRankData;
|
||||
|
||||
private UserData lastUserData;
|
||||
private int currIndex = 0;
|
||||
@@ -80,6 +83,9 @@ namespace TcgEngine.UI
|
||||
hide_panel_button.onClick.AddListener(OffPresetLineupPanle);
|
||||
|
||||
deleteDeckButton.onClick.AddListener(OnDeleteDeck);
|
||||
start_game_button.onClick.AddListener(OnStartGame);
|
||||
|
||||
close.onClick += HidePanel;
|
||||
}
|
||||
|
||||
#region 卡组
|
||||
@@ -161,24 +167,63 @@ namespace TcgEngine.UI
|
||||
card_lines.Clear();
|
||||
|
||||
UserDeckData udeck = active_lines[GetCurrIndex()].GetUserDeck();
|
||||
Debug.Log("卡组数量:"+udeck.cards.Length);
|
||||
for (int i = 0; i < udeck.cards.Length; i++)
|
||||
int index = 0; // 对象池索引
|
||||
foreach (var ucard in udeck.cards)
|
||||
{
|
||||
UserCardData ucard = udeck.cards[i];
|
||||
CardUI line = card_pool[i];
|
||||
for (int q = 0; q < ucard.quantity; q++)
|
||||
{
|
||||
if (index >= card_pool.Count)
|
||||
break;
|
||||
|
||||
CardData cdata = CardData.Get(ucard.tid);
|
||||
VariantData variant = VariantData.Get(ucard.variant);
|
||||
CardUI line = card_pool[index++];
|
||||
CardData cdata = CardData.Get(ucard.tid);
|
||||
VariantData variant = VariantData.Get(ucard.variant);
|
||||
|
||||
line.Refresh(cdata, variant);
|
||||
line.gameObject.SetActive(true);
|
||||
card_lines.Add(line);
|
||||
line.Refresh(cdata, variant);
|
||||
line.gameObject.SetActive(true);
|
||||
card_lines.Add(line);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 天梯排行榜使用
|
||||
/// </summary>
|
||||
public void SetupUserCardList(UserDeckData udeck, string name)
|
||||
{
|
||||
_isRankData = true;
|
||||
Show();
|
||||
foreach (var line in card_pool)
|
||||
line.ResetLine();
|
||||
|
||||
card_lines.Clear();
|
||||
|
||||
int index = 0; // 对象池索引
|
||||
foreach (var ucard in udeck.cards)
|
||||
{
|
||||
for (int q = 0; q < ucard.quantity; q++)
|
||||
{
|
||||
if (index >= card_pool.Count)
|
||||
break;
|
||||
|
||||
CardUI line = card_pool[index++];
|
||||
CardData cdata = CardData.Get(ucard.tid);
|
||||
VariantData variant = VariantData.Get(ucard.variant);
|
||||
|
||||
line.Refresh(cdata, variant);
|
||||
line.gameObject.SetActive(true);
|
||||
card_lines.Add(line);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
private void OnStartGame()
|
||||
{
|
||||
MainMenu.Get().OnClickPvP();
|
||||
}
|
||||
/// <summary>
|
||||
/// 打开预设面板
|
||||
/// </summary>
|
||||
@@ -200,13 +245,38 @@ namespace TcgEngine.UI
|
||||
{
|
||||
base.Show(instant);
|
||||
|
||||
SetupUserDeckList();
|
||||
|
||||
if (!_isRankData)
|
||||
{
|
||||
SetupUserDeckList();
|
||||
preset_lineup_button.gameObject.SetActive(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
preset_lineup_button.gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
if (currIndex != 0)
|
||||
{
|
||||
SetupUserCardList();
|
||||
}
|
||||
preset_lineup.Hide();
|
||||
hide_panel.Hide();
|
||||
}
|
||||
|
||||
private void HidePanel()
|
||||
{
|
||||
if (_isRankData)
|
||||
{
|
||||
LeaderboardPanel.Get().Show();
|
||||
_isRankData = false;
|
||||
}
|
||||
}
|
||||
|
||||
public override void Hide(bool instant = false)
|
||||
{
|
||||
base.Hide(instant);
|
||||
}
|
||||
|
||||
public static PresetDeck Get()
|
||||
{
|
||||
return instance;
|
||||
|
||||
Reference in New Issue
Block a user