168 lines
4.4 KiB
C#
168 lines
4.4 KiB
C#
// ***********************************************************************
|
|
// Assembly : Game
|
|
// Author : Kimch
|
|
// Created : 2022-02-28
|
|
// Description :
|
|
// Last Modified By :
|
|
// Last Modified On :
|
|
// ***********************************************************************
|
|
// <copyright file= "WomanWindow" company="Kunpo"></copyright>
|
|
// <summary></summary>
|
|
// ***********************************************************************
|
|
|
|
namespace G.UI
|
|
{
|
|
using TMPro;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public partial class FunctionRewardsWindow
|
|
{
|
|
class FunctionBoxWidget : KUIWidget
|
|
{
|
|
#region Fide
|
|
#pragma warning disable CS0649 // 从未对字段赋值,字段将一直保持其默认值 null
|
|
[KUIFlag]
|
|
Button _btnReceive;
|
|
[KUIFlag]
|
|
TextMeshProUGUI _tmpPrice;
|
|
[KUIFlag]
|
|
KUIList __listRewards;
|
|
[KUIFlag]
|
|
TextMeshProUGUI _tmpGet;
|
|
[KUIFlag]
|
|
Image _imgIcon;
|
|
#pragma warning restore CS0649 // 从未对字段赋值,字段将一直保持其默认值 null
|
|
#endregion
|
|
|
|
#region Method
|
|
public override void Refresh()
|
|
{
|
|
if (this.data is FunctionProxy.Function function)
|
|
{
|
|
if (function.IsUnlock())
|
|
{
|
|
_imgIcon.color = Color.white;
|
|
_tmpPrice.gameObject.SetActive(false);
|
|
_btnReceive.gameObject.SetActive(true);
|
|
if (function.status < 2)
|
|
{
|
|
_btnReceive.interactable = true;
|
|
_tmpGet.text = "领取";
|
|
}
|
|
else
|
|
{
|
|
_btnReceive.interactable = false;
|
|
_tmpGet.text = "已领取";
|
|
}
|
|
}
|
|
else
|
|
{
|
|
_imgIcon.color = new Color32(150, 150, 150, 255);
|
|
_tmpPrice.gameObject.SetActive(true);
|
|
_btnReceive.gameObject.SetActive(false);
|
|
_tmpPrice.text = function.lockTips;
|
|
}
|
|
IconProxy.Instance.SetSprite(_imgIcon, function.icon);
|
|
__listRewards.Clear();
|
|
foreach (var itemInfo in function.rewardInfos)
|
|
{
|
|
__listRewards.GetItem<PropWidget>().SetItem(itemInfo);
|
|
}
|
|
}
|
|
}
|
|
private void OnReceiveBtnClick() //领取奖励
|
|
{
|
|
if (this.data is FunctionProxy.Function function)
|
|
{
|
|
FunctionProxy.Instance.GetRewards(function);
|
|
GetWindow<FunctionRewardsWindow>().RefreshView();
|
|
PostNotification(GlobalDefine.EVENT_MISSION_CHANGED, "FunctionRewards");
|
|
}
|
|
}
|
|
private void Awake()
|
|
{
|
|
SetViewData();
|
|
_btnReceive.onClick.AddListener(this.OnReceiveBtnClick);
|
|
__listRewards.AddTemplate<PropWidget>(true);
|
|
}
|
|
#endregion
|
|
}
|
|
#region Constructor
|
|
#pragma warning disable CS0649 // 从未对字段赋值,字段将一直保持其默认值 null
|
|
[KUIFlag]
|
|
Button _btnClose;
|
|
[KUIFlag]
|
|
KUIList __listRankings;
|
|
|
|
#pragma warning restore CS0649 // 从未对字段赋值,字段将一直保持其默认值 null
|
|
|
|
#endregion
|
|
|
|
#region Method
|
|
public void RefreshView()
|
|
{
|
|
var functions = FunctionProxy.Instance.Functions;
|
|
var mask = __listRankings.transform.Find("goMask");
|
|
if (mask)
|
|
{
|
|
mask.gameObject.SetActive(false);
|
|
}
|
|
bool isAllUnlock = true;
|
|
__listRankings.Clear();
|
|
var timer = 3;
|
|
foreach (var function in functions)
|
|
{
|
|
if (function.status < 2)
|
|
{
|
|
isAllUnlock = false;
|
|
if (function.IsUnlock())
|
|
{
|
|
__listRankings.GetItem().SetData(function);
|
|
}
|
|
else
|
|
{
|
|
timer--;
|
|
if (timer < 0)
|
|
{
|
|
if (mask)
|
|
{
|
|
mask.gameObject.SetActive(true);
|
|
mask.SetAsLastSibling();
|
|
}
|
|
return;
|
|
}
|
|
__listRankings.GetItem().SetData(function);
|
|
}
|
|
}
|
|
}
|
|
//foreach (var function in functions)
|
|
//{
|
|
// if (function.status == 2)
|
|
// {
|
|
// __listRankings.GetItem().SetData(function);
|
|
// }
|
|
//}
|
|
if (isAllUnlock)
|
|
{
|
|
CloseWindow(this);
|
|
}
|
|
}
|
|
private void OnCloseBtnClick()
|
|
{
|
|
CloseWindow(this);
|
|
}
|
|
|
|
private void InitView()
|
|
{
|
|
SetViewData();
|
|
_btnClose.onClick.AddListener(this.OnCloseBtnClick);
|
|
|
|
__listRankings.AddTemplate<FunctionBoxWidget>(true);
|
|
}
|
|
|
|
#endregion
|
|
|
|
|
|
}
|
|
} |