shaoxiadiablo/Assets/AGame/Scripts/UI/AdventureBox/AdventureBox.RewardWidget.cs

84 lines
2.1 KiB
C#
Raw Normal View History

2025-05-18 01:04:31 +08:00
// ***********************************************************************
// Assembly : Game
// Author : Kimch
// Created : 2021-05-01
// Description :
// Last Modified By :
// Last Modified On :
// ***********************************************************************
// <copyright file= "AdventureBox.View" company="Kunpo"></copyright>
// <summary></summary>
// ***********************************************************************
namespace G.UI
{
using TMPro;
using UnityEngine;
using UnityEngine.UI;
/// <summary>
///
/// </summary>
partial class AdventureBox
{
private class RewardWidget : KUIWidget
{
#pragma warning disable CS0649 // 从未对字段赋值,字段将一直保持其默认值 null
[KUIFlag]
KUIImage _imgQuality;
[KUIFlag]
Image _imgIcon;
[KUIFlag]
TextMeshProUGUI _tmpName;
[KUIFlag]
TextMeshProUGUI _tmpDescription;
[KUIFlag]
Button _btnBg;
#pragma warning restore CS0649 // 从未对字段赋值,字段将一直保持其默认值 null
public override void Refresh()
{
_btnBg.onClick.RemoveAllListeners();
if (this.data is ItemProp prop)
{
_imgQuality.gameObject.SetActive(true);
_imgQuality.ShowSprite(Mathf.Max(0, prop.quality - 1));
IconProxy.Instance.SetSprite(_imgIcon, prop.icon);
_tmpName.text = prop.name;
_tmpDescription.text = "";
}
else if (this.data is ItemBuff buff)
{
_imgQuality.gameObject.SetActive(false);
IconProxy.Instance.SetSprite(_imgIcon, buff.icon);
_tmpName.text = buff.name;
_tmpDescription.text = buff.text;
}
else if (this.data is ItemMoves moves)
{
_imgQuality.gameObject.SetActive(false);
IconProxy.Instance.SetSprite(_imgIcon, moves.icon);
_tmpName.text = moves.name;
_tmpDescription.text = "";
}
}
public void AddListener(UnityEngine.Events.UnityAction call)
{
_btnBg.onClick.RemoveAllListeners();
_btnBg.onClick.AddListener(call);
}
public void ClearListener()
{
_btnBg.onClick.RemoveAllListeners();
}
private void Awake()
{
SetViewData();
}
}
}
}