/// <summary> /// The actual modifiers listened in a list order. /// </summary> /// <param name="stat"></param> /// <returns></returns> private string GetModifiersText(CharacterStat stat) { sb.Length = 0; for (int i = 0; i < stat.StatModifiers.Count; i++) { StatModifier mod = stat.StatModifiers[i]; sb.Append(((Item)mod.Source).name); sb.Append(": "); if (mod.Value > 0) { sb.Append("+"); } if (mod.Type == StatModType.Flat) { sb.Append(mod.Value); } else { sb.Append(mod.Value * 100); sb.Append("%"); } if (i < stat.StatModifiers.Count - 1) { sb.AppendLine(); } } return(sb.ToString()); }
public void ShowTooltip(CharacterStat stat, string statName) { gameObject.SetActive(true); // Update the text on the tooltip. statNameText.text = FirstLetterToUpper(statName); finalValueText.text = GetValueText(stat); modifiersListText.text = GetModifiersText(stat); }
/// <summary> /// 15 + (5). Shows the stat boosts given by armor or weapons. /// </summary> /// <param name="stat"></param> /// <returns></returns> private string GetValueText(CharacterStat stat) { sb.Length = 0; sb.Append(stat.Value); sb.Append(" ("); sb.Append(stat.BaseValue); sb.Append(" + "); sb.Append((float)System.Math.Round(stat.Value - stat.BaseValue, 4)); sb.Append(")"); return(sb.ToString()); }