Esempio n. 1
0
    public static Chart JCharttoChart(JSONChart jchart)
    {
        Chart chart = new Chart
        {
            speed = jchart.speed
        };

        while (chart.notes.Count > 0)
        {
            chart.notes.RemoveAt(0);
        }
        foreach (JSONChart.note jnote in jchart.notes)
        {
            Note note = new Note
            {
                position = jnote.pos,
                size     = jnote.size,
                time     = jnote.time,
                shift    = jnote.shift
            };
            foreach (JSONChart.sound jsound in jnote.sounds)
            {
                PianoSound sound = new PianoSound
                {
                    delay    = jsound.w,
                    duration = jsound.d,
                    pitch    = jsound.p,
                    volume   = jsound.v
                };
                note.sounds.Add(sound);
            }
            chart.notes.Add(note);
        }
        foreach (JSONChart.link jlink in jchart.links)
        {
            int prev = -1;
            foreach (int noteref in jlink.noteRef)
            {
                if (prev != -1)
                {
                    chart.notes[prev].nextLink = noteref - 1;             //Note number in Chart starts by 0
                }
                chart.notes[noteref - 1].isLink   = true;
                chart.notes[noteref - 1].prevLink = prev;
                prev = noteref - 1;
            }
            if (prev != -1)
            {
                chart.notes[prev].nextLink = -1;
            }
        }
        return(chart);
    }
Esempio n. 2
0
 public void Deactivate(bool save)
 {
     CurrentState.ignoreAllInput = false;
     if (save)
     {
         List <PianoSound> pianoSounds = new List <PianoSound>();
         foreach (PianoSoundItem item in items)
         {
             PianoSound pianoSound = new PianoSound
             {
                 delay    = item.delay,
                 duration = item.duration,
                 pitch    = item.pitch,
                 volume   = item.volume
             };
             pianoSounds.Add(pianoSound);
             itemPool.ReturnObject(item);
         }
         while (items.Count > 0)
         {
             items.RemoveAt(0);
         }
         editor.PianoSoundFinishedEdit(pianoSounds);
     }
     else
     {
         foreach (PianoSoundItem item in items)
         {
             itemPool.ReturnObject(item);
         }
         while (items.Count > 0)
         {
             items.RemoveAt(0);
         }
         if (editor != null)
         {
             editor.PianoSoundFinishedEdit(null);
         }
     }
 }
Esempio n. 3
0
    public static Chart CopyChart(Chart chart)
    {
        Chart copy = new Chart();

        foreach (float time in chart.beats)
        {
            copy.beats.Add(time);
        }
        copy.difficulty = chart.difficulty;
        copy.level      = chart.level;
        foreach (Note note in chart.notes)
        {
            Note newNote = new Note
            {
                position = note.position,
                isLink   = note.isLink,
                nextLink = note.nextLink,
                prevLink = note.prevLink,
                shift    = note.shift,
                size     = note.size
            };
            foreach (PianoSound sound in note.sounds)
            {
                PianoSound newSound = new PianoSound
                {
                    delay    = sound.delay,
                    duration = sound.duration,
                    pitch    = sound.pitch,
                    volume   = sound.volume
                };
                newNote.sounds.Add(newSound);
            }
            newNote.time = note.time;
            copy.notes.Add(newNote);
        }
        copy.speed = chart.speed;
        return(copy);
    }
Esempio n. 4
0
    public void PlaySound()
    {
        List <PianoSound> pianoSounds = new List <PianoSound>();

        foreach (PianoSoundItem item in items)
        {
            PianoSound pianoSound = new PianoSound
            {
                delay    = item.delay,
                duration = item.duration,
                pitch    = item.pitch,
                volume   = item.volume
            };
            pianoSounds.Add(pianoSound);
        }
        foreach (PianoSound sound in pianoSounds)
        {
            if (editor.stage.pianoVolume > 0)
            {
                piano.PlayNote(sound.pitch, sound.volume * editor.stage.pianoVolume / 100, editor.stage.musicPlaySpeed / 10.0f,
                               sound.duration, sound.delay);
            }
        }
    }