105 lines
2.3 KiB
C#
105 lines
2.3 KiB
C#
![]() |
// ***********************************************************************
|
|||
|
// Assembly : Game
|
|||
|
// Author : Kimch
|
|||
|
// Created : 2021-04-23
|
|||
|
// Description :
|
|||
|
// Last Modified By :
|
|||
|
// Last Modified On :
|
|||
|
// ***********************************************************************
|
|||
|
// <copyright file= "MailDetailWidget" company="Kunpo"></copyright>
|
|||
|
// <summary></summary>
|
|||
|
// ***********************************************************************
|
|||
|
|
|||
|
using TMPro;
|
|||
|
using UnityEngine;
|
|||
|
using UnityEngine.UI;
|
|||
|
|
|||
|
namespace G.UI
|
|||
|
{
|
|||
|
/// <summary>
|
|||
|
///
|
|||
|
/// </summary>
|
|||
|
public class MailDetailWidget : KUIWidget
|
|||
|
{
|
|||
|
#region Field
|
|||
|
|
|||
|
#pragma warning disable CS0649 // 从未对字段赋值,字段将一直保持其默认值 null
|
|||
|
[KUIFlag]
|
|||
|
Button _btnAction;
|
|||
|
[KUIFlag]
|
|||
|
TextMeshProUGUI _tmpMailTitle;
|
|||
|
[KUIFlag]
|
|||
|
TextMeshProUGUI _tmpMailContent;
|
|||
|
[KUIFlag]
|
|||
|
KUIList _listRewards;
|
|||
|
[KUIFlag]
|
|||
|
TextMeshProUGUI _tmpStatus;
|
|||
|
#pragma warning restore CS0649 // 从未对字段赋值,字段将一直保持其默认值 null
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region Method
|
|||
|
|
|||
|
public override void Refresh()
|
|||
|
{
|
|||
|
if (this.data is Mail mail)
|
|||
|
{
|
|||
|
_tmpMailTitle.text = mail.title;
|
|||
|
_tmpMailContent.text = mail.content;
|
|||
|
|
|||
|
if (mail.status < 2 && mail.giveItems != null && mail.giveItems.Length > 0)
|
|||
|
{
|
|||
|
//_btnAction.interactable = true;
|
|||
|
_tmpStatus.text = "领取";
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
//_btnAction.interactable = true;
|
|||
|
_tmpStatus.text = "删除";
|
|||
|
}
|
|||
|
|
|||
|
_listRewards.Clear();
|
|||
|
var giveItems = mail.giveItems;
|
|||
|
if (giveItems != null)
|
|||
|
for (int i = 0; i < giveItems.Length; i++)
|
|||
|
{
|
|||
|
_listRewards.GetItem<PropWidget>().SetItem(giveItems[i]);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
private void OnActionBtnClick()
|
|||
|
{
|
|||
|
if (this.data is Mail mail)
|
|||
|
{
|
|||
|
if (mail.status < 2 && mail.giveItems != null && mail.giveItems.Length > 0)
|
|||
|
{
|
|||
|
MailProxy.Instance.GetAttach(mail, null);
|
|||
|
Refresh();
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
MailProxy.Instance.Delete(mail, null);
|
|||
|
KUIWindow.GetWindow<MailWindow>().RefreshView();
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region Unity
|
|||
|
|
|||
|
/// <summary>
|
|||
|
///
|
|||
|
/// </summary>
|
|||
|
private void Awake()
|
|||
|
{
|
|||
|
SetViewData();
|
|||
|
_listRewards.AddTemplate<PropWidget>(true);
|
|||
|
_btnAction.onClick.AddListener(this.OnActionBtnClick);
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
}
|
|||
|
}
|