/// <summary> /// 画面更新时调用一次,主线程 /// 暂停时也会持续调用,谱面尚未加载时也会持续调用,下同 /// 画面更新 是指 Unity显示层(以玩家眼中的游戏画面为准)更新,距离上次调用的时间为 UnityEngine.Time.deltaTime /// 当前歌曲播放的进度(秒)为 TentacleGuitarUnity.Stage.Time,暂停时持续刷新同一个秒数 /// 请适当 cache 节约性能 /// </summary> public static void StageLateUpdate() { if (Stage.GamePlaying && StageMusic.Main.IsReady && StageMusic.Main.IsPlaying && CurrentNoteNum > 0) { float time = StageMusic.Main.Time; for (; CurrentLoadedIndex < Notes.Count; CurrentLoadedIndex++) { float noteTime = Notes[CurrentLoadedIndex].Time; if (noteTime > time + CurrentShowNoteTime) { break; } else { Stage.AddNote(Notes[CurrentLoadedIndex]); } } int minX = 23; int maxX = 0; bool[] stringLighted = new bool[6]; for (int i = 0; i < Stage.NotePool.Count; i++) { Note n = Stage.NotePool[i].GetComponent <Note>(); if (n) { minX = Mathf.Min(minX, n.X); maxX = Mathf.Max(maxX, n.X); stringLighted[n.Y] = true; } } if (Stage.NotePool.Count > 0) { Stage.MoveCamera((int)(0.5f * (minX + maxX))); for (int i = 0; i < 24; i++) { Stage.SetTrackHightLight(i, i >= minX && i <= maxX); Stage.SetFretWireLight(i, i >= minX && i - 1 <= maxX); } for (int i = 0; i < 6; i++) { Stage.SetStringLight(i, stringLighted[i]); } } } }