public void ParseProps() { var sections = m_Props.Split(';'); int finalStacking = 0; var staticProps = new List <StaticPropsEntry>(); var generateProps = new List <GeneratePropsEntry>(); foreach (var section in sections) { var equalsSplit = section.Split('='); // Need both sides of the equals if (equalsSplit.Length < 2) { continue; } if (equalsSplit[0] == "stacking") { finalStacking = int.Parse(equalsSplit[1]); } else // random prop { if (equalsSplit[1].Contains("-")) { var dashSplit = equalsSplit[1].Split('-'); if (finalStacking == 0) { finalStacking = 1; //props are generated so we can't stack this item } generateProps.Add(new GeneratePropsEntry() { m_Name = equalsSplit[0], m_Low = float.Parse(dashSplit[0]), m_High = float.Parse(dashSplit[1]) }); } else { staticProps.Add(new StaticPropsEntry() { m_Name = equalsSplit[0], m_Value = equalsSplit[1] }); } } } m_Stacking = finalStacking; m_GenerateProps = new GenerateProps() { m_Entries = generateProps.ToArray() }; m_StaticProps = new StaticProps() { m_Entries = staticProps.ToArray() }; }
public static SerializableDictionary <string, string> Generate(string item, GenerateProps props) { if (props == null || props.m_Entries.Length == 0) { return(null); } var result = new SerializableDictionary <string, string>(); foreach (var entry in props.m_Entries) { result[entry.m_Name] = UnityEngine.Random.Range(entry.m_Low, entry.m_High).ToString(); } return(result); }