protected string floatTypeToName(GAME_DEFINE_FLOAT type) { if (mFloatDefineToName.ContainsKey(type)) { return(mFloatDefineToName[type]); } return(""); }
public string getFloatComment(GAME_DEFINE_FLOAT param) { if (mFloatList.ContainsKey(param)) { return(mFloatList[param].mComment); } return(""); }
public float getFloatParam(GAME_DEFINE_FLOAT param) { if (mFloatList.ContainsKey(param)) { return(mFloatList[param].mValue); } return(0.0f); }
public void setFloatParam(GAME_DEFINE_FLOAT param, float value, string comment = "") { if (!mFloatList.ContainsKey(param)) { FloatParameter floatParam = new FloatParameter(); floatParam.mValue = value; floatParam.mComment = comment; floatParam.mType = param; floatParam.mTypeString = param.ToString(); mFloatList.Add(param, floatParam); } else { mFloatList[param].mValue = value; if (comment != "") { mFloatList[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_FLOAT param) { return(mFloatList.ContainsKey(param)); }
//---------------------------------------------------------------------------------------------------------------------------------------------- protected void addFloatParam(GAME_DEFINE_FLOAT type) { mFloatNameToDefine.Add(type.ToString(), type); mFloatDefineToName.Add(type, type.ToString()); }