// 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); }
//获取注册时间列表 private void LoadEventSampleTime() { KoreographyTrack rhythmTrack = playingKoreo.GetTrackByID(eventID); List <KoreographyEvent> rawEvents = rhythmTrack.GetAllEvents(); for (int i = 0; i < rawEvents.Count; i++) { TwoDData temp = new TwoDData { beginTime = rawEvents[i].StartSample, typeEnum = rawEvents[i].GetIntValue() }; eventSampleTimeList.Add(temp); } }
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 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); } } }
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; } } } }
void Start() { InitializeLeadIn(); // Initialize all the Lanes. for (int i = 0; i < noteLanes.Count; ++i) { noteLanes[i].Initialize(this); } Debug.Log(noteLanes.Count);//6 // Initialize events. playingKoreo = Koreographer.Instance.GetKoreographyAtIndex(0); // Grab all the events out of the Koreography. KoreographyTrack rhythmTrack = playingKoreo.GetTrackByID(eventID); List <KoreographyEvent> rawEvents = rhythmTrack.GetAllEvents(); 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) { LaneController lane = noteLanes[j]; if (lane.DoesMatchPayload(payload)) { // Add the object for input tracking. lane.AddEventToLane(evt); // Break out of the lane searching loop. break; } } } }
void Start() { InitializeLeadIn(); for (int i = 0; i < noteLines.Count; i++) { noteLines[i].Initialize(this);//音轨初始化 } //获取到koreography对象 playingKoreo = Koreographer.Instance.GetKoreographyAtIndex(0); KoreographyTrack 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 < noteLines.Count; j++) { LaneController lane = noteLines[j]; if (noteID > 6) { noteID = noteID - 6; if (noteID > 6) { noteID = noteID - 6; } } if (lane.DoesMatch(noteID)) { lane.AddEventToLane(evt); break; } } } hitWindowRangeInSamples = (int)(SampleRate * hitWindowRangeInMS * 0.0001f); }
private void InitializeNotes() { List <KoreographyEvent> rawEvents = mKoreo.GetTrackByID("FurEliseRhythmEASY").GetAllEvents(); foreach (KoreographyEvent kevent in rawEvents) { if (kevent.HasTextPayload()) { char[] payload = kevent.GetTextValue().ToCharArray(); NoteDataObject newNote = new NoteDataObject(); if (payload[0].Equals('N')) { //payload[1] == color newNote.Initialize(payload[1], payload[0], kevent.StartSample); } mNotesToSpawn[payload[1]].Enqueue(newNote); } } }
void Start() { gameManager = GameObject.Find("GameManager"); //PlayerPrefs.SetFloat("noteSpeed", noteSpeed); //PlayerPrefs.SetFloat("hitDelay", hitDelay); noteSpeed = PlayerPrefs.GetFloat("noteSpeed", 6f); hitDelay = PlayerPrefs.GetFloat("hitDelay", 0.08f); gameManager.transform.position = new Vector3(0, (float)(-noteSpeed * hitDelay - (2 + 0.5) * noteSpeed / 6), 0);//holy shit string songName; if (PlayerPrefs.GetString("PlayMode", "Play") == "Play") { songName = PlayerPrefs.GetString("SongName", GameStatics.songs[0].PlayBackName); eventID = PlayerPrefs.GetString("Difficulty", "Easy"); } else { songName = GameStatics.testSong.PlayBackName; eventID = "Easy"; } Debug.Log(songName); simpleMusicPlayer = GameObject.Find(songName).GetComponent <SimpleMusicPlayer>(); audioCom = GameObject.Find(songName).GetComponent <AudioSource>(); Koreographer.Instance.EventDelayInSeconds = 0f; InitializeLeadIn(); // Initialize all the Lanes. for (int i = 0; i < noteLanes.Count; ++i) { noteLanes[i].Initialize(this); } //Debug.Log(noteLanes.Count);//9 // Initialize events. if (songName == GameStatics.songs[0].PlayBackName) { playingKoreo = Koreographer.Instance.GetKoreographyAtIndex(0); } else { playingKoreo = Koreographer.Instance.GetKoreographyAtIndex(1); } //playingKoreo = Koreographer.Instance. // Grab all the events out of the Koreography. KoreographyTrack rhythmTrack = playingKoreo.GetTrackByID(eventID);//Easy or Hard List <KoreographyEvent> rawEvents = rhythmTrack.GetAllEvents(); Debug.Log(rawEvents.Count); 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) { Lane lane = noteLanes[j]; if (lane.DoesMatchPayload(payload)) { // Add the object for input tracking. lane.AddEventToLane(evt); // Break out of the lane searching loop. //break; } } } }