public static void poisonOnHit(Collider2D other, ref float damageAmount) { if (Random.value <= poisonChance) { StatusEffect_Poison poisonEffect = other.gameObject.GetComponent <StatusEffect_Poison>(); if (poisonEffect == null) { other.gameObject.AddComponent <StatusEffect_Poison> (); } } }
public void AddEffect(int effectType, float duration, int value = -1) { StatusEffectType type = (StatusEffectType)effectType; for (int i = 0; i < activeEffects.Count; i++) { if (activeEffects[i].type == type) { activeEffects[i].Refresh(); return; } } StatusEffect newEffect = null; switch (type) { case StatusEffectType.Bleed: newEffect = new StatusEffect_Bleed(); break; case StatusEffectType.Slow: newEffect = new StatusEffect_Slow(); break; case StatusEffectType.ArmorBreak: newEffect = new StatusEffect_ArmorBreak(); break; case StatusEffectType.WeaponBreak: newEffect = new StatusEffect_WeaponBreak(); break; case StatusEffectType.Poison: newEffect = new StatusEffect_Poison(); break; } newEffect.Initialise(myEntity, duration, value); activeEffects.Add(newEffect); OnEffectStarted(type); }