Files
ichni_Official/Assets/Scripts/Game/UI/GameUICanvas.cs

67 lines
2.1 KiB
C#
Raw Normal View History

2025-07-21 05:42:20 -04:00
using System;
2025-06-03 02:42:28 -04:00
using System.Collections;
using System.Collections.Generic;
2025-07-08 14:28:40 -04:00
using Ichni.UI;
2025-07-21 05:42:20 -04:00
using Sirenix.OdinInspector;
2025-06-03 02:42:28 -04:00
using TMPro;
using UnityEngine;
using UnityEngine.UI;
2025-07-08 14:28:40 -04:00
namespace Ichni.RhythmGame.UI
2025-06-03 02:42:28 -04:00
{
2025-07-08 14:28:40 -04:00
public class GameUICanvas : UIPageBase
2025-06-03 02:42:28 -04:00
{
public Button pauseButton;
2025-08-22 14:54:40 -04:00
public TMP_Text difficultyNameText;
public TMP_Text difficultyValueText;
2025-07-21 05:42:20 -04:00
public TMP_Text readyText;
2025-06-03 02:42:28 -04:00
public TMP_Text accuracyText;
public TMP_Text comboText;
2025-08-22 14:54:40 -04:00
public Image progressBar;
2025-07-21 05:42:20 -04:00
public GamePauseInterface pauseInterface;
[Title("Debug")]
public TMP_Text fpsText;
private void Start()
{
pauseButton.onClick.AddListener(()=>
{
2025-08-22 14:54:40 -04:00
if (GameManager.instance.audioManager.isPlaying)
{
GameManager.instance.audioManager.songPlayer.PauseSong();
pauseButton.interactable = false;
pauseInterface.FadeIn(0.5f, true);
}
2025-07-21 05:42:20 -04:00
});
2025-08-22 14:54:40 -04:00
difficultyNameText.text = InformationTransistor.instance.difficulty.difficultyName;
difficultyNameText.color = InformationTransistor.instance.difficulty.color / 2f;
difficultyValueText.text = InformationTransistor.instance.difficulty.difficultyValue.ToString();
2025-07-21 05:42:20 -04:00
}
private void Update()
{
fpsText.text = (1.0f / Time.unscaledDeltaTime).ToString("F2");
2025-08-22 14:54:40 -04:00
if (GameManager.instance.audioManager.isPlaying)
{
float songLength = GameManager.instance.songInformation.songLength;
progressBar.fillAmount = songLength > 0 ? GameManager.instance.songTime / songLength : 0f; // 如果歌曲长度为0填充量为0
}
}
2025-07-21 05:42:20 -04:00
2025-06-03 02:42:28 -04:00
public void UpdateAccuracy(float accuracy)
{
accuracyText.text = accuracy.ToString("F2") + "%";
}
public void UpdateCombo(int currentCombo)
{
comboText.text = currentCombo.ToString("D");
}
}
}