Beispiel #1
0
        // returns all the cells affected by the buff at the targeted location
        public List <Cell> getBuffEffectAffectedCells(EffectBuff effect, Entity origin, Cell target)
        {
            int areaType = effect.areaType;
            int minArea  = effect.minArea;
            int maxArea  = effect.maxArea;

            return(grid.getCellsInRange(target, minArea, maxArea, areaType));
        }
Beispiel #2
0
 public static EffectBuff[] buildEffectBuffs(ArrayJSON effects)
 {
     EffectBuff[] output = new EffectBuff[effects.Length];
     for (int i = 0; i < effects.Length; i++)
     {
         output[i] = buildEffectBuff((ObjectJSON)effects[i]);
     }
     return(output);
 }
Beispiel #3
0
 public void resolveBuffEffect(EffectBuff effect, Entity origin, Cell target, string trigger)
 {
     if (areGlobalConditionsValid(effect.conditions))
     {
         if (areOriginConditionsValid(effect.conditions, origin))
         {
             // look if effect is trigered
             Type          effectType    = typeof(EffectBuff);
             FieldInfo     myFieldInfo   = effectType.GetField(trigger);
             EffectHandler effectHandler = (EffectHandler)myFieldInfo.GetValue(effect);
             if (effectHandler != null)
             {
                 foreach (Cell c in getBuffEffectAffectedCells(effect, origin, target))
                 {
                     Entity e = c.currentEntity; // get entity on cell
                     if (e != null)
                     {
                         if (e == origin && effect.affectSelf ||
                             e.teamId != origin.teamId && effect.affectEnemy ||
                             e != origin && e.teamId == origin.teamId && effect.affectAlly)
                         {
                             if (areTargetConditionsValid(effect.conditions, e))
                             {
                                 handleEntityEffect(effectHandler, origin, e);
                             }
                         }
                     }
                     if (effect.affectCell)
                     {
                         handleCellEffect(effectHandler, origin, c);
                     }
                 }
             }
         }
     }
 }
Beispiel #4
0
        public static EffectBuff buildEffectBuff(ObjectJSON effect)
        {
            EffectBuff output = new EffectBuff();

            output.affectAlly         = effect.getBool("affectAlly");
            output.affectEnemy        = effect.getBool("affectEnemy");
            output.affectSelf         = effect.getBool("affectSelf");
            output.affectCell         = effect.getBool("affectCell");
            output.minArea            = effect.getInt("minArea", 0);
            output.maxArea            = effect.getInt("maxArea", 0);
            output.areaType           = SpellData.stringToRangeAreaType(effect.getString("areaType", ""));
            output.onGainedHandler    = buildEffectHandler(effect.getObjectJSON("onGainedHandler"));
            output.onLostHandler      = buildEffectHandler(effect.getObjectJSON("onLostHandler"));
            output.onDamageHandler    = buildEffectHandler(effect.getObjectJSON("onDamageHandler"));
            output.onHealHandler      = buildEffectHandler(effect.getObjectJSON("onHealHandler"));
            output.onSpellHandler     = buildEffectHandler(effect.getObjectJSON("onSpellHandler"));
            output.onBuffedHandler    = buildEffectHandler(effect.getObjectJSON("onBuffedHandler"));
            output.onEnterHandler     = buildEffectHandler(effect.getObjectJSON("onEnterHandler"));
            output.onLeaveHandler     = buildEffectHandler(effect.getObjectJSON("onLeaveHandler"));
            output.onTurnStartHandler = buildEffectHandler(effect.getObjectJSON("onTurnStartHandler"));
            output.onTurnEndHandler   = buildEffectHandler(effect.getObjectJSON("onTurnEndHandler"));
            output.conditions         = buildEffectConditions(effect.getArrayJSON("conditions"));
            return(output);
        }
