Пример #1
0
    private bool IsValidOnsetForFrame(int frameIndex)
    {
        bool lowOnset  = (low.GetOnset(frameIndex) > 0);
        bool beatOnset = (rhythmTool.IsBeat(frameIndex) == 1);

        return(lowOnset || beatOnset);
    }
Пример #2
0
    // Update is called once per frame
    void Update()
    {
        for (int i = lastFrame + 1; i < rhythmTool.CurrentFrame + 1; i++)
        {
            int nextBeat = rhythmTool.NextBeatIndex();

            if (rhythmTool.CurrentFrame > nextBeat && rhythmTool.CurrentFrame > rhythmTool.TotalFrames / 2 && !end)          //if we're on the last beat (that's looked at), prepare to finish
            {
                GameObject.Find("success").GetComponent <TextMesh> ().text = "";
                GameObject.Find("misses").GetComponent <TextMesh> ().text  = "";
                GameObject.Find("errors").GetComponent <TextMesh> ().text  = "";

                GameObject.Find("labels").GetComponent <TextMesh>().text = "finish!\nplease\nwait...";
                end = true;
            }
            if (rhythmTool.IsBeat(i, 0) == 1 || end)            //if we're on a beat, head thorugh the process
            {
                if (beats % (StartVar.difficultylevel) == 0)    // if we're on a beat on which something happens (aka every other beat), make that something happen.


                //chance of bomb (1/5)
                {
                    int isBomb = Random.Range(0, 5);


                    //randomly choose the ID of which ball will spawn
                    int pickBall = Random.Range(0, 31);                      //gives every ball a 1/3 chance
                    pickBall = pickBall % (3);

                    //add oldest ID to reserve, add newest ID in it's place
                    missReserve[steps % (backAmount - 1)] = nbacktrack[steps % (backAmount + 1)];
                    nbacktrack[steps % (backAmount + 1)]  = pickBall + 1;

                    if (isBomb == 3)                    //if we're spawning a bomb,
                    {
                        pickBall += 3;                  //add to the pickball to shift the index over to the bombs

                        //randomly choose which spawner creates the ball (50/50) chance
                        int pickSpawner = Random.Range(0, 101);
                        pickSpawner = pickSpawner % 2;

                        //spawn selected ball from selected spawner, play sound of which one was selected
                        if (!end)
                        {
                            spawners[pickSpawner].doIt(pickBall);
                            indicators[pickSpawner].Play();
                        }

                        //swap the circle colors here:

                        //code to set up and call shift
                        //if(backAmount==2)
                        //{
                        //	int S = nbacktrack[(steps)%3];
                        //	int A = nbacktrack[(steps+1)%3];
                        //	int B = nbacktrack[(steps+2)%3];
                        //	GameObject.Find("CircleController").GetComponent<ChangeColor>().shift(S, A, B);
                        //}

                        //

                        steps++;                    //add to steps

                        //some debug to print out the current signal chart (what's current and what's reserved)
                        string printOut = "(";

                        for (int j = 0; j < (backAmount + 1); j++)
                        {
                            printOut += nbacktrack[j] + ", ";
                        }
                        printOut += ")(";

                        for (int k = 0; k < (backAmount - 1); k++)
                        {
                            printOut += missReserve[k] + ", ";
                        }
                        printOut += ")";

                        print(printOut);


                        //spawn a new belt piece
                        foreach (spawn S in beltSpawners)
                        {
                            S.doIt(0);
                            if (end)
                            {
                                S.active = false;
                            }
                        }

                        //get each mover to pass their object

                        foreach (pass P in movers)
                        {
                            P.doIt();
                            if (end)
                            {
                                P.active = false;
                            }
                        }
                    }
                    beats++;
                }

                lastFrame = i;
            }
            if (mis + err >= 20)    //if our misses and errors total 20, force end the game
            {
                print("Stopping forcefully!!");
            }
            rhythmTool.Stop();
            GameObject.Find("success").GetComponent <TextMesh> ().text = "";
            GameObject.Find("misses").GetComponent <TextMesh> ().text  = "";
            GameObject.Find("errors").GetComponent <TextMesh> ().text  = "";

            GameObject.Find("labels").GetComponent <TextMesh>().text = "finish!\nplease\nwait...";
            end = true;

            GameObject[] remaining;                                             //find and delete all remaining objects
            remaining = GameObject.FindGameObjectsWithTag("ball");
            foreach (GameObject A in remaining)
            {
                Destroy(A);
            }
            remaining = GameObject.FindGameObjectsWithTag("bomb");
            foreach (GameObject A in remaining)
            {
                Destroy(A);
            }

            foreach (spawn S in beltSpawners)                   //have the belts continue to move
            {
                S.doIt(0);
                if (end)
                {
                    S.active = false;
                }
            }
            foreach (pass P in movers)
            {
                P.doIt();
                if (end)
                {
                    P.active = false;
                }
            }

            forcestop = true;
            OnEndOfSong();
        }
    }