private bool LoadFromReader(ConfigReader reader) { if (reader == null) { return(false); } // load Begin Action for (int i = 0; i < reader.SectionCount; ++i) { ConfigSection section = reader.GetSections(i); if (section == null) { continue; } string tile = section.Tile; if (tile.StartsWith(_cBeginAction, StringComparison.CurrentCultureIgnoreCase)) { string stateStr = tile.Substring(_cBeginAction.Length).Trim(); int state; if (int.TryParse(stateStr, out state) && (state >= 0) /*&& (state < (int)PlayerState.psPlayerStateCount)*/) { PlayerState playerState = (PlayerState)state; BeginAction action = new BeginAction(/*playerState,*/ section); AddOrSetBeginAction(playerState, action); } } } return(true); }
public bool LoadFromReader(ConfigReader reader) { if (reader == null) { return(false); } for (int i = 0; i < reader.SectionCount; ++i) { var section = reader.GetSections(i); if (section == null) { continue; } if (string.IsNullOrEmpty(section.Tile)) { continue; } if (!section.Tile.StartsWith(_cBG, System.StringComparison.CurrentCultureIgnoreCase)) { continue; } string name = section.Tile.Substring(_cBG.Length).Trim(); BgStaticInfo staticInfo = null; BgAniInfo aniInfo = null; BgType bgType = BgType.none; for (int j = 0; j < section.ContentListCount; ++j) { string key, value; if (!section.GetKeyValue(j, out key, out value)) { continue; } if (string.IsNullOrEmpty(key) || string.IsNullOrEmpty(value)) { continue; } if (key.StartsWith("type", System.StringComparison.CurrentCultureIgnoreCase)) { if (string.Compare(value, "normal", true) == 0) { bgType = BgType.normal; staticInfo = new BgStaticInfo(); staticInfo.name = name; staticInfo.bgType = bgType; if (m_BgList == null) { m_BgList = new List <IBg>(); } m_BgList.Add(staticInfo); continue; } else if (string.Compare(value, "anim", true) == 0) { bgType = BgType.anim; aniInfo = new BgAniInfo(); aniInfo.name = name; aniInfo.bgType = bgType; if (m_BgList == null) { m_BgList = new List <IBg>(); } m_BgList.Add(aniInfo); continue; } } if (bgType == BgType.none) { continue; } if (bgType == BgType.normal) { string[] arr = null; if (string.Compare(key, "spriteno", true) == 0) { arr = value.Split(ConfigSection._cContentArrSplit, System.StringSplitOptions.RemoveEmptyEntries); if (arr != null && arr.Length >= 2) { staticInfo.srpiteno_Group = int.Parse(arr[0]); staticInfo.spriteno_Image = int.Parse(arr[1]); } } else if (string.Compare(key, "layerno", true) == 0) { staticInfo.layerno = int.Parse(value); } else if (string.Compare(key, "start", true) == 0) { arr = value.Split(ConfigSection._cContentArrSplit, System.StringSplitOptions.RemoveEmptyEntries); if (arr != null && arr.Length >= 2) { staticInfo.start_x = int.Parse(arr[0]); staticInfo.start_y = int.Parse(arr[1]); } } else if (string.Compare(key, "delta", true) == 0) { arr = value.Split(ConfigSection._cContentArrSplit, System.StringSplitOptions.RemoveEmptyEntries); if (arr != null && arr.Length >= 2) { float x1 = float.Parse(arr[0]); float y1 = float.Parse(arr[1]); staticInfo.delta = new Vector2(x1, y1); } } else if (string.Compare(key, "trans", true) == 0) { if (string.Compare(value, "none", true) == 0) { staticInfo.transType = TransType.none; } } else if (string.Compare(key, "mask", true) == 0) { int i1 = int.Parse(value); staticInfo.mask = (MaskType)i1; } } else if (bgType == BgType.anim) { string[] arr = null; if (string.Compare(key, "actionno", true) == 0) { aniInfo.actionno = int.Parse(value); } else if (string.Compare(key, "layerno", true) == 0) { aniInfo.layerno = int.Parse(value); } else if (string.Compare(key, "start", true) == 0) { arr = value.Split(ConfigSection._cContentArrSplit, System.StringSplitOptions.RemoveEmptyEntries); if (arr != null && arr.Length >= 2) { aniInfo.start_x = int.Parse(arr[0]); aniInfo.start_y = int.Parse(arr[1]); } } else if (string.Compare(key, "delta", true) == 0) { arr = value.Split(ConfigSection._cContentArrSplit, System.StringSplitOptions.RemoveEmptyEntries); if (arr != null && arr.Length >= 2) { float x1 = float.Parse(arr[0]); float y1 = float.Parse(arr[1]); aniInfo.delta = new Vector2(x1, y1); } } else if (string.Compare(key, "trans", true) == 0) { if (string.Compare(value, "none", true) == 0) { aniInfo.transType = TransType.none; } } else if (string.Compare(key, "mask", true) == 0) { int i1 = int.Parse(value); aniInfo.mask = (MaskType)i1; } } } } // 排序 SortBg(); return(true); }
public bool LoadFromReader(ConfigReader reader) { Clear(); if (reader == null) { return(false); } ConfigSection section = reader.GetSection("Remap"); if (section != null) { m_Remap = new Cmd_Remap(); if (!section.GetPropertysValues(m_Remap)) { m_Remap = null; } } section = reader.GetSection("Defaults"); if (section != null) { for (int i = 0; i < section.ContentListCount; ++i) { string key, value; if (section.GetKeyValue(i, out key, out value)) { if (string.Compare(key, "command.time", true) == 0) { m_Command__Time = int.Parse(value); } else if (string.Compare(key, "command.buffer.time", true) == 0) { m_Command__Buffer__Time = int.Parse(value); } } } } // 创建Command for (int i = 0; i < reader.SectionCount; ++i) { section = reader.GetSections(i); if (section == null) { continue; } if (string.Compare(section.Tile, "Command", true) == 0) { Cmd_Command cmd = null; for (int j = 0; j < section.ContentListCount; ++j) { string key, value; if (section.GetKeyValue(j, out key, out value)) { if (string.Compare(key, "name", true) == 0) { if (cmd == null) { cmd = new Cmd_Command(); } cmd.name = value; } else if (string.Compare(key, "time", true) == 0) { if (cmd == null) { cmd = new Cmd_Command(); } cmd.time = int.Parse(value); } else if (string.Compare(key, "buffer.time", true) == 0) { if (cmd == null) { cmd = new Cmd_Command(); } cmd.buffer__time = int.Parse(value); } else if (string.Compare(key, "command", true) == 0) { if (cmd == null) { cmd = new Cmd_Command(); } cmd.keyCommands = ConfigSection.Split(value); } } } if (cmd != null && !string.IsNullOrEmpty(cmd.name)) { AddCommand(cmd); } } else if (section.Tile.StartsWith("State -1", StringComparison.CurrentCultureIgnoreCase)) { string[] names = ConfigSection.Split(section.Tile); if (names == null || names.Length < 2) { continue; } string aiName = names [1]; AI_Type aiType = AI_Type.none; AI_Command aiCmd = null; for (int j = 0; j < section.ContentListCount; ++j) { string key, value; if (section.GetKeyValue(j, out key, out value)) { if (string.Compare(key, "type", true) == 0) { if (string.Compare(value, "ChangeState", true) == 0) { aiType = AI_Type.ChangeState; if (aiCmd == null) { aiCmd = new AI_Command(); aiCmd.type = aiType; aiCmd.name = aiName; } } } else { if (aiCmd == null) { continue; } if (string.Compare(key, "value", true) == 0) { aiCmd.value = value; } else if (string.Compare(key, "triggerall", true) == 0) { if (value.StartsWith("command", StringComparison.CurrentCultureIgnoreCase)) { int idx = value.IndexOf("="); if (idx >= 0) { aiCmd.command = value.Substring(idx + 1, value.Length - idx - 1).Trim(); if (!string.IsNullOrEmpty(aiCmd.command)) { Cmd_Command cmdCmd = GetCommand(aiCmd.command); if (cmdCmd != null) { cmdCmd.aiName = aiCmd.name; } } } } } } } } if (aiCmd == null || aiCmd.type == AI_Type.none) { continue; } if (m_AICmdMap == null) { m_AICmdMap = new Dictionary <string, AI_Command> (); } m_AICmdMap [aiCmd.name] = aiCmd; } } return(true); }
public bool LoadFromFile(string fileName) { Reset(); string str = AppConfig.GetInstance().Loader.LoadText(fileName); if (str == null || string.IsNullOrEmpty(str)) { return(false); } ConfigReader reader = new ConfigReader(); reader.LoadString(str); ConfigSection section = reader.GetSection("Velocity"); if (section != null) { if (!LoadVelocity(section)) { return(false); } } section = reader.GetSection("Size"); if (section != null) { if (!LoadSize(section)) { return(false); } } string dd = "Statedef"; string ddd = "State"; for (int i = 0; i < reader.SectionCount; ++i) { section = reader.GetSections(i); if (section == null || string.IsNullOrEmpty(section.Tile)) { continue; } CNSStateDef parent = null; if (section.Tile.StartsWith(dd, StringComparison.CurrentCultureIgnoreCase)) { string name = section.Tile.Substring(dd.Length); if (string.IsNullOrEmpty(name)) { continue; } name = name.Trim(); if (string.IsNullOrEmpty(name)) { continue; } CNSStateDef def = new CNSStateDef(); if (def.LoadConfigReader(section)) { AddStateDef(name, def); parent = def; } else { parent = null; continue; } } if (section.Tile.StartsWith(ddd, StringComparison.CurrentCultureIgnoreCase)) { if (parent == null) { continue; } } } return(true); }