Exemplo n.º 1
0
        // Update is called once per frame
        void Update()
        {
            if (splashCount >= boardSize * boardSize && !timer.isEndOfLevel)
            {
                timer.FilledText.SetActive(true);
                timer.isEndOfLevel = true;
                timer.EndGame();
            }

            if (gameHasStarted && !timer.isEndOfLevel && (splashCount < boardSize * boardSize))
            {
                int posx;
                int posy;
                do
                {
                    posx = Random.Range(0, boardSize);
                    posy = Random.Range(0, boardSize);
                } while (colorBoard[posx][posy]);

                Debug.Log(colorBoard[posx][posy]);
                if (fbHandler.GetKeysDown(1))
                {
                    Splash(posx, posy, 0);
                }
                else if (fbHandler.GetKeysDown(2))
                {
                    Splash(posx, posy, 1);
                }
                else if (fbHandler.GetKeysDown(3))
                {
                    Splash(posx, posy, 2);
                }
                else if (fbHandler.GetKeysDown(4))
                {
                    Splash(posx, posy, 3);
                }     /* else if (fbInput.GetKeyDown("e")) {
                       * Application.LoadLevel(Application.loadedLevel);
                       * } else if (fbInput.GetKeyDown("f")) {
                       * UnityEditor.EditorApplication.isPlaying = false;
                       * } */

                /*
                 * if (fbInput.GetKeyDown("a")) {
                 *  // Debug.Log("Up Pressed");
                 *  Splash(posx, posy, 0);
                 * } else if (fbInput.GetKeyDown("b")) {
                 *  Splash(posx, posy, 1);
                 * } else if (fbInput.GetKeyDown("c")) {
                 *  Splash(posx, posy, 2);
                 * } else if (fbInput.GetKeyDown("d")) {
                 *  Splash(posx, posy, 3);
                 * } else if (fbInput.GetKeyDown("e")) {
                 *  Application.LoadLevel(Application.loadedLevel);
                 * } else if (fbInput.GetKeyDown("f")) {
                 *  UnityEditor.EditorApplication.isPlaying = false;
                 * } */
            }
        }
Exemplo n.º 2
0
 // Update is called once per frame
 void Update()
 {
     turnDegree = (0.0015f * Mathf.Pow(turnDegreeInput, 2));
     if (active)
     {
         transform.Translate(0, 0, velocity);
         if (!moving)
         {
             if (fb.GetKeysDown(4) && (curLanePos > -1 * maxLanePos))   // Left : Key 4
             {
                 curLanePos--;
                 moving   = true;
                 left     = true;
                 velocity = velocityExp;
                 marker.updateMarker(velocityExp);
                 InvokeRepeating("newTurnLeft", 0, laneChangeSpeed);
             }
             if (fb.GetKeysDown(3) && (curLanePos < maxLanePos))   // Right : Key 3
             {
                 curLanePos++;
                 moving   = true;
                 right    = true;
                 velocity = velocityExp;
                 marker.updateMarker(velocityExp);
                 InvokeRepeating("newTurnRight", 0, laneChangeSpeed);
             }
             if (velocity != 0)
             {
                 if (fb.GetKeysDown(1))   // Up : Key 1
                 {
                     if (velocityExp < maxSpeed)
                     {
                         velocityExp += 0.05f;
                         velocity     = velocityExp;
                         marker.updateMarker(velocityExp);
                     }
                 }
                 if (fb.GetKeysDown(2))   // Down: Key 2
                 {
                     if (velocityExp > minSpeed)
                     {
                         velocityExp -= 0.05f;
                         velocity     = velocityExp;
                         marker.updateMarker(velocityExp);
                     }
                 }
             }
             if (velocity == 0 && fb.GetKeysDown(1))   // Up: Key 1
             {
                 velocity = velocityExp;
                 marker.updateMarker(velocityExp);
             }
         }
     }
 }
Exemplo n.º 3
0
                // Update is called once per frame
                void Update()
                {
                    if (splashCount >= boardSize * boardSize && !timer.isEndOfLevel)
                    {
                        timer.FilledText.SetActive(true);
                        timer.isEndOfLevel = true;
                        timer.EndGame();
                    }

                    if (gameHasStarted && !timer.isEndOfLevel && (splashCount < boardSize * boardSize))
                    {
                        int posx;
                        int posy;
                        // randomly find an unsplashed position
                        do
                        {
                            posx = Random.Range(0, boardSize);
                            posy = Random.Range(0, boardSize);
                        } while (colorBoard[posx][posy]);

                        Debug.Log(colorBoard[posx][posy]);
                        if (Input.GetKeyDown(KeyCode.UpArrow))  //fbHandler.GetKeysDown(1)) {
                        {
                            Debug.Log("Help");
                            Splash(posx, posy, 0);
                        }
                        else if (fbHandler.GetKeysDown(2))
                        {
                            Splash(posx, posy, 1);
                        }
                        else if (fbHandler.GetKeysDown(3))
                        {
                            Splash(posx, posy, 2);
                        }
                        else if (fbHandler.GetKeysDown(4))
                        {
                            Splash(posx, posy, 3);
                        }
                    }
                }
