完善抽卡界面以及根据优化意见和功能缺失做出调整
This commit is contained in:
@@ -6,7 +6,7 @@ using TcgEngine.Gameplay;
|
||||
namespace TcgEngine
|
||||
{
|
||||
/// <summary>
|
||||
/// Defines all ability data
|
||||
/// 定义所有能力数据
|
||||
/// </summary>
|
||||
|
||||
[CreateAssetMenu(fileName = "ability", menuName = "TcgEngine/AbilityData", order = 5)]
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
using System.Collections;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using TcgEngine.Client;
|
||||
using TcgEngine.UI;
|
||||
|
||||
namespace TcgEngine
|
||||
{
|
||||
@@ -19,6 +21,8 @@ namespace TcgEngine
|
||||
private HashSet<string> ability_ids = new HashSet<string>();
|
||||
private HashSet<string> deck_ids = new HashSet<string>();
|
||||
|
||||
public static Action onLoadComplete;
|
||||
|
||||
private static DataLoader instance;
|
||||
|
||||
void Awake()
|
||||
@@ -27,29 +31,27 @@ namespace TcgEngine
|
||||
LoadData();
|
||||
}
|
||||
|
||||
public void LoadData()
|
||||
private void LoadData()
|
||||
{
|
||||
//To make loading faster, add a path inside each Load() function, relative to Resources folder
|
||||
//For example CardData.Load("Cards"); to only load data inside the Resources/Cards folder
|
||||
CardData.Load();
|
||||
TeamData.Load();
|
||||
RarityData.Load();
|
||||
TraitData.Load();
|
||||
VariantData.Load();
|
||||
PackData.Load();
|
||||
LevelData.Load();
|
||||
DeckData.Load();
|
||||
AbilityData.Load();
|
||||
StatusData.Load();
|
||||
AvatarData.Load();
|
||||
CardbackData.Load();
|
||||
RewardData.Load();
|
||||
CardCoverData.Load();
|
||||
|
||||
CheckCardData();
|
||||
CheckAbilityData();
|
||||
CheckDeckData();
|
||||
CheckVariantData();
|
||||
CardData.Load();
|
||||
TeamData.Load();
|
||||
RarityData.Load();
|
||||
TraitData.Load();
|
||||
VariantData.Load();
|
||||
PackData.Load();
|
||||
LevelData.Load();
|
||||
DeckData.Load();
|
||||
AbilityData.Load();
|
||||
StatusData.Load();
|
||||
AvatarData.Load();
|
||||
CardbackData.Load();
|
||||
RewardData.Load();
|
||||
CardCoverData.Load();
|
||||
|
||||
CheckCardData();
|
||||
CheckAbilityData();
|
||||
CheckDeckData();
|
||||
CheckVariantData();
|
||||
}
|
||||
|
||||
//Make sure the data is valid
|
||||
@@ -93,7 +95,7 @@ namespace TcgEngine
|
||||
}
|
||||
}
|
||||
|
||||
//Make sure the data is valid
|
||||
// 确保数据有效
|
||||
private void CheckAbilityData()
|
||||
{
|
||||
ability_ids.Clear();
|
||||
|
||||
@@ -19,6 +19,8 @@ namespace TcgEngine.Client
|
||||
public float card_angle = 10f;
|
||||
public float card_offset_y = 10f;
|
||||
|
||||
public UIPanel buyButton;
|
||||
|
||||
private List<HandPack> packs = new List<HandPack>();
|
||||
|
||||
private Vector3 start_pos;
|
||||
@@ -66,6 +68,7 @@ namespace TcgEngine.Client
|
||||
public void RefreshPacks()
|
||||
{
|
||||
UserData udata = Authenticator.Get().UserData;
|
||||
Debug.Log("玩家卡包有:"+udata.packs.Length+"种");
|
||||
foreach (UserCardData pack in udata.packs)
|
||||
{
|
||||
Debug.Log("服务器返回的卡包tid:" + pack.tid+",");
|
||||
@@ -75,9 +78,10 @@ namespace TcgEngine.Client
|
||||
PackData dpack = PackData.Get(pack.tid);
|
||||
if (dpack != null && !HasPack(pack.tid))
|
||||
SpawnNewPack(pack);
|
||||
Debug.Log($"其中有{pack.tid}:{pack.quantity}个");
|
||||
}
|
||||
|
||||
//Remove removed cards
|
||||
// 移除已移除的卡片
|
||||
for (int i = packs.Count - 1; i >= 0; i--)
|
||||
{
|
||||
HandPack pack = packs[i];
|
||||
@@ -88,6 +92,15 @@ namespace TcgEngine.Client
|
||||
pack.Remove();
|
||||
}
|
||||
}
|
||||
|
||||
if (udata.packs==null || udata.packs.Length == 0)
|
||||
{
|
||||
buyButton.Show();
|
||||
}
|
||||
else
|
||||
{
|
||||
buyButton.Hide();
|
||||
}
|
||||
}
|
||||
|
||||
void Update()
|
||||
|
||||
@@ -37,6 +37,8 @@ namespace TcgEngine.Client
|
||||
private bool removed = false;
|
||||
private bool is_new = false;
|
||||
private float timer = 0f;
|
||||
|
||||
private bool hasOpenedStandardPack = false;
|
||||
|
||||
private static List<PackCard> card_list = new List<PackCard>();
|
||||
|
||||
@@ -61,12 +63,9 @@ namespace TcgEngine.Client
|
||||
transform.rotation = Quaternion.Slerp(transform.rotation, rtarget, flip_speed * Time.deltaTime);
|
||||
}
|
||||
|
||||
if (removed && timer > 4f)
|
||||
Destroy(gameObject);
|
||||
|
||||
if (card_list.Count==5)
|
||||
if (removed && timer > 1f)
|
||||
{
|
||||
|
||||
Destroy(gameObject);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -102,7 +102,7 @@ namespace TcgEngine.UI
|
||||
{
|
||||
base.Start();
|
||||
|
||||
//Set power abilities hover text
|
||||
// 设置点击能力悬停文本
|
||||
foreach (IconButton btn in hero_powers)
|
||||
{
|
||||
CardData icard = CardData.Get(btn.GetValue());
|
||||
@@ -117,10 +117,6 @@ namespace TcgEngine.UI
|
||||
hover.text += " <size=16>Mana: " + iability.mana_cost + "</size>";
|
||||
}
|
||||
}
|
||||
if (!spawned)
|
||||
{
|
||||
SpawnCards();
|
||||
}
|
||||
}
|
||||
|
||||
protected override void Update()
|
||||
@@ -149,7 +145,7 @@ namespace TcgEngine.UI
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void SpawnCards()
|
||||
{
|
||||
spawned = true;
|
||||
@@ -200,7 +196,7 @@ namespace TcgEngine.UI
|
||||
|
||||
//----- Refresh UI --------
|
||||
|
||||
private void RefreshAll()
|
||||
public void RefreshAll()
|
||||
{
|
||||
RefreshFilters();
|
||||
RefreshCards();
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using TcgEngine.UI;
|
||||
using UnityEngine;
|
||||
using Random = UnityEngine.Random;
|
||||
|
||||
namespace TcgEngine.Client
|
||||
{
|
||||
@@ -12,7 +15,10 @@ namespace TcgEngine.Client
|
||||
public class OpenPackMenu : MonoBehaviour
|
||||
{
|
||||
public GameObject card_prefab;
|
||||
|
||||
|
||||
public PackBuyPanel packBuyPanel;
|
||||
|
||||
|
||||
private bool revealing = false;
|
||||
|
||||
private static OpenPackMenu instance;
|
||||
@@ -20,6 +26,7 @@ namespace TcgEngine.Client
|
||||
void Awake()
|
||||
{
|
||||
instance = this;
|
||||
packBuyPanel.SetPack(PlayerPrefs.GetString("pack_id"));
|
||||
}
|
||||
|
||||
void Update()
|
||||
|
||||
90
Assets/TcgEngine/Scripts/Menu/PackBuyPanel.cs
Normal file
90
Assets/TcgEngine/Scripts/Menu/PackBuyPanel.cs
Normal file
@@ -0,0 +1,90 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using TcgEngine.Client;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace TcgEngine.UI
|
||||
{
|
||||
/// <summary>
|
||||
/// 简化卡包购买面板,只提供“买1包”和“买2包”按钮,保留API购买逻辑
|
||||
/// </summary>
|
||||
public class PackBuyPanel : UIPanel
|
||||
{
|
||||
public Button buy_five_btn; // 购买1张按钮
|
||||
public Button buy_ten_btn; // 购买2张按钮
|
||||
|
||||
[Header("准备购买数据!")]
|
||||
public PackData pack; // 当前购买的卡包数据
|
||||
|
||||
|
||||
protected override void Awake()
|
||||
{
|
||||
base.Awake();
|
||||
this.Show();
|
||||
|
||||
buy_five_btn.onClick.AddListener(() => OnClickBuy(1));
|
||||
buy_ten_btn.onClick.AddListener(() => OnClickBuy(2));
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
buy_five_btn.onClick.RemoveAllListeners();
|
||||
buy_ten_btn.onClick.RemoveAllListeners();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// id传输
|
||||
/// </summary>
|
||||
/// <param name="pack">卡牌id</param>
|
||||
public void SetPack(string packId)
|
||||
{
|
||||
pack = PackData.Get(packId);
|
||||
}
|
||||
|
||||
public void SetPack(PackData pack)
|
||||
{
|
||||
this.pack = pack;
|
||||
Show();
|
||||
}
|
||||
|
||||
private async void BuyPackApi(int quantity)
|
||||
{
|
||||
if (pack == null || quantity <= 0) return;
|
||||
|
||||
BuyPackRequest req = new BuyPackRequest
|
||||
{
|
||||
pack = pack.id,
|
||||
quantity = quantity
|
||||
};
|
||||
|
||||
string url = ApiClient.ServerURL + "/users/packs/buy/";
|
||||
string jdata = ApiTool.ToJson(req);
|
||||
|
||||
WebResponse res = await ApiClient.Get().SendPostRequest(url, jdata);
|
||||
if (res.success)
|
||||
{
|
||||
if (PackPanel.Get() != null)
|
||||
{
|
||||
PackPanel.Get()?.ReloadUserPack();
|
||||
PackPanel.Get()?.RefreshCurrency();
|
||||
}
|
||||
|
||||
if (HandPackArea.Get() != null)
|
||||
{
|
||||
HandPackArea.Get().LoadPacks();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogError(res.error);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnClickBuy(int quantity)
|
||||
{
|
||||
BuyPackApi(quantity);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
11
Assets/TcgEngine/Scripts/Menu/PackBuyPanel.cs.meta
Normal file
11
Assets/TcgEngine/Scripts/Menu/PackBuyPanel.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ff8ebde9cba8f9548a236d8789ee537e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -19,9 +19,12 @@ namespace TcgEngine.UI
|
||||
[Header("货币")]
|
||||
public Text coin;
|
||||
public Text crystal;
|
||||
|
||||
|
||||
[Header("当前选择准备卡组")]
|
||||
public Toggle standard_toggle;
|
||||
public Toggle elite_toggle;
|
||||
public PackData preparePack;
|
||||
public PackBuyPanel packBuyPanel;
|
||||
|
||||
private List<GameObject> pack_list = new List<GameObject>();
|
||||
|
||||
@@ -40,6 +43,15 @@ namespace TcgEngine.UI
|
||||
protected override void Start()
|
||||
{
|
||||
base.Start();
|
||||
|
||||
if (standard_toggle != null)
|
||||
standard_toggle.onValueChanged.AddListener(OnToggleStandard);
|
||||
|
||||
if (elite_toggle != null)
|
||||
elite_toggle.onValueChanged.AddListener(OnToggleElite);
|
||||
|
||||
// 默认设置卡组
|
||||
OnToggleStandard(standard_toggle.isOn);
|
||||
}
|
||||
|
||||
protected override void Update()
|
||||
@@ -80,10 +92,6 @@ namespace TcgEngine.UI
|
||||
pack_ui.onClick += OnClickPack;
|
||||
pack_ui.onClickRight += OnClickPack;
|
||||
pack_list.Add(nPack);
|
||||
if (pack.title == "白银卡包")
|
||||
{
|
||||
SetPackData(pack);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -100,16 +108,6 @@ namespace TcgEngine.UI
|
||||
}
|
||||
}
|
||||
|
||||
private void OnClickPack()
|
||||
{
|
||||
|
||||
if (preparePack != null)
|
||||
{
|
||||
PackZoomPanel.Get().OnClickBuy(preparePack);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 刷新货币
|
||||
/// </summary>
|
||||
@@ -118,20 +116,6 @@ namespace TcgEngine.UI
|
||||
coin.text = MainMenu.Get().credits_txt.text;
|
||||
crystal.text = MainMenu.Get().crystalText.text;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置即将打开卡包的数据
|
||||
/// </summary>
|
||||
private string SetPackData(PackData pack)
|
||||
{
|
||||
PlayerPrefs.SetString("SetPack",pack.id);
|
||||
if (PlayerPrefs.GetString("SetPack") != null)
|
||||
{
|
||||
string setPack = PlayerPrefs.GetString("SetPack");
|
||||
Debug.Log($"已设置{setPack},准备就绪");
|
||||
}
|
||||
return PlayerPrefs.GetString("SetPack");
|
||||
}
|
||||
|
||||
public void OnClickPack(PackUI pack)
|
||||
{
|
||||
@@ -147,6 +131,35 @@ namespace TcgEngine.UI
|
||||
{
|
||||
MainMenu.Get().FadeToScene("OpenPack");
|
||||
}
|
||||
|
||||
private void OnToggleStandard(bool value)
|
||||
{
|
||||
if (value)
|
||||
{
|
||||
// 设置当前卡组为标准卡组
|
||||
preparePack = PackData.Get("standard");
|
||||
SetBuyPack("standard");
|
||||
Debug.Log("当前选择标准卡组");
|
||||
}
|
||||
}
|
||||
private void OnToggleElite(bool value)
|
||||
{
|
||||
if (value)
|
||||
{
|
||||
// 设置当前卡组为精英卡组
|
||||
preparePack = PackData.Get("elite");
|
||||
SetBuyPack("elite");
|
||||
Debug.Log("当前选择精英卡组");
|
||||
}
|
||||
}
|
||||
|
||||
private void SetBuyPack(string packId)
|
||||
{
|
||||
packBuyPanel.SetPack(packId);
|
||||
PlayerPrefs.SetString("pack_id", packId);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public override void Show(bool instant = false)
|
||||
{
|
||||
|
||||
@@ -120,19 +120,6 @@ namespace TcgEngine.UI
|
||||
}
|
||||
}
|
||||
|
||||
public void OnClickBuy(PackData setPack)
|
||||
{
|
||||
pack = setPack;
|
||||
if (Authenticator.Get().IsTest())
|
||||
{
|
||||
BuyPackTest();
|
||||
}
|
||||
if (Authenticator.Get().IsApi())
|
||||
{
|
||||
BuyPackApi();
|
||||
}
|
||||
}
|
||||
|
||||
private void OnClickTab(TabButton btn)
|
||||
{
|
||||
if (btn.group == "menu")
|
||||
|
||||
@@ -7,7 +7,7 @@ using UnityEngine.EventSystems;
|
||||
namespace TcgEngine.UI
|
||||
{
|
||||
/// <summary>
|
||||
/// Target in the UI that can be hovered (and text will appear)
|
||||
/// 在UI中可以悬停的目标(并且文本将出现)
|
||||
/// </summary>
|
||||
|
||||
public class HoverTargetUI : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler
|
||||
|
||||
@@ -235,7 +235,7 @@ namespace TcgEngine.UI
|
||||
/// <summary>
|
||||
/// 关闭预设面板
|
||||
/// </summary>
|
||||
private void OffPresetLineupPanle()
|
||||
public void OffPresetLineupPanle()
|
||||
{
|
||||
preset_lineup.Hide();
|
||||
hide_panel.Hide();
|
||||
|
||||
Reference in New Issue
Block a user