public MinionData()
 {
     _life = UpgradeManager.MinionLifeInitial;
     _currencyGivenOnDeath = UpgradeManager.MinionDeathRewardInitial;
     _speed    = 10f;
     _mageLoot = false;
 }
 public MinionData(BigIntWithUnit life, BigIntWithUnit deathCurrency, float speed)
 {
     _life = life;
     _currencyGivenOnDeath = deathCurrency;
     _speed    = speed;
     _mageLoot = false;
 }
Example #3
0
 private void SetValuesForMageLevel()
 {
     if (UpgradeInfo[_element].Count <= _mageLevel)
     {
         IncreaseSpellDamage();
         IncreaseSpellRange();
         IncreaseSpellRate();
         IncreaseSkillDamage();
         UpdateDps();
         _upgradePrice *= UpgradeManager.MageUpgradePriceMultiplier;
         return;
     }
     _prefabId = UpgradeInfo[_element][_mageLevel].Type;
     //Integration code from published version.
     //Should be fixed better not here.
     if (_damageBonus < 1.0f)
     {
         _damageBonus = 1.0f;
     }
     _spellDamage  = UpgradeInfo[_element][_mageLevel].SpellDamage * _damageBonus;
     _spellRange   = UpgradeInfo[_element][_mageLevel].SpellRange;
     _delay        = UpgradeInfo[_element][_mageLevel].Delay;
     _skillDamage  = UpgradeInfo[_element][_mageLevel].SkillDamage;
     _upgradePrice = UpgradeInfo[_element][_mageLevel].UpgradePrice;
     UpdateDps();
 }
Example #4
0
        //resets the player data to beginning state
        public void ResetPlayer(Element bonusElement)
        {
            _spellDamage             = UpgradeManager.PlayerDamageInitial;
            _spellSpeed              = 10;
            _playerLevel             = 1;
            _resetAmount            += 1;
            _pricePlayerSpellUpgrade = UpgradeManager.MageUpgradePriceInitial;
            _element = bonusElement;
            switch (bonusElement)
            {
            case Element.Air:
                _airBonus    *= 1.5f;
                _spellDamage *= _airBonus;
                break;

            case Element.Earth:
                _earthBonus  *= 1.5f;
                _spellDamage *= _earthBonus;
                break;

            case Element.Fire:
                _fireBonus   *= 1.5f;
                _spellDamage *= _fireBonus;
                break;

            case Element.Water:
                _waterBonus  *= 1.5f;
                _spellDamage *= _waterBonus;
                break;

            default:
                throw new ArgumentOutOfRangeException("bonusElement", bonusElement, null);
            }
        }
Example #5
0
        public void UpgradePlayer()
        {
            //Upgrade
            _spellDamage *= UpgradeManager.PlayerDamageMultiplier;
            _playerLevel += 1;

            //Scaling
            _pricePlayerSpellUpgrade *= UpgradeManager.MageUpgradePriceMultiplier;
        }
Example #6
0
        public BigIntWithUnit CumulativeIdleEarning()
        {
            BigIntWithUnit result = 0;

            foreach (MageData mage in _mageList)
            {
                result += mage.GetIdleCurrency();
            }
            return(result);
        }
        public BigIntWithUnit GetTotalLoot()
        {
            var            minionData   = GetMinionDataForCurrentWave();
            var            minionCounts = GetCurrentWaveLengths();
            BigIntWithUnit totalLoot    = 0;

            for (var i = 0; i < minionCounts.Length; i++)
            {
                totalLoot += minionCounts[i] * minionData[i].GetDeathLoot();
            }
            return(totalLoot);
        }
Example #8
0
        public BigIntWithUnit CumulativeDps()
        {
            BigIntWithUnit result = 0;

            foreach (MageData mage in _mageList)
            {
                if (mage.IsInTower())
                {
                    result += mage.IndividualDps();
                }
            }
            return(result);
        }
Example #9
0
        public SkillData(Element element, BigIntWithUnit spellDamage, int spellRange, int spellSpeed, float spellMultiplier)
        {
            _element         = element;
            _type            = ElementController.Instance.GetSkillType(element);
            _spellDamage     = spellDamage;
            _spellRange      = spellRange;
            _spellSpeed      = spellSpeed;
            _spellMultiplier = spellMultiplier;

            _minionEffects = ElementController.Instance.GetSkillEffectsToMinions(element);

            _towerEffects = ElementController.Instance.GetSkillEffectsToTowers(element);
        }
