Example #1
0
        private void CalculateIdleIncomeAndShowNotification()
        {
            UIManager.CloseNotifIfOpen();
            var idleManager = new IdleManager(this, WaveManager);
            int killedMinionCount;
            int passedWaveCount;
            var currencyGainedWhileIdle = idleManager.CalculateIdleIncome(out killedMinionCount, out passedWaveCount);

            Data.IncreaseCurrency(currencyGainedWhileIdle);
            //Debug.Log("currency gained while idle: " + currencyGainedWhileIdle);
            if (currencyGainedWhileIdle != 0)
            {
                if (killedMinionCount == 0)
                {
                    UIManager.CreateNotificications("Welcome back!",
                                                    "Your mages earned " + currencyGainedWhileIdle +
                                                    " gold while you were gone.");
                }
                else
                {
                    UIManager.CreateNotificications("Welcome back!",
                                                    "Your mages killed " + killedMinionCount + " attackers and earned " + currencyGainedWhileIdle +
                                                    " gold while you were gone.");
                }
            }
        }
        private void HandleShowResult(ShowResult result)
        {
            switch (result)
            {
            case ShowResult.Finished:
                Debug.Log("The ad was successfully shown.");
                //
                // YOUR CODE TO REWARD THE GAMER
                // Give coins etc.
                var bonus = Player.CurrentBonus;
                switch (bonus)
                {
                case Player.AdSelector.Damage:
                    var dmgmodifier = 1.2f;
                    Player.SetModifier(Player.AdSelector.Damage, dmgmodifier, BonusTime);
                    Player.CurrentBonus = Player.AdSelector.Currency;
                    UIManager.CreateNotificications("Congratulations!", "You have gained " + (int)(dmgmodifier * 100 - 100) + "% damage bonus for " + BonusTime / 60 + " minutes!");
                    break;

                case Player.AdSelector.Currency:
                    var curmodifier = 1.5f;
                    Player.SetModifier(Player.AdSelector.Currency, curmodifier, BonusTime);
                    Player.CurrentBonus = Player.AdSelector.Damage;
                    UIManager.CreateNotificications("Congratulations!", "You have gained " + (int)(curmodifier * 100 - 100) + "% income bonus for " + BonusTime / 60 + " minutes!");
                    break;
                }
                Timer.Cooldown(BonusTime, Time.time);                 //burda mı olmalı?
                break;

            case ShowResult.Skipped:
                Debug.Log("The ad was skipped before reaching the end.");
                Timer.Cooldown(WaitTime, Time.time);                 //no cooldown if not finished
                break;

            case ShowResult.Failed:
                Debug.LogError("The ad failed to be shown.");
                Timer.Cooldown(WaitTime, Time.time);                 //no cooldown if not finished
                break;
            }
        }