void Update() { // Timer of the level if (isTimerActivate) { timeLeft -= Time.deltaTime; textTimer.text = (timeLeft).ToString("0"); textTimer2.text = (timeLeft).ToString("0"); if (timeLeft < 0) { isTimerActivate = false; audioSource.Stop(); ShowWinningCoins(false); if (levelData.Level == PlayerPrefs.GetInt("NextLevel")) { PlayerPrefs.SetInt("NumberLostLevels", PlayerPrefs.GetInt("NumberLostLevels") + 1); } audioSource.PlayOneShot(sndWrong); PlayerPrefs.SetInt("HeartsNumber", PlayerPrefs.GetInt("HeartsNumber") - 1); panelUserInfo.UpdateHearts(); WriteResult("Temps écoulé !"); RevealAnswer(); } } else { timeLeft = 0.0f; textTimer.text = (timeLeft).ToString("0"); textTimer2.text = (timeLeft).ToString("0"); } }
// It's the AI's turn to play public void ComputerPlay() { int button = ai.BestPosition(gameManagerScript.LevelData.Difficulty); Button btn = GameObject.Find(button.ToString()).GetComponent <Button>(); btn.interactable = false; btn.GetComponentInChildren <Text>().text = "O"; Tab[button] = "O"; if (IsWinner("O")) { IsGameOver = true; PlayLosingSound(); if (gameManagerScript.LevelData.Level == PlayerPrefs.GetInt("NextLevel")) { PlayerPrefs.SetInt("NumberLostLevels", PlayerPrefs.GetInt("NumberLostLevels") + 1); } PanelNextScene.GetComponent <NextSceneScript>().ActiveWinningCoins(false); PanelNextScene.GetComponentInChildren <PanelNextScene>().GoToNextLevel = 2; PlayerPrefs.SetInt("HeartsNumber", PlayerPrefs.GetInt("HeartsNumber") - 1); panelUserInfo.UpdateHearts(); PanelNextScene.SetActive(true); return; } if (ArrayIsFull()) { IsGameOver = true; PanelNextScene.SetActive(true); PanelNextScene.GetComponentInChildren <PanelNextScene>().GoToNextLevel = 0; PanelNextScene.GetComponent <NextSceneScript>().ActiveWinningCoins(false); ColorBlue(); return; } }
void onClaimButtonClick() { Reward reward = rewardsDB.GetReward(nextRewardIndex); //check reward type if (reward.Type == RewardType.Hearts) { GameData.Hearts += reward.Amount; panelUserInfo.UpdateHearts(); } else if (reward.Type == RewardType.Coins) { GameData.Coins += reward.Amount; panelUserInfo.UpdateCoins(); } fx.Play(); isRewardReady = false; //increment reward index nextRewardIndex++; if (nextRewardIndex >= rewardsDB.rewardsCount) { nextRewardIndex = 0; } PlayerPrefs.SetInt("NextRewardIndex", nextRewardIndex); PlayerPrefs.SetString("RewardClaimDatetime", DateTime.Now.ToString()); desactivateReward(); }
// Implement IUnityAdsListener interface methods: public void OnUnityAdsDidFinish(string placementId, ShowResult showResult) { // Define conditional logic for each ad completion status: if (showResult == ShowResult.Finished) { // Reward the user for watching the ad to completion. if (placementId == rewardedVideoId) { //Heart PlayerPrefs.SetInt("HeartsNumber", PlayerPrefs.GetInt("HeartsNumber") + 1); panelUserInfo.UpdateHearts(); } else if (placementId == coinsRewardedVideoId) { //Coins panelNextSceneScript = GameObject.Find("PanelNextScene").GetComponent <NextSceneScript>(); panelNextSceneScript.OnAdFinished(); } } else if (showResult == ShowResult.Skipped) { // Do not reward the user for skipping the ad. } else if (showResult == ShowResult.Failed) { Debug.LogWarning("The ad did not finish due to an error."); } }
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); }