154 lines
3.6 KiB
C#
154 lines
3.6 KiB
C#
using BX;
|
|
using DG.Tweening;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using TMPro;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
/// <summary>
|
|
/// 复活界面
|
|
/// </summary>
|
|
public class ResurgenceUI : UIBaseClass
|
|
{
|
|
/// <summary>
|
|
/// 分数
|
|
/// </summary>
|
|
public TextMeshProUGUI scoreTetx;
|
|
|
|
/// <summary>
|
|
/// 关卡进度
|
|
/// </summary>
|
|
public TextMeshProUGUI schedule;
|
|
|
|
/// <summary>
|
|
/// 复活倒计时
|
|
/// </summary>
|
|
public TextMeshProUGUI countdownResurrectionText;
|
|
|
|
/// <summary>
|
|
/// 关卡进度条
|
|
/// </summary>
|
|
public Image scheduleBar;
|
|
|
|
/// <summary>
|
|
/// 复活倒计时
|
|
/// </summary>
|
|
public Image countdownResurrection;
|
|
|
|
/// <summary>
|
|
/// 复活
|
|
/// </summary>
|
|
public Button resurgenceBtn;
|
|
|
|
/// <summary>
|
|
/// 忽略
|
|
/// </summary>
|
|
public Button loseBtn;
|
|
|
|
/// <summary>
|
|
/// 倒计时
|
|
/// </summary>
|
|
private Tween countdownTween;
|
|
|
|
private void Start()
|
|
{
|
|
ResurgenceBtnListener();
|
|
LoseBtnListenet();
|
|
}
|
|
|
|
public override void OnShow()
|
|
{
|
|
base.OnShow();
|
|
BXSdk.Instance.LogEvent("RV_Button_Show", new System.Collections.Generic.Dictionary<string, object>()
|
|
{
|
|
{"Position","RV_Revive"}
|
|
});
|
|
SetScheduleBar();
|
|
SetCountdownResurrection();
|
|
SetScore();
|
|
resurgenceBtn.interactable = true;
|
|
loseBtn.interactable = true;
|
|
}
|
|
|
|
public override void OnHide()
|
|
{
|
|
base.OnHide();
|
|
countdownTween.Kill();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 设置关卡进度
|
|
/// </summary>
|
|
private void SetScheduleBar()
|
|
{
|
|
float value = 0;
|
|
DOTween.To(() => value, x => value = x, Scenes.Instance.gameScene.GetSchedule(), 1f).OnUpdate(() =>
|
|
{
|
|
scheduleBar.fillAmount = value;
|
|
schedule.text =(value* 100).ToString("0") + "%";
|
|
});
|
|
}
|
|
|
|
/// <summary>
|
|
/// 设置分数
|
|
/// </summary>
|
|
private void SetScore()
|
|
{
|
|
float value = 0;
|
|
DOTween.To(() => value, x => value = x, Scenes.Instance.gameScene.GetScore(), 1f).OnUpdate(() =>
|
|
{
|
|
scoreTetx.text = value.ToString("0");
|
|
});
|
|
}
|
|
|
|
/// <summary>
|
|
/// 设置复活倒计时
|
|
/// </summary>
|
|
private void SetCountdownResurrection()
|
|
{
|
|
float value = 10;
|
|
countdownTween=DOTween.To(() => value, x => value = x, 0, 10).OnUpdate(() =>
|
|
{
|
|
countdownResurrection.fillAmount = value/10;
|
|
countdownResurrectionText.text =Mathf.RoundToInt(value).ToString();
|
|
}).OnComplete(() =>
|
|
{
|
|
HideMe();
|
|
UIManager.Instance.AsynShowUI<SettlementUI>();
|
|
}).SetEase(Ease.Linear);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 复活按钮
|
|
/// </summary>
|
|
private void ResurgenceBtnListener()
|
|
{
|
|
resurgenceBtn.onClick.AddListener(() =>
|
|
{
|
|
var rewardReady = BXSdk.Instance.IsReadyReward();
|
|
if(rewardReady)
|
|
{
|
|
resurgenceBtn.interactable = false;
|
|
loseBtn.interactable = false;
|
|
}
|
|
SDKManager.Instance.ShowReward("RV_Revive", () =>
|
|
{
|
|
Scenes.Instance.gameScene.Resurgence();
|
|
});
|
|
});
|
|
}
|
|
|
|
/// <summary>
|
|
/// 忽略按钮
|
|
/// </summary>
|
|
private void LoseBtnListenet()
|
|
{
|
|
loseBtn.onClick.AddListener(() =>
|
|
{
|
|
HideMe();
|
|
UIManager.Instance.AsynShowUI<SettlementUI>();
|
|
});
|
|
}
|
|
}
|