Beispiel #5
0
    // Use this for initialization
    void Start()
    {
        Active = this;

        EffectDefault         = new Effect();
        AttackManagerDefault  = new AttackManagerPrototype(0.0f, 0.0f, 0, EffectDefault);
        AbilityManagerDefault = new AbilityManagerPrototype(0.0f, 0, AbilityManagerPrototype.TRIGGER.ON_ATTACK, EffectDefault);
        PowerManagerDefault   = new PowerManagerPrototype(0, 0);



        Wall = new TowerPrototype("Wall Tower", 2, null);
        Wall._powerManagerPrototype.SetCanRecieve(false);

        // Rock Launcher
        {
            int[] Damage        = { 31, 96, 224, 448, 960, 1680 };      // Would prefer using a function to generate.
            int   BasePrice     = 10;
            int   BasePower     = 50;
            int   BasePowerRate = 10;
            for (int z = 0; z < 6; z++)
            {
                // Create a Effectdamage, and a projectile to deliver it.
                ProjectilePrototype projectilePrototype = new ProjectilePrototype(9.0f, new EffectDamage(Damage [z], true), SpriteProjectileCannon);

                // Make an EffectProjectile to throw said projectile
                Effect effectCreateProjectile = new EffectProjectile(projectilePrototype, false);
                int    level = z + 1;
                // Make a TowerPrototype
                Cannon [z] = new TowerPrototype("Rock Launcher " + level, (int)LevelScale(level, BasePrice), SpriteTurretCannon);
                // Attach an AttackManagerPrototype to throw that effect, also display the damage.
                Cannon [z]._attackManagerPrototype = new AttackManagerPrototype(5.0f, 3.0f, Damage [z], effectCreateProjectile);

                // Attack a SpellManager.
                Effect effectOverclockAdd    = new EffectMutableStat(Tower.ATTACK_SPEED, "overclock", 4.0f, true);
                Effect effectOverclockRemove = new EffectMutableStat(Tower.ATTACK_SPEED, "overclock", false);
                Effect effectAddbuff         = new EffectBuff(new BuffPrototype(effectOverclockAdd, effectOverclockRemove, EffectDefault, 5.0f, 0f, true, "Overclock"), EffectBuff.TARGET.SELF, false);

                Cannon[z]._abilityManagerPrototype = new AbilityManagerPrototype(5.0f, (int)LevelScale(level, 25), AbilityManagerPrototype.TRIGGER.CONSTANT, effectAddbuff, "Overclock", "+300% Attack Speed");
                // (float iCooldown, int iEnergyCost, TRIGGER iTrigger, int iDamageDisplay, Effect iEffect)
                // (5.0f, 25, TRIGGER.ON_ATTACK, -1, new EFFECT(Apply Buff self -cooldown, 5 second, something),"Overclock");


                // Attach a PowerManagerPrototype as well, to supply power.
                Cannon [z]._powerManagerPrototype = new PowerManagerPrototype((int)LevelScale(level, BasePower), (int)LevelScale(level, BasePowerRate));
            }

            for (int z = 0; z < 5; z++)
            {
                Cannon [z].SetUpgradesTo(Cannon [z + 1]);
            }
        }


        {
            // Poison Tower
            int[] Damage        = { 20, 53, 107, 196, 341, 567 };
            int[] AbilityDamage = { 33, 156, 489, 1306, 3218, 7560 };
            int   BasePrice     = 20;
            int[] Power         = { 150, 400, 900, 1700, 3300, 6400 };
            int[] PowerCost     = { 40, 115, 250, 500, 980, 1890 };   //{ 40,113,248,500,979,1890 };
            int[] PowerRate     = { 28, 75, 165, 333, 653, 1260 };
            for (int z = 0; z < 6; z++)
            {
                // Create a Effectdamage, and a projectile to deliver it.
                ProjectilePrototype projectilePrototype = new ProjectilePrototype(5.0f, new EffectDamage(Damage[z], true), SpriteProjectilePoison);

                BuffPrototype       buff = new BuffPrototype(new EffectDamage(AbilityDamage[z], false), EffectDefault, new EffectDamage(AbilityDamage[z] / 10, false), 15.1f, 1.0f, true, "Poison");
                ProjectilePrototype abilityProjectilePrototype = new ProjectilePrototype(9.0f, new EffectBuff(buff, EffectBuff.TARGET.RUNNER, true), SpriteAbilityProjectilePoison);

                // Make an EffectProjectile to throw said projectile
                Effect effect        = new EffectProjectile(projectilePrototype, false);
                Effect effectAbility = new EffectProjectile(abilityProjectilePrototype, false);
                int    level         = z + 1;
                // Make a TowerPrototype
                Poison[z] = new TowerPrototype("Posion Tower " + level, (int)LevelScale(level, BasePrice), SpriteTurretPoison);

                // Attach an AttackManagerPrototype to throw that effect, also display the damage.
                Poison[z]._attackManagerPrototype = new AttackManagerPrototype(3.5f, 0.4f, Damage [z], effect);


                // Attach a SpellManager.
                Poison[z]._abilityManagerPrototype = new AbilityManagerPrototype(
                    3.0f, PowerCost[z],
                    AbilityManagerPrototype.TRIGGER.ON_ATTACK,
                    effectAbility,
                    "Poison",
                    AbilityDamage[z] + "damage + " + (AbilityDamage[z] / 10) + "dps for 15sec"
                    );



                // Attach a PowerManagerPrototype as well, to supply power.
                Poison [z]._powerManagerPrototype = new PowerManagerPrototype(Power[z], LevelScale(level, PowerRate[z]));
            }
            for (int z = 0; z < 5; z++)
            {
                Poison [z].SetUpgradesTo(Poison [z + 1]);
            }
        }


        {
            // Slow Tower
            int[]   Damage        = { 20, 53, 107, 196, 341, 567 };
            int[]   AbilityDamage = { 33, 156, 489, 1306, 3218, 7560 }; // Huh, Poison and Frost have same damage. Well, sort of.
            int     BasePrice     = 15;
            int[]   Power         = { 90, 225, 450, 843, 1551, 2835 };
            int[]   PowerCost     = { 18, 45, 105, 500, 979, 1890 };
            int[]   PowerRate     = { 30, 75, 150, 281, 517, 945 };
            float[] AbilityRange  = { 0.25f, 0.375f, 0.5f, 0.625f, 0.75f, 0.875f }; // A guess, Revamp later.
            float[] Duration      = { 2f, 4f, 7f, 11f, 16f, 21f };
            for (int z = 0; z < 6; z++)
            {
                // Create a Effectdamage, and a projectile to deliver it.
                ProjectilePrototype projectilePrototype = new ProjectilePrototype(5.0f, new EffectDamage(Damage[z], true), SpriteProjectileFrost);

                Effect effectBuffAdd       = new EffectMutableStat(Runner.MOVEMENT_SPEED, "slow", 0.5f, true);
                Effect effectBuffRemove    = new EffectMutableStat(Runner.MOVEMENT_SPEED, "slow", false);
                Effect effectAddBuff       = new EffectBuff(new BuffPrototype(effectBuffAdd, effectBuffRemove, EffectDefault, Duration[z], 0f, true, "slow"), EffectBuff.TARGET.RUNNER, false);
                Effect effectAOE           = new EffectSplash(effectAddBuff, AbilityRange[z], Effect.TARGET.RUNNER, false);
                Effect effectAbilityDamage = new EffectDamage(AbilityDamage[z], true);
                Effect effectFork          = new EffectFork(effectAOE, effectAbilityDamage, EffectDefault, EffectDefault);
                // Need splash effect and fork effect for this to work correctly.
                // On Impact, call Fork. Damage Target, and AOE on Target ->Apply Debuff
                ProjectilePrototype abilityProjectilePrototype = new ProjectilePrototype(9.0f, effectFork, SpriteAbilityProjectileFrost);

                // Make an EffectProjectile to throw said projectile
                Effect effect        = new EffectProjectile(projectilePrototype, false);
                Effect effectAbility = new EffectProjectile(abilityProjectilePrototype, false);
                int    level         = z + 1;
                // Make a TowerPrototype
                Frost[z] = new TowerPrototype("Frost Tower " + level, (int)LevelScale(level, BasePrice), SpriteTurretFrost);

                // Attach an AttackManagerPrototype to throw that effect, also display the damage.
                Frost[z]._attackManagerPrototype = new AttackManagerPrototype(3.5f, 1f, Damage[z], effect);


                // Attach a SpellManager.
                Frost[z]._abilityManagerPrototype = new AbilityManagerPrototype(
                    1.0f, PowerCost[z],
                    AbilityManagerPrototype.TRIGGER.ON_ATTACK,
                    effectAbility,
                    "Slow",
                    "50% Slow for " + Duration[z] + "sec"
                    );



                // Attach a PowerManagerPrototype as well, to supply power.
                Frost[z]._powerManagerPrototype = new PowerManagerPrototype(Power[z], LevelScale(level, PowerRate[z]));
            }
            for (int z = 0; z < 5; z++)
            {
                Frost[z].SetUpgradesTo(Frost[z + 1]);
            }
        }

        {
            // Pyro Trap -- NYA
            int   BasePrice     = 25;
            int[] Damage        = { 2, 5, 11, 24, 51, 105 };
            int[] AbilityDamage = { 450, 1443, 3594, 8220, 18135, 39375 };
            float Range         = 1.5f;
            float AbilityRange  = 1.75f;
            int[] Power         = { 200, 600, 2000, 4000, 8000, 20000 };
            int[] PowerCost     = { 113, 356, 875, 1968, 4360, 9450 };
            int[] PowerRate     = { 25, 80, 194, 441, 967, 2100 };
            for (int z = 0; z < 6; z++)
            {
                int level = z + 1;

                // Create a Splash effect that Applies a damage over time buff.
                EffectDamage initialDamage  = new EffectDamage(AbilityDamage[z], false);
                EffectDamage periodicDamage = new EffectDamage(AbilityDamage[z] / 20, false);

                BuffPrototype buff = new BuffPrototype(initialDamage, EffectDefault, periodicDamage, 10.1f, 1.0f, true, "Pyro", "On Fire");

                EffectBuff   dotEffect    = new EffectBuff(buff, Effect.TARGET.RUNNER, false);
                EffectSplash splashEffect = new EffectSplash(dotEffect, AbilityRange, Effect.TARGET.RUNNER, false);

                // Create a direct damage effect.
                EffectDamage attackDamage = new EffectDamage(Damage[z], false);


                // Make a TowerPrototype
                Pyro[z] = new TowerPrototype("Pyro Trap " + level, (int)LevelScale(level, BasePrice), null);

                // Attach an AttackManagerPrototype to throw that effect, also display the damage.
                Pyro[z]._attackManagerPrototype = new AttackManagerPrototype(Range, 1.0f, Damage [z], attackDamage);


                // Attack a SpellManager.
                Pyro[z]._abilityManagerPrototype = new AbilityManagerPrototype(
                    8.5f, PowerCost[z],
                    AbilityManagerPrototype.TRIGGER.ON_ATTACK,
                    splashEffect,
                    "Firestorm",
                    AbilityDamage[z] + "damage + " + (AbilityDamage[z] / 20) + "dps for 10sec in Range"
                    );



                // Attach a PowerManagerPrototype as well, to supply power.
                Pyro [z]._powerManagerPrototype = new PowerManagerPrototype(Power[z], LevelScale(level, PowerRate[z]));
            }

            for (int z = 0; z < 5; z++)
            {
                Pyro [z].SetUpgradesTo(Pyro [z + 1]);
            }
        }

        {
            // Flame Tower
            int   BaseDamage    = 36;//	  { 36, 108, 252,  540, 1116, 2268 };
            int[] AbilityDamage = { 48, 135, 294, 585, 1116, 2079 };
            int   BasePrice     = 20;
            int[] Power         = { 120, 300, 720, 1440, 3000, 6600 };
            int   BasePowerCost = 15;
            int   BasePowerRate = 40;
            for (int z = 0; z < 6; z++)
            {
                int level = z + 1;

                // Create a Effectdamage, and a projectile to deliver it.
                ProjectilePrototype projectilePrototype        = new ProjectilePrototype(5.0f, new EffectDamage(LevelScale(level, BaseDamage), true), SpriteProjectileFlame);
                ProjectilePrototype abilityProjectilePrototype = new ProjectilePrototype(5.0f, new EffectDamage(LevelScale(level, BaseDamage) + AbilityDamage[z], true), SpriteAbilityProjectileFlame);



                // Make an EffectProjectile to throw said projectile
                Effect effect        = new EffectProjectile(projectilePrototype, false);
                Effect effectAbility = new EffectProjectile(abilityProjectilePrototype, false);
                // Make a TowerPrototype
                Flame[z] = new TowerPrototype("Flame Tower " + level, LevelScale(level, BasePrice), SpriteTurretFlame);

                // Attach an AttackManagerPrototype to throw that effect, also display the damage.
                Flame[z]._attackManagerPrototype = new AttackManagerPrototype(3.0f, 0.75f, LevelScale(level, BaseDamage), effect);


                // Attack a SpellManager.
                Flame[z]._abilityManagerPrototype = new AbilityManagerPrototype(
                    0.75f, (int)LevelScale(level, BasePowerCost),
                    AbilityManagerPrototype.TRIGGER.ON_ATTACK_OVERRIDE,
                    effectAbility,
                    "Ignite",
                    AbilityDamage[z] + " bonus damage."
                    );



                // Attach a PowerManagerPrototype as well, to supply power.
                Flame [z]._powerManagerPrototype = new PowerManagerPrototype(Power[z], (int)LevelScale(level, BasePowerRate));
            }

            for (int z = 0; z < 5; z++)
            {
                Flame [z].SetUpgradesTo(Flame [z + 1]);
            }
        }

        {
            // Lightning Tower
            // Temperarlly a rapid-fire attack tower because no lightning effect yet.
            int BaseDamage        = 3;
            int BaseAbilityDamage = 9;            //90;
            int BasePrice         = 10;
            int BasePower         = 160;
            int BasePowerCost     = 2;        //20;
            int BasePowerRate     = 40;
            for (int z = 0; z < 6; z++)
            {
                int level = z + 1;

                // Create a Effectdamage, and a projectile to deliver it.
                ProjectilePrototype projectilePrototype        = new ProjectilePrototype(5.0f, new EffectDamage(LevelScale(level, BaseDamage), true), SpriteProjectileLightning);
                ProjectilePrototype abilityProjectilePrototype = new ProjectilePrototype(8.0f, new EffectDamage(LevelScale(level, BaseAbilityDamage), true), SpriteAbilityProjectileLightning);



                // Make an EffectProjectile to throw said projectile
                Effect effect        = new EffectProjectile(projectilePrototype, false);
                Effect effectAbility = new EffectProjectile(abilityProjectilePrototype, false);
                // Make a TowerPrototype
                Lightning[z] = new TowerPrototype("Lightning Tower " + level, LevelScale(level, BasePrice), SpriteTurretLightning);

                // Attach an AttackManagerPrototype to throw that effect, also display the damage.
                Lightning[z]._attackManagerPrototype = new AttackManagerPrototype(3.0f, 1f, LevelScale(level, BaseDamage), effect);


                // Attack a SpellManager.
                Lightning[z]._abilityManagerPrototype = new AbilityManagerPrototype(
                    0.1f, LevelScale(level, BasePowerCost),
                    AbilityManagerPrototype.TRIGGER.ON_ATTACK_OVERRIDE,
                    effectAbility,
                    "Lightning",
                    LevelScale(level, BaseAbilityDamage) + " damage."
                    );



                // Attach a PowerManagerPrototype as well, to supply power.
                Lightning [z]._powerManagerPrototype = new PowerManagerPrototype(LevelScale(level, BasePower), (int)LevelScale(level, BasePowerRate));
            }

            for (int z = 0; z < 5; z++)
            {
                Lightning [z].SetUpgradesTo(Lightning [z + 1]);
            }
        }

        {
            // Generator
            int BasePrice           = 5;
            int BasePowerGeneration = 5;
            int BasePowerRate       = 10;
            int BasePowerCap        = 250;

            for (int z = 0; z < 6; z++)
            {
                int level = z + 1;

                Generator [z] = new TowerPrototype("Generator " + level, (int)LevelScale(level, BasePrice), SpriteGenerator);

                // Attach a PowerManagerPrototype as well, to supply power.
                Generator [z]._powerManagerPrototype = new PowerManagerPrototype((int)LevelScale(level, BasePowerCap), (int)LevelScale(level, BasePowerRate));

                Generator[z]._powerManagerPrototype.SetPassiveProduction(LevelScale(level, BasePowerGeneration));
                Generator[z]._powerManagerPrototype.SetCanSend(true);
            }

            for (int z = 0; z < 5; z++)
            {
                Generator [z].SetUpgradesTo(Generator [z + 1]);
            }
        }

        {
            // Transfer Tower
            int BasePrice     = 3;
            int BasePowerRate = 30;
            int BasePowerCap  = 300;

            for (int z = 0; z < 6; z++)
            {
                int level = z + 1;

                Transfer [z] = new TowerPrototype("Transfer Tower " + level, (int)LevelScale(level, BasePrice), SpriteTransfer);

                // Attach a PowerManagerPrototype as well, to supply power.
                Transfer [z]._powerManagerPrototype = new PowerManagerPrototype(((int)Mathf.Pow(3, level - 1) * BasePowerCap), ((int)Mathf.Pow(3, level - 1) * BasePowerRate));

                Transfer[z]._powerManagerPrototype.SetCanSend(true);
                Transfer[z]._powerManagerPrototype.SetCanSendLong(true);
            }

            for (int z = 0; z < 5; z++)
            {
                Transfer [z].SetUpgradesTo(Transfer [z + 1]);
            }
        }
    }