Exemplo n.º 4
0
        // Update is called once per frame
        void Update()
        {
            float f = Random.Range(0f, 1f);

            // Debug.Log("random = " + f);
            if (canSpawn && MoleSpawner.CanSpawn() && f < MoleSpawner.SpawnProb)
            {
                Debug.Log(MoleSpawner.SpawnProb);
                MoleSpawner.MolesUp++;
                StartCoroutine(MoleUp());
            }
            else if (!canSpawn && fb.GetKeysDown(moleID) && !MoleTimer.isEndOfLevel)
            {
                StopAllCoroutines();
                StartCoroutine(Hit());
            }
        }
Exemplo n.º 5
0
 // This reacts to the four color buttons. Attempting to pop a ball
 // if it exists
 void Update()
 {
     if (fb.GetKeysDown(3))
     {
         if (greenBalls.Count != 0)
         {
             //Debug.Log("commanded removal!");
             popAudio.playPop();
             GameObject o = greenBalls[0];
             greenBalls.RemoveAt(0);
             if (playing)
             {
                 score++;
             }
             Destroy(o);
         }
     }
     if (fb.GetKeysDown(2))
     {
         if (blueBalls.Count != 0)
         {
             //Debug.Log("commanded removal!");
             popAudio.playPop();
             GameObject o = blueBalls[0];
             blueBalls.RemoveAt(0);
             if (playing)
             {
                 score++;
             }
             Destroy(o);
         }
     }
     if (fb.GetKeysDown(1))
     {
         if (redBalls.Count != 0)
         {
             //Debug.Log("commanded removal!");
             popAudio.playPop();
             GameObject o = redBalls[0];
             redBalls.RemoveAt(0);
             if (playing)
             {
                 score++;
             }
             Destroy(o);
         }
     }
     if (fb.GetKeysDown(4))
     {
         if (yellowBalls.Count != 0)
         {
             //Debug.Log("commanded removal!");
             popAudio.playPop();
             GameObject o = yellowBalls[0];
             yellowBalls.RemoveAt(0);
             if (playing)
             {
                 score++;
             }
             Destroy(o);
         }
     }
 }
