public void RemoveTrackedMod(StatType type, StatModifier mod, GameObject cause, params StatModifierOption[] statOptions) { List <StatModifierOption> options = ConvertStatOptionsToList(statOptions); BaseStat targetStat = GetStat(type); if (targetStat == null) { Debug.Log("Stat: " + type + " not found"); return; } if (options.Contains(StatModifierOption.Cap)) { CappedStat capped = TryConvertToCappedStat(targetStat); if (capped != null) { capped.RemoveCapModifier(mod); OnStatChanged(type, cause); } } if ((options.Count < 1 || options.Contains(StatModifierOption.Base))) { targetStat.RemoveModifier(mod); OnStatChanged(type, cause); } }
private void OnStatChanged(BaseStat.StatType stat, GameObject source) { if (stat == BaseStat.StatType.MoveSpeed) { maxSpeed = ProjectileStats.GetStatModifiedValue(BaseStat.StatType.MoveSpeed); } }
private void OnStatChanged(StatType type, GameObject cause) { if (onStatChanged != null) { onStatChanged(type, cause); } }
private StatAdjustment(StatCollection source, StatCollection target, StatType statType, params StatModifierOption[] options) { this.source = source; this.target = target; this.statType = statType; this.adjustmentOptions = options; }
public void ApplyPermanentMod(StatType type, float value, StatModificationType modType, GameObject cause, params StatModifierOption[] statOptions) { List <StatModifierOption> options = ConvertStatOptionsToList(statOptions); BaseStat targetStat = GetStat(type); if (targetStat == null) { Debug.LogError("Stat: " + type + " not found"); return; } if (options.Contains(StatModifierOption.Cap)) { CappedStat capped = TryConvertToCappedStat(targetStat); if (capped != null) { capped.ModifyCapPermanently(value, modType); OnStatChanged(type, cause); } } if ((options.Count < 1 || options.Contains(StatModifierOption.Base))) { targetStat.ModifyStatPermanently(value, modType); OnStatChanged(type, cause); } }
public StatModifier ApplyAndReturnTrackedMod(StatType type, float value, StatModificationType modType, GameObject cause, params StatModifierOption[] statOptions) { StatModifier newMod = new StatModifier(value, modType); ApplyTrackedMod(type, newMod, cause, statOptions); return(newMod); }
public float GetCappedStatRatio(StatType type) { BaseStat targetStat = GetStat(type); //Debug.Log("trying to get the stat ratio for " + type); CappedStat cap = TryConvertToCappedStat(targetStat); if (cap != null) { //Debug.Log(type + " has a ratio of " + cap.Ratio); return(cap.Ratio); } //if (targetStat != null && targetStat is CappedStat) { // CappedStat capped = targetStat as CappedStat; // return capped.Ratio; //} Debug.LogError("The ratio value was reqested for a stat with no max. Returning 0"); return(0f); }
private void OnStatChanged(BaseStat.StatType type, GameObject source) { if (type == BaseStat.StatType.CoolDown) { coolDownTimer.SetNewDuration(Stats.GetStatModifiedValue(BaseStat.StatType.CoolDown)); } }
//public void UpdateHealth() //{ // if (Health <= 0f && dying == false && cheat == false) // { // Die(); // } //} public void OnStatChanged(EventData data) { GameObject target = data.GetGameObject("Target"); BaseStat.StatType stat = (BaseStat.StatType)data.GetInt("Stat"); float value = data.GetFloat("Value"); //Debug.Log(target.name + " " + stat + " " + value); if (target != Owner.gameObject) { return; } if (stat != BaseStat.StatType.Health) { return; } if (value < 0f) { Owner.AnimHelper.PlayAnimTrigger("Flinch"); } //Debug.Log(Health + " is the current health of " + Owner.gameObject.name); if (Health <= 0f && dying == false && cheat == false) { Die(); } }
public void ResetStat(StatType type, params StatModifierOption[] statOptions) { List <StatModifierOption> options = ConvertStatOptionsToList(statOptions); BaseStat targetStat = GetStat(type); if (targetStat == null) { Debug.Log("Stat: " + type + " not found"); return; } if (options.Contains(StatModifierOption.Cap)) { CappedStat capped = TryConvertToCappedStat(targetStat); if (capped != null) { capped.ResetCap(); OnStatChanged(type, null); } } if ((options.Count < 1 || options.Contains(StatModifierOption.Base))) { targetStat.Reset(); OnStatChanged(type, null); } }
private static bool ValidateOnStatChanged(EventData data, AbilityActivationInfo activator, Ability ability) { //bool result = false; BaseStat.StatType stat = (BaseStat.StatType)data.GetInt("Stat"); GameObject target = data.GetGameObject("Target"); //GameObject cause = data.GetGameObject("Cause"); float value = data.GetFloat("Value"); if (activator.targetstat != stat) { return(false); } switch (activator.gainedOrLost) { case EffectConstraint.GainedOrLost.Gained: if (value <= 0) { return(false); } break; case EffectConstraint.GainedOrLost.Lost: if (value >= 0) { return(false); } break; } switch (activator.statChangeTarget) { case EffectConstraint.TargetConstraintType.Ally: if (target.IsSelfOrAlly(ability.Source) == false) { return(false); } break; case EffectConstraint.TargetConstraintType.Enemy: if (target.IsSelfOrAlly(ability.Source) == true) { return(false); } break; case EffectConstraint.TargetConstraintType.SelfOnly: if (target != ability.Source) { return(false); } break; } return(true); }
public StatAdjustmentInfo(float adjValue, BaseStat.StatType targetStat, StatModifier.StatModificationType modType, List <StatCollection.StatModifierOption> options, bool permanent) { this.adjustmentValue = adjValue; this.targetStat = targetStat; this.modType = modType; this.permanent = permanent; this.options = options; }
private void OnStatChanged(BaseStat.StatType type, GameObject cause) { //Local Event //Global Event //EventData data = new EventData(); //data.AddInt("Type", (int)type); //data.AddGameObject("Target", this.gameObject); //data.AddGameObject("Cause", cause); //EventGrid.EventManager.SendEvent(Constants.GameEvent.StatChanged, data); }
public void RemoveStat(StatType type) { BaseStat targetStat = GetStat(type); if (targetStat == null) { Debug.Log("Stat: " + type + " not found"); return; } RemoveStat(targetStat); }
//public StatusStatAdjustment(StatusInfo info, StatAdjustmentInfo adjInfo, float duration, float interval ) : base (info, duration, interval) //{ // StatAdjSetup(adjInfo); //} private void StatAdjSetup(StatAdjustmentInfo adjInfo) { this.baseAdjustmentvalue = adjInfo.adjustmentValue; this.adjValue = adjInfo.adjustmentValue; this.targetStat = adjInfo.targetStat; this.modType = adjInfo.modType; this.permanent = adjInfo.permanent; this.options = adjInfo.options.ToArray(); //mod = new StatModifier(adjValue, modType); Tick(); }
private void UpdateNavAgent(BaseStat.StatType type) { switch (type) { case BaseStat.StatType.MoveSpeed: navAgent.speed = Stats.GetStatModifiedValue(BaseStat.StatType.MoveSpeed); break; case BaseStat.StatType.RotateSpeed: navAgent.angularSpeed = Stats.GetStatModifiedValue(BaseStat.StatType.RotateSpeed); break; } }
public static void SendStatChangeEvent(GameObject source, GameObject target, StatType stat, float value) { EventData data = new EventData(); data.AddGameObject("Cause", source); data.AddGameObject("Target", target); data.AddInt("Stat", (int)stat); data.AddFloat("Value", value); EventGrid.EventManager.SendEvent(Constants.GameEvent.StatChanged, data); Debug.Log(source.name + " has altered " + stat + " on " + target.name + " by " + value); }
private BaseStat GetStat(StatType type) { int count = stats.Count; for (int i = 0; i < count; i++) { if (stats[i].Type == type) { return(stats[i]); } } return(null); }
public static void SendStatChangeEvent(GameObject source, GameObject target, StatType stat, float value) { EventData data = new EventData(); data.AddGameObject("Cause", source); data.AddGameObject("Target", target); data.AddInt("Stat", (int)stat); data.AddFloat("Value", value); EventGrid.EventManager.SendEvent(Constants.GameEvent.StatChanged, data); if (stat == StatType.Health && target != null) { VisualEffectLoader.MakeFloatingText(value.ToString(), target.transform.position); //Debug.Log(source.name + " has altered " + stat + " on " + target.name + " by " + value); } }
private void OnStatChanged(EventData data) { GameObject target = data.GetGameObject("Target"); BaseStat.StatType type = (BaseStat.StatType)data.GetInt("Stat"); if (target != owner.gameObject) { return; } if (type != BaseStat.StatType.AttackSpeed) { return; } UpdateAttackFloat(); }
public float GetStatMaxValue(StatType type) { BaseStat targetStat = GetStat(type); CappedStat cap = TryConvertToCappedStat(targetStat); if (cap != null) { return(cap.MaxValue); } //if(targetStat != null && targetStat is CappedStat) { // CappedStat capped = targetStat as CappedStat; // return capped.MaxValue; //} Debug.LogError("The maximum value was reqested for a stat with no max. Returning 0"); return(0f); }
public float GetStatBaseValue(StatType type) { BaseStat targetStat = GetStat(type); return(targetStat != null ? targetStat.BaseValue : 0f); }
//public void BuffStat(BaseStat stat) //{ // FindStat(stat.Type).Buff(stat.FinalValue); //} public void RemoveBuffStat(BaseStat.StatType type, int value) { FindStat(type).RemoveBuff(value); }
public BaseStat FindStat(BaseStat.StatType type) { return(Stats.Find(stat => stat.Type == type)); }
private void OnStatChanged(BaseStat.StatType type, GameObject cause) { }
public void AddStat(StatType type, float value, float maxValue) { CappedStat newCappedStat = new CappedStat(type, value, maxValue); AddStat(newCappedStat); }
public static void ApplyUntrackedStatMod(StatCollection source, StatCollection target, StatType stat, float value) { target.ApplyPermanentMod(stat, value, StatModificationType.Additive, source.Owner); SendStatChangeEvent(source.Owner, target.Owner, stat, value); }
public static void ApplyUntrackedStatMod(StatCollection source, StatCollection target, StatType stat, float value, StatModificationType modType, params StatModifierOption[] statOptions) { if (target == null) { return; } target.ApplyPermanentMod(stat, value, modType, source.Owner, statOptions); SendStatChangeEvent(source.Owner, target.Owner, stat, value); }
public static void RemoveTrackedStatMod(StatCollection source, StatCollection target, StatType stat, StatModifier mod, params StatModifierOption[] statOptions) { GameObject s = source != null ? source.Owner : null; GameObject t = target != null ? target.Owner : null; if (t != null) { target.RemoveTrackedMod(stat, mod, s, statOptions); SendStatChangeEvent(source.Owner, t, stat, -mod.Value); } else { Debug.LogWarning("a stat mod: " + mod + " could not be removed from a target because it was null"); } }
//public static void ApplyUntrackedStatMod(StatAdjustment adj) { // adj.target.ApplyUntrackedMod(adj.statType, adj.value, adj.modType, adj.adjustmentOptions); //} public static StatModifier ApplyTrackedStatMod(StatCollection source, StatCollection target, StatType stat, float value, StatModificationType modType, params StatModifierOption[] statOptions) { GameObject s = source != null ? source.Owner : null; GameObject t = target != null ? target.Owner : null; StatModifier mod = target.ApplyAndReturnTrackedMod(stat, value, modType, s, statOptions); if (t != null) { SendStatChangeEvent(s, t, stat, value); return(mod); } else { Debug.LogWarning("a stat mod: " + mod + " could not be added to a target because it was null"); return(null); } }