public void Awake() { instance = this; var keyImage = UI.instance.keyImages.FirstOrDefault(ki => ki.keyToken == keyToken); if (keyImage) { keyImage.counter = counter; } }
private static KeyCounter <int> CreateKeyCounter(int[] dataset) { var keyCounter = new KeyCounter <int>("Arbitrary"); foreach (var value in dataset) { keyCounter.Count(value); } return(keyCounter); }
public void Awake() { sound = GetComponent <AudioSource>(); keyCounter = FindObjectOfType <KeyCounter>(); }
private void associateHits() { int keyIndex = 0; var keyCounter = new KeyCounter(); if ((replay.Mods & Mods.HardRock) > 0) { applyHardrock(); } if (replay.Mods.HasFlag(Mods.Easy)) { beatmap.applyEasy(); } int breakIndex = 0; int combo = 0; Keys lastPress = Keys.None; foreach (CircleObject note in beatmap.HitObjects) { bool noteHitFlag = false; bool noteAttemptedHitFlag = false; if (note.Type.HasFlag(HitObjectType.Spinner)) { continue; } for (int j = keyIndex; j < replay.ReplayFrames.Count; ++j) { var frame = replay.ReplayFrames[j]; var lastKey = j > 0 ? replay.ReplayFrames[j - 1].Keys : Keys.None; var pressedKey = getKey(lastKey, frame.Keys); if (breakIndex < breaks.Count && frame.Time > breaks[breakIndex].EndTime) { ++breakIndex; } if (frame.Time >= beatmap.HitObjects[0].StartTime - hitTimeWindow && (breakIndex >= breaks.Count || frame.Time < breaks[breakIndex].StartTime - hitTimeWindow)) { keyCounter.Update(lastKey, frame.Keys); } frame.keyCounter = new KeyCounter(keyCounter); if (frame.Time - note.StartTime > hitTimeWindow) { break; } if ((pressedKey > 0 || lastPress > 0) && Math.Abs(frame.Time - note.StartTime) <= hitTimeWindow) { if (note.ContainsPoint(new Point2(frame.X, frame.Y)) && !(note is SliderObject slider && slider.SegmentEndTime <= frame.Time)) { noteAttemptedHitFlag = true; ++combo; frame.combo = combo; noteHitFlag = true; hits.Add(new HitFrame(note, frame, (lastPress > 0? lastPress : pressedKey))); keyIndex = j + (lastPress > 0 ? 0 : 1); if ((pressedKey.HasFlag(Keys.M1) && pressedKey.HasFlag(Keys.M2)) || (pressedKey.HasFlag(Keys.M1) && pressedKey.HasFlag(Keys.K2)) || (pressedKey.HasFlag(Keys.K1) && pressedKey.HasFlag(Keys.M2)) || (pressedKey.HasFlag(Keys.K1) && pressedKey.HasFlag(Keys.K2))) { lastPress = pressedKey; } else { lastPress = Keys.None; } break; } if (Utils.dist(note.Location.X, note.Location.Y, frame.X, frame.Y) > 150) { extraHits.Add(new ClickFrame(frame, getKey(lastKey, frame.Keys))); } else { noteAttemptedHitFlag = true; attemptedHits.Add(new HitFrame(note, frame, pressedKey)); } } if (pressedKey > 0 && Math.Abs(frame.Time - note.StartTime) <= 3 * hitTimeWindow && note.ContainsPoint(new Point2(frame.X, frame.Y))) { noteAttemptedHitFlag = true; attemptedHits.Add(new HitFrame(note, frame, pressedKey)); } frame.combo = combo; } if (!noteHitFlag) { misses.Add(note); } if (!noteAttemptedHitFlag) { effortlessMisses.Add(note); } } }
private void associateHits() { int keyIndex = 0; Keys lastKey; KeyCounter keyCounter = new KeyCounter(); if ((replay.Mods & Mods.HardRock) > 0) { applyHardrock(); } int breakIndex = 0; int combo = 0; for (int i = 0; i < beatmap.HitObjects.Count; ++i) { CircleObject note = beatmap.HitObjects[i]; bool noteHitFlag = false; bool noteAttemptedHitFlag = false; if ((note.Type.HasFlag(HitObjectType.Spinner))) { continue; } for (int j = keyIndex; j < replay.ReplayFrames.Count; ++j) { ReplayFrame frame = replay.ReplayFrames[j]; lastKey = j > 0 ? replay.ReplayFrames[j - 1].Keys : Keys.None; Keys pressedKey = Utils.getKey(lastKey, frame.Keys); if (breakIndex < breaks.Count && frame.Time > breaks[breakIndex].EndTime) { ++breakIndex; } if (frame.Time >= beatmap.HitObjects[0].StartTime - hitTimeWindow && (breakIndex >= breaks.Count || frame.Time < this.breaks[breakIndex].StartTime - hitTimeWindow)) { keyCounter.Update(lastKey, frame.Keys); } frame.keyCounter = new KeyCounter(keyCounter); if (frame.Time - note.StartTime > hitTimeWindow) { break; } if (pressedKey > 0 && Math.Abs(frame.Time - note.StartTime) <= hitTimeWindow) { if (note.ContainsPoint(new BMAPI.Point2(frame.X, frame.Y))) { noteAttemptedHitFlag = true; ++combo; frame.combo = combo; noteHitFlag = true; HitFrame hitFrame = new HitFrame(note, frame, pressedKey); hits.Add(hitFrame); lastKey = frame.Keys; keyIndex = j + 1; break; } else { if (Utils.dist(note.Location.X, note.Location.Y, frame.X, frame.Y) > 150) { extraHits.Add(new ClickFrame(frame, Utils.getKey(lastKey, frame.Keys))); } else { noteAttemptedHitFlag = true; attemptedHits.Add(new HitFrame(note, frame, pressedKey)); } } } if (pressedKey > 0 && Math.Abs(frame.Time - note.StartTime) <= 3 * hitTimeWindow && note.ContainsPoint(new BMAPI.Point2(frame.X, frame.Y))) { noteAttemptedHitFlag = true; attemptedHits.Add(new HitFrame(note, frame, pressedKey)); } lastKey = frame.Keys; frame.combo = combo; } if (!noteHitFlag) { misses.Add(new ReplayMissFrame(replay.ReplayFrames[keyIndex], keyIndex, note)); } if (!noteAttemptedHitFlag) { effortlessMisses.Add(note); } } }