Exemplo n.º 6
0
 // Update is called once per frame
 void Update()
 {
     if (fb.GetKeysDown(1) || fb.GetKeysDown(2) || fb.GetKeysDown(3) || fb.GetKeysDown(4))
     {
         keyPresses += 1;
     }
     if (gameMode == 0)
     {
         float newX;
         float newY;
         if (fb.GetKeysDown(1))
         {
             if (transform.localScale.x < 0)
             {
                 newX = Mathf.Clamp(transform.localScale.x + scaleSpeed, -7f, -.2f);
             }
             else
             {
                 newX = Mathf.Clamp(transform.localScale.x - scaleSpeed, .2f, 7f);
             }
             if (transform.localScale.y < 0)
             {
                 newY = Mathf.Clamp(transform.localScale.y + scaleSpeed, -7f, -.2f);
             }
             else
             {
                 newY = Mathf.Clamp(transform.localScale.y - scaleSpeed, .2f, 7f);
             }
             transform.localScale = new Vector3(newX, newY, 1);
         }
         else if (fb.GetKeysDown(2))
         {
             if (transform.localScale.x < 0)
             {
                 newX = Mathf.Clamp(transform.localScale.x - scaleSpeed, -7f, -.2f);
             }
             else
             {
                 newX = Mathf.Clamp(transform.localScale.x + scaleSpeed, .2f, 7f);
             }
             if (transform.localScale.y < 0)
             {
                 newY = Mathf.Clamp(transform.localScale.y - scaleSpeed, -7f, -.2f);
             }
             else
             {
                 newY = Mathf.Clamp(transform.localScale.y + scaleSpeed, .2f, 7f);
             }
             transform.localScale = new Vector3(newX, newY, 1);
         }
         else if (fb.GetKeysDown(3))
         {
             transform.localScale = new Vector3(transform.localScale.x, -transform.localScale.y, 1);
         }
         else if (fb.GetKeysDown(4))
         {
             transform.localScale = new Vector3(-transform.localScale.x, transform.localScale.y, 1);
         }
     }
     else if (gameMode == 1)
     {
         if (fb.GetKeysDown(1))
         {
             transform.position += Vector3.down;
         }
         else if (fb.GetKeysDown(2))
         {
             transform.position += Vector3.up;
         }
         else if (fb.GetKeysDown(3))
         {
             transform.position += Vector3.right;
         }
         else if (fb.GetKeysDown(4))
         {
             transform.position += Vector3.left;
         }
     }
     else if (gameMode == 2)
     {
         if (fb.GetKeysDown(1))
         {
             spritenum = (spritenum - 1) % 4;
             if (spritenum < 0)
             {
                 spritenum += 4;
             }
             sr.sprite = sprites[spritenum];
             ps.Play();
         }
         else if (fb.GetKeysDown(2))
         {
             spritenum = (spritenum + 1) % 4;
             sr.sprite = sprites[spritenum];
             ps.Play();
         }
         else if (fb.GetKeysDown(3))
         {
             spritenum = (spritenum - 2) % 4;
             if (spritenum < 0)
             {
                 spritenum += 4;
             }
             ps.Play();
             sr.sprite = sprites[spritenum];
         }
         else if (fb.GetKeysDown(4))
         {
             spritenum = (spritenum + 2) % 4;
             sr.sprite = sprites[spritenum];
             ps.Play();
         }
     }
     else if (gameMode == 3)
     {
         if (fb.GetKeysDown(1))
         {
             // set gradients
             // play sounds
             audioSource.clip = sfx[Random.Range(0, sfx.Length)];
             audioSource.Play();
             ps.Play();
         }
         else if (fb.GetKeysDown(2))
         {
             audioSource.clip = sfx[Random.Range(0, sfx.Length)];
             audioSource.Play();
             ps.Play();
         }
         else if (fb.GetKeysDown(3))
         {
             audioSource.clip = sfx[Random.Range(0, sfx.Length)];
             audioSource.Play();
             ps.Play();
             sr.sprite = sprites[spritenum];
         }
         else if (fb.GetKeysDown(4))
         {
             audioSource.clip = sfx[Random.Range(0, sfx.Length)];
             audioSource.Play();
             ps.Play();
         }
     }
 }
Exemplo n.º 7
0
        // Update is called once per frame
        void Update()
        {
            if (startGame)
            {
                // Time Manipulation
                time = Time.time - startTime;
                int minutes = ((int)time / 60);
                int seconds = ((int)time % 60);

                // Handles game timeout
                if (minutes >= minLimit && seconds >= secLimit)
                {
                    startGame = false;
                    endLight.SetActive(true);
                    oriLight.SetActive(false);
                    endLight.GetComponent <Animation>().Play();
                    scoreText.text = "Score: " + points;
                    SaveUtils.SaveTrial();
                }

                // Handles evaluating answers
                if (answerCount == level)
                {
                    if (sameArray(answer, sequence))
                    {
                        Debug.Log(true);
                        correct.Play();

                        if (points + 1 == level)
                        {
                            points += 1;
                            Debug.Log(points);
                        }

                        updateSequence(true);
                        Invoke("glowCubes", (float)1);
                    }
                    else if (level == 1)
                    {
                        Debug.Log(answerCount + " " + level);
                        Debug.Log(false);
                        wrong.Play();
                        answerCount = 0;

                        Invoke("glowCubes", (float)1);
                    }
                    else
                    {
                        Debug.Log(false);
                        wrong.Play();

                        updateSequence(false);
                        Invoke("glowCubes", (float)1);
                    }
                }

                // Handles answer inputs
                if (answerTurn)
                {
                    if (fbHandler.GetKeysDown(2))
                    {
                        answer[answerCount] = 0;
                        answerCount        += 1;
                        glow(blue, 0.1);
                        Debug.Log(sequence.Length + " - " + answer.Length);
                    }
                    else if (fbHandler.GetKeysDown(1))
                    {
                        answer[answerCount] = 1;
                        answerCount        += 1;
                        glow(red, 0.1);
                        Debug.Log(sequence.Length + " - " + answer.Length);
                    }
                    else if (fbHandler.GetKeysDown(4))
                    {
                        answer[answerCount] = 2;
                        answerCount        += 1;
                        glow(yellow, 0.1);
                        Debug.Log(sequence.Length + " - " + answer.Length);
                    }
                    else if (fbHandler.GetKeysDown(3))
                    {
                        answer[answerCount] = 3;
                        answerCount        += 1;
                        glow(green, 0.1);
                        Debug.Log(sequence.Length + " - " + answer.Length);
                    }
                }
            }
        }