111 lines
2.6 KiB
C#
111 lines
2.6 KiB
C#
// ***********************************************************************
|
|
// Assembly : Game
|
|
// Author : Kimch
|
|
// Created : 2020-12-07
|
|
// Description :
|
|
// Last Modified By :
|
|
// Last Modified On :
|
|
// ***********************************************************************
|
|
// <copyright file= "ShopPanel.CoinBoxWidget" company="Kunpo"></copyright>
|
|
// <summary></summary>
|
|
// ***********************************************************************
|
|
|
|
using TMPro;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
namespace G.UI
|
|
{
|
|
partial class ShopPanel
|
|
{
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
class CoinBoxWidget : KUIWidget
|
|
{
|
|
#region Field
|
|
|
|
#pragma warning disable CS0649 // 从未对字段赋值,字段将一直保持其默认值 null
|
|
[KUIFlag]
|
|
TextMeshProUGUI _tmpName;
|
|
[KUIFlag]
|
|
KUIImage _imgIcon;
|
|
[KUIFlag]
|
|
Button _btnGet;
|
|
[KUIFlag]
|
|
GameObject __goPrice;
|
|
#pragma warning restore CS0649 // 从未对字段赋值,字段将一直保持其默认值 null
|
|
//[KUIFlag]
|
|
//TextMeshProUGUI _tmpGet;
|
|
|
|
//private EquipmentItem _equipmentItem;
|
|
private CostWidget _priceItem;
|
|
|
|
#endregion
|
|
|
|
#region Method
|
|
|
|
public override void Refresh()
|
|
{
|
|
if (this.data is ShopProxy.CoinBox slot)
|
|
{
|
|
var boxItem = BoxProxy.Instance.GetBoxInfo(slot.itemId);
|
|
if (boxItem != null)
|
|
{
|
|
_tmpName.text = boxItem.item.name;
|
|
_imgIcon.ShowSprite(Mathf.Max(0, boxItem.item.quality - 1));
|
|
//_equipmentItem.SetData(ItemProxy.Instance.GetStaticItem<ItemEquipment>(slot.itemId));
|
|
//_btnGet.interactable = slot.status == 0;
|
|
_priceItem.SetPrice(boxItem.item.priceInfo);
|
|
//_tmpGet.text = slot.status == 0 ? "领取" : "已领取";
|
|
}
|
|
}
|
|
}
|
|
|
|
private void OnGetBtnClick()
|
|
{
|
|
if (this.data is ShopProxy.CoinBox slot)
|
|
{
|
|
int result = ShopProxy.Instance.OpenShopSlot(slot.id);
|
|
switch (result)
|
|
{
|
|
case 0:
|
|
Refresh();
|
|
break;
|
|
case 1:
|
|
ToastBox.ShowText("领取次数已达到每日上限");
|
|
break;
|
|
case 2:
|
|
ToastBox.ShowText("所需货币不足");
|
|
break;
|
|
case 3:
|
|
ToastBox.ShowText("宝箱配置错误");
|
|
break;
|
|
case 4:
|
|
ToastBox.ShowText("宝箱未初始化");
|
|
break;
|
|
}
|
|
}
|
|
SoundProxy.PlayFxAsync(GlobalDefine.BUTTON_CLICK_SOUND);
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Unity
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
private void Awake()
|
|
{
|
|
SetViewData();
|
|
_priceItem = __goPrice.AddComponent<CostWidget>();
|
|
//_equipmentItem = _equipment.AddComponent<EquipmentItem>();
|
|
_btnGet.onClick.AddListener(this.OnGetBtnClick);
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
}
|
|
}
|