Example #1
0
    public virtual void DeactivateEquipStatusEffectsForEquipment(Equipment equipment)
    {
        List <EquipStatusEffect> currentEquipStatusEffects = this.gameObject.GetComponents <EquipStatusEffect>().ToList();

        foreach (AggregateStatusEffectMetaData metaData in equipment.statusEffectMetaData)
        {
            if (metaData.statusEffect.activateOnEquip == true)
            {
                EquipStatusEffect currentStatusEffect = currentEquipStatusEffects.Find(x => x.statusEffectName == metaData.statusEffect.statusEffectName);
                if (currentStatusEffect == null)
                {
                    Debug.LogError("Creature.DeactivateEquipStatusEffectsForEquipment: Attempting to deactivate Status Effect " + metaData.statusEffect.statusEffectName + " but it is not currently active on the creature");
                    return;
                }
                currentStatusEffect.level -= metaData.aggregateLevel;
                if (currentStatusEffect.level <= 0)
                {
                    currentStatusEffect.StopStatusEffect();
                    Destroy(currentStatusEffect);
                }
                else
                {
                    currentStatusEffect.UpdateStatusEffect();
                }
            }
        }
    }
Example #2
0
    public virtual void ActivateEquipStatusEffectsForEquipment(Equipment equipment)
    {
        foreach (AggregateStatusEffectMetaData metaData in equipment.statusEffectMetaData)
        {
            if (metaData.statusEffect.activateOnEquip == true)
            {
                List <EquipStatusEffect> currentEquipStatusEffects = this.gameObject.GetComponents <EquipStatusEffect>().ToList();
                EquipStatusEffect        currentStatusEffect       = currentEquipStatusEffects.Find(x => x.statusEffectName == metaData.statusEffect.statusEffectName);

                if (currentStatusEffect != null)
                {
                    currentStatusEffect.level += metaData.aggregateLevel;
                    currentStatusEffect.UpdateStatusEffect();
                }
                else
                {
                    currentStatusEffect = this.gameObject.AddComponent(Type.GetType(metaData.statusEffect.statusEffectName)) as EquipStatusEffect;
                    currentStatusEffect.equipmentType    = equipment.equipmentType;
                    currentStatusEffect.level            = metaData.aggregateLevel;
                    currentStatusEffect.statusEffectName = metaData.statusEffect.statusEffectName;
                    currentStatusEffect.ApplyStatusEffect(this);
                }
            }
        }
    }