public static System.Xml.Schema.XmlSchemaComplexType GetTypedTableSchema(System.Xml.Schema.XmlSchemaSet xs) { System.Xml.Schema.XmlSchemaComplexType type = new System.Xml.Schema.XmlSchemaComplexType(); System.Xml.Schema.XmlSchemaSequence sequence = new System.Xml.Schema.XmlSchemaSequence(); Bots ds = new Bots(); xs.Add(ds.GetSchemaSerializable()); System.Xml.Schema.XmlSchemaAny any1 = new System.Xml.Schema.XmlSchemaAny(); any1.Namespace = "http://www.w3.org/2001/XMLSchema"; any1.MinOccurs = new decimal(0); any1.MaxOccurs = decimal.MaxValue; any1.ProcessContents = System.Xml.Schema.XmlSchemaContentProcessing.Lax; sequence.Items.Add(any1); System.Xml.Schema.XmlSchemaAny any2 = new System.Xml.Schema.XmlSchemaAny(); any2.Namespace = "urn:schemas-microsoft-com:xml-diffgram-v1"; any2.MinOccurs = new decimal(1); any2.ProcessContents = System.Xml.Schema.XmlSchemaContentProcessing.Lax; sequence.Items.Add(any2); System.Xml.Schema.XmlSchemaAttribute attribute1 = new System.Xml.Schema.XmlSchemaAttribute(); attribute1.Name = "namespace"; attribute1.FixedValue = ds.Namespace; type.Attributes.Add(attribute1); System.Xml.Schema.XmlSchemaAttribute attribute2 = new System.Xml.Schema.XmlSchemaAttribute(); attribute2.Name = "tableTypeName"; attribute2.FixedValue = "BotDataTable"; type.Attributes.Add(attribute2); type.Particle = sequence; return(type); }
public override DataSet Clone() { Bots cln = ((Bots)(base.Clone())); cln.InitVars(); return(cln); }
public override System.Data.DataSet Clone() { Bots cln = ((Bots)(base.Clone())); cln.InitVars(); cln.SchemaSerializationMode = this.SchemaSerializationMode; return(cln); }
public static Bots ReadBots(string dir) { Bots data = new Bots(); string[] files = Directory.GetFiles(dir, "*.bot"); for (int x = 0; x < files.Length; x++) { AppendBotRowFromFile(data, files[x]); } return data; }
public static System.Xml.Schema.XmlSchemaComplexType GetTypedDataSetSchema(System.Xml.Schema.XmlSchemaSet xs) { Bots ds = new Bots(); System.Xml.Schema.XmlSchemaComplexType type = new System.Xml.Schema.XmlSchemaComplexType(); System.Xml.Schema.XmlSchemaSequence sequence = new System.Xml.Schema.XmlSchemaSequence(); xs.Add(ds.GetSchemaSerializable()); System.Xml.Schema.XmlSchemaAny any = new System.Xml.Schema.XmlSchemaAny(); any.Namespace = ds.Namespace; sequence.Items.Add(any); type.Particle = sequence; return(type); }
public static Bots ReadBots(string dir) { Bots data = new Bots(); string[] files = Directory.GetFiles(dir, "*.bot"); for (int x = 0; x < files.Length; x++) { AppendBotRowFromFile(data, files[x]); } return(data); }
public int Add(Bots.BotRow bot) { if (base.InnerList.Count == 0) { return base.InnerList.Add(bot); } else { int count = 0; bool positionFound = false; string lastTeam = ""; // loop through, find 2 adjacent with other team // and insert between (after enumerating) foreach (Bots.BotRow row in this) { if (row.Team != bot.Team && lastTeam == row.Team) { // insert at this pos positionFound = true; break; } else { lastTeam = row.Team; count++; } } if (positionFound) { base.InnerList.Insert(count, bot); return count; } else { return base.InnerList.Add(bot); } } }
private void btnImport_Click(object sender, System.EventArgs e) { try { if (txtBotDirectory.Text.Trim().Length == 0) { MessageBox.Show(this.ParentForm, "Please choose the bots directory.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } Bots bots = BotReader.ReadBots(txtBotDirectory.Text); if (bots.Bot.Count == 0) { MessageBox.Show(this.ParentForm, "No bots found in directory.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } string dataFile = GetBotsDataFile(); if (File.Exists(dataFile)) { File.Delete(dataFile); } bots.WriteXml(dataFile); MessageBox.Show(this.ParentForm, "Imported " + bots.Bot.Count + " bots.", "Imported", MessageBoxButtons.OK, MessageBoxIcon.Information); InitializeBots(); } catch (Exception ex) { MessageBox.Show(this.ParentForm, "Unable to import bots. " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void InitializeBots() { try { tvBots.Nodes.Clear(); TreeNode axis = new TreeNode("Axis", 17, 17); TreeNode allies = new TreeNode("Allies", 18, 18); TreeNode axisSoldier = new TreeNode("Soldier", 12, 12); TreeNode alliesSoldier = new TreeNode("Soldier", 12, 12); TreeNode axisMedic = new TreeNode("Medic", 13, 13); TreeNode alliesMedic = new TreeNode("Medic", 13, 13); TreeNode axisEngineer = new TreeNode("Engineer", 14, 14); TreeNode alliesEngineer = new TreeNode("Engineer", 14, 14); TreeNode axisFieldOps = new TreeNode("Field Ops", 15, 15); TreeNode alliesFieldOps = new TreeNode("Field Ops", 15, 15); TreeNode axisCovertOps = new TreeNode("Covert Ops", 16, 16); TreeNode alliesCovertOps = new TreeNode("Covert Ops", 16, 16); tvBots.Nodes.Add(axis); tvBots.Nodes.Add(allies); axis.Nodes.Add(axisCovertOps); axis.Nodes.Add(axisEngineer); axis.Nodes.Add(axisFieldOps); axis.Nodes.Add(axisMedic); axis.Nodes.Add(axisSoldier); allies.Nodes.Add(alliesCovertOps); allies.Nodes.Add(alliesEngineer); allies.Nodes.Add(alliesFieldOps); allies.Nodes.Add(alliesMedic); allies.Nodes.Add(alliesSoldier); string dataFile = GetBotsDataFile(); if (!File.Exists(dataFile)) { MessageBox.Show(this.ParentForm, "Please import a bots data file.", "Import Needed", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } Bots bots = new Bots(); bots.ReadXml(dataFile); foreach (Bots.BotRow botRow in bots.Bot) { try { string name = botRow.Name; string funname = botRow.FunName; int classIndex = Convert.ToInt32(botRow.Class); int teamIndex = Convert.ToInt32(botRow.Team); int weaponIndex = Convert.ToInt32(botRow.Weapon); TreeNode bot = new TreeNode(name, weaponIndex, weaponIndex); bot.Tag = botRow; // used for drag / drop TreeNode botFunName = new TreeNode(funname); // empty icon TreeNode botWeapon = GetWeaponNode(weaponIndex); bot.Nodes.Add(botFunName); bot.Nodes.Add(botWeapon); switch (classIndex) { case 0: // soldier botFunName.ImageIndex = 12; botFunName.SelectedImageIndex = 12; if (teamIndex == 0) { axisSoldier.Nodes.Add(bot); } else { alliesSoldier.Nodes.Add(bot); } break; case 1: // medic botFunName.ImageIndex = 13; botFunName.SelectedImageIndex = 13; if (teamIndex == 0) { axisMedic.Nodes.Add(bot); } else { alliesMedic.Nodes.Add(bot); } break; case 2: // engineer botFunName.ImageIndex = 14; botFunName.SelectedImageIndex = 14; if (teamIndex == 0) { axisEngineer.Nodes.Add(bot); } else { alliesEngineer.Nodes.Add(bot); } break; case 3: // field ops botFunName.ImageIndex = 15; botFunName.SelectedImageIndex = 15; if (teamIndex == 0) { axisFieldOps.Nodes.Add(bot); } else { alliesFieldOps.Nodes.Add(bot); } break; case 4: // covert ops botFunName.ImageIndex = 16; botFunName.SelectedImageIndex = 16; if (teamIndex == 0) { axisCovertOps.Nodes.Add(bot); } else { alliesCovertOps.Nodes.Add(bot); } break; } } catch { // ignore bogus bots } } } catch (Exception ex) { MessageBox.Show(this.ParentForm, "Unable to initialize bots. " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private static void AppendBotRowFromFile(Bots bots, string file) { StreamReader reader = null; try { reader = new StreamReader(file); bool inDef = false; string line = null; string name = Path.GetFileNameWithoutExtension(file); string funname = ""; string classIndex = ""; string weaponIndex = ""; string teamIndex = ""; while ((line = reader.ReadLine()) != null) { /* { funname ^0Atla^3s class 0 weapon 10 team 1 } */ if (inDef) { if (line.Trim().StartsWith("funname")) { funname = line.Substring(7).Trim(); } else if (line.Trim().StartsWith("class")) { classIndex = line.Substring(5).Trim(); } else if (line.Trim().StartsWith("weapon")) { weaponIndex = line.Substring(6).Trim(); } else if (line.Trim().StartsWith("team")) { teamIndex = line.Substring(4).Trim(); } } else { if (line.Trim().StartsWith("{")) { inDef = true; } if (line.Trim().StartsWith("}")) { break; } } } bots.Bot.AddBotRow(name, funname, classIndex, weaponIndex, teamIndex); } catch { // just allow for continuing to next file by not raising the exception } finally { if (reader != null) { reader.Close(); } } }
public static System.Xml.Schema.XmlSchemaComplexType GetTypedTableSchema(System.Xml.Schema.XmlSchemaSet xs) { System.Xml.Schema.XmlSchemaComplexType type = new System.Xml.Schema.XmlSchemaComplexType(); System.Xml.Schema.XmlSchemaSequence sequence = new System.Xml.Schema.XmlSchemaSequence(); Bots ds = new Bots(); xs.Add(ds.GetSchemaSerializable()); System.Xml.Schema.XmlSchemaAny any1 = new System.Xml.Schema.XmlSchemaAny(); any1.Namespace = "http://www.w3.org/2001/XMLSchema"; any1.MinOccurs = new decimal(0); any1.MaxOccurs = decimal.MaxValue; any1.ProcessContents = System.Xml.Schema.XmlSchemaContentProcessing.Lax; sequence.Items.Add(any1); System.Xml.Schema.XmlSchemaAny any2 = new System.Xml.Schema.XmlSchemaAny(); any2.Namespace = "urn:schemas-microsoft-com:xml-diffgram-v1"; any2.MinOccurs = new decimal(1); any2.ProcessContents = System.Xml.Schema.XmlSchemaContentProcessing.Lax; sequence.Items.Add(any2); System.Xml.Schema.XmlSchemaAttribute attribute1 = new System.Xml.Schema.XmlSchemaAttribute(); attribute1.Name = "namespace"; attribute1.FixedValue = ds.Namespace; type.Attributes.Add(attribute1); System.Xml.Schema.XmlSchemaAttribute attribute2 = new System.Xml.Schema.XmlSchemaAttribute(); attribute2.Name = "tableTypeName"; attribute2.FixedValue = "BotDataTable"; type.Attributes.Add(attribute2); type.Particle = sequence; return type; }
public static System.Xml.Schema.XmlSchemaComplexType GetTypedDataSetSchema(System.Xml.Schema.XmlSchemaSet xs) { Bots ds = new Bots(); System.Xml.Schema.XmlSchemaComplexType type = new System.Xml.Schema.XmlSchemaComplexType(); System.Xml.Schema.XmlSchemaSequence sequence = new System.Xml.Schema.XmlSchemaSequence(); xs.Add(ds.GetSchemaSerializable()); System.Xml.Schema.XmlSchemaAny any = new System.Xml.Schema.XmlSchemaAny(); any.Namespace = ds.Namespace; sequence.Items.Add(any); type.Particle = sequence; return type; }
private static void AppendBotRowFromFile(Bots bots, string file) { StreamReader reader = null; try { reader = new StreamReader(file); bool inDef = false; string line = null; string name = Path.GetFileNameWithoutExtension(file); string funname = ""; string classIndex = ""; string weaponIndex = ""; string teamIndex = ""; while ((line = reader.ReadLine()) != null) { /* * { * funname ^0Atla^3s * class 0 * weapon 10 * team 1 * } */ if (inDef) { if (line.Trim().StartsWith("funname")) { funname = line.Substring(7).Trim(); } else if (line.Trim().StartsWith("class")) { classIndex = line.Substring(5).Trim(); } else if (line.Trim().StartsWith("weapon")) { weaponIndex = line.Substring(6).Trim(); } else if (line.Trim().StartsWith("team")) { teamIndex = line.Substring(4).Trim(); } } else { if (line.Trim().StartsWith("{")) { inDef = true; } if (line.Trim().StartsWith("}")) { break; } } } bots.Bot.AddBotRow(name, funname, classIndex, weaponIndex, teamIndex); } catch { // just allow for continuing to next file by not raising the exception } finally { if (reader != null) { reader.Close(); } } }