/// <summary> /// Initialize the status effect via constructor. /// </summary> /// <param name="data">Reference to Scriptable status effects which storing data about the status effect.</param> /// <param name="target">Target which has applied this status effect.</param> /// <param name="caster">Caster which casted the status effect.</param> protected StatusEffect(ScriptableStatusEffect data, Character target, Character caster) { Data = data; Target = target; Caster = caster; DurationTimer = Data.Duration; _startDelayTimer = Data.StartActivationDelay; _repeatTimer = Data.RepeatTime; _isAlreadyActivated = false; _isAlreadyDelayActivated = false; }
/// <summary> /// Apply a new status effect to a list of other effects which are already applied. /// </summary> /// <param name="target">Target who will get a new status effect.</param> /// <param name="caster">Caster who applied status effect on the target. Can be NULL.</param> /// <param name="newScriptableStatusEffect">New scriptable status effect to be applied.</param> /// <returns>TRUE: Status effect has been applied!</returns> public bool ApplyStatusEffect(Character target, Character caster, ScriptableStatusEffect newScriptableStatusEffect) { if (target == null || newScriptableStatusEffect == null) { Debug.unityLogger.Log(LogType.Error, "Null reference for adding a new status effect!"); return(false); } if (target.IsStatusEffectImmune) { return(false); } // Get status effect. StatusEffect newStatusEffect = newScriptableStatusEffect.Initialize(target, caster); bool typeOccurrence = target.AppliedStatusEffects.Exists(item => item.Data.GetType() == newScriptableStatusEffect.GetType()); bool effectOccurrence = target.AppliedStatusEffects.Exists(item => item.Data == newScriptableStatusEffect); // Overwrite the status effect if there are some of the same type already in. if (newStatusEffect.Data.OverwriteTheSameTypes && typeOccurrence) { RemoveStatusEffect(target, caster, newScriptableStatusEffect, false, RemoveMethod.RemoveAllOfTheSameType); } // Overwrite the status effect if there are some of the same effect already in. else if (newStatusEffect.Data.OverwriteTheSameEffects && effectOccurrence) { RemoveStatusEffect(target, caster, newScriptableStatusEffect, false, RemoveMethod.RemoveAllOfTheSameEffect); } // Don't let it create a new status effect of the same effect if the status effect is not stackable and there is already one in. else if (!newStatusEffect.Data.IsStackable && effectOccurrence) { return(false); } Debug.unityLogger.LogFormat(LogType.Log, "[{0}] Status effect ({1}) applied!", target.Name, newStatusEffect); target.AppliedStatusEffects.Add(newStatusEffect); return(true); }
public AuraEffect(ScriptableStatusEffect data, Character target, Character caster) : base(data, target, caster) { }
public SpecialItemBombReplicator(ScriptableStatusEffect data, Character target, Character caster) : base(data, target, caster) { }
public ImmobileSlide(ScriptableStatusEffect data, Character target, Character caster) : base(data, target, caster) { }
public SpecialItemSlowingDoom(ScriptableStatusEffect data, Character target, Character caster) : base(data, target, caster) { }
public SpecialItemBanana(ScriptableStatusEffect data, Character target, Character caster) : base(data, target, caster) { }
/// <summary> /// Manually removes selected status effect/s. /// </summary> /// <param name="target">Target who will get a new status effect.</param> /// <param name="caster">Caster who applied status effect on the target. Can be NULL.</param> /// <param name="scriptableStatusEffect">New scriptable status effect to be applied.</param> /// <param name="isCasterImportant">Should the caster be added to filter for removation method?</param> /// <param name="method">Method of the removation.</param> public void RemoveStatusEffect(Character target, Character caster, ScriptableStatusEffect scriptableStatusEffect, bool isCasterImportant, RemoveMethod method) { if (target == null || scriptableStatusEffect == null) { Debug.unityLogger.Log(LogType.Error, "Null reference for removing a status effect!"); return; } // Remove all status effects of the same type. if (method == RemoveMethod.RemoveAllOfTheSameType) { target.AppliedStatusEffects.RemoveAll(delegate(StatusEffect item) { if (item.Data.GetType() != scriptableStatusEffect.GetType()) { return(false); } if (isCasterImportant) { if (item.Caster != caster) { return(false); } } item.ForceEnd(); Debug.unityLogger.LogFormat(LogType.Log, "[{0}] Status effect ({1}) removed!", target.Name, item); return(true); }); } // Remove all effects of the same effect. else if (method == RemoveMethod.RemoveAllOfTheSameEffect) { target.AppliedStatusEffects.RemoveAll(delegate(StatusEffect item) { if (item.Data != scriptableStatusEffect) { return(false); } if (isCasterImportant) { if (item.Caster != caster) { return(false); } } item.ForceEnd(); Debug.unityLogger.LogFormat(LogType.Log, "[{0}] Status effect ({1}) removed!", target.Name, item); return(true); }); } // Remove only the first occured status effect. else if (method == RemoveMethod.RemoveTheFirst) { target.AppliedStatusEffects.Remove(target.AppliedStatusEffects.First(delegate(StatusEffect item) { if (item.Data != scriptableStatusEffect) { return(false); } if (isCasterImportant) { if (item.Caster != caster) { return(false); } } item.ForceEnd(); Debug.unityLogger.LogFormat(LogType.Log, "[{0}] Status effect ({1}) removed!", target.Name, item); return(true); })); } }
public SwapControls(ScriptableStatusEffect data, Character target, Character caster) : base(data, target, caster) { }
public SwapPositions(ScriptableStatusEffect data, Character target, Character caster) : base(data, target, caster) { }
public MoveSpeedIncrease(ScriptableStatusEffect data, Character target, Character caster) : base(data, target, caster) { }
public SpecialItemRealityShifter(ScriptableStatusEffect data, Character target, Character caster) : base(data, target, caster) { }
public Invulnerability(ScriptableStatusEffect data, Character target, Character caster) : base(data, target, caster) { _isVisible = true; }