void Update() { // Don't do anything if no Stat name is defined if (string.IsNullOrEmpty(name_of_stat_to_retrieve)) { return; } string stat = ""; // Retrieve the correct stat switch (type_of_stat_to_retrieve) { case Type_of_Stat.Numbered_Stat: // Check if we should display nothing if the stat does not exist if (display_nothing_if_stat_not_present && !StatsManager.Numbered_Stat_Exists(name_of_stat_to_retrieve)) { text_element.text = ""; return; } stat = "" + StatsManager.Get_Numbered_Stat(name_of_stat_to_retrieve); break; case Type_of_Stat.String_Stat: if (display_nothing_if_stat_not_present && !StatsManager.String_Stat_Exists(name_of_stat_to_retrieve)) { text_element.text = ""; return; } stat = StatsManager.Get_String_Stat(name_of_stat_to_retrieve); break; case Type_of_Stat.Boolean_Stat: if (display_nothing_if_stat_not_present && !StatsManager.Boolean_Stat_Exists(name_of_stat_to_retrieve)) { text_element.text = ""; return; } stat = "" + StatsManager.Get_Boolean_Stat(name_of_stat_to_retrieve); break; } // Construct the actual string text_element.text = message_before_stat + stat + message_after_stat; }
// Checks if the given stat is > or < the value. Returns true/false. // If no stat of that name is found, 0 is given as the stat's value public static bool Compare_Float_Stat(string stat_name, Float_Stat_Comparator than, float value) { // Check if the stat exists if (!StatsManager.Numbered_Stat_Exists(stat_name)) { Debug.Log(stat_name + " Numbered Stat does not exist. Returning default value for stat: 0"); } bool result = false; // Check if it meets the requirements float stat = StatsManager.Get_Numbered_Stat(stat_name); switch (than) { case Float_Stat_Comparator.Greater_than: result = stat > value; break; case Float_Stat_Comparator.Less_than: result = stat < value; break; } return(result); }