120 lines
2.6 KiB
C#
120 lines
2.6 KiB
C#
![]() |
// ***********************************************************************
|
|||
|
// Assembly : Game
|
|||
|
// Author : Kimch
|
|||
|
// Created : 2021-01-03
|
|||
|
// Description :
|
|||
|
// Last Modified By :
|
|||
|
// Last Modified On :
|
|||
|
// ***********************************************************************
|
|||
|
// <copyright file= "MissionWidget" company="Kunpo"></copyright>
|
|||
|
// <summary></summary>
|
|||
|
// ***********************************************************************
|
|||
|
|
|||
|
using TMPro;
|
|||
|
using UnityEngine;
|
|||
|
using UnityEngine.UI;
|
|||
|
|
|||
|
namespace G.UI
|
|||
|
{
|
|||
|
/// <summary>
|
|||
|
/// 境界任务
|
|||
|
/// </summary>
|
|||
|
public class MissionWidget3 : KUIWidget
|
|||
|
{
|
|||
|
#region Field
|
|||
|
|
|||
|
[KUIFlag]
|
|||
|
#pragma warning disable CS0649 // 从未对字段赋值,字段将一直保持其默认值 null
|
|||
|
TextMeshProUGUI _tmpDescription;
|
|||
|
[KUIFlag]
|
|||
|
TextMeshProUGUI _tmpAward;
|
|||
|
[KUIFlag]
|
|||
|
Image _imgIcon;
|
|||
|
[KUIFlag]
|
|||
|
Button _btnStatus;
|
|||
|
[KUIFlag]
|
|||
|
Image _imgStatus;
|
|||
|
[KUIFlag]
|
|||
|
TextMeshProUGUI _tmpStatus;
|
|||
|
[KUIFlag]
|
|||
|
GameObject _goEffect;
|
|||
|
[KUIFlag]
|
|||
|
GameObject _imgStatus1;
|
|||
|
#pragma warning restore CS0649 // 从未对字段赋值,字段将一直保持其默认值 null
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region Method
|
|||
|
|
|||
|
public override void Refresh()
|
|||
|
{
|
|||
|
if (this.data is Mission mission)
|
|||
|
{
|
|||
|
_tmpDescription.text = mission.missionText;
|
|||
|
_tmpAward.text = mission.rewardText2;
|
|||
|
|
|||
|
var award = mission.rewards[0];
|
|||
|
var item = ItemProxy.Instance.GetStaticItem<ItemProp>(award.id);
|
|||
|
IconProxy.Instance.SetSprite(_imgIcon, item.icon);
|
|||
|
|
|||
|
if (mission.isRewarded)
|
|||
|
{
|
|||
|
_goEffect.SetActive(false);
|
|||
|
_btnStatus.gameObject.SetActive(false);
|
|||
|
_imgStatus1.SetActive(true);
|
|||
|
}
|
|||
|
else if (mission.isCompleted)
|
|||
|
{
|
|||
|
_imgStatus1.SetActive(false);
|
|||
|
_goEffect.SetActive(true);
|
|||
|
_btnStatus.gameObject.SetActive(true);
|
|||
|
_tmpStatus.text = "完成";
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
_imgStatus1.SetActive(false);
|
|||
|
_goEffect.SetActive(false);
|
|||
|
_btnStatus.gameObject.SetActive(true);
|
|||
|
_tmpStatus.text = "前往";
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
private void OnReceiveBtnClick()
|
|||
|
{
|
|||
|
SoundProxy.PlayFxAsync(GlobalDefine.BUTTON_CLICK_SOUND);
|
|||
|
if (this.data is Mission mission)
|
|||
|
{
|
|||
|
if (!mission.isCompleted)
|
|||
|
{
|
|||
|
KUIWindow.CloseWindow<SwordWindow>();
|
|||
|
MissionProxy.Instance.JumpMission(mission);
|
|||
|
}
|
|||
|
else if (!mission.isRewarded)
|
|||
|
{
|
|||
|
MissionProxy.Instance.GainReward(mission.id, (error, message) =>
|
|||
|
{
|
|||
|
if (error == 0)
|
|||
|
Refresh();
|
|||
|
});
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region Unity
|
|||
|
|
|||
|
/// <summary>
|
|||
|
///
|
|||
|
/// </summary>
|
|||
|
private void Awake()
|
|||
|
{
|
|||
|
SetViewData();
|
|||
|
_btnStatus.onClick.AddListener(this.OnReceiveBtnClick);
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
}
|
|||
|
}
|