public HitObjectContainer ReadHitObjects(string beatmapName, BeatmapSettings beatmapSettings) { HitObjectContainer hitObjectContainer = new HitObjectContainer(beatmapSettings.Difficulty.KeyAmount); LogHelper.Log($"BeatmapReader: Reading Beatmap Hit Objects '{beatmapName}'"); string path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, ProcessorSettings.BeatmapsFolder, beatmapName, ProcessorSettings.HitObjectsFolder, beatmapSettings.HitObjectsFilename + "_" + beatmapSettings.Metadata.Version); if (!File.Exists(path)) { throw new FileNotFoundException("hitobjects file not found"); } Console.WriteLine(path); // Reading HitObjects file, which contains all the objects used in the beatmap // HitObjects file uses this format: "Column Position" for a Click, and "Column Position EndPosition" for a Hold using (StreamReader sr = new StreamReader(path)) { LogHelper.Log($"BeatmapReader: Found Beatmap Hit Objects file '{beatmapSettings.HitObjectsFilename}'"); string full = sr.ReadToEnd(); string[] lines = full.Split('\n'); foreach (var line in lines) { // If the line is empty or contains only whitespaces, skip it if (string.IsNullOrWhiteSpace(line)) { continue; } // Split the line, remove all whitespaces string[] tokens = Array.ConvertAll(line.Split(' '), p => p.Trim()); // If length is 3, the object is a 'Hold', else it's 'Click' HitObject ho; if (tokens.Length == 2) { ho = new NoteClick(int.Parse(tokens[0]), int.Parse(tokens[1])); } else if (tokens.Length == 3) { ho = new NoteHold(int.Parse(tokens[0]), int.Parse(tokens[1]), int.Parse(tokens[2])); } else { throw new Exception("Unknown note type"); } hitObjectContainer.Add(ho); } } LogHelper.Log($"BeatmapReader: Successfully Read Beatmap Hit Objects. Total Hit Objects count: {hitObjectContainer.Count}"); return(hitObjectContainer); }
public void MakeMove(int keyNumber) { if (isFirstMove) { Start?.Invoke(); isFirstMove = false; } var firstLine = Map.GetFirstLine(); var pianoKey = firstLine[keyNumber]; var isPressNote = pianoKey.IsNote; pianoKey.Press(); Update(isPressNote); NoteClick?.Invoke(pianoKey.Note); }