MayHeCome/Assets/Scripts/UI/DifficultyIndicator.cs

36 lines
1.1 KiB
C#
Raw Normal View History

2024-12-18 09:55:34 +00:00
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();
}
}