Beispiel #1
0
        // Common Note sub-structure parsing
        protected static void noteProc(StructParseContext ctx, int linedex, char level)
        {
            NoteHold dad  = (ctx.Parent as NoteHold);
            var      note = NoteStructParse.NoteParser(ctx, linedex, level);

            dad.Notes.Add(note);
        }
Beispiel #2
0
    // Spawnds a hold note
    // Definition of a HOLDNOTE: [offset, noteType, startPath, length, isTransition]
    // isTransition - bool to decide weather the note is a transition note or not.
    public static void SpawnHold(string[] def)
    {
        // Change the name of the note for easier debugging.
        noteID = "Note " + noteIndex.ToString();
        noteIndex++;

        if (def.Length != 5)
        {
            Debug.Log("Something went wrong spawning the hold note");
            return;
        }

        float offset       = float.Parse(def[0]) / 1000f;
        int   path         = int.Parse(def[2]);
        float length       = float.Parse(def[3]);
        bool  isTransition = bool.Parse(def[4]);

        string definition = offset + "," + path.ToString() + "," + length.ToString() + "," + isTransition;

        Vector3 spawnPosition = new Vector3(NotePath.NotePaths[path].transform.position.x, basePosition.y, basePosition.z);

        NoteHold n = (NoteHold)GetNoteFromPool(NoteType.Hold);

        n.Construct(spawnPosition, offset, path, length, isTransition, noteID);
        n.gameObject.SetActive(true);
    }
Beispiel #3
0
        protected static void addNote(NoteHold dad, string txt)
        {
            // save some unexpected text as a note
            Note note = new Note();

            note.Text = txt;
            dad.Notes.Add(note);
        }
Beispiel #4
0
        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);
        }
Beispiel #5
0
 internal static void writeSubNotes(StreamWriter file, NoteHold rec, int level = 1)
 {
     // TODO embedded notes -> note xref
     if (rec == null || rec.Notes.Count == 0)
     {
         return;
     }
     foreach (var note in rec.Notes)
     {
         if (!string.IsNullOrWhiteSpace(note.Xref))
         {
             file.WriteLine("{0} NOTE @{1}@", level, note.Xref);
         }
         else
         {
             writeExtended(file, level, "NOTE", note.Text);
         }
     }
 }
Beispiel #6
0
    private void PreloadNotes()
    {
        for (int i = 0; i < noteAmount; i++)
        {
            Note tempNote = Instantiate(Note, spawnPosition, BoardObject.rotation).GetComponent <Note>();
            NoteList.Add(tempNote);
            tempNote.gameObject.SetActive(false);

            NoteFlick tempFlick = Instantiate(Flick, spawnPosition, BoardObject.rotation).GetComponent <NoteFlick>();
            FlickList.Add(tempFlick);
            tempFlick.gameObject.SetActive(false);

            NoteHold tempHold = Instantiate(Hold, spawnPosition, BoardObject.rotation).GetComponent <NoteHold>();
            HoldList.Add(tempHold);
            tempHold.gameObject.SetActive(false);
        }

        for (int i = 0; i < dragAmount; i++)
        {
            NoteDrag tempDrag = Instantiate(Drag, spawnPosition, BoardObject.rotation).GetComponent <NoteDrag>();
            DragList.Add(tempDrag);
            tempDrag.gameObject.SetActive(false);
        }
    }