Example #1
0
    public override void updateMutator()
    {
        MeteorMutator mutator                     = PlayerFinder.getPlayer().GetComponent <MeteorMutator>();
        float         increasedManaCost           = 0f;
        float         addedManaCostDivider        = 0f;
        int           additionalMeteors           = 0;
        float         increasedMeteorFrequency    = 0;
        float         increasedShowerRadius       = 0f;
        float         increasedFallSpeed          = 0f;
        float         increasedCastSpeed          = 0f;
        bool          usesAllMana                 = false;
        float         moreDamageAgainstFullHealth = 0f;
        float         shrapnelChance              = 0f;
        float         increasedShrapnelSpeed      = 0f;
        bool          shrapnelPierces             = false;
        float         increasedShrapnelDamage     = 0f;
        float         increasedStunChance         = 0f;
        bool          line = false;
        List <float>  moreDamageInstances = new List <float>();

        foreach (SkillTreeNode node in GetComponentsInChildren <SkillTreeNode>())
        {
            if (node.name == "Meteor Skill Tree Against Full Health")
            {
                moreDamageAgainstFullHealth += node.GetComponent <SkillTreeNode>().pointsAllocated * 0.15f;
            }
            if (node.name == "Meteor Skill Tree Shrapnel Chance")
            {
                shrapnelChance += node.GetComponent <SkillTreeNode>().pointsAllocated * 0.34f;
            }
            if (node.name == "Meteor Skill Tree Shrapnel Damage")
            {
                increasedShrapnelDamage += node.GetComponent <SkillTreeNode>().pointsAllocated * 0.25f;
            }
            if (node.name == "Meteor Skill Tree Shrapnel Speed")
            {
                increasedShrapnelSpeed += node.GetComponent <SkillTreeNode>().pointsAllocated * 0.3f;
            }
            if (node.name == "Meteor Skill Tree Shrapnel Pierces")
            {
                if (node.GetComponent <SkillTreeNode>().pointsAllocated > 0)
                {
                    shrapnelPierces         = true;
                    increasedShrapnelSpeed -= 0.2f;
                }
            }
            if (node.name == "Meteor Skill Tree Increased Damage")
            {
                moreDamageInstances.Add(node.GetComponent <SkillTreeNode>().pointsAllocated * 0.15f);
                increasedCastSpeed += node.GetComponent <SkillTreeNode>().pointsAllocated * -0.05f;
            }
            if (node.name == "Meteor Skill Tree Cast Speed")
            {
                increasedCastSpeed += node.GetComponent <SkillTreeNode>().pointsAllocated * 0.2f;
                increasedFallSpeed += node.GetComponent <SkillTreeNode>().pointsAllocated * 0.2f;
                increasedManaCost  += node.GetComponent <SkillTreeNode>().pointsAllocated * 0.2f;
            }
            if (node.name == "Meteor Skill Tree Stun Chance")
            {
                increasedStunChance += node.GetComponent <SkillTreeNode>().pointsAllocated * 0.2f;
            }
            if (node.name == "Meteor Skill Tree Stun And Mana")
            {
                increasedStunChance  += node.GetComponent <SkillTreeNode>().pointsAllocated * 0.1f;
                addedManaCostDivider += node.GetComponent <SkillTreeNode>().pointsAllocated * 0.1f;
            }
            if (node.name == "Meteor Skill Tree All Mana")
            {
                if (node.GetComponent <SkillTreeNode>().pointsAllocated > 0)
                {
                    usesAllMana = true;
                }
            }
            if (node.name == "Meteor Skill Tree Fall Speed")
            {
                increasedFallSpeed += node.GetComponent <SkillTreeNode>().pointsAllocated * 0.2f;
            }
            if (node.name == "Meteor Skill Tree Twin Meteors")
            {
                if (node.GetComponent <SkillTreeNode>().pointsAllocated > 0)
                {
                    additionalMeteors += 1;
                    moreDamageInstances.Add(-0.35f);
                }
            }
            if (node.name == "Meteor Skill Tree More Meteors")
            {
                additionalMeteors += node.GetComponent <SkillTreeNode>().pointsAllocated;
                moreDamageInstances.Add(node.GetComponent <SkillTreeNode>().pointsAllocated * -0.07f);
            }
            if (node.name == "Meteor Skill Tree Shower Radius")
            {
                increasedShowerRadius += node.GetComponent <SkillTreeNode>().pointsAllocated * 0.15f;
                moreDamageInstances.Add(node.GetComponent <SkillTreeNode>().pointsAllocated * 0.15f);
            }
            if (node.name == "Meteor Skill Tree Frequency")
            {
                increasedMeteorFrequency += node.GetComponent <SkillTreeNode>().pointsAllocated * 0.4f;
            }
            if (node.name == "Meteor Skill Tree Line")
            {
                if (node.GetComponent <SkillTreeNode>().pointsAllocated > 0)
                {
                    line = true;
                    increasedManaCost += 0.5f;
                }
            }
            if (node.name == "Meteor Skill Tree Mana Efficiency")
            {
                addedManaCostDivider += node.GetComponent <SkillTreeNode>().pointsAllocated * 0.15f;
            }
        }

        mutator.increasedManaCost           = increasedManaCost;
        mutator.addedManaCostDivider        = addedManaCostDivider;
        mutator.increasedFallSpeed          = increasedFallSpeed;
        mutator.increasedCastSpeed          = increasedCastSpeed;
        mutator.usesAllMana                 = usesAllMana;
        mutator.moreDamageAgainstFullHealth = moreDamageAgainstFullHealth;
        mutator.shrapnelChance              = shrapnelChance;
        mutator.increasedShrapnelSpeed      = increasedShrapnelSpeed;
        mutator.shrapnelPierces             = shrapnelPierces;
        mutator.increasedShrapnelDamage     = increasedShrapnelDamage;
        mutator.moreDamageInstances         = moreDamageInstances;
        mutator.increasedStunChance         = increasedStunChance;
        mutator.additionalMeteors           = additionalMeteors;
        mutator.increasedMeteorFrequency    = increasedMeteorFrequency;
        mutator.increasedShowerRadius       = increasedShowerRadius;
        mutator.line = line;
    }
