public void Clear() { m_Remap = null; m_Command__Buffer__Time = 1; m_Command__Time = 1; if (m_CommandMap != null) { m_CommandMap.Clear(); } }
public void AttachRemap(string x, string y, string z, string a, string b, string c) { if (m_Remap == null) { m_Remap = new Cmd_Remap(); } m_Remap.x = x; m_Remap.y = y; m_Remap.z = z; m_Remap.a = a; m_Remap.b = b; m_Remap.c = c; }
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); }