Files
ichni_Official/Assets/Scripts/GameUI/GameUICanvas.cs
SoulliesOfficial 7580c4d87c 大更
2026-03-14 03:13:10 -04:00

67 lines
2.1 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using System;
using System.Collections;
using System.Collections.Generic;
using Ichni.UI;
using Sirenix.OdinInspector;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
namespace Ichni.RhythmGame.UI
{
public class GameUICanvas : UIPageBase
{
public Button pauseButton;
public TMP_Text difficultyNameText;
public TMP_Text difficultyValueText;
public TMP_Text readyText;
public TMP_Text accuracyText;
public TMP_Text comboText;
public Image progressBar;
public GamePauseInterface pauseInterface;
[Title("Debug")]
public TMP_Text fpsText;
private void Start()
{
pauseButton.onClick.AddListener(()=>
{
if (GameManager.Instance.songPlayer.isPlaying)
{
GameManager.Instance.songPlayer.PauseSong();
pauseButton.interactable = false;
pauseInterface.FadeIn(0.5f, true);
}
});
difficultyNameText.text = InformationTransistor.instance.difficulty.difficultyName;
difficultyNameText.color = InformationTransistor.instance.difficulty.color / 2f;
difficultyValueText.text = InformationTransistor.instance.difficulty.difficultyValue.ToString();
}
private void Update()
{
fpsText.text = (1.0f / Time.unscaledDeltaTime).ToString("F2");
if (GameManager.Instance.songPlayer.isPlaying)
{
float songLength = GameManager.Instance.songInformation.songLength;
progressBar.fillAmount = songLength > 0 ? CoreServices.TimeProvider.SongTime / songLength : 0f; // 如果歌曲长度为0填充量为0
}
}
public void UpdateAccuracy(float accuracy)
{
accuracyText.text = accuracy.ToString("F2") + "%";
}
public void UpdateCombo(int currentCombo)
{
comboText.text = currentCombo.ToString("D");
}
}
}