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; } }
// Use this for initialization void Start() { InitializeLeadIn(); simpleMusicPlayer = simpleMusciPlayerTrans.GetComponent <SimpleMusicPlayer>(); simpleMusicPlayer.LoadSong(kgy, 0, false); // 初始化所有音轨. for (int i = 0; i < noteLanes.Count; ++i) { noteLanes[i].Initialize(this); } // 初始化事件。 playingKoreo = Koreographer.Instance.GetKoreographyAtIndex(0); // 获取Koreography中的所有事件。 KoreographyTrackBase rhythmTrack = playingKoreo.GetTrackByID(eventID); //获取事件轨迹 List <KoreographyEvent> rawEvents = rhythmTrack.GetAllEvents(); //获取所有事件 //KoreographyEvent rawEvent = rhythmTrack.GetEventAtStartSample(2419200); //rawEvent. for (int i = 0; i < rawEvents.Count; ++i) { //KoreographyEvent 基础Koreography事件定义。 每个事件实例都可以携带一个 //有效载荷 事件可以跨越一系列样本,也可以绑定到一个样本。 样品 //值(开始/结束)在“采样时间”范围内,* NOT *绝对采样位置。 //确保查询/比较在TIME而不是DATA空间中发生。 KoreographyEvent evt = rawEvents[i]; int noteID = evt.GetIntValue();//获取每个事件对应的字符串 // Find the right lane. 遍历所有音轨 for (int j = 0; j < noteLanes.Count; ++j) { LaneController lane = noteLanes[j]; if (noteID > 6) { noteID = noteID - 6; if (noteID > 6) { noteID = noteID - 6; } } if (lane.DoesMatch(noteID)) { //事件对应的字符串与某个音轨对应字符串匹配,则把该事件添加到该音轨 // Add the object for input tracking. lane.AddEventToLane(evt); // Break out of the lane searching loop. break; } } } //SampleRate采样率,在音频资源里有。 //命中窗口宽度,采样率*0.001*命中时长 hitWindowRangeInSamples = (int)(0.001f * hitWindowRangeInMS * SampleRate); }
void Start() { InitializeLeadIn(); //切歌选歌 simpleMusicPlayer = simpleMusciPlayerTrans.GetComponent <SimpleMusicPlayer>(); simpleMusicPlayer.LoadSong(kgy, 0, false); foreach (LaneController nl in noteLanes) { nl.Initialize(this); } //获取到Koreograhpy对象 playingKoreo = Koreographer.Instance.GetKoreographyAtIndex(0); foreach (string _eventID in eventID) { //获取事件轨迹 KoreographyTrackBase rhythmTrack = playingKoreo.GetTrackByID(_eventID); //获取事件 List <KoreographyEvent> rawEvents = rhythmTrack.GetAllEvents(); for (int i = 0; i < rawEvents.Count; i++) { KoreographyEvent evt = rawEvents[i]; int noteID = evt.GetIntValue(); //遍历所有音轨 for (int j = 0; j < noteLanes.Count; j++) { LaneController lane = noteLanes[j]; if (noteID > 4) { noteID = noteID - 4; if (noteID > 4) { noteID = noteID - 4; } } if (lane.DoesMatch(noteID)) { lane.AddEventToLane(evt); break; } } } } //SampleRate采样率,在音频资源里有。 //命中窗口宽度,采样率*0.001*命中时长 hitWindowRangeInSamples = (int)(SampleRate * hitWindowRangeInMS * 0.001f); }
private void Start() { //Para regirstar respuestas a eventos del koreographer //Koreographer.Instance.RegisterForEvents(lightsEventID, ChangeLightColor); Koreographer.Instance.RegisterForEvents(keyEventID, GenerateKey); //get the current koreographer koreography = Koreographer.Instance.GetKoreographyAtIndex(0); //Get all events out of the track KoreographyTrackBase keyTrack = koreography.GetTrackByID(keyEventID); keyEvents = keyTrack.GetAllEvents(); keyEventsLength = keyEvents.Count; keyManager.SetAllSongKeys(keyEventsLength); }
// Use this for initialization void Start() { PERFECT_HIT_RANGE_IN_SAMPLES = perfectHitRangeInSamples; invertedNoteSpeed = 1 / noteSpeed; koreo = Koreographer.Instance.GetKoreographyAtIndex(0); KoreographyTrackBase rhythmTrack = koreo.GetTrackByID(TrackID); List <KoreographyEvent> rawEvents = rhythmTrack.GetAllEvents(); noteTravelSampleTime = invertedNoteSpeed * SampleRate; nextEvent = new KoreographyEvent[6]; noteDirections = new Vector3[6]; lanes = new Queue <KoreographyEvent> [6]; for (int i = 0; i < 6; i++) { Vector2 dir; lanes[i] = new Queue <KoreographyEvent>(); Vector3[] corners = new Vector3[4]; buttonTransforms[i].GetWorldCorners(corners); Vector3 middlePoint = corners[0] + (corners[2] - corners[0]) / 2; dir = middlePoint - new Vector3(0, 0, 90); noteDirections[i] = new Vector3(dir.x, dir.y, 0); laneControllers[i].noteDirection = noteDirections[i]; } for (int i = 0; i < rawEvents.Count; ++i) { KoreographyEvent evt = rawEvents[i]; int payload = evt.GetIntValue(); lanes[payload].Enqueue(evt); } //prepare initial events for (int i = 0; i < 6; i++) { if (lanes[i].Count > 0) { nextEvent[i] = lanes[i].Dequeue(); } } Debug.Log("eventtest"); Debug.Log(nextEvent[0].StartSample); }
void Start() { //Find the animator for the dancing man. this.animationTarget = GameObject.FindObjectOfType <Animator>(); InitializeLeadIn(); // Initialize all the Lanes. for (int i = 0; i < noteLanes.Count; ++i) { noteLanes[i].Initialize(this); } // Initialize events. playingKoreo = Koreographer.Instance.GetKoreographyAtIndex(0); // Grab all the events out of the Koreography. KoreographyTrackBase rhythmTrack = playingKoreo.GetTrackByID(eventID); List <KoreographyEvent> rawEvents = rhythmTrack.GetAllEvents(); InitializeMetronomeIfPresent(rawEvents); for (int i = 0; i < rawEvents.Count; ++i) { KoreographyEvent evt = rawEvents[i]; string payload = evt.GetTextValue(); // Find the right lane. for (int j = 0; j < noteLanes.Count; ++j) { LaneControllerBeatInfinity lane = noteLanes[j]; if (lane.DoesMatchPayload(payload)) { // Add the object for input tracking. lane.AddEventToLane(evt); // Break out of the lane searching loop. break; } } } }
private void InitFlipNoteQueue() { KoreographyTrackBase rhythmTrack = playingKoreo.GetTrackByID(eventID[1]); //获取时间轨迹 List <KoreographyEvent> rawClickEvents = rhythmTrack.GetAllEvents(); //获取所有事件 int clickID = 0; foreach (var item in rawClickEvents) { string rawText = item.GetTextValue(); List <int> laneData = new TextTok().TokText(rawText); int index = 0; while (index < laneData.Count - 1) { filpNoteInitData temp = new filpNoteInitData(); temp.ID = clickID; clickID++; temp.sPosition = laneOrigins[laneData[index]].position; temp.tPosition = laneTargets[laneData[index]].position; temp.direction = new Vector3(-1, 0, 0); temp.nTime = item.StartSample; temp.dTime = item.StartSample - GetSpawnSampleOffset(temp.sPosition, laneTargets[laneData[index]].position); switch (laneData[index + 1]) { case 1: temp.aimDir = slideVector.up; break; case 2: temp.aimDir = slideVector.down; break; } index += 2; initFlipNotesDatas.Enqueue(temp); } } }
private void InitClickNoteQueue() { KoreographyTrackBase rhythmTrack = playingKoreo.GetTrackByID(eventID[0]); //获取时间轨迹 List <KoreographyEvent> rawClickEvents = rhythmTrack.GetAllEvents(); //获取所有事件 int clickID = 0; foreach (var item in rawClickEvents) { string rawText = item.GetTextValue(); List <int> laneData = new TextTok().TokText(rawText); foreach (var rawData in laneData) { clickNoteInitData temp = new clickNoteInitData(); temp.ID = clickID; clickID++; temp.sPosition = laneOrigins[rawData].position; temp.tPosition = laneTargets[rawData].position; temp.direction = new Vector3(-1, 0, 0); temp.nTime = item.StartSample; temp.dTime = item.StartSample - GetSpawnSampleOffset(temp.sPosition, laneTargets[rawData].position); initClickNotesDatas.Enqueue(temp); } } }
public void SetLaneEvents(KoreographyTrackBase track) { timeBeforeSpawn = GameManager.instance.spawnEarlyInSeconds * GameManager.instance.SampleRate; this.laneEvents = track.GetAllEvents(); laneEventIndex = 0; }