36 lines
1.1 KiB
C#
36 lines
1.1 KiB
C#
|
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();
|
|||
|
}
|
|||
|
}
|