From 56ab6cfe972be0d3e6d0c24a62138e9025628524 Mon Sep 17 00:00:00 2001 From: Jiangqvweihuan <15987148+jiangqvweihuan@user.noreply.gitee.com> Date: Sun, 20 Jul 2025 03:05:10 +0000 Subject: [PATCH] =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=96=87=E4=BB=B6=20Assets/s?= =?UTF-8?q?cripts/gamePlay=5Fgameplay/Note.cs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/scripts/gamePlay_gameplay/Note.cs | 130 ----------------------- 1 file changed, 130 deletions(-) delete mode 100644 Assets/scripts/gamePlay_gameplay/Note.cs diff --git a/Assets/scripts/gamePlay_gameplay/Note.cs b/Assets/scripts/gamePlay_gameplay/Note.cs deleted file mode 100644 index 492208aa..00000000 --- a/Assets/scripts/gamePlay_gameplay/Note.cs +++ /dev/null @@ -1,130 +0,0 @@ -using UnityEngine; - -public class Note : BaseNote -{ - private KeyCode keyToPress; - private string noteColor; - private AnimationController anim; - private NoteController controller; - private bool isJudged = false; - - private void Awake() - { - anim = GetComponent(); - controller = GetComponent(); - } - - public void Setup(KeyCode key, int trackIndex, float speed, float hitTime, string color) - { - keyToPress = key; - noteColor = color; - TrackIndex = trackIndex; - Speed = speed; - this.hitTime = hitTime; - isJudged = false; - - if (controller != null) - { - controller.SetSpeed(speed); - } - - InputManager.OnKeyPressed += HandlePress; - } - - private void OnDestroy() - { - InputManager.OnKeyPressed -= HandlePress; - } - - private void HandlePress(KeyCode key) - { - // 确保只有匹配的按键触发,并且音符处于判定区域 - if (isJudged || key != keyToPress || (controller != null && !controller.IsInJudgeZone())) - return; - - float timeDifference = Mathf.Abs(Time.time - hitTime); - - if (timeDifference <= 0.08f) - { - Debug.Log($"短音符 {keyToPress}: Perfect"); - } - else if (timeDifference <= 0.15f) - { - Debug.Log($"短音符 {keyToPress}: Great"); - } - else - { - Debug.Log($"短音符 {keyToPress} Miss"); - JudgeMiss(); - return; - } - - Judge(); - } - - public bool IsJudged() - { - return isJudged; - } - - public void Judge() - { - if (isJudged) - return; - isJudged = true; - - if (controller != null) - { - controller.StopMovement(); - controller.PlayHitEffect(); - } - ReturnToPool(); - if (anim !=null) - { - Debug.Log("执行"); - anim.PlayDestroyAnimation(noteColor); - } - - } - - public void JudgeMiss() - { - if (isJudged) return; - isJudged = true; - Debug.Log($"短音符 {keyToPress} Miss"); - ReturnToPool(); - } - - private void ReturnToPool() - { - InputManager.OnKeyPressed -= HandlePress; - if (controller != null) - { - controller.ResetState(); - } - gameObject.SetActive(false); - NotePool.Instance.ReturnNote(gameObject, noteColor); - } - - public int GetTrackIndex() - { - return TrackIndex; - } - - public KeyCode GetKey() - { - return keyToPress; - } - - /// - /// 由 Controller 调用,通知 Note 是否在判定区域内 - /// - public void SetJudgeZone(bool inZone) - { - // 如果音符离开判定区域且还未判定,则判为 Miss - if (!inZone && !isJudged) - { - JudgeMiss(); - } - } -}