private void WriteBotsFile(string fileName) { StringBuilder buff = new StringBuilder(); // random dude goes first buff.Append("random // random bot\r\n"); AlternatingBotRowCollection bots = new AlternatingBotRowCollection(); // engineer, medic, field ops, coverts, soldiers. AppendBot(_axisEngineer, bots); AppendBot(_alliesEngineer, bots); AppendBot(_axisMedic, bots); AppendBot(_alliesMedic, bots); AppendBot(_axisFieldOps, bots); AppendBot(_alliesFieldOps, bots); AppendBot(_axisCovertOps, bots); AppendBot(_alliesCovertOps, bots); AppendBot(_axisSoldier, bots); AppendBot(_alliesSoldier, bots); foreach (Bots.BotRow bot in bots) { buff.Append(bot.Name); buff.Append(" // "); buff.Append(bot.Team == "0" ? "axis " : "allies "); switch (bot.Class) { case "0": buff.Append("soldier\r\n"); break; case "1": buff.Append("medic\r\n"); break; case "2": buff.Append("engineer\r\n"); break; case "3": buff.Append("field ops\r\n"); break; case "4": buff.Append("covert ops\r\n"); break; } } buff.Append("\r\n#EOF\r\n"); StreamWriter writer = new StreamWriter(fileName, false); writer.Write(buff.ToString()); writer.Close(); }
private void AppendBot(TreeNode node, AlternatingBotRowCollection bots) { Bots.BotRow bot = node.Tag as Bots.BotRow; if (bot != null) { bots.Add(bot); } foreach (TreeNode child in node.Nodes) { AppendBot(child, bots); } }
private void WriteBotsFile(string fileName) { StringBuilder buff = new StringBuilder(); // random dude goes first buff.Append("random // random bot\r\n"); AlternatingBotRowCollection bots = new AlternatingBotRowCollection(); // engineer, medic, field ops, coverts, soldiers. AppendBot(_axisEngineer, bots); AppendBot(_alliesEngineer, bots); AppendBot(_axisMedic, bots); AppendBot(_alliesMedic, bots); AppendBot(_axisFieldOps, bots); AppendBot(_alliesFieldOps, bots); AppendBot(_axisCovertOps, bots); AppendBot(_alliesCovertOps, bots); AppendBot(_axisSoldier, bots); AppendBot(_alliesSoldier, bots); foreach (Bots.BotRow bot in bots) { buff.Append(bot.Name); buff.Append(" // "); buff.Append(bot.Team == "0" ? "axis " : "allies "); switch (bot.Class) { case "0": buff.Append("soldier\r\n"); break; case "1": buff.Append("medic\r\n"); break; case "2": buff.Append("engineer\r\n"); break; case "3": buff.Append("field ops\r\n"); break; case "4": buff.Append("covert ops\r\n"); break; } } buff.Append("\r\n#EOF\r\n"); StreamWriter writer = new StreamWriter(fileName, false); writer.Write(buff.ToString()); writer.Close(); }
private void AppendBot(TreeNode node, AlternatingBotRowCollection bots) { Bots.BotRow bot = node.Tag as Bots.BotRow; if (bot != null) { bots.Add(bot); } foreach (TreeNode child in node.Nodes) { AppendBot(child, bots); } }