Esempio n. 1
0
    private void CalculateOfflineRewards()
    {
        int allSecondsPassed = minutesPassed * 60 + PlayerPrefs.GetInt("rewardSecondsAlreadyPassed");

        minutesPassed += Mathf.FloorToInt(PlayerPrefs.GetInt("rewardSecondsAlreadyPassed") / 60);

        if (minutesPassed >= RewardIntervalMinute)
        {
            inGameManager.ChangeHeartAmount(Mathf.FloorToInt(minutesPassed / RewardIntervalMinute));
            Debug.Log("hearts to add to player: " + Mathf.FloorToInt(minutesPassed / RewardIntervalMinute));
        }
        else
        {
            Debug.Log("Not enough time passed.");
        }

        if (PlayerPrefs.GetInt("ActiveHearts") < inGameManager.GetMaxHeart())
        {
            StartCoroutine("RewardTimer", allSecondsPassed % (RewardIntervalMinute * 60));
        }
    }
Esempio n. 2
0
 public void onCoinUse()
 {
     if (PlayerPrefs.GetInt("playerCoins") >= requiredCoin)
     {
         inGameManager.AddCurrency(-requiredCoin, 0);
         inGameManager.ChangeHeartAmount(inGameManager.maxHeart);
     }
     else
     {
         inGameManager.ShowMessageBox("سکه های شما کافی نمی باشد. می توانید از فروشگاه سکه تهیه کنید.");
         shopPopup.SetActive(true);
     }
 }
Esempio n. 3
0
    public void ShowTapsellVideoAd(string zoneID)
    {
        Tapsell.requestAd(zoneID, false,
                          (TapsellAd result) => //onAdAvailable
        {
            Debug.Log("Action: onAdAvailable");
            TapsellAd ad = result;     // store this to show the ad later

            TapsellShowOptions showOptions = new TapsellShowOptions();
            showOptions.backDisabled       = false;
            showOptions.immersiveMode      = false;
            showOptions.rotationMode       = TapsellShowOptions.ROTATION_UNLOCKED;
            showOptions.showDialog         = true;
            Tapsell.showAd(ad, showOptions);

            loadingPopup.SetActive(true);

            Tapsell.setRewardListener((TapsellAdFinishedResult rewardResult) =>
            {
                if (rewardResult.completed && rewardResult.rewarded)
                {
                    //todo: give the reward
                    inGameManager.ChangeHeartAmount(1);
                    inGameManager.ShowCurrencyPopup(1, 1);
                    loadingPopup.SetActive(false);
                }
                else
                {
                    //todo: error popup
                    inGameManager.ShowMessageBox("متاسفانه خطایی در نمایش تبلیغ پیش آمد.");
                    loadingPopup.SetActive(false);
                }
            });
        },
                          (string zoneId) => //onNoAdAvailable
        {
            Debug.Log("No Ad Available");

            //todo: error popup
            inGameManager.ShowMessageBox("متاسفانه خطایی در نمایش تبلیغ پیش آمد.");
            loadingPopup.SetActive(false);
        },
                          (TapsellError error) => //onError
        {
            Debug.Log(error.error);
            //todo: error popup
            inGameManager.ShowMessageBox("متاسفانه خطایی در نمایش تبلیغ پیش آمد.");
            loadingPopup.SetActive(false);
        },
                          (string zoneId) => //onNoNetwork
        {
            Debug.Log("No Network");
            //todo: error popup
            inGameManager.ShowMessageBox("متاسفانه خطایی در نمایش تبلیغ پیش آمد.");
            loadingPopup.SetActive(false);
        },
                          (TapsellAd result) => //onExpiring
        {
            Debug.Log("Expiring");
            // this ad is expired, you must download a new ad for this zone
            inGameManager.ShowMessageBox("متاسفانه خطایی در نمایش تبلیغ پیش آمد.");
            loadingPopup.SetActive(false);
        });
    }
Esempio n. 4
0
    public void FinishedLevel()
    {
        blockerObj.SetActive(false);

        //checking game result
        if (wonTheLevel)
        {
            gameOverWin.SetActive(true);

            int gainedStars;
            if (levelGoalSlider.value >= 1)
            {
                gainedStars = 3;
            }
            else if (levelGoalSlider.value >= 0.8)
            {
                gainedStars = 2;
            }
            else
            {
                gainedStars = 1;
            }

            for (int i = 0; i < 3; i++)
            {
                gameOverStars[i].sprite = emptyStar;
            }
            for (int i = 0; i < gainedStars; i++)
            {
                gameOverStars[i].sprite = gainedStar;
            }

            overRewardTxt._rawText = levelRewardAmount.ToString();
            overRewardTxt.enabled  = false;
            overRewardTxt.enabled  = true;

            levelCountTxt._rawText = "مرحله " + (currentLevelIndex + 1).ToString();
            levelCountTxt.enabled  = false;
            levelCountTxt.enabled  = true;

            gameData.SetUpNewPlayerLevelData(currentLevelIndex, gainedStars, levelRewardAmount);

            //Game Analytics progression data update
            GameAnalyticsManager.Instance.SendProgressionEvent(2, "world0", "level" + (currentLevelIndex + 1));

            //adding level reward coins
            inGameManager.AddCurrency(levelRewardAmount, 0);
            GameAnalyticsManager.Instance.SendResourceEvent(1, "Coin", levelRewardAmount, "LevelReward", "LevelCoinReward");
        }
        else
        {
            inGameManager.ChangeHeartAmount(-1);

            if (!hasUsedContinue)
            {
                GameAnalyticsManager.Instance.SendDesignEvents("InGame:Continue:didn'tContinue");

                gameOverLose.SetActive(true);
                hasUsedContinue = true;
            }
            else
            {
                GameAnalyticsManager.Instance.SendDesignEvents("InGame:Continue:Continued");

                finalGameOverObj.SetActive(true);
            }
            //Game Analytics progression data update
            GameAnalyticsManager.Instance.SendProgressionEvent(3, "world 0", "level " + (currentLevelIndex + 1));
        }
    }