完善开卡
This commit is contained in:
@@ -11,11 +11,20 @@ namespace TcgEngine.UI
|
||||
/// </summary>
|
||||
public class PackBuyPanel : UIPanel
|
||||
{
|
||||
[Header("五连抽")]
|
||||
public Button buy_five_btn; // 购买1张按钮
|
||||
public Text buy_five_cove;
|
||||
public Image five_coin_img;
|
||||
public Image five_crystal_img;
|
||||
|
||||
[Header("十连抽")]
|
||||
public Button buy_ten_btn; // 购买2张按钮
|
||||
public Text buy_ten_cove;
|
||||
public Image ten_coin_img;
|
||||
public Image ten_crystal_img;
|
||||
|
||||
[Header("准备购买数据!")]
|
||||
public PackData pack; // 当前购买的卡包数据
|
||||
private PackData pack; // 当前购买的卡包数据
|
||||
|
||||
|
||||
protected override void Awake()
|
||||
@@ -40,6 +49,7 @@ namespace TcgEngine.UI
|
||||
public void SetPack(string packId)
|
||||
{
|
||||
pack = PackData.Get(packId);
|
||||
SetBuyMessage();
|
||||
}
|
||||
|
||||
public void SetPack(PackData pack)
|
||||
@@ -47,7 +57,35 @@ namespace TcgEngine.UI
|
||||
this.pack = pack;
|
||||
Show();
|
||||
}
|
||||
|
||||
private void OnClickBuy(int quantity)
|
||||
{
|
||||
BuyPackApi(quantity);
|
||||
}
|
||||
|
||||
private void SetBuyMessage()
|
||||
{
|
||||
// 设置图标
|
||||
switch (pack.tradeCurrency)
|
||||
{
|
||||
case TradeCurrency.Coin:
|
||||
five_coin_img.gameObject.SetActive(true);
|
||||
ten_coin_img.gameObject.SetActive(true);
|
||||
|
||||
five_crystal_img.gameObject.SetActive(false);
|
||||
ten_crystal_img.gameObject.SetActive(false);
|
||||
break;
|
||||
case TradeCurrency.Crystal:
|
||||
five_coin_img.gameObject.SetActive(false);
|
||||
ten_coin_img.gameObject.SetActive(false);
|
||||
|
||||
five_crystal_img.gameObject.SetActive(true);
|
||||
ten_crystal_img.gameObject.SetActive(true);
|
||||
break;
|
||||
}
|
||||
buy_five_cove.text = pack.cost.ToString();
|
||||
buy_ten_cove.text = (pack.cost * 2).ToString();
|
||||
}
|
||||
private async void BuyPackApi(int quantity)
|
||||
{
|
||||
if (pack == null || quantity <= 0) return;
|
||||
@@ -80,11 +118,7 @@ namespace TcgEngine.UI
|
||||
Debug.LogError(res.error);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnClickBuy(int quantity)
|
||||
{
|
||||
BuyPackApi(quantity);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user