关卡1流程实现(测试版)

This commit is contained in:
xinkl
2025-11-09 18:00:06 +08:00
parent ac4d6536f2
commit b88b2ac834
405 changed files with 1442 additions and 523 deletions

View File

@@ -1,11 +1,11 @@
using System.Collections.Generic;
using A2W;
using Unity.Cinemachine;
using UnityEngine;
using UnityEngine.InputSystem;
public class MusicGame : MonoBehaviour
public class MusicGame : SceneSingleton<MusicGame>
{
public static MusicGame Instance { get; private set; }
public MusicData musicData;
private bool isPlaying = false;
public Camera mainCamera;
@@ -19,12 +19,12 @@ public class MusicGame : MonoBehaviour
void Start()
{
mainCamera = Camera.main;
Instance = this;
}
void Update()
{
if (Keyboard.current.qKey.wasPressedThisFrame) Play();
// if (Keyboard.current.qKey.wasPressedThisFrame) Play();
}
public void Play()
@@ -98,6 +98,7 @@ public class MusicGame : MonoBehaviour
noteId = 0;
mainCamera.GetComponent<CinemachineBrain>().enabled = true;
Debug.Log("完成所有tick");
GameFlowMgr.instance.completeLevel(0);
}
}
}

View File

@@ -17,8 +17,8 @@ public class Note : MonoBehaviour
private double lastSpaceTime = double.NegativeInfinity;
private double spawnTime => beatTime - approach;
private float spawnY = MusicGame.Instance.judgeLine.y + 8f;
private float judgeY => MusicGame.Instance.judgeLine.y;
private float spawnY = MusicGame.instance.judgeLine.y + 8f;
private float judgeY => MusicGame.instance.judgeLine.y;
private bool canMove = false;
void Start() => canMove = false;
@@ -56,11 +56,11 @@ public class Note : MonoBehaviour
Debug.Log($"音符 {Uid}击中");
judged = true;
lastSpaceTime = double.NegativeInfinity;
MusicGame.Instance.onNoteHit(Uid);
MusicGame.instance.onNoteHit(Uid);
}
else
{
MusicGame.Instance.onNoteHit(-1);
MusicGame.instance.onNoteHit(-1);
Debug.Log($"Miss 音符 {Uid}(超时)");
}

View File

@@ -0,0 +1,19 @@
using UnityEngine;
public class PianoInteractable : MonoBehaviour, IInteractable
{
public void OnEnterInteractionRange()
{
Debug.Log("OnEnterInteractionRange");
}
public void OnExitInteractionRange()
{
Debug.Log("OnExitInteractionRange");
}
public void OnInteract()
{
MusicGame.instance.Play();
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: e79d148c7efbd67408d55230f5b99a02

View File

@@ -22,10 +22,12 @@ public class GameFlowMgr : Singleton<GameFlowMgr>
{
throw new System.Exception("请选择关卡");
}
Debug.Log(levelData.levels[levelData.currentLevelIndex].sceneName);
StageSelector.EnterStage(levelData.levels[levelData.currentLevelIndex].sceneName);
}
public void completeLevel(int index)
{
levelData.currentLevelIndex = ++index;
StageSelector.EnterStage("Stage1");
}
}