Exemplo n.º 1
0
 private void LoadSequence()
 {
     sequence = ClapWaveSequence.LoadSequenceFile(path, 1);
     if (sequence == null)
     {
       Debug.LogWarning("Editor can't load Sequencefile \"" + path + "\".");
       sequence = new ClapWaveSequence();
     }
     length = Sequence.Count();
 }
Exemplo n.º 2
0
    void Start()
    {
        ns = GameObject.FindObjectOfType<NoteSpawner>();
        juice = GameObject.FindObjectOfType<Juicificationator>();

        timeElapsed = 0;
        timePerBeat = 60 / GameProperties.BeatsPerMinute;
        timeTillNextBeat = timePerBeat;
        timeTillNextMeasure = timePerBeat * 4;		// 4/4 time signature, 4 beats per measure	timePerBeat = 60 / bpm;

        waveSequence = ClapWaveSequence.LoadSequenceFile(songName,timePerBeat);
    }
Exemplo n.º 3
0
    public static void SaveSequenceFile(string fileName, ClapWaveSequence seq)
    {
        if (File.Exists(Application.streamingAssetsPath + fileName))
        {
            File.Delete(Application.streamingAssetsPath + fileName);
        }
        string filePath = Path.Combine(Application.streamingAssetsPath, fileName);
        StreamWriter sr = File.CreateText(filePath);

        for (int x = 0; x < seq.Count(); x++)
        {
            if (x % MEASURELENGHT == 0)
            {
                sr.WriteLine(BARIER);
            }
            string line = "";
            ClapWave wave = seq.GetWave(x);
            for (int i = 0; i < GameProperties.NUMBER_OF_COLORS; i++)
            {
                line += (wave.Notes[i]) ? "X" : NONE.ToString();
            }
            if (wave.Hold)
            {
                line += HOLD.ToString();
            }
            else if (wave.Release)
            {
                line += RELEASE.ToString();
            }
            sr.WriteLine(line);
        }

        sr.Close();
    }
Exemplo n.º 4
0
    public static ClapWaveSequence LoadSequenceFile(string fileName, float timePerBeat)
    {
        ClapWaveSequence waveSequence = new ClapWaveSequence();
        StreamReader reader = null;
        try
        {
            string filePath = Path.Combine(Application.streamingAssetsPath, fileName);
            if (filePath.Contains("://"))
            { //android mobile
                string newPath = Path.Combine(Application.persistentDataPath, fileName);
                if (!File.Exists(newPath))
                {
                    WWW www = new WWW(filePath);
                    while (!www.isDone) {; }                // Wait for download to complete - not pretty at all but easy hack for now
                    if (System.String.IsNullOrEmpty(www.error))
                    {
                        File.WriteAllBytes(newPath, www.bytes);
                    }

                }
                filePath = newPath;
            }
            reader = new StreamReader(filePath, System.Text.Encoding.Default);
        }
        catch (System.Exception e)
        {
            Debug.LogWarning("Cant read \"" + fileName + "\"" + e.StackTrace);
            return null;
        }
        string line = reader.ReadLine();

        do
        {
            bool[] claps = new bool[GameProperties.NUMBER_OF_COLORS];
            if (line[0] == BARIER[0])
            {
                line = reader.ReadLine();
                continue;
            }

            for (int i = 0; i < GameProperties.NUMBER_OF_COLORS; i++)
                claps[i] = line[i] != NONE;
            bool hold = line.Length > GameProperties.NUMBER_OF_COLORS && line[GameProperties.NUMBER_OF_COLORS] == HOLD;
            bool release = line.Length > GameProperties.NUMBER_OF_COLORS && line[GameProperties.NUMBER_OF_COLORS] == RELEASE;
            ClapWave wave = new ClapWave(claps, hold, release);
            waveSequence.Add(wave);

            /*
            Debug.Log(line);
            Debug.Log(wave.ToString());
            */
            line = reader.ReadLine();
        } while (line != null);

        waveSequence.GenerateTimeStamps(timePerBeat);
        return waveSequence;
    }
Exemplo n.º 5
0
    public static ClapWaveSequence LoadSequenceFile(string fileName, float timePerBeat)
    {
        ClapWaveSequence waveSequence = new ClapWaveSequence();
        StreamReader reader = null;
        try
        {
          string filePath = Path.Combine(Application.streamingAssetsPath, fileName);
          reader = new StreamReader(filePath, System.Text.Encoding.Default);
        }
        catch (System.Exception e)
        {
          Debug.LogWarning("Cant read \"" + fileName + "\"" + e.StackTrace);
          return null;
        }
        string line = reader.ReadLine();

        do
        {
            bool[] claps = new bool[GameProperties.NUMBER_OF_COLORS];
          if (line[0] == BARIER[0])
          {
        line = reader.ReadLine();
        continue;
          }

          for (int i = 0; i < GameProperties.NUMBER_OF_COLORS; i++)
        claps[i] = line[i] != NONE;
          bool hold = line.Length > GameProperties.NUMBER_OF_COLORS && line[GameProperties.NUMBER_OF_COLORS] == HOLD;
          bool release = line.Length > GameProperties.NUMBER_OF_COLORS && line[GameProperties.NUMBER_OF_COLORS] == RELEASE;
          ClapWave wave = new ClapWave(claps, hold, release);
          waveSequence.Add(wave);

          /*
          Debug.Log(line);
          Debug.Log(wave.ToString());
          */
          line = reader.ReadLine();
        } while (line != null);

        waveSequence.GenerateTimeStamps(timePerBeat);
        return waveSequence;
    }