private void InitHoldNoteQueue() { KoreographyTrackBase rhythmTrack = playingKoreo.GetTrackByID(eventID[2]); //获取时间轨迹 List <KoreographyEvent> rawHoldEvents = rhythmTrack.GetAllEvents(); //获取所有事件 int clickID = 0; int index = 0; while (index < rawHoldEvents.Count - 1) { string rawText = rawHoldEvents[index].GetTextValue(); List <int> laneData = new TextTok().TokText(rawText); holdNoteInitData temp = new holdNoteInitData(); temp.ID = clickID; clickID++; temp.sPosition = laneOrigins[laneData[0]].position; temp.tPosition = laneTargets[laneData[0]].position; temp.direction = new Vector3(-1, 0, 0); temp.nTime0 = rawHoldEvents[index].StartSample; temp.dTime0 = rawHoldEvents[index].StartSample - GetSpawnSampleOffset(temp.sPosition, laneTargets[laneData[0]].position); temp.nTime1 = rawHoldEvents[index + 1].StartSample; temp.dTime1 = rawHoldEvents[index + 1].StartSample - GetSpawnSampleOffset(temp.sPosition, laneTargets[laneData[0]].position); initHoldNotesDatas.Enqueue(temp); index += 2; } }
//-------------------------Hold音符对象池方法-------------------------- private void CheckSpawnNextHoldNote() //不断检测是否生成下一个新音符 { int currentTime = DelayedSampleTime; int curNum = 1; while (curNum <= initHoldNotesDatas.Count && initHoldNotesDatas.Peek().dTime0 <= currentTime) { holdNoteInitData tempData = initHoldNotesDatas.Dequeue(); // Debug.Log("TimeToGo!"); HoldNote newObj = GetFreshHoldNote(); newObj.Initialized(this, tempData.ID, tempData.sPosition, tempData.tPosition, tempData.direction, tempData.nTime0, tempData.dTime0, tempData.nTime1, tempData.dTime1); curNum++; } }