コード例 #1
0
 public void PlayPhrase(SongPhrase phrase)
 {
     //Debug.Log($"play out of control phrase: {phrase.VolumeAmp}, {phrase.PitchShift}");
     audioMixer.SetFloat(volumeMixerParam, phrase.VolumeAmp);
     audioMixer.SetFloat(pitchMixerParam, phrase.PitchShift);
     sanityChecker.DropSanity(Mathf.Abs(phrase.VolumeAmp) + Mathf.Abs(phrase.PitchShift - 1.0f));
 }
コード例 #2
0
ファイル: NoteBar.cs プロジェクト: rainnymig/Project303
 public void Init(SongPhrase p, SongPlayer sp, SingerController sc, Color barColor)
 {
     phrase                  = p;
     singPos                 = new Vector3(SingPosX, (phrase.MidiNote - CENTER_MIDI_NOTE) * 0.1f, -1);
     boardcastPos            = new Vector3(BoardcastPosX, (phrase.MidiNote - CENTER_MIDI_NOTE) * 0.1f, -1);
     transform.localPosition = singPos;
     transform.localScale    = new Vector3(phrase.Duration - 0.2f, 2, 1);
     songPlayer              = sp;
     singerController        = sc;
     spriteRenderer          = GetComponent <SpriteRenderer>();
     spriteRenderer.color    = barColor;
     initialized             = true;
 }
コード例 #3
0
    private void LateUpdate()
    {
        if (songPlayer.IsPlaying)
        {
            if (!audioPlayer.isPlaying)
            {
                audioPlayer.Play();
                audioPlayer.time = songPlayer.PositionInSongInMillis / 1000.0f;
            }

            if (songPlayer.HasNewPhrase)
            {
                GameObject obj = Instantiate(noteBarPrefab, transform);
                NoteBar    nb  = obj.GetComponent <NoteBar>();
                nb.Init(songPlayer.NewPhrase, songPlayer, this, referenceBarColor);

                obj = Instantiate(singBarPrefab, transform);
                SingBar    sb         = obj.GetComponent <SingBar>();
                SongPhrase singPhrase = new SongPhrase {
                    StartBeat = songPlayer.NewPhrase.StartBeat,
                    Duration  = songPlayer.NewPhrase.Duration,
                    MidiNote  = songPlayer.NewPhrase.MidiNote
                };

                if (RollOutOfControlDice())
                {
                    //Debug.Log($"Out of control! {PhraseIdx}");
                    singPhrase.PitchShift = getRandomPitchShift();
                    singPhrase.VolumeAmp  = getRandomVolumeAmp();
                }
                else
                {
                    //Debug.Log($"In control. {PhraseIdx}");
                    singPhrase.PitchShift = 1.0f;
                    singPhrase.VolumeAmp  = 0.0f;
                }
                sb.Init(singPhrase, songPlayer, this, singerBarColor);
                singBars.Add(sb);
                if (!tuner.IsInitialized)
                {
                    tuner.CurrentSingBar = sb;
                }
            }
        }
    }
コード例 #4
0
ファイル: SongPlayer.cs プロジェクト: rainnymig/Project303
    private void loadSong(string songName)
    {
        TextAsset songText = Resources.Load <TextAsset>($"SongText/{songName}");

        string[] lines = songText.text.Split(new string[] { "\r\n", "\n" }, System.StringSplitOptions.RemoveEmptyEntries);

        SongPhrases = new SongPhrase[lines.Length - 1];
        for (int idx = 0; idx < lines.Length; idx++)
        {
            if (lines[idx].StartsWith("#BPM"))
            {
                BPM = float.Parse(lines[idx].Split(':')[1]);
            }
            else
            {
                string[]   words = lines[idx].Split(',');
                SongPhrase p     = new SongPhrase {
                    StartBeat = int.Parse(words[0]), Duration = int.Parse(words[1]), MidiNote = int.Parse(words[2])
                };
                SongPhrases[idx - 1] = p;
            }
        }
    }
コード例 #5
0
ファイル: SongPlayer.cs プロジェクト: rainnymig/Project303
 private void Update()
 {
     if (IsPlaying)
     {
         float beat = CurrentBeat;
         if (PhraseIdx < SongPhrases.Length && beat > SongPhrases[PhraseIdx].StartBeat - NoteBar.NoteTravelBeats)
         {
             HasNewPhrase = true;
             NewPhrase    = SongPhrases[PhraseIdx];
             PhraseIdx++;
         }
         else
         {
             HasNewPhrase = false;
         }
     }
     else
     {
         if (songStarted)
         {
             GameOver();
         }
     }
 }