Example #1
0
 public void SpawnFirstFruits()
 {
     for (int i = 0; i < StartingGoodFruits; ++i)
     {
         GoodFruitSpawner.SpawnFruit();
     }
 }
Example #2
0
    // Update is called once per frame
    void Update()
    {
        if (curGameState == GameState.PRE_GAME)
        {
            countdown = countdown - Time.deltaTime;
            feedbackCanvas.UpdateCountdownText(countdown);

            Vector2 currentCoP = CoPtoCM(Wii.GetCenterOfBalance(0));
            basket.GetComponent <Basket>().UpdatePosition(currentCoP);

            // Start game when countdown hits zero
            if (countdown < 0)
            {
                curGameState = GameState.GAME;
                fruitSpawner.SpawnFruit();
                trialTime = 0;
            }
        }
        else if (curGameState == GameState.GAME)
        {
            // Update canvas for the user to see score and time remaining
            timeRemaining = timeRemaining - Time.deltaTime;
            feedbackCanvas.UpdateTimeText(timeRemaining);
            feedbackCanvas.UpdateScoreText(score);

            // Update COP and move basket
            Vector2 currentCoP = CoPtoCM(Wii.GetCenterOfBalance(0));
            basket.GetComponent <Basket>().UpdatePosition(currentCoP);

            CheckBasketObstacle();

            // tick up trial time and check if a new fruit should be spawned
            trialTime = trialTime + Time.deltaTime;
            if (trialTime > trialLength)
            {
                GetComponent <SoundEffectPlayer>().PlaySpawnSound();
                fruitSpawner.SpawnFruit();
                trialTime = 0f;
            }

            if (timeRemaining < 0f)
            {
                curGameState = GameState.GAME_OVER;
                feedbackCanvas.DisplayGameOverText();
            }

            GetComponent <DataHandler>().recordContinuous(Time.time, currentCoP);
        }
        else
        {
            // Game is over
            if (Input.GetKeyUp(KeyCode.Space))
            {
                SceneManager.LoadScene("Menu");
            }
        }
    }
Example #3
0
    private void Update()
    {
        m_BadFruitTimer += Time.deltaTime;
        if (m_BadFruitTimer >= SpawnBadFruitTimer)
        {
            m_DelayBadFruitSpawn = BadFruitSpawner.GetAlive() >= MaxBadFruitsInScene;

            if (!m_DelayBadFruitSpawn)
            {
                SpawnBadFruit();
            }
        }

        if (m_DelayBadFruitSpawn && BadFruitSpawner.GetAlive() < MaxBadFruitsInScene)
        {
            BadFruitSpawner.SpawnFruit();
        }
    }