示例#1
0
    // Use this for initialization
    void Start()
    {
        refresh  = 0;
        audioS   = transform.GetComponent <AudioSource>();
        rend     = transform.GetComponent <Renderer>();
        TimeLine = transform.parent.parent.GetComponent <OctaveScript>().TimeLine;
        Octave   = transform.parent.parent.GetComponent <OctaveScript>().Octave;

        gameState = GameObject.Find("GameState");
        gs        = gameState.GetComponent <GameState>();
    }
示例#2
0
    public void doAct()
    {
        TimeLineScript TLS = transform.parent.parent.GetComponent <TimeLineScript>();

        if (transform.name.Equals("Rmvbutton"))
        {
            TLS.remove(target);
        }
        if (transform.name.Equals("InsertLeftbutton"))
        {
            TLS.indexToInsert = target.partitionIndex;
        }
        if (transform.name.Equals("InsertRightbutton"))
        {
            TLS.indexToInsert = target.partitionIndex + 1;
        }
        closeMenu();
    }
示例#3
0
    public void DoAction()
    {
        timeLineScript = GameObject.Find("EditMenu").GetComponent <TimeLineScript> ();

        if (gameObject.name.Equals("playSample"))
        {
            if (MFS.Length == 0)
            {
                timeLineScript.Save();
                Instantiate(prefabWin, transform.parent.parent.parent, true);
            }
            else
            {
                if (gs.tutoInc == 7)
                {
                    gs.audioSource.Stop();
                    gs.audioSource.PlayOneShot(gs.audioClip [7]);
                    gs.tutoInc = 8;
                }
                foreach (MusicFileScript mf in MFS)
                {
                    mf.Play();
                }
            }
        }
        if (gameObject.name.Equals("stop"))
        {
            if (gs.tutoInc == 8)
            {
                gs.audioSource.Stop();
                gs.audioSource.PlayOneShot(gs.audioClip [8]);
                gs.tutoInc = 9;
            }
            foreach (MusicFileScript mf in MFS)
            {
                mf.StopAllCoroutines();
            }
            timeLineScript.StopAllCoroutines();
        }
        if (gameObject.name.Equals("reset"))
        {
            if (gs.tutoInc == 9)
            {
                gs.audioSource.Stop();
                gs.audioSource.PlayOneShot(gs.audioClip [9]);
                gs.tutoInc = 10;
            }
            timeLineScript.Reset();
        }

        if (gameObject.name.Equals("rest"))
        {
            timeLineScript.AddRest();
        }

        if (gameObject.name.Equals("play"))
        {
            if (gs.tutoInc == 6)
            {
                gs.audioSource.Stop();
                gs.audioSource.PlayOneShot(gs.audioClip [6]);
                gs.tutoInc = 7;
            }

            timeLineScript.Play();
            if (MFS.Length != 0)
            {
                List <int> results      = MFS[0].MatchingLine(timeLineScript.partition);
                int        maxPartition = timeLineScript.partition.Count;
                for (int index = 0; index < maxPartition; index++)
                {
                    timeLineScript.setCorrection(timeLineScript.partition[index], results[index]);
                }
                if (MFS [0].MatchingPercentage(MFS [0].MatchingLine(timeLineScript.partition)) >= gs.neededPercentage)
                {
                    if (gs.tutoInc == 11)
                    {
                        gs.audioSource.Stop();
                        gs.audioSource.PlayOneShot(gs.audioClip [11]);
                        gs.tutoInc = 12;
                    }
                    Instantiate(prefabWin, transform.parent.parent.parent, true);
                    Debug.Log("Level Complete !");
                }
                else
                {
                    Debug.Log("Your composition does not match yet");
                }
            }
        }

        if (gameObject.name.Contains("WinObject"))
        {
            if (gs.tutoInc == 12)
            {
                gs.audioSource.Stop();
                gs.audioSource.PlayOneShot(gs.audioClip [12]);
                gs.tutoInc = 13;
            }
            gs.waitForSceneLoad = true;
            SceneManager.LoadScene(0);
        }
    }