static Audio() { Events.Audio.CustomMusicChanged.Subscribe(data => { CustomMusicChanged?.Invoke(default(object), new CustomMusicChangedEventArgs(data.newTrackName_)); }); Events.Audio.MIDIEvent.Subscribe(data => { MIDINote?.Invoke(default(object), new MIDINoteEventArgs(data.note_, data.velocity_)); }); Events.Audio.MusicBeatEvent.Subscribe(data => { MusicBeat?.Invoke(default(object), System.EventArgs.Empty); }); Events.Audio.MusicGridEvent.Subscribe(data => { MusicGridProgress?.Invoke(default(object), new MusicGridEventArgs(data.barCount_, data.beatCount_)); }); Events.Audio.MusicSegmentEnd.Subscribe(data => { MusicSegmentEnded?.Invoke(default(object), System.EventArgs.Empty); }); }
public void CheckBeatDistance(MusicBeat beat) { //store the distance between the beat and the center of the hitbox float beatDistance = Vector2.Distance(beat.gameObject.transform.position, transform.position); //create variable to store hit type HitType thisHit; //check the distance to determine score if (beatDistance <= perfectRadius) { //hit the beat as a perfect note thisHit = HitType.Perfect; //add to score playerScore += 1000; //add to combo and change background color comboScore++; } else if (beatDistance <= goodRadius) { //hit the beat as a good note thisHit = HitType.Good; //add to score playerScore += 500; //add to combo and change background color comboScore++; } else { //miss the beat thisHit = HitType.Miss; //drop the combo and reset the background comboScore = 0; Camera.main.GetComponent <BackgroundPulse>().ResetColor(); } //check if current combo is greater than the highest combo and set it accordingly if (comboScore > highestCombo) { highestCombo = comboScore; } //hit the beat beat.HitBeat(thisHit); }
public void CheckRight(InputAction.CallbackContext ctx) { //check the currently playable beat to see if it's a right beat if (playableNotes.Count > 0) { MusicBeat currentBeat = playableNotes.Dequeue(); //check if the beat type is right if (currentBeat.beatType == BeatType.Right) { //check beat distance if the type matches CheckBeatDistance(currentBeat); } else { //miss the beat and reset the background and combo currentBeat.HitBeat(HitType.Miss); comboScore = 0; Camera.main.GetComponent <BackgroundPulse>().ResetColor(); } } }
void Update() { string s = ""; foreach (KeyValuePair <int, PlayerInfo> entry in localFrags) { s += "\n" + (entry.Key == PhotonNetwork.player.ID? ">" : " ") + entry.Key + ": " + entry.Value.kills + " / " + entry.Value.deaths; if (entry.Key == PhotonNetwork.player.ID) { if (timeUI != null) { float timer = (float)gameDurationInBeats - Mathf.Floor((float)MusicBeat.BeatTimeFromBegin); if (!gameFinished && PhotonNetwork.isMasterClient && timer <= 0.0f && !sentRestart) { Debug.Log("--------------Finishing"); ScenePhotonView.RPC("FinishGame", PhotonTargets.All); sentRestart = true; } if (timer >= 0) { timeUI.text = "" + (timer <= gameDurationInBeats ? timer.ToString("#") : ""); sentRestart = false; gameFinished = false; Camera.main.GetComponent <ShowWithTab>().forceShow = false; } else { timeUI.text = ""; Camera.main.GetComponent <ShowWithTab>().forceShow = true; } } if (healthUI != null) { healthUI.text = "" + Mathf.Floor(entry.Value.health * 20); } if (killsUI != null) { killsUI.text = "" + entry.Value.kills; } if (deathsUI != null) { deathsUI.text = "" + entry.Value.deaths; } } } if (statsUI != null) { statsUI.text = s; } if (gameFinished && PhotonNetwork.isMasterClient && Input.GetButtonDown("Fire1")) { RestartSession(); MusicBeat.ForceStart(); } }