private void Apocalypse(Attack attack)
        {
            // will not proc from fireballs created from apocalypse
            if (_isApocalypseActive)
            {
                return;
            }

            // roll the proc chance
            if (Random.Range(0, 100) < UpgradeData.GetValue(0))
            {
                StartCoroutine(ApocalypseAttack(attack));
            }
        }
        IEnumerator ApocalypseAttack(Attack attack)
        {
            _isApocalypseActive = true;

            Base      target = ((ProjectileFireball)attack).Target;
            TowerUnit tower  = (TowerUnit)attack.Attacker.Unit;

            // find all enemies within range of the target enemy
            List <Collider> targetsFound = Physics.OverlapSphere(target.transform.position, tower.TowerAttributes.Range, tower.SearchLayer).ToList();

            // remove the primary target from the list of enemies found so it isn't targeted again
            targetsFound.Remove(target.Unit.Components.SearchCollider);

            // generate a fireball for each target found, up to the rank's maximum amount
            var fireballsGenerated = 0;

            foreach (var bonusTarget in targetsFound)
            {
                // stagger the creation of fireballs so the projectiles don't overlap
                yield return(new WaitForSeconds(0.2f));

                // ensure the target still exists (wasn't removed by hitting the nexus or being killed)
                if (bonusTarget == null)
                {
                    continue;
                }

                // create the fireball attack
                var fireball = Instantiate(tower.Components.AttackPrefab, tower.Components.AttackSpawnLocation.position, Quaternion.identity, tower.transform).GetComponent <ProjectileFireball>();
                fireball.InitializeAttack(attack.Attacker, tower.TowerAttributes.Damage, UI.CombatTextType.SpecialDamage);
                fireball.InitializeProjectile(bonusTarget.GetComponent <UnitCollider>().Base, tower.TowerAttributes.ProjectileSpeed);
                fireball.InitializeFireball(tower.TowerAttributes["explosionSize"].AttributeValue / 10);

                // stop generating fireballs when it reaches its rank's maximum
                fireballsGenerated++;
                if (fireballsGenerated == (UpgradeData.GetValue(1) - 1))
                {
                    break;
                }
            }

            _isApocalypseActive = false;
        }
Example #3
0
        // Heal a random damaged tower in range
        private void Rejuvenate(Attack attack, Base unit)
        {
            // roll the proc chance
            if (Random.Range(0, 100) >= UpgradeData.GetValue(0))
            {
                return;
            }

            // find all towers in range
            int towersCount = Physics.OverlapSphereNonAlloc(transform.position, TowerBase.Attributes.Range, _towersInRange, _towerLayer);

            // get active and damaged towers only
            for (int i = 0; i < towersCount; i++)
            {
                var tower = (TowerBase)_towersInRange[i].GetComponent <UnitCollider>().Base;

                if (tower.Unit.IsEnabled && tower.Attributes.GetHealthPercentage() != 1)
                {
                    _damagedTowersInRange.Add(tower);
                }
            }

            // all towers in range are full health or disabled
            if (_damagedTowersInRange.Count == 0)
            {
                return;
            }

            // choose a random damaged tower to heal
            TowerBase towerToHeal = _damagedTowersInRange[Random.Range(0, _damagedTowersInRange.Count)];

            // the heal amount is based off the damage of this attack
            float healAmount = ((AttackArcaneBolt)attack).Damage * UpgradeData.GetValue(1) / 100f;

            towerToHeal.Unit.HealUnit(TowerBase, healAmount);

            // play heal VFX on tower
            Instantiate(UpgradeData.PrefabComponents[0], towerToHeal.transform.position, Quaternion.identity, towerToHeal.transform);

            // reset the list of towers found
            _damagedTowersInRange.Clear();
        }
Example #4
0
 public void SetModifierValues()
 {
     UpgradeData.Modifiers[0].SetMaxDuration(UpgradeData.GetValue(0));
 }