Exemplo n.º 1
0
    public void BuildBar()
    {
        Tools.Note nextNote = NextNote();
        Dictionary <string, float> barToUse = nextNote.clef == lastClef ? BarLayouts.noClef : BarLayouts.clefAfterBarline;

        lastClef = nextNote.clef;
        float barWidth = BarLayouts.beatSpacing * BarLayouts.beatsPerBar;

        foreach (KeyValuePair <string, float> value in barToUse)
        {
            if (value.Key == "BarLine")
            {
                GameObject barLine = Instantiate(barLinePrefab, transform.position + new Vector3(startX + (barWidth * value.Value), 0, 0), Quaternion.identity);
                barLine.transform.parent     = transform;
                barLine.transform.localScale = new Vector3(Tools.lineWidth, Tools.lineGap * 4, 0.2f);
            }
            if (value.Key == "Note")
            {
                GameObject note = Instantiate(notePrefab, transform.position + new Vector3(startX + (barWidth * value.Value), 0, 0), Quaternion.identity);
                note.transform.parent = transform;
                NoteScript noteScript = note.GetComponent <NoteScript>();
                string     acc        = "";
                if (nextNote.sharp == true)
                {
                    acc = "sharp";
                }
                if (nextNote.flat == true)
                {
                    acc = "flat";
                }
                noteScript.NoteStartup(nextNote.position, acc);
            }
            if (value.Key == "Clef")
            {
                lastClef = nextNote.clef;
                GameObject clef = Instantiate(clefPrefab, transform.position + new Vector3(startX + (barWidth * value.Value), 0, 0), Quaternion.identity);
                clef.transform.parent = transform;
                ClefScript clefScript = clef.GetComponent <ClefScript>();
                clefScript.ShowClef(nextNote.clef);
            }
            if (value.Key == "CRest")
            {
                GameObject crotchetRest = Instantiate(crotchetRestPrefab, transform.position + new Vector3(startX + (barWidth * value.Value), 0, 0), Quaternion.identity);
                crotchetRest.transform.parent = transform;
            }
            if (value.Key == "MRest")
            {
                GameObject minimRest = Instantiate(minimRestPrefab, transform.position + new Vector3(startX + (barWidth * value.Value), 0, 0.5f), Quaternion.identity);
                minimRest.transform.parent = transform;
            }
        }
    }
Exemplo n.º 2
0
    private IEnumerator StartingUp()
    {
        yield return(null);

        staff.GetComponent <StaffScript>().ShowClef(nextNote.clef);
        yield return(new WaitForSeconds(1));        //to allow staffScript to wake up!

        staff.GetComponent <StaffScript>().ShowNote(nextNote.position, nextNote.sharp, nextNote.flat, nextNote.clef);
        StartCoroutine(noteController.Fade(noteMaterial, clefMaterial, noteDelay, false, colourController.getItem()));
        yield return(new WaitForSeconds(1));

        nextNoteTime     = Time.time + noteDelay;
        currentBeat      = 1;
        countInText.text = currentBeat.ToString();
        flashController.StartFlash(2);
        while (currentBeat <= 4)
        {
            if (isPaused)
            {
                nextNoteTime += Time.deltaTime;
            }
            if (NextBeat())
            {
                currentBeat++;

                if (currentBeat <= 4)
                {
                    countInText.text = currentBeat.ToString();
                    flashController.StartFlash(currentBeat);
                }
            }

            yield return(null);
        }
        currentBeat      = 1;
        startup          = false;
        countInText.text = "Go!";
        lastNote         = nextNote;
        nextNote         = NextNote();
        flashController.StartFlash(currentBeat);
        StartCoroutine(noteController.Fade(noteMaterial, clefMaterial, noteDelay, nextNote.clef != lastNote.clef, colourController.getBG()));
        yield return(new WaitForSeconds(2));

        countInText.text = "";
        if (timeLeft <= 600f)
        {
            displayTimer = true;
        }
    }
Exemplo n.º 3
0
    public Tools.Note GetNextNote(int num, int dif)
    {
        Tools.Note n            = new Tools.Note();
        int        noteInOctave = GetNoteInOctave(num);
        int        octave       = GetOctave(num);

        Tools.SemitoneInfo semiInfo = semitoneStore.getSemitone(noteInOctave, dif);
        int    posToMidC            = semiInfo.position + (octave * 7);
        string clef            = GetClef(posToMidC);
        int    positionOnStave = Tools.clefMidCPos[clef] + posToMidC;

        n.clef     = clef;
        n.flat     = (semiInfo.accidental == "flat");
        n.sharp    = (semiInfo.accidental == "sharp");
        n.position = positionOnStave;
        return(n);
    }
Exemplo n.º 4
0
 private void Awake()       // sort out the colour stuff?
 {
     timeLeft                   = globalData.duration > 60 ? 1000000 : globalData.duration * 10;
     noteDelay                  = 60f / (float)globalData.bPM;
     lastNote                   = NextNote();
     nextNote                   = NextNote();
     staffMaterial.color        = colourController.getItem();
     clefMaterial.color         = colourController.getItem(); //fading alpha doesnt work?
     noteMaterial.color         = colourController.getBG();
     mainCamera.backgroundColor = colourController.getBG();
     counter.color              = colourController.getItem();
     counter.text               = "";
     buttonText.color           = colourController.getItem();
     countInText.color          = colourController.getItem();
     countInText.text           = "";
     flash.GetComponent <Renderer>().material.color = colourController.getItem();
     StartCoroutine(colourController.SceneChange(""));
     startup  = true;
     finished = false;
     StartCoroutine(StartingUp());
 }
Exemplo n.º 5
0
 void Update()
 {
     if (!isPaused && !startup)
     {
         ShowTimer();
         if (NextBeat())
         {
             currentBeat++;
             if (currentBeat > 4)
             {
                 currentBeat = 1;
             }
             flashController.StartFlash(currentBeat);
             if (currentBeat == 2)
             {
                 staff.GetComponent <StaffScript>().ShowNote(nextNote.position, nextNote.sharp, nextNote.flat, nextNote.clef);
                 StartCoroutine(noteController.Fade(noteMaterial, clefMaterial, noteDelay, nextNote.clef != lastNote.clef, colourController.getItem()));
             }
             else if (currentBeat == 1)
             {
                 lastNote = nextNote;
                 nextNote = NextNote();
                 if (!finished)
                 {
                     StartCoroutine(noteController.Fade(noteMaterial, clefMaterial, noteDelay, nextNote.clef != lastNote.clef, colourController.getBG()));
                 }
             }
             if (currentBeat == 1 && finished)
             {
                 counter.text  = "Finished";
                 counter.color = colourController.getItem();
                 isPaused      = true;
             }
         }
     }
 }