Exemple #1
0
    private void Update()
    {
        if (player.plantsKilled >= requiredPlants && isTimeBased)
        {
            gameOver     = true;
            isSuccessful = true;
        }

        if (gameOver)
        {
            CheckResult();
            if (isSuccessful)
            {
                if (isTimeBased)
                {
                    timeTaken = countDown.maxTime - countDown.timeLeft;
                }
                GameOver();
                for (int i = 0; i < acquiredStars; i++)
                {
                    stars[i].SetActive(true);
                }
                data.AutoSaveGame();
                player.plantsKilled = 0;
                if (newBest)
                {
                    crown.SetActive(true);
                }
            }
            else
            {
                TryAgain();
            }
        }
    }
    //Function used to exchange points earned in game with currency usable in shops
    public void ExchangeValues()
    {
        if (gameMaster.totalPoints != 0)
        {
            Debug.Log("You received: " + (int)(gameMaster.totalPoints * currentExchangeRate));
            gameMaster.totalMoney += (int)(gameMaster.totalPoints * currentExchangeRate);
            gameMaster.totalPoints = 0;
        }
        else
        {
            Debug.Log("You didn't have any points to exchange!");
        }

        data.AutoSaveGame();
    }
 public void LoadAndSaveLevel(int sceneIndex)
 {
     data.AutoSaveGame();
     StartCoroutine(LoadAsynchronously(sceneIndex));
 }