public void openInGameMenu()
    {
        if (dialogBackStack.Count == 0)
        {
            dialogBackStack.Push(inGameMenuDialog);
            inGameMenuDialog.SetActive(true);

            //disable ui
            foreach (GameObject go in uiDisable)
            {
                go.SetActive(false);
            }

            //makes the go321 countdown move to background
            go321SpriteRenderer.sortingOrder = -1;

            yourScoreText.text = "Your Score: " + ScoreAndSpeedScript.getScore();

            //pause game
            Time.timeScale = 0;
        }
        else
        {
            closeInGameMenu();
        }
    }
    public void openEndGameMenu()
    {
        int highScore;

        //disable ui
        foreach (GameObject go in uiDisable)
        {
            go.SetActive(false);
        }

        //check if score is high score
        highScore = HighScoreLoaderSaver.current.loadHighScore();
        if (highScore < ScoreAndSpeedScript.getScore())
        {
            HighScoreLoaderSaver.current.saveHighScore();
            highScore = ScoreAndSpeedScript.getScore();              //ste highscore to new score
        }
        endGameHighScoreText.text = "High Score: " + highScore;
        endGameYourScoreText.text = "Your Score: " + ScoreAndSpeedScript.getScore();

        endGameMenuDialog.SetActive(true);

        //set menu button to false
        menuButtonDisable.SetActive(false);

        //set bobby to false, do not pause game
        bobby.SetActive(false);
    }
Пример #3
0
    void Update()
    {
        if (ScoreAndSpeedScript.getScore() >= codeSpawnTime && !timerStart)
        {
            //new codeSpawnTime will be set when in clearCodeContainer
            //start timer for code
            timerStart = true;

            //spawn code in space
            for (int i = 0; i < codeLength; i++)
            {
                int buttonCode = Random.Range(7, 13);                  //7-13 corrseponds to the poolNumbers in ObjectPoolingScript

                GameObject code = ObjectPoolerScript.current.GetPooledObject(buttonCode);
                codeContainer.Add(code);

                code.transform.position = codeSpawnPosition[i];
                code.SetActive(true);
            }

            codeCountdown.SetActive(true);

            StartCoroutine("failedToPass");
            //can only stop coroutines called with a string, so im calling it with a string instead.
        }
    }
    public void lockUnlock()
    {
        //swap between lock and unlcok sprite images

        if (!locked)
        {
            text.text    = "UNLOCK";
            image.sprite = unlockButton;
            locked       = true;
        }
        else
        {
            locked       = false;
            text.text    = "LOCK";
            image.sprite = lockButton;


            //submit the code by unlocking
            if (CodeSpawner.currentCodeSpawner.getCurrentCode() == CodeSpawner.currentCodeSpawner.getCodeLength())
            {
                CodeSpawner.currentCodeSpawner.clearCodeContainer();
                CodeSpawner.currentCodeSpawner.stopFailedToPass();
                //give him health
                BobbyHealth.current.setHealth(BobbyHealth.current.getHealth() + 1);
                //give him 100 points
                CodeSpawner.currentCodeSpawner.setTimerStart(true);                 //set timer to true to prevent the default codeSpawn from triggering from adding 100 points
                ScoreAndSpeedScript.addPointsToScore(100);
                CodeSpawner.currentCodeSpawner.resetCodeSpawnTime();                //set a new timer relative to the newly added 100 points
                CodeSpawner.currentCodeSpawner.setTimerStart(false);
                //slow down highway nightsky cars
            }
        }
    }
Пример #5
0
    public void saveHighScore()
    {
        BinaryFormatter bf   = new BinaryFormatter();
        FileStream      file = File.Create(Application.persistentDataPath + "/playerHighScore.dat");
        PlayerData      data = new PlayerData();

        data.highScore = ScoreAndSpeedScript.getScore();          //reads score in playerData

        bf.Serialize(file, data);
        file.Close();
    }
Пример #6
0
    public void clearCodeContainer()
    {
        foreach (GameObject code in codeContainer)
        {
            code.SetActive(false);
        }
        codeContainer.Clear();

        //set new time for code to spawn
        codeSpawnTime = ScoreAndSpeedScript.getScore() + Random.Range(4, 7);
        //codeSpawnTime must be b4 timerStart
        timerStart = false;
        codeCountdown.SetActive(false);
        currentCode = 0;

        //new code length
        if (codeLength > 5)
        {
            codeLength--;
        }
    }
Пример #7
0
 public void resetCodeSpawnTime()
 {
     //set new time for code to spawn
     codeSpawnTime = ScoreAndSpeedScript.getScore() + Random.Range(4, 7);
 }