Пример #1
0
    /// <summary>
    /// AddEffect adds the effect to the enemy's activeEffects list or just applies the effect if it is on hit
    /// </summary>
    public void AddEffect(IEnemy enemy)
    {
        int enchantIndex;

        switch (enchantType)
        {
        case EnchantType.Bleed:
            enchantIndex = Contains(enemy.ActiveEffects, EnchantType.Bleed);
            if (enchantIndex >= 0)
            {
                if (enemy.ActiveEffects[enchantIndex].strength < maxStack)
                {
                    enemy.UpgradeEffect(enchantIndex, effectDuration);
                }
            }
            else
            {
                enemy.AddEffect(CloneOf(this));
            }
            break;

        case EnchantType.Fire:
            enchantIndex = Contains(enemy.ActiveEffects, EnchantType.Fire);
            if (enchantIndex >= 0)
            {
                if (enemy.ActiveEffects[enchantIndex].strength < maxStack)
                {
                    enemy.UpgradeEffect(enchantIndex, effectDuration);
                }
            }
            else
            {
                enemy.AddEffect(CloneOf(this));
            }
            break;

        case EnchantType.Frost:
            if (!(Contains(enemy.ActiveEffects, EnchantType.Poison) >= 0))
            {
                enemy.AddEffect(CloneOf(this));
            }
            break;

        case EnchantType.Knockback:
            //enemy.Knockback(Irbis.Irbis.jamie.direction, effectValue);
            break;

        case EnchantType.Poison:
            if (uses > 0)
            {
                enchantIndex = Contains(enemy.ActiveEffects, EnchantType.Poison);
                if (enchantIndex >= 0)
                {
                    if (enemy.ActiveEffects[enchantIndex].strength < maxStack)
                    {
                        enemy.UpgradeEffect(enchantIndex, effectDuration);
                    }
                }
                else
                {
                    enemy.AddEffect(CloneOf(this));
                }

                uses--;
            }
            break;

        case EnchantType.Sharpness:
            enemy.Hurt(effectValue);
            break;

        case EnchantType.Stun:
            enemy.Stun(effectDuration);
            break;
        }
    }