コード例 #1
0
    void GameOver()
    {
        bHasGameStarted = false;
        pauseMenuUI.SetActive(false);
        mainGameUI.SetActive(false);
        gameOverUI.SetActive(true);
        bShouldPauseGame = true;

        SaveStuff savedData = LoadData();

        savedData.AddDoCats(flyHits * doCatsPerFlyHit);

        switch (currentGameMode)
        {
        case GameModes.TIME30:
            if (goals > savedData.GetBest30sScore())
            {
                savedData.SetBest30sScore(goals);
            }
            highScoreText.text = savedData.GetBest30sScore().ToString();
            break;

        case GameModes.TIME60:
            if (goals > savedData.GetBest60sScore())
            {
                savedData.SetBest60sScore(goals);
            }
            highScoreText.text = savedData.GetBest60sScore().ToString();
            break;

        case GameModes.TIME90:
            if (goals > savedData.GetBest90sScore())
            {
                savedData.SetBest90sScore(goals);
            }
            highScoreText.text = savedData.GetBest90sScore().ToString();
            break;
        }
        Save(savedData);

        currentScoreText.text = goals.ToString();
        doCatsScore.text      = "$" + savedData.GetDoCats().ToString();
    }
コード例 #2
0
    //public  Animator goalsTextAnimator;
    //public float shakeSpeed;

    void Start()
    {
        SaveStuff savedData = LoadData();

        bShouldPauseGame = false;
        mainGameUI.SetActive(true);
        pauseMenuUI.SetActive(false);
        gameOverUI.SetActive(false);

        currentGameMode = (GameModes)LoadGameMode();

        switch (currentGameMode)
        {
        case GameModes.TIME30:
            gameTime         = 10.0f;
            timeLeft         = 10.0f;
            currentHighScore = s30HighScore = savedData.GetBest30sScore();
            break;

        case GameModes.TIME60:
            gameTime         = 60.0f;
            timeLeft         = 60.0f;
            currentHighScore = s60HighScore = savedData.GetBest60sScore();
            break;

        case GameModes.TIME90:
            gameTime         = 90.0f;
            timeLeft         = 90.0f;
            currentHighScore = s90HighScore = savedData.GetBest90sScore();
            break;

        default:
            Debug.Log("ERROR: No game mode selected");
            timeLeft = 30.0f;
            break;
        }
        UpdateHUD();
        mainAudioSource = GetComponent <AudioSource>();
        //goalsTextAnimator = goalsText.GetComponent<Animator>();
    }