// Finds the stat of the given name and compares it to is_ // If the stat is not found, false is given as the stat value public static bool Compare_Bool_Stat_To(string stat_name, bool is_) { // Check if the stat exists if (!StatsManager.Boolean_Stat_Exists(stat_name) && VNSceneManager.verbose_debug_logs) { Debug.Log("Comparing bool stat. " + stat_name + " does not exist"); } return(StatsManager.Get_Boolean_Stat(stat_name) == is_); }
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; }
public string Insert_Stats_into_Text(string in_text) { // Find any [ ] characters string[] splits = in_text.Split('[', ']'); // Now check each split if it's legitimate foreach (string original_s in splits) { bool is_variable = false; string new_s = ""; string modified_s; if (original_s.StartsWith("b:")) { is_variable = true; modified_s = original_s.Replace("b:", ""); new_s = StatsManager.Get_Boolean_Stat(modified_s).ToString(); } else if (original_s.StartsWith("f:")) { is_variable = true; modified_s = original_s.Replace("f:", ""); new_s = StatsManager.Get_Numbered_Stat(modified_s) + ""; } else if (original_s.StartsWith("s:")) { is_variable = true; modified_s = original_s.Replace("s:", ""); new_s = StatsManager.Get_String_Stat(modified_s); } if (is_variable) { in_text = in_text.Replace("[" + original_s + "]", new_s); } } return(in_text); }