Example #10
0
        public void UpgradeIdleGenerated()
        {
            if (_currency < _priceIdleGeneratedUpgrade)
            {
                return;
            }
            //Upgrade
            foreach (var mage in _mageList)
            {
                mage.UpgradeIdleCurrency();
            }

            //Scaling
            _priceIdleGeneratedUpgrade *= UpgradeManager.MageUpgradePriceMultiplier;
        }
Example #11
0
        private void UpdateLabels()
        {
            if (Player.Data != null)
            {
                CurrText.text     = Player.Data.GetCurrency().ToString();
                WaveLifeText.text = Player.WaveManager.WaveLife.ToString();
                if (Player.WaveManager.WaveLife != 0)
                {
                    BigIntWithUnit WaveLifeBarAmount = Player.WaveManager.WaveLife / Player.WaveManager.TotalWaveLife;
                    WaveLifeBar.value = WaveLifeBarAmount.ToFloat();
                }
                else
                {
                    WaveLifeBar.value = 0;
                }
                MageText.text = Player.Data.CumulativeDps().ToString();

                if (Player.WaveManager.Data.CurrentWave == 0)
                {
                    PrevWave.text = "";
                }
                else
                {
                    if (Player.WaveManager.Data.IsPreviousWaveBossWave)
                    {
                        PrevWaveImage.color = new Color(0.78f, 0.78f, 0.78f, 0.5f);
                    }
                    else
                    {
                        PrevWaveImage.color = Color.white;
                    }
                    PrevWave.text = Player.WaveManager.Data.CurrentWave.ToString();
                }

                CurrWave.text = (Player.WaveManager.Data.CurrentWave + 1).ToString();

                if (Player.WaveManager.Data.CurrentWave == Player.WaveManager.Data.GetMaxReachedWave())
                {
                    NextWave.text        = "";
                    NextWaveImage.sprite = EmptyWaveButton;
                }
                else
                {
                    NextWave.text        = (Player.WaveManager.Data.CurrentWave + 2).ToString();
                    NextWaveImage.sprite = FullWaveButton;
                }
            }
        }
        public void CalculateReward()
        {
            int consecutiveDays = GetConsecutiveDays();

            if (consecutiveDays != 2 && consecutiveDays != 5)
            //proposing new reward amount: CurrencyGainedWhileIdle / 2
            {
                float multiplier = (float)(consecutiveDays) / 2 + 1;
                _reward     = Player.WaveManager.Data.GetTotalLoot() * multiplier;
                _rewardText = "You have gained " + _reward.ToString() + " Golds! Click here to claim your prize.";
            }
            else
            {
                _rewardText = "You have gained damage and income bonus! Click here to claim your prize.";
            }
        }
Example #13
0
        public void RegisterEvent(AchievementType type, BigIntWithUnit count)
        {
            if (!_achievements.ContainsKey(type))
            {
                return;
            }
            BigIntWithUnit oldValue = 0;

            if (_achievementKeeper.ContainsKey(type))
            {
                oldValue = _achievementKeeper[type];
            }

            _achievementKeeper[type] = type.UpdateAchievementCount(oldValue, count);

            ParseAchievements(type);
        }
