Exemple #1
0
        public void randomizeNetwork()
        {
            for (var index = 0; index < 10; ++index)
            {
                nodes.Add(new Computer(NameGenerator.generateName(), generateRandomIP(),
                                       new Vector2((float)Utils.random.NextDouble() * bounds.Width,
                                                   (float)Utils.random.NextDouble() * bounds.Height), Utils.random.Next(0, 4),
                                       Utils.randomCompType(), os));
            }
            var num1 = 2;

            for (var index1 = 0; index1 < nodes.Count; ++index1)
            {
                var num2 = num1 + Utils.random.Next(0, 2);
                for (var index2 = 0; index2 < num2; ++index2)
                {
                    nodes[index1].links.Add(Utils.random.Next(0, nodes.Count - 1));
                }
            }
        }
Exemple #2
0
        public List <Computer> generateNetwork(OS os)
        {
            List <Computer> computerList1 = new List <Computer>();
            List <Computer> computerList2 = new List <Computer>();
            List <Computer> computerList3 = new List <Computer>();
            int             num1          = 2;
            float           num2          = 0.5f;
            int             num3          = 4;
            int             num4          = 0;
            float           num5          = (float)num1;
            bool            flag1         = false;
            float           x             = (float)((this.bounds.Width - 40) / (num3 * 2 + 3));
            float           num6          = (float)(this.bounds.Height - 30);
            float           y             = 10f;
            Vector2         compLocation  = new Vector2(x, y);
            bool            flag2         = false;

            while (num4 >= 0 || !flag1)
            {
                float num7 = num6 / (num5 + 1f);
                compLocation.Y = num7;
                for (int index1 = 0; index1 < (int)num5; ++index1)
                {
                    Computer computer = new Computer(NameGenerator.generateName(), NetworkMap.generateRandomIP(), compLocation, num4, Utils.flipCoin() ? (byte)1 : (byte)2, os);
                    Utils.random.NextDouble();
                    int index2 = Math.Min(Math.Max(num4, 0), PortExploits.services.Count - 1);
                    computer.files.root.folders[2].files.Add(new FileEntry(PortExploits.crackExeData[PortExploits.portNums[index2]], PortExploits.cracks[PortExploits.portNums[index2]]));
                    computerList3.Add(computer);
                    computerList1.Add(computer);
                    compLocation.Y += num7;
                }
                for (int index = 0; index < computerList2.Count; ++index)
                {
                    bool flag3 = index - 1 >= 0 && index < computerList2.Count - 1;
                    bool flag4 = index < computerList3.Count && index < computerList2.Count;
                    bool flag5 = index + 1 < computerList3.Count && index + 1 < computerList2.Count - 1;
                    if (flag3)
                    {
                        computerList3[index - 1].links.Add(computerList1.IndexOf(computerList2[index]));
                        computerList2[index - 1].links.Add(computerList1.IndexOf(computerList3[index]));
                    }
                    if (flag4)
                    {
                        computerList3[index].links.Add(computerList1.IndexOf(computerList2[index]));
                        computerList2[index].links.Add(computerList1.IndexOf(computerList3[index]));
                    }
                    if (flag5)
                    {
                        computerList3[index + 1].links.Add(computerList1.IndexOf(computerList2[index]));
                        computerList2[index + 1].links.Add(computerList1.IndexOf(computerList3[index]));
                    }
                }
                computerList2.Clear();
                for (int index = 0; index < computerList3.Count; ++index)
                {
                    computerList2.Add(computerList3[index]);
                }
                computerList3.Clear();
                compLocation.X += x;
                if (flag1)
                {
                    --num4;
                    num5 -= num2;
                }
                else
                {
                    ++num4;
                    num5 += num2;
                }
                if (num4 > num3)
                {
                    --num4;
                    flag1 = true;
                    num5 += num2;
                }
                flag2 = false;
            }
            if (!os.multiplayer)
            {
                computerList1.AddRange((IEnumerable <Computer>) this.generateGameNodes());
            }
            if (Settings.isDemoMode)
            {
                computerList1.AddRange((IEnumerable <Computer>) this.generateDemoNodes());
            }
            return(computerList1);
        }