void OnTriggerEnter(Collider other)
    {
        if (other.CompareTag("TriggerStick"))
        {
            int wheel_number = other.GetComponent <TriggerStickController> ().wheel_number;
            // Generate Sound
            if (sync)
            {
                chuck.SetInt("sndIdx", wheel_number);
                chuck.SetInt("noiseIdx", other.GetComponent <TriggerStickController> ().color_index);
                chuck.SetFloat("bpm", GlobalVariables.bpm);
                chuck.BroadcastEvent("touchHappened");
                GlobalVariables.counter = wheel_number;
            }
            // Make cupcake
            int index = other.GetComponent <Collider>().GetComponent <TriggerStickController> ().color_index;
            if (index > 0 && !GlobalVariables.warmingUp())
            {
                tubes [wheel_number].GetComponent <EmitterTubeController>().emitCake(index);
//				GameObject cupcake = (GameObject)Instantiate (Resources.Load ("Muffin"));
//				cupcake.transform.position = gen_cake_pos[t_count];
//				cupcake.transform.localScale = new Vector3 (size, size, size);
//				cupcake.SetActive (true);
            }
            if (sync && wheel_number == tubes.Count - 1)
            {
                GlobalVariables.round++;
            }
        }
    }
Beispiel #2
0
    //Change the amount of Red (punishment) on ticker
    public void updateStaticBar(int level)
    {
        if (level >= ticker.transform.childCount)
        {
            level = ticker.transform.childCount;
        }
        for (int i = 0; i < level; i++)
        {
            ticker.transform.GetChild(i).gameObject.SetActive(true);
        }

        for (int i = level; i < ticker.transform.childCount; i++)
        {
            ticker.transform.GetChild(i).gameObject.SetActive(false);
        }

        myChuck.SetFloat("staticGain", (float)level / (float)250);
        myChuck.BroadcastEvent("staticLevelUpdated");
    }
 void OnCollisionEnter(Collision other)
 {
     if (other.collider.CompareTag("Cupcake"))
     {
         CupcakeController cc = other.collider.GetComponent <CupcakeController> ();
         if (!cc.touchdown)
         {
             cc.touchdown = true;
             float size = cc.transform.localScale.x;
             chuck.SetFloat("freqIntensity", size);
             chuck.BroadcastEvent("touchdownHappened");
         }
     }
 }
Beispiel #4
0
    // Update is called once per frame
    void Update()
    {
        // Sounds
        if (GlobalVariables.counter == eater_number)
        {
            if (!played && cache.Count > 0)
            {
                // Generate Sound
                Vector4 v = cache[0];
                current_index = (int)v.x;
                int s_type = (int)v.y;
                int octave = (int)v.z;
                int effect = (int)v.w;
                cache.RemoveAt(0);
                chuck.SetInt("midi", GlobalVariables.midi_list[current_index] + octave * 12);
                chuck.SetInt("type", s_type);
                chuck.SetInt("effect", effect);
                chuck.SetFloat("bpm", GlobalVariables.bpm);
                chuck.BroadcastEvent("genSound");

                played = true;
            }
            if (current_index > 0 && current_index < GlobalVariables.color_list.Count)
            {
                change_color(GlobalVariables.color_list[current_index]);
            }
//			distance * GlobalVariables.bpm / 30;
        }
        else
        {
            played = false;
        }

        // Mouth
//		if (mouth_stat != 0) {
//			mouth.transform.Rotate (0.0f, mouth_stat * mouth_speed * Time.deltaTime, 0.0f);
//			print (mouth.transform.rotation.y);
//			if (mouth.transform.rotation.y >= mouth_ro) {
//				mouth_stat = -1;
//				mouth.transform.Rotate (0.0f, mouth_stat * mouth_speed * Time.deltaTime, 0.0f);
//			} else if (mouth.transform.rotation.y <= 0.0f) {
//				mouth_stat = 0;
//				mouth.transform.rotation = new Quaternion (0.0f, 0.0f, 0.0f, 0.0f);
//			}
//		}
    }
