// // Private Methods // /// <summary> /// Permanently adds SP to the given StatData instance and removes the same amount from the global pool /// Warning: Will not check for null parameters! /// </summary> /// <param name="spToAdd">Sp to add.</param> /// <param name="stat">Stat.</param> private void PrivAddSpFromUnallocPool(int spToAdd, StatData stat) { if (spToAdd < 0) { spToAdd = -spToAdd; } int remainingUnallocatedSp = this.UnallocatedSp - spToAdd; if (remainingUnallocatedSp < 0) { spToAdd = spToAdd + remainingUnallocatedSp; // You can uncomment out this log if you want //Debug.Log("Unallocated Pool has ran out"); } this.PrivAddSpToStatData(spToAdd, stat); this.unallocatedSpPool -= spToAdd; }
/// <summary> /// Search for a stat in this Character by a Stat data asset (BaseStat, SecondaryStat, SkillStat). /// Will return null if no such stat is found /// </summary> public StatData SearchStat(AbstractStat statDefinition) { if (statDefinition == null) { Debug.LogWarning("RpgCharacterData.SearchStat(AbstractStat) was given a null AbstractStat!"); return(null); } StatData foundStat = null; foreach (StatData s in this.appliedStats) { if (s.StatReference.Id.Equals(statDefinition.Id)) { foundStat = s; break; } } return(foundStat); }
/// <summary> /// Search for a stat in this Character by ID. Will return null if no such stat is found /// </summary> public StatData SearchStat(Guid statId) { if (statId.Equals(Guid.Empty)) { Debug.LogWarning("RpgCharacterData.SearchStat(Guid) was given an empty GUID!"); return(null); } StatData foundStat = null; foreach (StatData s in this.appliedStats) { if (s.Id.Equals(statId)) { foundStat = s; break; } } return(foundStat); }
/// <summary> /// Search for a stat in this Character by name. Will return null if no such stat is found /// </summary> public StatData SearchStat(string statName) { if (string.IsNullOrEmpty(statName)) { Debug.LogWarning("RpgCharacterData.SearchStat(string) was given a null or empty string!"); return(null); } StatData foundStat = null; foreach (StatData s in this.appliedStats) { if (s.Name.Equals(statName)) { foundStat = s; break; } } return(foundStat); }
/// <summary> /// Permanently adds SP to the given StatData instance. /// Warning: Will not check for null parameters! /// </summary> /// <param name="spToAdd">SP to add to the given stat instance</param> /// <param name="stat">The stat instance to increment</param> private void PrivAddSpToStatData(int spToAdd, StatData stat) { stat.AddStatPointsToRawPool(spToAdd); this.RecalculateAllLinkedStatsPools(); }