示例#1
0
        // prevents adding duplicate child nodes to the parent
        private void AddBotNode(TreeNode parent, TreeNode bot)
        {
            Bots.BotRow childBot = bot.Tag as Bots.BotRow;
            if (childBot == null)
            {
                return;
            }

            foreach (TreeNode child in parent.Nodes)
            {
                Bots.BotRow existingChildBot = child.Tag as Bots.BotRow;

                if (existingChildBot != null)
                {
                    // dupe found?
                    if (existingChildBot.Name == childBot.Name)
                    {
                        // expand the parent for visual indication that the
                        // bot is there
                        parent.Parent.Expand();
                        parent.Expand();
                        return;
                    }
                }
            }

            parent.Nodes.Add(bot);
            parent.Parent.Expand();
            parent.Expand();
        }
示例#2
0
        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);
            }
        }
示例#3
0
        private void ClearBotNode(TreeNode node)
        {
            Bots.BotRow bot = node.Tag as Bots.BotRow;

            if (bot != null)
            {
                node.Remove();
            }
            else
            {
                foreach (TreeNode child in node.Nodes)
                {
                    ClearBotNode(child);
                }
            }
        }
示例#4
0
        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));
                }
            }
        }
示例#5
0
        private void DoDrop(TreeNode node)
        {
            Bots.BotRow botRow = node.Tag as Bots.BotRow;

            if (botRow == null)
            {
                return;
            }
            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 file creation
                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)
                    {
                        AddBotNode(_axisSoldier, bot);
                    }
                    else
                    {
                        AddBotNode(_alliesSoldier, bot);
                    }
                    break;

                case 1:                         // medic
                    botFunName.ImageIndex         = 13;
                    botFunName.SelectedImageIndex = 13;
                    if (teamIndex == 0)
                    {
                        AddBotNode(_axisMedic, bot);
                    }
                    else
                    {
                        AddBotNode(_alliesMedic, bot);
                    }
                    break;

                case 2:                         // engineer
                    botFunName.ImageIndex         = 14;
                    botFunName.SelectedImageIndex = 14;
                    if (teamIndex == 0)
                    {
                        AddBotNode(_axisEngineer, bot);
                    }
                    else
                    {
                        AddBotNode(_alliesEngineer, bot);
                    }
                    break;

                case 3:                         // field ops
                    botFunName.ImageIndex         = 15;
                    botFunName.SelectedImageIndex = 15;
                    if (teamIndex == 0)
                    {
                        AddBotNode(_axisFieldOps, bot);
                    }
                    else
                    {
                        AddBotNode(_alliesFieldOps, bot);
                    }
                    break;

                case 4:                         // covert ops
                    botFunName.ImageIndex         = 16;
                    botFunName.SelectedImageIndex = 16;
                    if (teamIndex == 0)
                    {
                        AddBotNode(_axisCovertOps, bot);
                    }
                    else
                    {
                        AddBotNode(_alliesCovertOps, bot);
                    }
                    break;
                }
            }
            catch
            {
                // ignore bogus bots
            }
        }