Exemplo n.º 1
0
    public void Start()
    {
        Time.timeScale = 1f;
        if (!PlayerPrefs.HasKey("version"))
        {
            if (!PlayerPrefs.HasKey("MaxScore"))
            {
                PlayerPrefs.SetInt("MaxScore", 0);
                PlayerPrefs.SetInt("Money", 0);
                PlayerPrefs.SetInt("version", 2);
                PlayerPrefs.SetInt("Experience", 0);
                PlayerPrefs.SetInt("Level", 0);
                PlayerPrefs.SetFloat("Sound", 0.5f);
                PlayerPrefs.SetFloat("Music", 0f);
                PlayerPrefs.SetString("Teach", "true");

                PlayerPrefs.SetString("Hand", "right");
                PlayerPrefs.SetString("Notifications", "on");
                PlayerPrefs.SetString("FirstGame", "");
                PlayerPrefs.SetFloat("MiddleScoreInGame", 0f);
                PlayerPrefs.SetInt("MaxCutSimpleScore", 0);
                PlayerPrefs.SetInt("MaxCutSimpleMoney", 0);
                PlayerPrefs.SetInt("MaxCutGameMoney", 0);
                PlayerPrefs.SetInt("RemoveMoney", 0);
                PlayerPrefs.SetInt("AllMoney", 0);
                PlayerPrefs.SetInt("AllGames", 0);
                PlayerPrefs.SetInt("AdsReward", 3);
                PlayerPrefs.SetInt("AdsRestart", 3);
                PlayerPrefs.SetInt("Day", DateTime.Now.DayOfYear);
            }
            else
            {
                int maxScore = p.EnCrypt(PlayerPrefs.GetString("MaxScore"));
                int money    = p.EnCrypt(PlayerPrefs.GetString("Money"));
                PlayerPrefs.DeleteKey("MaxScore");
                PlayerPrefs.DeleteKey("Money");
                p.DeletePassword();
                PlayerPrefs.SetInt("MaxScore", maxScore);
                PlayerPrefs.SetInt("Money", money);
                PlayerPrefs.SetInt("version", 2);
                PlayerPrefs.SetInt("Experience", 0);
                PlayerPrefs.SetInt("Level", 0);
                PlayerPrefs.SetFloat("Sound", 0.5f);
                PlayerPrefs.SetFloat("Music", 0f);
                PlayerPrefs.SetString("Teach", "false");

                PlayerPrefs.SetString("Hand", "right");
                PlayerPrefs.SetString("Notifications", "on");
                PlayerPrefs.SetString("FirstGame", "false");
                PlayerPrefs.SetFloat("MiddleScoreInGame", 0f);
                PlayerPrefs.SetInt("MaxCutSimpleScore", 0);
                PlayerPrefs.SetInt("MaxCutSimpleMoney", 0);
                PlayerPrefs.SetInt("MaxCutGameMoney", 0);
                PlayerPrefs.SetInt("RemoveMoney", 0);
                PlayerPrefs.SetInt("AllMoney", 0);
                PlayerPrefs.SetInt("AllGames", 0);
                PlayerPrefs.SetInt("AdsReward", 3);
                PlayerPrefs.SetInt("AdsRestart", 3);
                PlayerPrefs.SetInt("Day", DateTime.Now.DayOfYear);
            }
        }
        else
        {
            switch (PlayerPrefs.GetInt("version"))
            {
            case 1:
                PlayerPrefs.SetInt("version", 2);
                PlayerPrefs.SetString("Hand", "right");
                PlayerPrefs.SetString("Notifications", "on");
                PlayerPrefs.SetString("FirstGame", "false");
                PlayerPrefs.SetFloat("MiddleScoreInGame", 0f);
                PlayerPrefs.SetInt("MaxCutSimpleScore", 0);
                PlayerPrefs.SetInt("MaxCutSimpleMoney", 0);
                PlayerPrefs.SetInt("MaxCutGameMoney", 0);
                PlayerPrefs.SetInt("RemoveMoney", 0);
                PlayerPrefs.SetInt("AllMoney", 0);
                PlayerPrefs.SetInt("AllGames", 0);
                PlayerPrefs.SetInt("AdsReward", 3);
                PlayerPrefs.SetInt("AdsRestart", 3);
                PlayerPrefs.SetInt("Day", DateTime.Now.DayOfYear);
                break;
            }
        }
        forTeach = PlayerPrefs.GetString("Teach") == "true";
        PlayerPrefs.SetString("FirstGame", forTeach.ToString().ToLower());
        teach.SetActive(forTeach);
        if (forTeach)
        {
            tch.StartTeach();
        }

        UpdateLevelHunting();
        cut.isActiveActivity = false;
        count = 0; countMoney = PlayerPrefs.GetInt("Money");
        textScore.GetComponent <Text>().text = count.ToString();
        if (PlayerPrefs.GetInt("Day") != DateTime.Now.DayOfYear)
        {
            PlayerPrefs.SetInt("Day", DateTime.Now.DayOfYear);
            PlayerPrefs.SetInt("AdsReward", 3);
            PlayerPrefs.SetInt("AdsRestart", 3);
        }
        addReward         = PlayerPrefs.GetInt("AdsReward");
        addRestart        = PlayerPrefs.GetInt("AdsRestart");
        maxTextScore.text = PlayerPrefs.GetInt("MaxScore").ToString();
        moneyScore.text   = countMoney.ToString();
        moneyScore2.text  = countMoney.ToString();
        moneyScore3.text  = countMoney.ToString();
        version.text      = "v: " + Application.version;
        float exp = PlayerPrefs.GetInt("Experience");
        float alg = PlayerPrefs.GetInt("AllGames");

        if (alg == 0)
        {
            PlayerPrefs.SetFloat("MiddleScoreInGame", 0);
        }
        else
        {
            PlayerPrefs.SetFloat("MiddleScoreInGame", exp / alg);
        }
        lockIsGame     = false;
        cut.isTeaching = forTeach;
        cut.isGame     = forTeach;
        menuUI.SetActive(!forTeach);
        lines.speedGraph = 75f;
        levelHunting.SetActive(!forTeach && PlayerPrefs.GetString("FirstGame") == "false");
        youlose.SetActive(false);
        prelose.SetActive(false);
        pauseBut.SetActive(false);
        moneyGame.SetActive(false);
        textScore.SetActive(false);
        pause.SetActive(false);
        author1.SetActive(true);
        author2.SetActive(false);
        author3.SetActive(false);

        bool ad = PlayerPrefs.GetInt("AdsReward") > 0 && adsManager.CheckMonetizationReward();

        adsReward.SetActive(ad);
        UpdateNotifications();
        UpdateHand();
        if (isStartOffRenderGameUI == true)
        {
            isStartOffRenderGameUI = false;
            StartCoroutine(OffRenderGameUI());
        }

        if (PlayerPrefs.GetFloat("Sound") == 0f)
        {
            sound.sprite = audioOff;
        }
        else
        {
            sound.sprite = audioOn;
        }
        sliderSound.value = PlayerPrefs.GetFloat("Sound");
        SoundActive(PlayerPrefs.GetFloat("Sound"));

        if (PlayerPrefs.GetFloat("Music") == 0f)
        {
            music.sprite = musicOff;
        }
        else
        {
            music.sprite = musicOn;
        }
        sliderMusic.value = PlayerPrefs.GetFloat("Music");
        MusicActive(PlayerPrefs.GetFloat("Music"));

        if (PlayerPrefs.GetString("FirstGame") == "false")
        {
            StartCoroutine(StartGameNext(0.5f));
        }
        else
        {
            startGame.SetBool("isActive", true);
            StartCoroutine(StartGameNext(0.3f));
            Restart();
        }

        levelHunt.SetBool("isActive", true);
        return;
    }