67 lines
2.1 KiB
C#
67 lines
2.1 KiB
C#
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");
|
||
}
|
||
}
|
||
} |