Example #14
0
        public PlayerData(Element element)
        {
            _fireBonus = _airBonus = _earthBonus = _waterBonus = 1.0f;

            _playerLevel             = 1;
            _spellDamage             = UpgradeManager.PlayerDamageInitial;
            _spellSpeed              = 10;
            _currency                = 0;
            _pricePlayerSpellUpgrade = UpgradeManager.MageUpgradePriceInitial;
            _element = element;
            _priceIdleGeneratedUpgrade = UpgradeManager.MageIdleGenerationUpgradePriceInitial;
            _mageCap          = 10;
            _mageList         = new List <MageData>();
            _mageObjectList   = new List <Mage>();
            _currentSceneName = SceneLoader.DefaultStartScene;
            _resetAmount      = 0;
        }
        public void CreateCurrentWave()
        {
            ClearCurrentWave();
            var minionData   = Data.GetMinionDataForCurrentWave();
            var minionCounts = Data.GetCurrentWaveLengths();

            var lastForward     = _startWaypoint.transform.forward * 0;
            var minionPrefabIds = GenerateMinionPrefabIdsForCurrentWave();

            for (var i = 0; i < minionCounts.Length; i++)
            {
                for (int j = 0; j < minionCounts[i]; j++)
                {
                    lastForward += _startWaypoint.transform.forward * Random.Range(4, 9);
                    var rightOffset = _startWaypoint.transform.right * Random.Range(-5f, 5f);
                    if (Data.IsBossWave)
                    {
                        rightOffset = _startWaypoint.transform.right;
                    }
                    var instantPos = _startWaypoint.transform.position - lastForward + rightOffset;
                    var instantRot = _startWaypoint.transform.rotation;

                    var clone = Instantiate(MinionPrefabs[minionPrefabIds[i]], instantPos, instantRot) as Minion;
                    if (clone == null)
                    {
                        continue;
                    }
                    clone.Data = (MinionData)minionData[i].Clone();
                    clone.Data.SetMageLoot(Data.IsDropWave);
                    clone.tag = "Minion";

                    if (Data.IsBossWave)
                    {
                        clone.tag = "Boss";
                    }
                    clone.Initialize(Player);
                    _wave.Add(clone);
                }
            }
            TotalWaveLife = WaveLife;
        }
Example #16
0
        public MageData(string name, string line, Element element, float elementBonus)
        {
            _name         = name;
            _line         = line;
            _element      = element;
            _currentState = MageState.Dropped;
            _buildingId   = null;
            _mageLevel    = 0;

            _skillEffect = ElementController.Instance.GetSkillPowerInitial(element);
            _damageBonus = elementBonus;

            SetValuesForMageLevel();

            //ToDo: Make Element dependent
            _spellSpeed       = 90;
            _idleCurrency     = UpgradeManager.MageIdleGenerationInitial;
            _skillCoolDown    = 10;
            _minSkillCoolDown = 1;
            _skillRange       = 15;
            _prefabId         = 0;
        }
        public MinionData[] GetMinionDataForCurrentWave()
        {
            var currentWaveData     = _waveInfos[CurrentWave % _waveInfos.Count];
            var waveMinionTypeCount = currentWaveData.Type.Length;
            var waveMinions         = new MinionData[waveMinionTypeCount];

            //Multipliers are 1 as long as waveInfo.count > CurrentWave
            BigIntWithUnit multiplierLife  = 1;
            BigIntWithUnit multiplierMoney = 1;

            if (CurrentWave / _waveInfos.Count >= 1)
            {
                multiplierLife  = UpgradeManager.MinionLifeMultiplier * (CurrentWave / _waveInfos.Count);
                multiplierMoney = UpgradeManager.MinionDeathRewardMultiplier * (CurrentWave / _waveInfos.Count);
            }

            for (var i = 0; i < waveMinionTypeCount; i++)
            {
                waveMinions[i] = new MinionData(currentWaveData.Life[i] * multiplierLife, currentWaveData.CurrencyOnDeath[i] * multiplierMoney, currentWaveData.Speed[i]);
            }

            return(waveMinions);
        }
        public BigIntWithUnit CalculateIdleIncome(out int killedCreatures, out int passedLevels)
        {
            var gameCloseTime     = DateTime.Parse(PlayerPrefs.GetString("_gameCloseTime"));
            var idleTime          = DateTime.Now - gameCloseTime;
            var idleTimeInSeconds = idleTime.TotalSeconds;

            killedCreatures = 0;
            passedLevels    = 0;
            if (idleTimeInSeconds > 7200)
            {
                //2hrs max
                idleTimeInSeconds = 7200;
            }
            else if (idleTimeInSeconds < 60)
            {
                return(0);
            }

            var damageModifierSeconds = (_player.GetModifierTime(Player.AdSelector.Damage) - gameCloseTime).TotalSeconds;
            var incomeModifierSeconds = (_player.GetModifierTime(Player.AdSelector.Currency) - gameCloseTime).TotalSeconds;
            var damageModifier        = _player.GetModifier(Player.AdSelector.Damage);
            var incomeModifier        = _player.GetModifier(Player.AdSelector.Currency);

            while (_waveManager.Data.IsBossWave)
            {
                _waveManager.Data.DecreaseCurrentWave();
            }
            _waveManager.ClearCurrentWave();
            _waveManager.CreateCurrentWave();
            var            mageAttackDuration = _roadLength / _waveManager.WaveSpeed;
            BigIntWithUnit totalIncome        = 0;
            //Calculate Total Idle Damage, use avarage attack of 6 towers
            var maxPotentialWaveDmg = _player.Data.CumulativeDps() * mageAttackDuration / 6;

            //Calculate the idle mage currency
            totalIncome += _player.Data.CumulativeIdleEarning() * idleTimeInSeconds;

            //Idle Currency Gaining
            while (idleTimeInSeconds > 0)
            {
                var timeMultiplier = 1.0;
                if (idleTimeInSeconds < mageAttackDuration) //not enough time left to kill the wave
                {
                    timeMultiplier = idleTimeInSeconds / mageAttackDuration;
                }
                var waveKilledPercent = (maxPotentialWaveDmg * damageModifier) / _waveManager.WaveLife;
                totalIncome           += _waveManager.WaveReward * waveKilledPercent * timeMultiplier * incomeModifier;
                killedCreatures       += (int)(_waveManager.Data.GetCurrentWaveLength() * waveKilledPercent.ToFloat() * timeMultiplier);
                idleTimeInSeconds     -= mageAttackDuration;
                damageModifierSeconds -= mageAttackDuration;
                incomeModifierSeconds -= mageAttackDuration;
                if (damageModifierSeconds < 0)
                {
                    damageModifier = 1.0f;
                }
                if (incomeModifierSeconds < 0)
                {
                    incomeModifier = 1.0f;
                }

                if (waveKilledPercent >= 1 && timeMultiplier >= 0.99 && !_waveManager.Data.IsNextWaveBossWave)  //calculate currency gain of next wave if it comes
                {
                    passedLevels++;
                    _waveManager.Data.IncreaseCurrentWaveAndMaxWave();
                    _waveManager.ClearCurrentWave();
                    _waveManager.CreateCurrentWave();
                }
            }
            _waveManager.ClearCurrentWave();
            return(totalIncome);
        }
