static VarValue GetVarValue(string text, VarValue.EType eType) { switch (eType) { case VarValue.EType.Int: return(new VarValue(int.Parse(text))); case VarValue.EType.Bool: switch (text) { case "0": return(false); case "1": return(true); } return(false); //return new VarValue(bool.Parse(text)); case VarValue.EType.Float: return(new VarValue(float.Parse(text))); case VarValue.EType.Vector3: return(new VarValue(GetVector3(text))); case VarValue.EType.String: return(new VarValue(text)); case VarValue.EType.Var: return(new VarValue((object)text)); default: throw new System.Exception("error value type"); } }
//if is variable name, it must be bracketed in % public static VarRef GetVarRefOrValue(XmlNode xmlNode, string name, VarValue.EType eType, Trigger trigger) { VarRef varRef = null; string text = Util.GetString(xmlNode, name); if (IsVarName(text)) { string varName = GetVarName(text); varRef = new VarRef(varName, trigger); } else { VarValue varValue = GetVarValue(text, eType); varRef = new VarRef(varValue); } return(varRef); }