Example #2
0
    public override GameObject Mutate(GameObject abilityObject, Vector3 location, Vector3 targetLocation)
    {
        // if this is a meteor shower
        if (additionalMeteors > 0)
        {
            Destroy(abilityObject);

            abilityObject = Instantiate(AbilityIDList.getAbility(AbilityID.meteorShower).abilityPrefab);
            abilityObject.transform.position = location;
            CastAtRandomPointAfterDuration meteorCaster = abilityObject.GetComponent <CastAtRandomPointAfterDuration>();
            meteorCaster.duration       /= (1 + increasedMeteorFrequency);
            meteorCaster.remainingCasts += additionalMeteors;
            meteorCaster.radius         *= (1 + increasedShowerRadius);

            if (line)
            {
                StartsAtTarget sat = meteorCaster.GetComponent <StartsAtTarget>();
                if (sat)
                {
                    sat.active = false;
                    Destroy(sat);
                }
                AbilityMover mover = Comp <AbilityMover> .GetOrAdd(abilityObject);

                mover.SetDirection(targetLocation - location);
                mover.speed         = 10 * (1 + increasedShowerRadius);
                meteorCaster.radius = 0;
                StartsTowardsTarget stt = abilityObject.AddComponent <StartsTowardsTarget>();
                stt.distance       = 1f;
                stt.addWeaponRange = false;
            }

            // create a mutator on the meteor shower object
            MeteorMutator newMutator = abilityObject.AddComponent <MeteorMutator>();



            // variables for all damage
            newMutator.moreDamageInstances = moreDamageInstances;

            // meteor variables (except use all mana)
            newMutator.increasedFallSpeed     = increasedFallSpeed;
            newMutator.increasedCastSpeed     = increasedCastSpeed;
            newMutator.shrapnelChance         = shrapnelChance;
            newMutator.increasedShrapnelSpeed = increasedShrapnelSpeed;
            newMutator.shrapnelPierces        = shrapnelPierces;
            newMutator.replaceFireCircle      = replaceFireCircle;

            // aoe variables
            newMutator.moreDamageAgainstFullHealth = moreDamageAgainstFullHealth;
            newMutator.increasedShrapnelDamage     = increasedShrapnelDamage;
            newMutator.increasedStunChance         = increasedStunChance;
            newMutator.moreDamageInstances         = new List <float>();
            newMutator.moreDamageInstances.AddRange(moreDamageInstances);

            // apply mana variable once for all meteors
            if (usesAllMana && myMana)
            {
                float totalCost = myMana.getManaCost(ability);
                totalCost += myMana.currentMana;

                float proportion = totalCost / myMana.maxMana;
                newMutator.moreDamageInstances.Add(proportion * 2);

                myMana.currentMana = 0;
            }

            return(abilityObject);
        }


        // if this is a regular meteor

        // apply aoe variables
        MeteorAoEMutator aoeMutator = abilityObject.AddComponent <MeteorAoEMutator>();

        aoeMutator.moreDamageAgainstFullHealth = moreDamageAgainstFullHealth;
        aoeMutator.increasedStunChance         = increasedStunChance;
        aoeMutator.moreDamageInstances         = new List <float>();
        aoeMutator.moreDamageInstances.AddRange(moreDamageInstances);


        // meteor variables

        if (increasedFallSpeed != 0)
        {
            abilityObject.GetComponent <AbilityMover>().speed *= (1 + increasedFallSpeed);
        }

        MeteorShrapnelMutator shrapnelMutator = null;

        if (shrapnelChance > 0)
        {
            float rand = Random.Range(0f, 1f);
            if (rand < shrapnelChance)
            {
                CreateAbilityObjectOnDeath caood = abilityObject.AddComponent <CreateAbilityObjectOnDeath>();
                caood.abilityToInstantiate = AbilityIDList.getAbility(AbilityID.meteorShrapnel);
                caood.createAtTarget       = true;
                caood.offset    = -caood.GetComponent <LocationDetector>().targetLocationOffset;
                shrapnelMutator = abilityObject.AddComponent <MeteorShrapnelMutator>();
                shrapnelMutator.increasedDamage     = increasedShrapnelDamage;
                shrapnelMutator.increasedSpeed      = increasedShrapnelSpeed;
                shrapnelMutator.pierces             = shrapnelPierces;
                shrapnelMutator.increasedStunChance = increasedStunChance;
                shrapnelMutator.moreDamageInstances = new List <float>();
                shrapnelMutator.moreDamageInstances.AddRange(moreDamageInstances);
            }
        }

        if (replaceFireCircle)
        {
            CreateAtTargetLocationOnCreation component = abilityObject.GetComponent <CreateAtTargetLocationOnCreation>();
            if (component)
            {
                component.objectsToCreate.Clear();
                GameObject prefab = PrefabList.getPrefab("EnemyMeteorCircle");
                if (prefab)
                {
                    CreateAtTargetLocationOnCreation.GameObjectHolder holder = new CreateAtTargetLocationOnCreation.GameObjectHolder();
                    holder.gameObject          = prefab;
                    holder.destroyWhenThisDies = true;
                    component.objectsToCreate.Add((holder));
                }
            }
        }

        if (usesAllMana && myMana)
        {
            float totalCost = myMana.getManaCost(ability);
            totalCost += myMana.currentMana;

            float proportion = totalCost / myMana.maxMana;

            aoeMutator.moreDamageInstances.Add(proportion * 2);
            if (shrapnelMutator)
            {
                shrapnelMutator.moreDamageInstances.Add(proportion * 2);
            }

            myMana.currentMana = 0;
        }


        return(abilityObject);
    }