Example #19
0
 public void UpgradeIdleCurrency()
 {
     _idleCurrency *= UpgradeManager.MageIdleGenerationMultiplier;
 }
Example #20
0
 private void IncreaseSkillDamage()
 {
     _skillDamage *= ElementController.Instance.GetSkillDamageMultiplier(_element);
 }
Example #21
0
 public void UpdateDps()
 {
     DPS = _spellDamage / _delay;
 }
Example #22
0
 public SpellData(BigIntWithUnit damage, int speed, Element element)
 {
     _damage  = damage;
     _speed   = speed;
     _element = element;
 }
Example #23
0
 public void DecreaseCurrency(BigIntWithUnit amount)
 {
     _currency -= amount;
 }
Example #24
0
 public void IncreaseCurrency(BigIntWithUnit amount)
 {
     _currency += amount;
 }
 public void Kill()
 {
     _life = 0;
 }
 /// <summary>
 /// If you want damage floating text, call minion.DecreaseLife instead
 /// </summary>
 /// <param name="damage"></param>
 /// <returns></returns>
 public BigIntWithUnit DecreaseLife(BigIntWithUnit damage)
 {
     _life -= damage;
     return(_life);
 }
Example #27
0
        public static BigIntWithUnit UpdateAchievementCount(this AchievementType type, BigIntWithUnit oldValue, BigIntWithUnit update)
        {
            switch (type)
            {
            case AchievementType.AirMage:
                return(oldValue > update ? oldValue : update);

            case AchievementType.FireMage:
                return(oldValue > update ? oldValue : update);

            case AchievementType.WaterMage:
                return(oldValue > update ? oldValue : update);

            case AchievementType.EarthMage:
                return(oldValue > update ? oldValue : update);

            case AchievementType.Wave:
                return(update);

            case AchievementType.Spend:
                return(oldValue + update);

            case AchievementType.Earn:
                return(oldValue + update);

            case AchievementType.Reset:
                return(oldValue + update);
            }
            return(0);
        }