110 lines
2.5 KiB
C#
110 lines
2.5 KiB
C#
![]() |
// ***********************************************************************
|
|||
|
// Assembly : Game
|
|||
|
// Author : Kimch
|
|||
|
// Created : 2021-04-25
|
|||
|
// Description :
|
|||
|
// Last Modified By :
|
|||
|
// Last Modified On :
|
|||
|
// ***********************************************************************
|
|||
|
// <copyright file= "BattlePassWindow" company="Kunpo"></copyright>
|
|||
|
// <summary></summary>
|
|||
|
// ***********************************************************************
|
|||
|
using TMPro;
|
|||
|
using UnityEngine;
|
|||
|
using UnityEngine.UI;
|
|||
|
|
|||
|
namespace G.UI
|
|||
|
{
|
|||
|
public partial class BattlePassWindow
|
|||
|
{
|
|||
|
public class MissionWidget : KUIWidget
|
|||
|
{
|
|||
|
#region Field
|
|||
|
|
|||
|
#pragma warning disable CS0649 // 从未对字段赋值,字段将一直保持其默认值 null
|
|||
|
[KUIFlag]
|
|||
|
TextMeshProUGUI _tmpDescription;
|
|||
|
[KUIFlag]
|
|||
|
Slider _slidProgress;
|
|||
|
[KUIFlag]
|
|||
|
TextMeshProUGUI _tmpProgress;
|
|||
|
[KUIFlag]
|
|||
|
Button _btnReceive;
|
|||
|
[KUIFlag]
|
|||
|
TextMeshProUGUI _tmpReceive;
|
|||
|
[KUIFlag]
|
|||
|
KUIList __listRewards;
|
|||
|
|
|||
|
#pragma warning restore CS0649 // 从未对字段赋值,字段将一直保持其默认值 null
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region Method
|
|||
|
|
|||
|
public override void Refresh()
|
|||
|
{
|
|||
|
if (this.data is Mission mission)
|
|||
|
{
|
|||
|
_tmpDescription.text = mission.description;
|
|||
|
_slidProgress.value = mission.curValue / Mathf.Max(1f, mission.maxValue);
|
|||
|
_tmpProgress.text = $"{mission.curValue}/{mission.maxValue}";
|
|||
|
|
|||
|
__listRewards.Clear();
|
|||
|
foreach (var itemInfo in mission.rewards)
|
|||
|
{
|
|||
|
__listRewards.GetItem<PropWidget>().SetItem(itemInfo);
|
|||
|
}
|
|||
|
|
|||
|
if (mission.isRewarded)
|
|||
|
{
|
|||
|
_tmpReceive.text = "已领取";
|
|||
|
_btnReceive.interactable = false;
|
|||
|
}
|
|||
|
else if (mission.isCompleted)
|
|||
|
{
|
|||
|
_tmpReceive.text = "领取";
|
|||
|
_btnReceive.interactable = true;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
_tmpReceive.text = "领取";
|
|||
|
_btnReceive.interactable = false;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
private void OnReceiveBtnClick()
|
|||
|
{
|
|||
|
if (this.data is Mission mission)
|
|||
|
{
|
|||
|
MissionProxy.Instance.GainReward(mission.id, (error, message) =>
|
|||
|
{
|
|||
|
if (error == 0)
|
|||
|
{
|
|||
|
BattlePassProxy.Instance.SyncExp();
|
|||
|
GetWindow<BattlePassWindow>().RefreshView();
|
|||
|
}
|
|||
|
});
|
|||
|
}
|
|||
|
SoundProxy.PlayFxAsync(GlobalDefine.BUTTON_CLICK_SOUND);
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region Unity
|
|||
|
|
|||
|
/// <summary>
|
|||
|
///
|
|||
|
/// </summary>
|
|||
|
private void Awake()
|
|||
|
{
|
|||
|
SetViewData();
|
|||
|
_btnReceive.onClick.AddListener(this.OnReceiveBtnClick);
|
|||
|
__listRewards.AddTemplate<PropWidget>(true);
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
}
|
|||
|
}
|
|||
|
}
|