void AdjustLight(KoreographyEvent evt, int sampleTime, int sampleDelta, DeltaSlice deltaSlice) { if (evt.HasIntPayload()) { if (evt.GetIntValue() == 1) { lights[0].SetActive(true); lights[1].SetActive(true); lights[2].SetActive(false); lights[3].SetActive(false); } else if (evt.GetIntValue() == 2) { lights[0].SetActive(false); lights[1].SetActive(false); lights[2].SetActive(true); lights[3].SetActive(true); } else if (evt.GetIntValue() == 3) { lights[0].SetActive(true); lights[1].SetActive(true); lights[2].SetActive(true); lights[3].SetActive(true); } else { lights[0].SetActive(false); lights[1].SetActive(false); lights[2].SetActive(false); lights[3].SetActive(false); } } }
private void Beat(KoreographyEvent koreoEvent) { int beatNum = koreoEvent.GetIntValue(); if (beatNum == 1) { playAni.SetTrigger("clap01"); playAni.ResetTrigger("clap02"); playAni.ResetTrigger("clap03"); playAni.ResetTrigger("auto"); beatHit.Play(); } else if (beatNum == 2) { playAni.SetTrigger("clap02"); playAni.ResetTrigger("clap01"); playAni.ResetTrigger("clap03"); playAni.ResetTrigger("auto"); beatHit.Play(); } else if (beatNum == 3) { beatHit.Play(); } }
//检测是否生成下一个新音符 void CheckSpawnNext() { int samplesToTarget = GetSpawnSampleOffset(); int currentTime = gameController.DelayedSampleTime; while (pendingEventIdx < laneEvents.Count && laneEvents[pendingEventIdx].StartSample < currentTime + samplesToTarget) { KoreographyEvent evt = laneEvents[pendingEventIdx]; int noteNum = evt.GetIntValue(); NoteObject newObj = gameController.GetFreshNoteObject(); bool isLongNoteStart = false; bool isLongNoteEnd = false; if (noteNum > 6) { isLongNoteStart = true; noteNum = noteNum - 6; if (noteNum > 6) { isLongNoteEnd = true; isLongNoteStart = false; noteNum = noteNum - 6; } } newObj.Initialize(evt, noteNum, this, gameController, isLongNoteStart, isLongNoteEnd); trackedNotes.Enqueue(newObj); pendingEventIdx++; } }
// Update is called once per frame void SpawnFundo(KoreographyEvent evt) { int valor = evt.GetIntValue(); if (valor == 3) { Instantiate(fundos [0], transform.position, transform.rotation); } else if (valor == 4) { Instantiate(fundos [1], transform.position, transform.rotation); } else if (valor == 5) { Vector3 pos = new Vector3(-0.2f, -5.8f, 58.7f); Instantiate(fundos [2], pos, transform.rotation); } else if (valor == 6) { Vector3 pos = new Vector3(-0.2f, -5.8f, 58.6f); Instantiate(fundos [3], pos, transform.rotation); } //Fim da demo /*else if (valor == 7) { * Instantiate (fundos [4], transform.position, transform.rotation); * }*/ }
// 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); }
public void GenerateKey(KoreographyEvent koreographyEvent) { lightManager.ChangeLightColors(); // asignar un color random por ahorita if (koreographyEvent.HasIntPayload()) { if (koreographyEvent.GetIntValue() == (int)KoreoInts._1_GenerateRandomKey) { if (keyEvents.Contains(koreographyEvent)) { Debug.Log("Se encontro!"); for (int i = 0; i < keyEventsLength; i++) { //si empiezan en el mismo tiempo es que son el mismo if (keyEvents[i].StartSample == koreographyEvent.StartSample) { if (i + 1 < keyEventsLength) { keyManager.GenerateRandomKey(koreographyEvent.EndSample, keyEvents[i + 1].StartSample, koreography.SampleRate); } else { keyManager.GenerateRandomKey(koreographyEvent.EndSample, 0, koreography.SampleRate, true); } break; } } } else { Debug.Log("No se encontro ):"); } } else if (koreographyEvent.GetIntValue() == (int)KoreoInts._2_SondEnded) { //Se acabo el juego keyManager.GameWon(); } Debug.Log(koreographyEvent.GetIntValue()); } }
void FireMelody(KoreographyEvent koreoEvent) { // Debug.Log("BUMP "+Time.time); if (koreoEvent.GetFloatValue() != 0) { GameManager.instance.om.AddObstacle(Mathf.RoundToInt(koreoEvent.GetFloatValue())); } else { GameManager.instance.om.AddObstacle(koreoEvent.GetIntValue()); } // GameManager.instance.om.test(); }
void spawnMusica(KoreographyEvent evt) { int valor = evt.GetIntValue(); if (valor == 4) { for (int i = 0; i < objetosRock.Length; i++) { Destroy(objetosRock[i].gameObject); } StartCoroutine(spawnPop()); } }
void spawnMusica(KoreographyEvent evt) { int valor = evt.GetIntValue(); if (valor == 6) { Instantiate(objeto, transform.position, transform.rotation); for (int i = 0; i < objetosSer.Length; i++) { Destroy(objetosSer[i].gameObject); } } }
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); }
public void TeleportRandom(KoreographyEvent evt) { alpha = 0; GameObject go = Instantiate(magiaPrefab, transform.Find("Lurker").gameObject.transform.position, magiaPrefab.transform.rotation); go.GetComponent <MagiaTeleport>().bulletPrefab = bulletPrefab; Vector2 desloc = Random.insideUnitCircle.normalized; transform.Find("Lurker").gameObject.transform.localPosition = new Vector3(desloc.x, desloc.y) * 2f; if (evt.GetIntValue() == 1) { transform.Find("Lurker").gameObject.transform.localPosition = new Vector3(0, 0, 0); } }
private void HandleTrackEvent(KoreographyEvent ev, TrackType track) { if (this.canMoveToNextSection || track != this.currentFocusedTrack) { return; } var value = ev.HasIntPayload() ? ev.GetIntValue() : -1; if (value > this.GetCurrentMinNoteValue()) { return; } OnTrackNoteEvent(track, value); }
// 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 spawnLuz(KoreographyEvent evt) { int valor = evt.GetIntValue(); if (valor == 3) { Vector3 pos = new Vector3(0.18f, 10.49f, 1.08f); Instantiate(luzRock1, pos, transform.rotation); Vector3 pos1 = new Vector3(0.18f, 6.3f, 8.4f); Instantiate(luzRock2, pos1, transform.rotation); Vector3 pos2 = new Vector3(0.18f, 5.06f, 15.31f); Instantiate(luzRock3, pos2, transform.rotation); } else if (valor == 4) { Destroy(gameObject); } }
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 HandleBeatTrackEvent(KoreographyEvent ev) { var moveToNextMeasure = ev.HasIntPayload() && ev.GetIntValue() >= 0; if (moveToNextMeasure) { this.currentBeat = 0; this.currentMeasure++; this.OnMeasureChange(this.currentMeasure); } else { this.currentBeat++; } if (!this.canMoveToNextSection) { this.currentScoreBeat++; this.OnScoreBeat(this.currentScoreBeat); } var lengthInMeasures = (int)Koreographer.Instance.GetMusicBeatLength(this.currentFocusedTrack.ToString()) / 4; var measureProgress = 0; if (lengthInMeasures > 0) { measureProgress = this.currentMeasure % lengthInMeasures; } if (this.currentBeat == 0 && measureProgress == 0 && this.canMoveToNextSection) { this.currentSection++; this.StartSection(); } }
/// <summary> /// 检测是否生成下一个新音符 /// </summary> public void CheckSpawnNext() { int samplesToTarget = GetSpawnSampleOffset(); int currentTime = gameController.DelayedSampleTime; while (pendingEventIdx < laneEvents.Count && laneEvents[pendingEventIdx].StartSample < currentTime + samplesToTarget) { KoreographyEvent evt = laneEvents[pendingEventIdx]; NoteNum = evt.GetIntValue(); //Debug.Log("noteNum:" + noteNum); NoteObject newObj = gameController.GetFreshNoteObject(); bool isLongNoteStart = false; bool isLongNoteEnd = false; if (NoteNum > 4) { isLongNoteStart = true; InLongNote = true; NoteNum = NoteNum - 4; CreateLongNote(); if (NoteNum > 4) { isLongNoteEnd = true; isLongNoteStart = false; NoteNum = NoteNum - 4; InLongNote = false; } } //Debug.Log("NoteNum: " + NoteNum); newObj.Initialize(evt, NoteNum, this, gameController, isLongNoteStart, isLongNoteEnd); trackedNotes.Enqueue(newObj); //Debug.Log(trackedNotes.Count); pendingEventIdx++; } }
void spawn(KoreographyEvent evt) { valor = evt.GetIntValue(); if (valorTroca == 2) { if (valor == 5) { Vector3 pos = new Vector3(1.16f, -0.5f, 17.15f); Instantiate(obstaculos[0], pos, transform.rotation); } else if (valor == 6) { Instantiate(obstaculos[1], transform.position, transform.rotation); } else if (valor == 7) { Vector3 pos = new Vector3(0.05f, -0.5f, 17.15f); Instantiate(obstaculos[2], pos, transform.rotation); } else if (valor == 8) { Vector3 pos = new Vector3(0.028f, -0.5f, 17.15f); Instantiate(obstaculos[3], pos, transform.rotation); } } //rock obstaculos if (valorTroca == 3) { if (valor == 5) { Instantiate(obstaculos[4], transform.position, transform.rotation); } else if (valor == 6) { Instantiate(obstaculos[5], transform.position, transform.rotation); } else if (valor == 7) { Vector3 pos = new Vector3(0.761f, -0.5f, 17.15f); Instantiate(obstaculos[6], pos, transform.rotation); } else if (valor == 8) { Vector3 pos = new Vector3(0.941f, -0.5f, 17.15f); Instantiate(obstaculos[7], pos, transform.rotation); } } //pop obstaculos if (valorTroca == 4) { if (valor == 5) { Instantiate(obstaculos[8], transform.position, transform.rotation); } else if (valor == 6) { Instantiate(obstaculos[9], transform.position, transform.rotation); } else if (valor == 7) { Instantiate(obstaculos[10], transform.position, transform.rotation); } else if (valor == 8) { Instantiate(obstaculos[11], transform.position, transform.rotation); } } //sertaneijo obstaculos if (valorTroca == 5) { if (valor == 5) { Instantiate(obstaculos[12], transform.position, transform.rotation); } else if (valor == 6) { Instantiate(obstaculos[13], transform.position, transform.rotation); } else if (valor == 7) { Vector3 pos = new Vector3(0.489f, -0.5f, 17.15f); Instantiate(obstaculos[14], pos, transform.rotation); } else if (valor == 8) { Vector3 pos = new Vector3(0.5f, -0.5f, 17.15f); Instantiate(obstaculos[15], pos, transform.rotation); } } //classico obstaculos if (valorTroca == 6) { if (valor == 5) { Instantiate(obstaculos[16], transform.position, transform.rotation); } else if (valor == 6) { Instantiate(obstaculos[17], transform.position, transform.rotation); } else if (valor == 7) { Vector3 pos = new Vector3(0f, -0.5f, 17.15f); Instantiate(obstaculos[18], pos, transform.rotation); } else if (valor == 8) { Vector3 pos = new Vector3(0f, -0.5f, 17.15f); Instantiate(obstaculos[19], pos, transform.rotation); } } }
void onNewBar(KoreographyEvent evt) { int barNum = evt.GetIntValue(); text.text = "BAR: " + barNum; }
void Valor(KoreographyEvent troca) { valorTroca = troca.GetIntValue(); }