NLDClient-yudde/ProjectNLD/Assets/Code/Scripts/Gameplay/UI/LevelFight/UIDefeatGameController.cs

103 lines
1.9 KiB
C#
Raw Normal View History

using cfg;
using Framework;
2023-10-19 15:00:19 +08:00
using Gameplay.Level;
2023-08-22 19:08:45 +08:00
using TMPro;
using Button = UnityEngine.UI.Button;
using Image = UnityEngine.UI.Image;
public class UIDefeatGameController : UIWindow{
//UI GameObj
///Auto Gen Start///
public Image Image_FailedBG;
public Image Image_Tip;
public TMP_Text Text_Failed;
public TMP_Text Text_FightTime;
public Image Image_Clock;
public TMP_Text Text_Time;
public Image Image_PhysicalPower;
public TMP_Text Text_PPNum;
public TMP_Text Text_PhysicalPowerBack;
public TMP_Text Text_FailedDescribe0;
public TMP_Text Text_FailedDescribe1;
public TMP_Text Text_FailedDescribe2;
public Image Image_AccountLogo;
public Button Button_Continue;
public TMP_Text Text_Continue;
2023-08-22 19:08:45 +08:00
///Auto Gen End///
2023-08-22 19:08:45 +08:00
// Use this for initialization
2024-01-23 12:25:47 +08:00
public override void OnInit()
2023-08-22 19:08:45 +08:00
{
//bind UI GameObj
UIDefeatGameBinder.GetComponents(this);
BindButton(Button_Continue, () =>
2023-08-22 19:08:45 +08:00
{
2023-10-19 15:00:19 +08:00
LevelManager.Instance.ExitLevelDirectly();
});
2023-08-22 19:08:45 +08:00
}
//invoke when open window
protected override void OnShowWindow(object data = null)
2023-08-22 19:08:45 +08:00
{
_Refresh();
2023-08-22 19:08:45 +08:00
}
#region RefreshWindow
private void _Refresh()
{
_RefreshTime();
_RefreshPhysical();
}
private void _RefreshTime()
{
var minutes = TeamManager.Instance.GetFightPastMinute();
var seconds = TeamManager.Instance.GetFightPastSecond();
var timeStr = "";
if (minutes < 10)
{
timeStr += minutes;
}
else
{
timeStr += "0";
timeStr += minutes;
}
timeStr += ":";
if (minutes < 10)
{
timeStr += seconds;
}
else
{
timeStr += "0";
timeStr += seconds;
}
Text_Time.text = timeStr;
}
private void _RefreshPhysical()
{
var levelID = LevelManager.Instance.CurrentLevel.ID;
var levelCfg = TableManager.Instance.Tables.Level.GetOrDefault(levelID);
int count;
if (levelCfg != null)
{
var costPhysicals = levelCfg.CostItems;
count = costPhysicals.Count;
Text_PPNum.text = "x" + count;
}
}
#endregion
2023-08-22 19:08:45 +08:00
}