Beispiel #5
0
    void OnTriggerEnter(Collider col)
    {
        if (col.tag == "Detector")
        {
            Vector2 hitPos    = new Vector2(col.transform.position [0], col.transform.position [1]);
            Vector2 barPos    = new Vector2(transform.position [0], transform.position [1]);
            int     direction = hitPos [1] > barPos [1] ? 1 : -1;
            float   distance  = Vector2.Distance(hitPos, barPos);
            float   scale     = (direction * distance + transform.localScale [1] / 2) / transform.localScale [1];

            gameObject.GetComponent <Renderer>().material.color = Color.white;

            /*
             * int freqIndex = (int) (scale * 8);
             * if (freqIndex == 8)
             *      freqIndex--;
             */
            GetComponent <ParticleSystem> ().Play();
            ci.SetFloat("scale", scale);
            ci.BroadcastEvent("hitEvent");
        }
    }
    //RUN EVERY FRAME
    void Update()
    {
        //UPDATE SCREEN EACH ROUND
        if (!updatedRound)
        {
            step1Script.stepInstructions = oneD(currRound, playerNumber);
            Debug.Log("step 1 instruction set" + step1Script.stepInstructions[0]);
            step1Script.newRound = true;
            updatedRound         = true;
        }

        //START TICKER
        if (step1Script.startTheTicker && !tickerStarted)
        {
            myChuck.BroadcastEvent("startTicker");
            tickerStarted = true;
        }

        //YOU LOSE
        if (staticLevel == 3)
        {
            stopBassline();
            offChord();
        }

        myChuck.GetFloat("pos", myGetPosCallback);
        myChuck.GetFloat("count", myGetBeatCallback);


        //TRIGGER NEW LEVEL ANIMATION
        if (specialWords [currRound, playerNumber, 3] == "LEVEL")
        {
            if (!leftLevelScript.doneAnimation && !rightLevelScript.doneAnimation)
            {
                leftLevelScript.startAnimation  = true;
                rightLevelScript.startAnimation = true;
            }
            else
            {
                //up the key of the music
                if (currRound > 10)
                {
                    currKey++;
                    setKey(currKey);
                    currStepInLevel = 1;
                }

                //up the speed not on the first time
                if (currRound > 10)
                {
                    offChord();
                    timestep--;
                    myChuck.SetInt("timeStep", timestep);
                    setLength(timestep * 1000.0f);
                }

                //RESET ALL VARIABLES TO INITIAL POSITION
                leftLevelScript.doneAnimation   = false;
                rightLevelScript.doneAnimation  = false;
                leftLevelScript.startAnimation  = false;
                rightLevelScript.startAnimation = false;
                leftLevelScript.closeDone       = false;
                rightLevelScript.closeDone      = false;
                leftLevelScript.openDone        = false;
                rightLevelScript.openDone       = false;

                currRound++;
                updatedRound = false;
                Debug.Log("done with level animation");
                levelAnimationDone = true;                                              //weird bool to make level after the animation not skip
                previousPos        = myPos - 1;
            }
        }
        else if (specialWords [currRound, playerNumber, 3] == "SETUP")
        {
            setupScreen.SetActive(true);
            if (setupScreen.GetComponent <SetupController> ().setupDone)
            {
                currRound++;
                updatedRound = false;
                Debug.Log("done with setup");
                setupScreen.SetActive(false);
                setupDone = true;                                               //weird bool to make level after the animation not skip
            }
        }
        else
        {
            //USER IS DONE WITH STEP BEFORE END OF TRIGGER
            if (myPos >= previousPos && step1Script.bottomDone == true && step1Script.topDone == true && (!alreadyCorrect || step1Script.goToNextStep))
            {
                Debug.Log("alreadyCorrect: " + alreadyCorrect + " goToNextStep: " + step1Script.goToNextStep);
                //REWARD BY DECREASING STATIC
                if (staticLevel > 0)
                {
                    staticLevel--;
                }
                step1Script.updateStaticBar(staticLevel);
                alreadyCorrect = true;

                //immediacy (brings to end of round)
                if (step1Script.goToNextStep)                   //BUG: remove hacky currRound Check
                {
                    Debug.Log("go to next round");
                    previousPos = myPos - 1;
                    step1Script.goToNextStep = false;
                    gotCorrect = true;
                }
            }

            //IF ticker gets to end of screen
            if (myPos >= previousPos + 1.0f)
            {
                alreadyCorrect = false;

                //turn off intro music
                if (currRound == 3)
                {
                    if (playerNumber == 0)
                    {
                        myChuck.BroadcastEvent("endIntroMusic");
                    }
                }

                resetBassline();
                Debug.Log("currRound in Main: " + currRound);

                //user got it wrong
                if (step1Script.bottomDone != true || step1Script.topDone != true && staticLevel < 3 || !gotCorrect)
                {
                    if (currRound >= 10)
                    {
                        myChuck.BroadcastEvent("keyFailTrigger");
                        staticLevel++;
                    }
                }
                step1Script.updateStaticBar(staticLevel);

                previousPos = previousPos + 1.0f;

                //move on to next round
                if (currRound < specialWords.GetLength(0) && !levelAnimationDone && !setupDone)
                {
                    currRound++;
                    int currLevelText = (currRound - 2) / 5;
                    if (currRound == 6)
                    {
                        levelMesh.text = "SURPRISE";
                    }
                    else
                    {
                        levelMesh.text = "Level " + currLevelText.ToString();
                    }
                    updatedRound = false;
                    playSelectChord();
                }
                levelAnimationDone = false;
                setupDone          = false;
                Debug.Log("Current Round: " + currRound);

                if (currRound == 7)
                {
                    startBassline();
                }
                gotCorrect = false;
            }
            float distanceMultiplier = 1.5f;
            step1Script.linePos = (myPos - previousPos) * distanceMultiplier;

            // Background updates when instructions are complete
            if (step1Script.bottomDone == true && step1Script.topDone == true)
            {
                mainBackground.GetComponent <Renderer> ().material.color = correctColor;
            }
            else
            {
                //flash screen red if incorrect at end!
                if (myPos >= previousPos + 0.96f)
                {
                    if (step1Script.bottomDone != true || step1Script.topDone != true)
                    {
                        mainBackground.GetComponent <Renderer> ().material.color = failBackgroundColor;
                    }
                }
                else
                {
                    //mainBackground.GetComponent<Renderer> ().material.color = normalBackgroundColor;
                }
            }
        }
    }