public override void ApplyEffect() { // get the base stat value of the user of this effect int baseValue = 0; if (StatBase != 0) // prevents people forgetting to give a stat base name { IHasStats owner = Source.GetOwner().GetComponent <IHasStats>(); if (owner != null) { owner.TryGetStatValue(StatBase, out baseValue); // prevents the case where the statname doesn't exist } } // apply effect to target IHasTargetEffects targetSource = Source as IHasTargetEffects; if (targetSource != null) { if (targetSource.GetTarget() != null) { IHasStats target = targetSource.GetTarget().GetComponent <IHasStats> (); if (target != null) { target.ModifyStat(StatBase, TargetStat, Modifier, FlatValue, baseValue); } } } }
public override void ApplyEffect() { // get the base stat value of the user of this effect int baseValue = 0; if (StatBase != "") // prevents people forgetting to give a stat base name { IHasStats owner = Source.GetOwner().GetComponent <IHasStats>(); if (owner != null) { owner.TryGetStatValue(StatBase, out baseValue); // prevents the case where the statname doesn't exist } } // get source as a targettable source IHasTargetEffects targetSource = Source as IHasTargetEffects; if (targetSource == null) { return; } // get source owner IHasPerception perceptionOwner = Source.GetOwner().GetComponent <IHasPerception>(); if (perceptionOwner == null) { return; } // for each found percept, if the tag is inside the target type mask, process foreach (var percept in perceptionOwner.Perception.Percepts.Values) { IPerceivable perceivable = percept.Entity.GetComponent <IPerceivable>(); if (perceivable != null && ((perceivable.Tag & TargetType) != 0) && (Vector3.Magnitude(percept.Entity.transform.position - targetSource.GetTarget().transform.position) <= Radius)) { if (percept.Entity != targetSource.GetTarget() || IncludeTarget) { IHasStats target = percept.Entity.GetComponent <IHasStats> (); if (target != null) { target.ModifyStat(TargetStat, Modifier, FlatValue, baseValue); } } } } }
public override void ApplyEffect() { Debug.Log("applying room wide stat effect"); // get the base stat value of the user of this effect int baseValue = 0; if (StatBase != "") // prevents people forgetting to give a stat base name { IHasStats owner = Source.GetOwner().GetComponent <IHasStats>(); if (owner != null) { owner.TryGetStatValue(StatBase, out baseValue); // prevents the case where the statname doesn't exist } } // if the owner doesn't have a perception component, it sees nothing basically, nothing can be affected IHasPerception perceptionOwner = Source.GetOwner().GetComponent <IHasPerception>(); if (perceptionOwner == null) { return; } // for each found percept, if the tag is inside the target type mask, process foreach (var percept in perceptionOwner.Perception.Percepts.Values) { IPerceivable perceivable = percept.Entity.GetComponent <IPerceivable>(); if (perceivable != null && ((perceivable.Tag & TargetType) != 0)) { if (percept.Entity != Source.GetOwner() || IncludeSelf) { // this effect should only apply to perceivable that has stats component IHasStats target = percept.Entity.GetComponent <IHasStats> (); if (target != null) { target.ModifyStat(TargetStat, Modifier, FlatValue, baseValue); } } } } }
/// <summary> /// called when a skill is used on the stat owner /// </summary> public void ApplyPrerequisite(IHasStats affected) { affected.ModifyStat(StatName, -StatValue); }