public void EventJudge(byte eventLane, Common.EVENT eventTyoe) { List <byte> judgeLanes = new List <byte>(); if (eventLane == 0) { judgeLanes.Add(0); } else if (1 <= eventLane && eventLane <= 6) { judgeLanes.Add((byte)(eventLane - 1)); judgeLanes.Add(eventLane); } else if (eventLane == 7) { judgeLanes.Add(6); } foreach (NoteData note in this.notesManager.notes) { bool isLaneMatch = false; foreach (byte lane in judgeLanes) { if (note.lane == lane) { isLaneMatch = true; } } if (!isLaneMatch) { continue; } switch (eventTyoe) { case Common.EVENT.PRESS: if (note.type != Common.NOTE.SINGLE && note.type != Common.NOTE.SLIDE_PRESS) { continue; } break; case Common.EVENT.RELEASE: if (note.type != Common.NOTE.SLIDE_RELEASE) { continue; } break; case Common.EVENT.FLICK: if (note.type != Common.NOTE.FLICK) { continue; } break; } float time = this.soundManager.time + this.regulation; if (time < note.time - this.badRangeBefore || note.time + this.badRangeAfter < time) { continue; } else if (time < note.time - this.goodRangeBefore || note.time + this.goodRangeAfter < time) { //Debug.Log(this.name + ": Bad"); judgeDisplay.Launch(Common.JUDGE.BAD); } else if (time < note.time - this.greatRangeBefore || note.time + this.greatRangeAfter < time) { //Debug.Log(this.name + ": Good"); judgeDisplay.Launch(Common.JUDGE.GOOD); } else if (time < note.time - this.perfectRangeBefore || note.time + this.perfectRangeAfter < time) { //Debug.Log(this.name + ": Great"); judgeDisplay.Launch(Common.JUDGE.GREAT); } else { //Debug.Log(this.name + ": Perfect"); judgeDisplay.Launch(Common.JUDGE.PERFECT); } SEManager.PlayOneShot(SEManager.clip); notesManager.DestroyNote(note); break; } }
public void EventJudge(byte eventLane, Common.EVENT eventTyoe, int pointerId) { List <byte> judgeLanes = new List <byte>(); byte trueLane = 0; if (eventLane == 0) { judgeLanes.Add(0); trueLane = 0; } else if (1 <= eventLane && eventLane <= 12) { if (eventLane % 2 == 0) { judgeLanes.Add((byte)(Mathf.Floor(eventLane / 2) - 1)); } else { judgeLanes.Add((byte)(Mathf.Floor(eventLane / 2) + 1)); } judgeLanes.Add((byte)Mathf.Floor(eventLane / 2)); trueLane = (byte)Mathf.Floor(eventLane / 2); } else if (eventLane == 13) { judgeLanes.Add(6); trueLane = 6; } NoteData nearestNote = null; float time = this.soundManager.time + this.regulation; foreach (NoteData note in this.notesManager.notes) { bool isLaneMatch = false; foreach (byte lane in judgeLanes) { if (note.lane == lane) { isLaneMatch = true; } } if (!isLaneMatch) { continue; } switch (eventTyoe) { case Common.EVENT.PRESS: if (note.type != Common.NOTE.SINGLE && note.type != Common.NOTE.SLIDE_PRESS) { continue; } break; case Common.EVENT.RELEASE: if (note.type != Common.NOTE.SLIDE_RELEASE) { continue; } break; case Common.EVENT.FLICK: if (note.type != Common.NOTE.FLICK) { continue; } break; } if (note.time - this.badRangeBefore < time && time < note.time + this.badRangeAfter) { if (note.type == Common.NOTE.SLIDE_RELEASE) { bool isForwardExists = false; foreach (NoteData nd in this.notesManager.notes) { if (note.chainForward == nd.index) { isForwardExists = true; } } if (isForwardExists) { continue; } } if (nearestNote == null) { nearestNote = note; } else if (Mathf.Abs(nearestNote.time - time) > Mathf.Abs(note.time - time)) { nearestNote = note; } } } if (nearestNote != null) { Debug.Log(this.name + ": JudgeEnter index=" + nearestNote.index + " type=" + nearestNote.type + " lane=" + nearestNote.lane); if (time < nearestNote.time - this.goodRangeBefore || nearestNote.time + this.goodRangeAfter < time) { //Debug.Log(this.name + ": Bad"); judgeDisplay.Launch(Common.JUDGE.BAD); this.scoreManager.ScoreAdd(Common.JUDGE.BAD); this.hpManager.Damage(Common.JUDGE.BAD); this.comboManager.LoseCombo(); this.SEManager.Play(0); } else if (time < nearestNote.time - this.greatRangeBefore || nearestNote.time + this.greatRangeAfter < time) { //Debug.Log(this.name + ": Good"); judgeDisplay.Launch(Common.JUDGE.GOOD); this.scoreManager.ScoreAdd(Common.JUDGE.GOOD); this.comboManager.LoseCombo(); this.SEManager.Play(1); } else if (time < nearestNote.time - this.perfectRangeBefore || nearestNote.time + this.perfectRangeAfter < time) { //Debug.Log(this.name + ": Great"); judgeDisplay.Launch(Common.JUDGE.GREAT); this.scoreManager.ScoreAdd(Common.JUDGE.GREAT); this.comboManager.AddCombo(); this.SEManager.Play(1); } else { //Debug.Log(this.name + ": Perfect"); judgeDisplay.Launch(Common.JUDGE.PERFECT); this.scoreManager.ScoreAdd(Common.JUDGE.PERFECT); this.comboManager.AddCombo(); this.SEManager.Play(2); } notesManager.DestroyNote(nearestNote); this.effectManager.GenerateEffect(nearestNote.type, nearestNote.lane); if (nearestNote.type == Common.NOTE.SLIDE_PRESS) { nearestNote.slideLine.isPressing = true; nearestNote.slideLine.effectTransform = this.effectManager.GenerateSlideEffect(nearestNote.lane).GetComponent <RectTransform>(); this.SEManager.PlayLoop(3); AimedRelease aim = new AimedRelease(); aim.pointerId = pointerId; foreach (NoteData aimNote in this.notesManager.notes) { if (aimNote.index == nearestNote.chainBehind) { aim.note = aimNote; Debug.Log(this.name + ": aim lane=" + aim.note.lane + " id=" + aim.pointerId); break; } } this.aimedRelease.Add(aim); } else if (nearestNote.type == Common.NOTE.SLIDE_RELEASE || nearestNote.type == Common.NOTE.FLICK) { this.SEManager.StopLoop(); foreach (AimedRelease aim in this.aimedRelease) { if (aim.pointerId != pointerId) { continue; } this.aimedRelease.Remove(aim); Debug.Log(this.name + ": aimRelease lane=" + aim.note.lane + " id=" + aim.pointerId); return; } } } else { if (eventTyoe == Common.EVENT.PRESS) { //Debug.Log("pressed"); this.effectManager.GenerateEffect(Common.NOTE.NONE, trueLane); } if (eventTyoe == Common.EVENT.RELEASE && this.aimedRelease.Count != 0) { foreach (AimedRelease aim in this.aimedRelease) { if (aim.pointerId != pointerId) { continue; } Debug.Log(this.name + ": aimDelete lane=" + aim.note.lane + " id=" + aim.pointerId); this.notesManager.DestroyNote(aim.note);// this.aimedRelease.Remove(aim); //Debug.Log(this.name + ": Miss"); this.judgeDisplay.Launch(Common.JUDGE.MISS); this.scoreManager.ScoreAdd(Common.JUDGE.MISS); this.hpManager.Damage(Common.JUDGE.MISS); this.SEManager.Play(0); this.SEManager.StopLoop(); this.comboManager.LoseCombo(); return; } } } }