static private string ReplaceFlagsWithStat(string text, int indexOfId, Resources_Character subject) { string stat = text.Substring(indexOfId + 1, text.Length - (indexOfId + 1)); // Holy shit. This is getting a dynamic property from a dynamic object. That's pretty baller! PropertyInfo myPropertyInfo = typeof(Resources_Character).GetProperty(stat); if (myPropertyInfo.GetValue(subject, null) != null) { return(myPropertyInfo.GetValue(subject, null).ToString()); } else { Debug.LogError("The subject '" + subject + "' does not have a stat for '" + stat + "'."); return(text); } }
private static string ReplaceFlagsWithStat(string text, int indexOfId, Resources_Character subject) { string stat = text.Substring (indexOfId + 1, text.Length -(indexOfId + 1)); // Holy shit. This is getting a dynamic property from a dynamic object. That's pretty baller! PropertyInfo myPropertyInfo = typeof(Resources_Character).GetProperty(stat); if (myPropertyInfo.GetValue (subject, null) != null) { return myPropertyInfo.GetValue (subject, null).ToString(); } else { Debug.LogError ("The subject '" + subject + "' does not have a stat for '" + stat +"'."); return text; } }