Exemplo n.º 1
0
    private IEnumerator PlaySong(int id)
    {
        if (songStart != null)
        {
            songStart(id);
        }
        currentlyPlaying     = true;
        currentlyPlayingSong = id;
        sMelody currentMelodie = this.melodies[id];

        if (currentMelodie.speed <= 0)
        {
            instance.melodies[id].speed = 1;
        }

        for (int i = 0; i < currentMelodie.melody.Length; i++)
        {
            sSimpleNote note = currentMelodie.melody[i];
            sSimpleTone tone = gamut.Get(note.tone);

            if (tone != null)
            {
                PlayTone(tone, note.volume * currentMelodie.volume, note.pitch * currentMelodie.pitch);
                if (singleNote != null)
                {
                    singleNote(note);
                }
                if (MovementScript.ghostWorldActive && mySymbol)
                {
                    mySymbol.ShowSymbol(tone.symbol);
                }
            }

            yield return(new WaitForSeconds(note.timeUntilNext / currentMelodie.speed));
        }
        if (mySymbol)
        {
            mySymbol.HideSymbol();
        }
        //Debug.Log("Song ended");
        if (songEnded != null)
        {
            songEnded(id);
        }
        currentlyPlaying = false;
        NextSong();
    }
Exemplo n.º 2
0
    /// <summary>
    /// button was pressed and triggered reaction
    /// </summary>
    protected override void AfterReaction()
    {
        sMelody song = pipeOrgan.melodies[melodyID];

        if (song.speed <= 0)
        {
            song.speed = 1;
        }
        float melodyDuration = 0;

        for (int i = 0; i < song.melody.Length; i++)
        {
            melodyDuration += song.melody[i].timeUntilNext / song.speed;
        }
        nextDeafDuration = (melodyDuration > minDontReactSeconds)
                            ? melodyDuration : minDontReactSeconds;
        base.AfterReaction();
    }
Exemplo n.º 3
0
    IEnumerator DontListen()
    {
        busy = true;
        sMelody song = myOrgan.melodies[seekedMelody];

        if (song.speed <= 0)
        {
            song.speed = 1;
        }
        float duration = 0;

        for (int i = 0; i < song.melody.Length; i++)
        {
            duration += song.melody[i].timeUntilNext / song.speed;
        }
        yield return(new WaitForSeconds(duration));

        busy = false;
        Debug.Log("Listening again.");
        if (readyAgain != null)
        {
            readyAgain();
        }
    }