public void TriggerAI(AI_Type aiType) { AISubSet next = null; foreach (AISubSet s in AIList) { s.gameObject.SetActive(false); if (s.aI_Type == aiType) { next = s; } } next.gameObject.SetActive(true); }
/// <summary> /// The Constructor will deal with assigning the mob it's AI /// </summary> /// <param name="info">The Monsters Info (I.E it's stats etc..)</param> public AICustom(MonsterInfo info) : base(info) { // Get the AI without having to cycle. Custom = Envir.CustomAIs.Where(e => e.MobIndex == info.Index).FirstOrDefault(); // Ensure the Custom AI is valid if (Custom != null) { // Assign the Attack Variables as long as it exists in the Custom AI. if (Custom.AttackTypes.Count >= 1) { Attack0 = Custom.AttackTypes[0]; } if (Custom.AttackTypes.Count >= 2) { Attack1 = Custom.AttackTypes[1]; } if (Custom.AttackTypes.Count >= 3) { Attack2 = Custom.AttackTypes[2]; } if (Custom.AttackTypes.Count >= 4) { Attack3 = Custom.AttackTypes[3]; } if (Custom.AttackTypes.Count >= 5) { Attack4 = Custom.AttackTypes[4]; } if (Custom.AttackTypes.Count >= 6) { Attack5 = Custom.AttackTypes[5]; } if (Custom.AttackTypes.Count >= 7) { Attack6 = Custom.AttackTypes[6]; } } }
void SelectAI() { AI = (AI_Type)Random.Range(0, 4); }
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); }
/// <summary> /// Initiate world AI process /// </summary> /// <param name="wm"></param> /// <param name="org"></param> public void world(WorldMap wm, String org) { type = AI_Type.WORLD; iorg = org; needDelay = true; isActive = true; if (cityMesh == null) { init_cityMesh(); City c; foreach (CityNode cn in cityMesh) { System.Console.Out.WriteLine(">" + cn.city.Name); for(int i=0; i<cn.conls.Count; i++) { c=cn.conls[i]; System.Console.Out.WriteLine("-" + c.Name + " FROM " + cn.sidels[i].ToString()); } System.Console.Out.WriteLine(); } } }
/// <summary> /// Initiate region AI process /// </summary> /// <param name="org"></param> public void region(Region freg, String org) { reg = freg; useUnit = true; reg_step = Region_Steps.FIND; type = AI_Type.REGION; iorg = org; needDelay = true; isActive = true; }
/// <summary> /// Initiate battle AI process /// </summary> /// <param name="b"></param> /// <param name="org"></param> public void battle(Battle fbat, String org) { bat = fbat; useUnit = false; bat_step = 0; cc = new Point(-1, -1); type = AI_Type.BATTLE; iorg = org; needDelay = true; isActive = true; }