/// <summary> /// constructor /// </summary> public TargetStatEffect(TargetStatEffectAsset asset) : base(asset) { Modifier = asset.Modifier; StatBase = (RPGStatType)asset.StatBase; FlatValue = asset.FlatValue; TargetStat = (RPGStatType)asset.TargetStat; }
/// <summary> /// Creates the stat. /// </summary> /// <returns>The stat.</returns> /// <param name="statType">Stat type.</param> /// <typeparam name="T">The 1st type parameter.</typeparam> protected T CreateStat <T>(RPGStatType statType) where T : RPGStat { T stat = System.Activator.CreateInstance <T>(); StatDict.Add(statType, (RPGStat)stat); return(stat); }
/// <summary> /// Gets the stat. /// </summary> /// <returns>The stat.</returns> /// <param name="statType">Stat type.</param> public RPGStat GetStat(RPGStatType statType) { if (ContainStat(statType)) { return(StatDict [statType]); } return(null); }
public void ModifyStat(RPGStatType statName, float value) { RPGVital stat = null; if (StatCollection.TryGetStat <RPGVital> (statName, out stat)) { stat.StatValueCurrent += value; } }
public RPGStat GetStat(RPGStatType type) { RPGStat stat; if (_stats.TryGetValue(type, out stat)) { return(stat); } return(null); }
/// <summary> /// constructor taking an effect asset /// </summary> public StatGlobalEffect(StatGlobalEffectAsset asset) : base(asset) { TargetType = asset.TargetType; IncludeSelf = asset.IncludeSelf; Modifier = asset.Modifier; StatBase = (RPGStatType)asset.StatBase; FlatValue = asset.FlatValue; TargetStat = (RPGStatType)asset.TargetStat; }
/// <summary> /// Creates the or get stat. /// </summary> /// <returns>The or get stat.</returns> /// <param name="statType">Stat type.</param> /// <typeparam name="T">The 1st type parameter.</typeparam> protected T CreateOrGetStat <T>(RPGStatType statType) where T : RPGStat { T stat = GetStat <T>(statType); if (stat == null) { stat = CreateStat <T>(statType); } return(stat); }
protected T CreateOrGetStat <T>(RPGStatType type) where T : RPGStat { if (Contains(type)) { return(GetStat <T>(type)); } else { return(CreateStat <T>(type)); } }
/// <summary> /// constructor /// </summary> public PositionAOEStatEffect(PositionAOEStatEffectAsset asset) : base(asset) { IncludeSelf = asset.IncludeSelf; TargetType = asset.TargetType; Radius = asset.Radius; Modifier = asset.Modifier; StatBase = (RPGStatType)asset.StatBase; FlatValue = asset.FlatValue; TargetStat = (RPGStatType)asset.TargetStat; }
public bool TryGetStatPercentValue(RPGStatType statName, out float value) { RPGVital stat = null; value = 0; if (StatCollection.TryGetStat <RPGVital> (statName, out stat)) { value = stat.StatValueCurrent / stat.StatValue; return(true); } return(false); }
public bool TryGetStatValue(RPGStatType statName, out int value) { RPGStat stat = null; value = 0; if (StatCollection.TryGetStat(statName, out stat)) { value = stat.StatValue; return(true); } return(false); }
protected T CreateStat <T>(RPGStatType type) where T : RPGStat { T t = Activator.CreateInstance <T>(); _stats.Add(type, t); var change = t as IStatValueChange; if (change != null) { change.OnValueChange += OnStatValueChanged; } return(t); }
protected T CreateOrGetStat <T>(RPGStatType type) where T : RPGStat { if (Contains(type)) { return(GetStat <T>(type)); } else { T stat = CreateStat <T>(type); _stats.Add(type, stat); return(stat); } }
public virtual RPGAttribute GetAttributeStat(RPGStatType stat) { switch (stat) { case RPGStatType.Alive: return(alive); case RPGStatType.Speed: return(speed); default: return(speed); ///TODO what should be the default for this? } }
public virtual RPGVital GetVitalStat(RPGStatType stat) { switch (stat) { case RPGStatType.Stamina: return(stamina); case RPGStatType.Health: return(health); case RPGStatType.Willpower: return(willpower); default: return(stamina); ///TODO what should be the default for this? } }
public RPGAttribute GetRPGAttributeStat(RPGStatType stat) { switch (gameObject.name) { case "Player": return(gameObject.GetComponent <StatsPlayer>().GetAttributeStat(stat)); case "Chace": return(gameObject.GetComponent <StatsChace>().GetAttributeStat(stat)); case "Guard": return(gameObject.GetComponent <StatsGuard>().GetAttributeStat(stat)); default: return(gameObject.GetComponent <StatsGuard>().GetAttributeStat(stat)); } }
/// <summary> /// Scales the target stat in the collection to the target level /// </summary> public void ScaleStat(RPGStatType target, int level) { if (ContainStat(target)) { var stat = GetStat(target) as IStatScalable; if (stat != null) { stat.ScaleStat(level); } else { Debug.Log("[RPGStats] Trying to Scale Stat with a non scalable stat \"" + target.ToString() + "\""); } } else { Debug.Log("[RPGStats] Trying to Scale Stat for \"" + target.ToString() + "\", but RPGStatCollection does not contain that stat"); } }
/// <summary> /// Scales the stat. /// </summary> /// <param name="target">Target.</param> /// <param name="level">Level.</param> public void ScaleStat(RPGStatType target, int level) { if (ContainStat(target)) { var modStat = GetStat(target) as IStatScalable; if (modStat != null) { modStat.ScaleStat(level); } else { Debug.Log("[RPGStatCollection] Trying to scale Stat Modifiers to non modifiable stat\"" + target.ToString() + "\""); } } else { Debug.Log("[RPGStatCollection] Trying to scale Stat Modifiers to \"" + target.ToString() + "\", but RPGStatCollection does not contain that stat"); } }
/// <summary> /// Updates the stat modifier. /// </summary> /// <param name="target">Target.</param> public void UpdateStatModifier(RPGStatType target) { if (ContainStat(target)) { var modStat = GetStat(target) as IStatModifiable; if (modStat != null) { modStat.UpdateModifiers(); } else { Debug.Log("[RPGStatCollection] Trying to update Stat Modifiers to non modifiable stat\"" + target.ToString() + "\""); } } else { Debug.Log("[RPGStatCollection] Trying to update Stat Modifiers to \"" + target.ToString() + "\", but RPGStatCollection does not contain that stat"); } }
/// <summary> /// Adds a Stat Modifier to the Target stat and then updates the stat's value. /// </summary> public void AddStatModifier(RPGStatType target, RPGStatModifier mod, bool update) { if (ContainStat(target)) { var modStat = GetStat(target) as IStatModifiable; if (modStat != null) { modStat.AddModifier(mod); if (update == true) { modStat.UpdateModifiers(); } } else { Debug.Log("[RPGStats] Trying to add Stat Modifier to non modifiable stat \"" + target.ToString() + "\""); } } else { Debug.Log("[RPGStats] Trying to add Stat Modifier to \"" + target.ToString() + "\", but RPGStats does not contain that stat"); } }
/// <summary> /// Clears all stat modifiers from the target stat then updates the stat's value. /// </summary> public void ClearStatModifier(RPGStatType target, bool update) { if (ContainStat(target)) { var modStat = GetStat(target) as IStatModifiable; if (modStat != null) { modStat.ClearModifiers(); if (update == true) { modStat.UpdateModifiers(); } } else { Debug.Log("[RPGStats] Trying to clear Stat Modifiers from non modifiable stat \"" + target.ToString() + "\""); } } else { Debug.Log("[RPGStats] Trying to clear Stat Modifiers from \"" + target.ToString() + "\", but RPGStatCollection does not contain that stat"); } }
public virtual void UpdateModifiedStat(RPGStatType stat, int newAmount) { switch (stat) { case RPGStatType.Stamina: stamina.StatCurrentValue = newAmount; break; case RPGStatType.Alive: alive.StatBaseValue = newAmount; break; case RPGStatType.Health: health.StatCurrentValue = newAmount; break; case RPGStatType.Willpower: willpower.StatCurrentValue = newAmount; break; default: break; } }
public void ModifyStat(RPGStatType sourceStat, RPGStatType targetStat, float modifier, float flatValue, float baseValue) { float rawValue = flatValue + modifier * baseValue; float bufferValue = 1.0f; if (sourceStat == RPGStatType.Power) { RPGStat stat = null; if (StatCollection.TryGetStat(RPGStatType.Defense, out stat)) { bufferValue = stat.StatValue; } } else if (sourceStat == RPGStatType.Mind) { RPGStat stat = null; if (StatCollection.TryGetStat(RPGStatType.Spirit, out stat)) { bufferValue = stat.StatValue; } } ModifyStat(targetStat, (int)((rawValue < 0) ? (-1) : (1) * rawValue * rawValue / bufferValue)); }
public RPGStatModifier() { _type = Types.None; _value = 0; _statType = RPGStatType.None; }
static public void ScaleStat(this RPGStatCollection collection, RPGStatType statType, int level) { collection.ScaleStat((int)statType, level); }
/// <summary> /// Gets the stat. /// </summary> /// <returns>The stat.</returns> /// <param name="type">Type.</param> /// <typeparam name="T">The 1st type parameter.</typeparam> public T GetStat <T>(RPGStatType type) where T : RPGStat { return(GetStat(type) as T); }
static public bool ContainStat(this RPGStatCollection collection, RPGStatType statType) { return(collection.ContainStat((int)statType)); }
/// <summary> /// Contains the stat. /// </summary> /// <returns><c>true</c>, if stat was contained, <c>false</c> otherwise.</returns> /// <param name="statType">Stat type.</param> public bool ContainStat(RPGStatType statType) { return(StatDict.ContainsKey(statType)); }
/// <summary> /// Clears the stat modifier. /// </summary> /// <param name="target">Target.</param> public void ClearStatModifier(RPGStatType target) { ClearStatModifier(target, false); }
/// <summary> /// Removes the stat modifier. /// </summary> /// <param name="target">Target.</param> /// <param name="mod">Mod.</param> public void RemoveStatModifier(RPGStatType target, RPGStatModifier mod) { RemoveStatModifier(target, mod, false); }
/// <summary> /// Adds the modifier. /// </summary> /// <param name="target">Target.</param> /// <param name="mod">Mod.</param> public void AddModifier(RPGStatType target, RPGStatModifier mod) { AddModifier(target, mod, false); }
public RPGStatModifier(RPGStatType targetStat, Types modType, float value) { _type = modType; _statType = targetStat; _value = value; }