165 lines
3.7 KiB
C#
165 lines
3.7 KiB
C#
// ***********************************************************************
|
|
// Assembly : Game
|
|
// Author : Kimch
|
|
// Created : 2021-05-02
|
|
// Description :
|
|
// Last Modified By :
|
|
// Last Modified On :
|
|
// ***********************************************************************
|
|
// <copyright file= "BonusLevelBox.View" company="Kunpo"></copyright>
|
|
// <summary></summary>
|
|
// ***********************************************************************
|
|
namespace G.UI
|
|
{
|
|
using TMPro;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
partial class BonusLevelBox
|
|
{
|
|
#region Field
|
|
|
|
#pragma warning disable CS0649 // 从未对字段赋值,字段将一直保持其默认值 null
|
|
|
|
[KUIFlag]
|
|
TextMeshProUGUI _tmpRemainCount;
|
|
[KUIFlag]
|
|
TextMeshProUGUI _tmpRemainTimer;
|
|
|
|
[KUIFlag]
|
|
Button _btnClose;
|
|
[KUIFlag]
|
|
Button _btnBack;
|
|
|
|
[KUIFlag]
|
|
Button _btnChallenge;
|
|
[KUIFlag]
|
|
TextMeshProUGUI _tmpChallenge;
|
|
|
|
[KUIFlag]
|
|
Button _btnTips;
|
|
[KUIFlag]
|
|
TextMeshProUGUI _tmpTitle;
|
|
|
|
[KUIFlag]
|
|
Button _btnUp;
|
|
[KUIFlag]
|
|
GameObject __goUpCost;
|
|
|
|
[KUIFlag]
|
|
KUIList __listRewards;
|
|
[KUIFlag]
|
|
KUIList __listStar;
|
|
|
|
#pragma warning restore CS0649 // 从未对字段赋值,字段将一直保持其默认值 null
|
|
|
|
private CostWidget _upCostWidget;
|
|
private int _currentStar = 0;
|
|
|
|
#endregion
|
|
|
|
#region Method
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public void InitView()
|
|
{
|
|
SetViewData();
|
|
_btnClose.onClick.AddListener(this.OnBackBtnClick);
|
|
_btnBack.onClick.AddListener(this.OnBackBtnClick);
|
|
_btnChallenge.onClick.AddListener(this.OnChallengeBtnClick);
|
|
|
|
_btnTips.onClick.AddListener(this.OnTipsBtnClick);
|
|
_btnUp.onClick.AddListener(this.OnUpBtnClick);
|
|
|
|
_upCostWidget = __goUpCost.AddComponent<CostWidget>();
|
|
__listRewards.AddTemplate<PropWidget>(true);
|
|
__listStar.AddTemplate<StarWidget>(true);
|
|
}
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public void RefreshView()
|
|
{
|
|
var amount = TimeProxy.Instance.GetTimeInfo2(TimeProxy.奖励关);
|
|
_tmpRemainCount.text = $"本日可挑战次数:{amount.remain}/{amount.max}";
|
|
|
|
RefreshRewards();
|
|
}
|
|
|
|
void RefreshRewards()
|
|
{
|
|
if (this.data is ActivityInfo activity)
|
|
{
|
|
_tmpTitle.text = activity.name;
|
|
|
|
var subInfos = activity.subInfos;
|
|
if (subInfos != null)
|
|
{
|
|
if (_currentStar >= subInfos.Length)
|
|
_currentStar = subInfos.Length - 1;
|
|
|
|
var subInfo = activity.subInfos[_currentStar];
|
|
__listStar.Clear();
|
|
for (int i = 0; i < subInfos.Length; i++)
|
|
{
|
|
__listStar.GetItem<StarWidget>().SetGray(i > _currentStar);
|
|
}
|
|
__listRewards.Clear();
|
|
if (subInfo.rewardInfos != null)
|
|
for (int i = 0; i < subInfo.rewardInfos.Length; i++)
|
|
{
|
|
__listRewards.GetItem<PropWidget>().SetItem(subInfo.rewardInfos[i]);
|
|
}
|
|
|
|
_upCostWidget.SetAndCheckPrice(1, 5000 + 5000 * _currentStar);
|
|
}
|
|
}
|
|
}
|
|
|
|
private void OnBackBtnClick()
|
|
{
|
|
CloseWindow(this);
|
|
SoundProxy.PlayFxAsync(GlobalDefine.BUTTON_CLICK_SOUND);
|
|
}
|
|
|
|
private void OnChallengeBtnClick()
|
|
{
|
|
if (this.data is ActivityInfo activity)
|
|
{
|
|
var args = activity.item.typeArgs;
|
|
if (args != null && args.Length > 0)
|
|
LevelProxy.Instance.StartSpecial(args[0]);
|
|
}
|
|
SoundProxy.PlayFxAsync(GlobalDefine.BUTTON_CLICK_SOUND);
|
|
}
|
|
|
|
private void OnTipsBtnClick()
|
|
{
|
|
MessageBox.ShowMessage(KLocalization.GetLocalString(61), KLocalization.GetLocalString(62));
|
|
SoundProxy.PlayFxAsync(GlobalDefine.BUTTON_CLICK_SOUND);
|
|
}
|
|
|
|
private void OnUpBtnClick()
|
|
{
|
|
var rnd = Random.value;
|
|
if (rnd < 0.1f)
|
|
{
|
|
_currentStar += 2;
|
|
}
|
|
else if (rnd < 0.6f)
|
|
{
|
|
_currentStar += 1;
|
|
}
|
|
RefreshRewards();
|
|
SoundProxy.PlayFxAsync(GlobalDefine.BUTTON_CLICK_SOUND);
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
}
|