收拾烂摊子
增加编队初步,改动了判定系统,编队UI组装好
This commit is contained in:
@@ -1,11 +1,33 @@
|
||||
using UnityEngine;
|
||||
using TMPro;
|
||||
using System;
|
||||
|
||||
public class InputManager : MonoBehaviour
|
||||
{
|
||||
public static InputManager Instance { get; private set; }
|
||||
public static event Action<KeyCode> OnKeyPressed;
|
||||
public static event Action<KeyCode> OnKeyReleased;
|
||||
|
||||
[Header("轨道判定显示TMP对象(请在Inspector中连接)")]
|
||||
public TextMeshProUGUI[] trackJudgeTexts = new TextMeshProUGUI[5];
|
||||
|
||||
[Header("是否显示判定文字")]
|
||||
public bool showJudgeText = true;
|
||||
|
||||
// 判定结果对应颜色
|
||||
public Color perfectColor = Color.yellow;
|
||||
public Color greatColor = Color.green;
|
||||
public Color goodColor = Color.cyan;
|
||||
public Color missColor = Color.red;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
if (Instance == null)
|
||||
Instance = this;
|
||||
else
|
||||
Destroy(gameObject);
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
foreach (string color in new string[] { "red", "green", "yellow", "purple", "blue" })
|
||||
@@ -23,4 +45,34 @@ public class InputManager : MonoBehaviour
|
||||
OnKeyReleased?.Invoke(key);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新指定轨道的判定文本和颜色
|
||||
/// </summary>
|
||||
public void ShowJudgeResult(int trackIndex, string result)
|
||||
{
|
||||
if (!showJudgeText) return;
|
||||
if (trackJudgeTexts == null || trackIndex < 0 || trackIndex >= trackJudgeTexts.Length) return;
|
||||
var textObj = trackJudgeTexts[trackIndex];
|
||||
if (textObj == null) return;
|
||||
textObj.text = result;
|
||||
switch (result)
|
||||
{
|
||||
case "Perfect":
|
||||
textObj.color = perfectColor;
|
||||
break;
|
||||
case "Great":
|
||||
textObj.color = greatColor;
|
||||
break;
|
||||
case "Good":
|
||||
textObj.color = goodColor;
|
||||
break;
|
||||
case "Miss":
|
||||
textObj.color = missColor;
|
||||
break;
|
||||
default:
|
||||
textObj.color = Color.white;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user