MayHeCome/Assets/Scripts/UI/DifficultyIndicator.cs
2024-12-18 17:55:34 +08:00

36 lines
1.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 TMPro;
using UnityEngine;
public class DifficultyIndicator : MonoBehaviour
{
public TextMeshProUGUI DayLabel;
public RectTransform DifficultyBar;
public TextMeshProUGUI DifficultyLabel;
private void Start()
{
GameProcedureManager.Instance.onDifficultyChange += ChangeDifficulty;
GameProcedureManager.Instance.OnDay += ChangeDayCount;
}
public float DifficultyToPosition(int difficulty)
{
// 55初始位置每一个难度块宽度都是110一个难度块难度从0-10简化前公式为55 + (-110) * difficulty / 10
return 55 - (11/90f) * difficulty;
}
public void ChangeDifficulty(int difficulty)
{
if (DifficultyLabel) DifficultyLabel.text = difficulty.ToString();
if (DifficultyBar) DifficultyBar.anchoredPosition = new Vector2(DifficultyToPosition(difficulty), 0);
DayLabel.text = (15 - difficulty / 60).ToString();
}
public void ChangeDayCount()
{
//if (DayLabel) DayLabel.text = GameProcedureManager.Instance.DayCount.ToString();
}
}