// Buy a wildcard to go to next level
 public void BuyGoToNextLevel()
 {
     if (PlayerPrefs.GetInt("CoinsNumber") >= 150)
     {
         audioSource.Stop();
         audioSource.PlayOneShot(sndWin);
         PlayerPrefs.SetInt("CoinsNumber", PlayerPrefs.GetInt("CoinsNumber") - 150);
         PlayerPrefs.SetInt("NumberWonLevels", PlayerPrefs.GetInt("NumberWonLevels") + 1);
         panelUserInfo.UpdateCoins();
         PanelNextScene.GetComponent <NextSceneScript>().ActiveWinningCoins(false);
         OnClickShowJokersPanel();
         PanelNextScene.GetComponentInChildren <PanelNextScene>().GoToNextLevel = 1;
         PanelNextScene.SetActive(true);
         int nextLevel = gameManagerScript.LevelData.Level + 1;
         if (PlayerPrefs.GetInt("NextLevel") < nextLevel)
         {
             PlayerPrefs.SetInt("NextLevel", nextLevel);
         }
         panelUserInfo.UpdateCurrentLvl();
     }
     else
     {
         GameObject.Find("GameObjectUI").GetComponent <UIScript>().PanelNoCoins.SetActive(true);
     }
 }
Example #2
0
    void Start()
    {
        //Initializing callback for active scene changes
        SceneManager.activeSceneChanged += changedActiveScene;

        //Updating user UI
        panelUserInfo.UpdateHearts();
        panelUserInfo.UpdateCoins();
        panelUserInfo.UpdateCurrentLvl();

        //Using player prefs to mute or not the audio
        Mute(PlayerPrefs.GetInt("mute") == 1);
    }
Example #3
0
 // For input quiz or directly mode, check the answer
 public void CheckAnswer(string playerAnswer)
 {
     audioSource.Stop();
     ShowWinningCoins(false);
     playerAnswer = playerAnswer.ToLower();
     if (levelData.RightAnswer.ToLower() == playerAnswer ||
         (levelData.OtherAcceptedAnswer1 != "" && levelData.OtherAcceptedAnswer1.ToLower() == playerAnswer) ||
         (levelData.OtherAcceptedAnswer2 != "" && levelData.OtherAcceptedAnswer2.ToLower() == playerAnswer) ||
         (levelData.OtherAcceptedAnswer3 != "" && levelData.OtherAcceptedAnswer3.ToLower() == playerAnswer))
     {
         audioSource.PlayOneShot(sndWin);
         if (levelData.Level == PlayerPrefs.GetInt("NextLevel"))
         {
             PlayerPrefs.SetInt("NumberWonLevels", PlayerPrefs.GetInt("NumberWonLevels") + 1);
             if (isDirectlyAnswerMode)
             {
                 ShowWinningCoins(true, 30);
                 GameData.Coins += 30;
             }
             else
             {
                 ShowWinningCoins(true);
                 GameData.Coins += 10;
             }
             panelUserInfo.UpdateCoins();
         }
         WriteResult("Bonne réponse !");
     }
     else
     {
         if (levelData.Level == PlayerPrefs.GetInt("NextLevel"))
         {
             PlayerPrefs.SetInt("NumberLostLevels", PlayerPrefs.GetInt("NumberLostLevels") + 1);
         }
         else
         {
             audioSource.PlayOneShot(sndWrong);
         }
         PlayerPrefs.SetInt("HeartsNumber", PlayerPrefs.GetInt("HeartsNumber") - 1);
         panelUserInfo.UpdateHearts();
         WriteResult("Mauvaise réponse !");
     }
     RevealAnswer();
     panelUserInfo.UpdateCurrentLvl();
 }
 // If the player buy a wildcard to go directly to next level
 public void BuyGoToNextLevel()
 {
     if (PlayerPrefs.GetInt("CoinsNumber") >= 150)
     {
         audioSource.Stop();
         audioSource.PlayOneShot(sndWin);
         PlayerPrefs.SetInt("CoinsNumber", PlayerPrefs.GetInt("CoinsNumber") - 150);
         PlayerPrefs.SetInt("NumberWonLevels", PlayerPrefs.GetInt("NumberWonLevels") + 1);
         panelUserInfo.UpdateCoins();
         OnClickShowJokersPanel();
         YouWin();
         ShowWinningCoins(false);
         panelUserInfo.UpdateCurrentLvl();
     }
     else
     {
         uiScript.PanelNoCoins.SetActive(true);
     }
 }