示例#1
0
        // generate location star map


        public List <XYPair> GeneratePlanetLocations(RandomPlanetGenerationScope scope)
        {
            int           splitFactor     = scope.splitFactor;
            int           gridSizeX       = scope.size.x;
            int           gridSizeY       = scope.size.y;
            int           radius          = scope.radius;
            int           maxAmount       = scope.maxAmountPerArea;
            List <XYPair> planetLocations = new List <XYPair>();

            for (int x = 0; x < splitFactor; x++)
            {
                for (int y = 0; y < splitFactor; y++)
                {
                    planetLocations.AddRange(GeneratePlanetLocationsInGridSection(x * (gridSizeX + radius),
                                                                                  y * (gridSizeY + radius),
                                                                                  gridSizeX, gridSizeY, maxAmount, radius));
                }
            }
            return(planetLocations);
        }
示例#2
0
        public void GenerateNewGalaxy()
        {
            AssetGenerator assetG             = new AssetGenerator();
            int            radius             = 7;
            int            sectionSizeX       = 70;
            int            sectionSizeY       = 50;
            int            splitFactor        = 4;//280 by 200
            RandomPlanetGenerationScope scope = new RandomPlanetGenerationScope(new XYPair(sectionSizeX, sectionSizeY),
                                                                                splitFactor, radius, 40);

            PrintGenerationInfo("Locating Planets...");
            List <XYPair> potentialPlanetLocations = assetG.GeneratePlanetLocations(scope);

            System.Threading.Thread.Sleep(1000);

            PrintGenerationInfo("Locating Home Planet System...");
            XYPair homeTownPosition = new XYPair(r.Next(50, 230), r.Next(50, 140));

            potentialPlanetLocations = assetG.EmptySpaceForHomeTown(potentialPlanetLocations, homeTownPosition);
            System.Threading.Thread.Sleep(1000);

            PrintGenerationInfo("Acquiring HomeTown Planet Names...");
            planets.AddRange(assetG.GenerateHomeTown(homeTownPosition));
            System.Threading.Thread.Sleep(1000);

            PrintGenerationInfo("Acquiring Planet Names...");
            planets.AddRange(assetG.PopulateLocation(potentialPlanetLocations));
            System.Threading.Thread.Sleep(1000);

            PrintGenerationInfo("Analyzing Market Data...");
            foreach (Planet p in planets)
            {
                p.GenerateMarket(ref r, categoryDatas);
                p.RefreshFuelPrice(ref r);
            }
            System.Threading.Thread.Sleep(1000);

            PrintGenerationInfo($"Locating {player.GetName()}...");
            player.setPlanet(planets.Find(p => p.GetName() == "Earth"));
            System.Threading.Thread.Sleep(1000);



            // BitMap for debug
            //PrintGenerationInfo($"Generating Galaxy Map...");
            //Bitmap bmp = new Bitmap((sectionSizeX + radius) * splitFactor * 10, (sectionSizeY + radius) * splitFactor * 10);
            //Graphics g = Graphics.FromImage(bmp);
            //foreach (XYPair l in potentialPlanetLocations)
            //{
            //    g.DrawEllipse(new Pen(Color.FromArgb(12,12,12), 3f),
            //        new Rectangle(new Point((l.x - radius) * 10, (l.y - radius) * 10), new Size(radius * 10, radius * 10)));
            //}
            //List<String> homePlanets = new List<string> { "Earth", "Mars", "XCentrolStation", "YoRHa", "Ernasis", "Alpha Centauri 3",
            // "Lisnar", "Amenias", "Agnesia"};
            //foreach (Planet p in planets)
            //{
            //    if (homePlanets.Contains(p.name))
            //    {
            //        g.FillEllipse(new SolidBrush(ColorTranslator.FromHtml("#ff00ffff")), new Rectangle(new Point((p.GetLocation().x - radius) * 10, (p.GetLocation().y - radius) * 10),
            //        new Size(radius * 2, radius * 2))
            //        );
            //    }

            //}

            //g.Dispose();
            //bmp.Save(@"C:\MSSA\Galaxy Map.PNG", System.Drawing.Imaging.ImageFormat.Png);
            //bmp.Dispose();
            PrintGenerationInfo($"Process Complete!");
            System.Threading.Thread.Sleep(3000);
            PrintGenerationInfo($"Welcome, {player.name}!");
            System.Threading.Thread.Sleep(2000);
        }