protected string stringTypeToName(GAME_DEFINE_STRING type) { if (mStringDefineToName.ContainsKey(type)) { return(mStringDefineToName[type]); } return(""); }
public string getStringParam(GAME_DEFINE_STRING param) { if (mStringList.ContainsKey(param)) { return(mStringList[param].mValue); } return(""); }
public string getStringComment(GAME_DEFINE_STRING param) { if (mStringList.ContainsKey(param)) { return(mStringList[param].mComment); } return(""); }
public static float calcuteConfigExpression(GAME_DEFINE_STRING expDefine, float variableValue) { string variableStr = "(" + variableValue.ToString("F2") + ")"; string expression = mGameConfig.getStringParam(expDefine); expression = expression.Replace("i", variableStr); float expressionValue = MathUtility.calculateFloat(expression); return(expressionValue); }
public static float calcuteConfigExpression(GAME_DEFINE_STRING CommonDefine, float variableValue) { string variableStr = "(" + floatToString(variableValue, 2) + ")"; string expression = mGameConfig.getStringParam(CommonDefine); expression = expression.Replace("i", variableStr); float expressionValue = calculateFloat(expression); return(expressionValue); }
public void setStringParam(GAME_DEFINE_STRING param, string value, string comment = "") { if (!mStringList.ContainsKey(param)) { StringParameter strParam = new StringParameter(); strParam.mValue = value; strParam.mComment = comment; strParam.mType = param; strParam.mTypeString = param.ToString(); mStringList.Add(param, strParam); } else { mStringList[param].mValue = value; if (comment != "") { mStringList[param].mComment = comment; } } }
protected void readFile(string fileName, bool floatParam) { string text = ""; FileUtility.openTxtFile(fileName, ref text); string[] lineList = StringUtility.split(text, true, "\r\n"); Dictionary <string, ConfigInfo> valueList = new Dictionary <string, ConfigInfo>(); string comment = ""; // 前4行需要被丢弃 int dropLine = 4; for (int i = 0; i < lineList.Length; ++i) { if (i < dropLine) { continue; } string line = lineList[i]; // 去除所有空白字符 line = Regex.Replace(line, @"\s", ""); // 如果该行是空的,或者是注释,则不进行处理 if (line.Length > 0) { if (line.Substring(0, 2) == "//") { comment = line.Substring(2, line.Length - 2); } else { string[] value = StringUtility.split(line, true, "="); ConfigInfo info = new ConfigInfo(); info.mComment = comment; info.mName = value[0]; info.mValue = value[1]; if (!valueList.ContainsKey(info.mName)) { valueList.Add(info.mName, info); } } } } List <string> keys = new List <string>(valueList.Keys); List <ConfigInfo> values = new List <ConfigInfo>(valueList.Values); for (int i = 0; i < keys.Count; ++i) { if (floatParam) { GAME_DEFINE_FLOAT def = floatNameToType(keys[i]); if (def != GAME_DEFINE_FLOAT.GDF_NONE) { setFloatParam(def, StringUtility.stringToFloat(values[i].mValue), values[i].mComment); } } else { GAME_DEFINE_STRING def = stringNameToType(keys[i]); if (def != GAME_DEFINE_STRING.GDS_NONE) { setStringParam(def, values[i].mValue, values[i].mComment); } } } }
protected bool hasParameter(GAME_DEFINE_STRING param) { return(mStringList.ContainsKey(param)); }
protected void addStringParam(GAME_DEFINE_STRING type) { mStringNameToDefine.Add(type.ToString(), type); mStringDefineToName.Add(type, type.ToString()); }