Ejemplo n.º 1
0
        public static void GenNovus()
        {
            //WorldGen.TileRunner(x, y, (double)WorldGen.genRand.Next(3, 6), WorldGen.genRand.Next(2, 6), TileType<ExampleOre>(), false, 0f, 0f, false, true);
            for (double k = 0; k < (Main.maxTilesX - 200) * (Main.maxTilesY - 150 - (int)Main.rockLayer) / 25.0 / 1.0; k += 1.0)
            {
                int   genx     = WorldGen.genRand.Next(100, Main.maxTilesX - 100);
                int   geny     = WorldGen.genRand.Next((int)0, (int)Main.rockLayer + 150);
                Tile  tile     = Framing.GetTileSafely(genx, geny);
                int   chance   = 0;
                int[] size     = { 3, 8 };
                int   tiletype = TileType <UnmanedOreTile>();
                if (tile.active() && (tile.type == TileID.Dirt || tile.type == TileID.Stone || tile.type == TileID.RainCloud || tile.type == TileID.Cloud))
                {
                    chance = 2;
                    if (tile.active() && tile.type == TileID.RainCloud || tile.type == TileID.Cloud)
                    {
                        chance   = 5;
                        tiletype = TileType <Biomass>();
                        size[0]  = 2;
                        size[1]  = 5;
                    }
                    if (tile.active() && (geny < WorldGen.worldSurfaceLow || (WorldGen.genRand.Next(0, 1000) < 2)))
                    {
                        chance   = 100;
                        tiletype = TileType <Biomass>();
                    }
                }

                if (WorldGen.genRand.Next(0, 100) < chance)
                {
                    IDGWorldGen.TileRunner(genx, geny, (double)WorldGen.genRand.Next(size[0], size[1]), WorldGen.genRand.Next(5, 16), tiletype, false, 0f, 0f, false, true);
                }
            }
        }
Ejemplo n.º 2
0
        public virtual void AGenPass(GenerationProgress prog)
        {
            UnifiedRandom UniRand  = new UnifiedRandom(DimDungeonsProxy.DungeonSeeds);
            int           lastseed = WorldGen._genRandSeed;

            WorldGen._genRandSeed = DimDungeonsProxy.DungeonSeeds;
            enemyseed             = (DimDungeonsProxy.DungeonSeeds);
            prog.Message          = "Loading";          //Sets the text above the worldgen progress bar
            Main.worldSurface     = Main.maxTilesY - 2; //Hides the underground layer just out of bounds
            Main.rockLayer        = Main.maxTilesY;     //Hides the cavern layer way out of bounds
            //Main.spawnTileX = (Main.maxTilesX / 2) / 16;
            prog.Message = "Once was nothing...";
            int        tileheight   = UniRand.Next(250, 400);
            List <int> surfacelevel = new List <int>();
            int        updown       = UniRand.Next(0, 2) == 0 ? 1 : -1;

            EnemySpawnsOverride = delegate(IDictionary <int, float> pool, NPCSpawnInfo spawnInfo, SGAPocketDim pocket)
            {
                UnifiedRandom UniRand2 = new UnifiedRandom(pocket.enemyseed);
                for (int i = 0; i < pool.Count; i += 1)
                {
                    pool[i] = 0f;
                }
                pool[ModContent.NPCType <NullWatcher>()] = 1f;
                pool[ModContent.NPCType <StygianVein>()] = 0.05f;

                pocket.chooseenemies = true;
                return(1);
            };

            //Base Terrain
            for (int x = 0; x < Main.maxTilesX; x += 1)
            {
                for (int y = tileheight; y < Main.maxTilesY; y += 1)
                {
                    Tile thetile = Framing.GetTileSafely(x, y);
                    thetile.active(true);
                    thetile.type = (ushort)SGAmod.Instance.TileType("Fabric");
                }
                if (Math.Abs(x - Main.maxTilesX / 2) < 30)
                {
                    Main.spawnTileY = tileheight;
                }
                else
                {
                    if (UniRand.Next(0, 10) == 1)
                    {
                        tileheight += UniRand.Next(1, 3) * updown;
                        if (UniRand.Next(0, 4) == 1)
                        {
                            updown = UniRand.Next(0, 2) == 0 ? 1 : -1;
                        }
                    }
                }
                if (surfacelevel.Count < x + 1)
                {
                    surfacelevel.Add(tileheight);
                }
            }


            for (int i = 0; i < 100; i += 1)
            {
                int randomx = UniRand.Next(Main.maxTilesX);
                int randomy = UniRand.Next(surfacelevel[randomx] + UniRand.Next(50, 100), Main.maxTilesY);
                IDGWorldGen.TileRunner(randomx, randomy, (double)UniRand.Next(5, 15), UniRand.Next(5, 15), SGAmod.Instance.TileType("EntrophicOre"), false, 0f, 0f, false, true, UniRand);
            }

            for (int i = 0; i < 300; i += 1)
            {
                int randomx = UniRand.Next(Main.maxTilesX);
                int randomy = UniRand.Next(surfacelevel[randomx] + (i % 20 == 0 ? -10 : 60), Main.maxTilesY);
                IDGWorldGen.TileRunner(randomx, randomy, (double)UniRand.Next(10, 50), UniRand.Next(15, 45) + i, -2, false, 0f, 0f, false, true, UniRand);
            }

            for (int i = 0; i < 150; i += 1)
            {
                int randomx = UniRand.Next(Main.maxTilesX);
                int randomy = UniRand.Next(surfacelevel[randomx] + UniRand.Next(20, 160), Main.maxTilesY);
                IDGWorldGen.TileRunner(randomx, randomy, (double)UniRand.Next(3, 6), UniRand.Next(2, 4), SGAmod.Instance.TileType("HopeOre"), false, 0f, 0f, false, true, UniRand);
            }

            //Noisegen.Frequency

            surfacelevel.Clear();


            //Ancient Fabric and fill in
            tileheight = Main.maxTilesY - Main.rand.Next(400, 400);

            for (int x = Main.maxTilesX - 1; x > 0; x -= 1)
            {
                Tile thetile = Framing.GetTileSafely(x, tileheight);
                IDGWorldGen.TileRunner(x, tileheight, (double)UniRand.Next(5, 10), UniRand.Next(2, 4), SGAmod.Instance.TileType("AncientFabric"), true, 0f, 0f, false, true, UniRand);
                thetile.active(true);
                thetile.type = (ushort)SGAmod.Instance.TileType("AncientFabric");

                for (int i = tileheight; i < Main.maxTilesY; i += 1)
                {
                    Framing.GetTileSafely(x, i).wall = (ushort)SGAmod.Instance.WallType("NullWall");
                }

                if (UniRand.Next(0, 10) == 1)
                {
                    tileheight += UniRand.Next(1, 3) * updown;
                    if (UniRand.Next(0, 4) == 1)
                    {
                        updown = (UniRand.Next(0, 2) == 0 || tileheight > Main.maxTilesY - 300) ? -1 : 1;
                    }
                }
            }

            NoiseGenerator Noisegen = new NoiseGenerator(DimDungeonsProxy.DungeonSeeds);

            Noisegen.Amplitude   = 1;
            Noisegen.Octaves     = 4;
            Noisegen.Persistence = 0.750;
            Noisegen.Frequency  *= 1.25;


            for (int y = 0; y < Main.maxTilesY; y += 1)
            {
                for (int x = 0; x < Main.maxTilesX; x += 1)
                {
                    float tilerate = -0.25f + (1f - (y / (float)Main.maxTilesY)) * 1f;
                    Tile  tile     = Main.tile[x, y];
                    if (tile.active() && tile.type == (ushort)SGAmod.Instance.TileType("Fabric"))
                    {
                        float nousey = MathHelper.Clamp((float)Noisegen.Noise(x, y), -1.00f, 1.00f);
                        if (nousey > tilerate)
                        {
                            Main.tile[x, y].type = (ushort)SGAmod.Instance.TileType("HardenedFabric");
                            Main.tile[x, y].color((byte)Paints.Shadow);
                        }
                        else
                        {
                            if (nousey > tilerate - 0.20f)
                            {
                                Main.tile[x, y].color((byte)Paints.Gray);
                            }
                        }
                    }
                }
            }


            WorldGen._genRandSeed = lastseed;
        }
Ejemplo n.º 3
0
        public virtual void AGenPass(GenerationProgress prog)
        {
            UniRand = new UnifiedRandom(DimDungeonsProxy.DungeonSeeds);
            int lastseed = WorldGen._genRandSeed;

            WorldGen._genRandSeed = DimDungeonsProxy.DungeonSeeds;
            enemyseed             = (DimDungeonsProxy.DungeonSeeds);
            prog.Message          = "Loading";          //Sets the text above the worldgen progress bar
            Main.worldSurface     = Main.maxTilesY - 2; //Hides the underground layer just out of bounds
            Main.rockLayer        = Main.maxTilesY;     //Hides the cavern layer way out of bounds
            //Main.spawnTileX = (Main.maxTilesX / 2) / 16;
            prog.Message = "Once was nothing...";

Restart:

            //Rectangle BoxedArea = new Rectangle(bufferSize, bufferSize + surfaceDeep, width - bufferSize * 2, (height - surfaceDeep) - (bufferSize * 2));

            //currentPosition = new Point16(width / 2 + (UniRand.Next(12) * sizeCheck) - sizeCheck * 6, height-200);
            currentPosition = new Point16(width / 2, height / 2);

            BossRoom       = new Rectangle(currentPosition.X - 160, currentPosition.Y - 100, 320, 200);
            BossRoomInside = new Rectangle(BossRoom.Center.X - 100, BossRoom.Center.Y - 60, 200, 120);

            currentPosition = new Point16(currentPosition.X + (UniRand.NextBool() ? 1 : -1) * ((BossRoom.Width / 2) + sizeCheck / 2), currentPosition.Y);


            int     xloc   = 200 + UniRand.Next(width - 400);
            Vector2 center = new Vector2(width, height) / 2f;

            for (int x = 0; x < width; x += 1)
            {
                for (int y = 0; y < height; y += 1)
                {
                    prog.Message = ((x * y) + y) / (float)(width * height) * 100f + "%";
                    float dist = (new Vector2(x, y) - center).LengthSquared();
                    Main.tile[x, y].type = (BossRoom.Contains(x, y) || dist > (height * height) / 8f) ? TileID.Adamantite : TileID.CobaltBrick;
                    Main.tile[x, y].active(true);
                }
            }

            for (int i = 0; i < 70; i += 1)
            {
                int     randomx = UniRand.Next(Main.maxTilesX);
                int     randomy = UniRand.Next(surfaceDeep, Main.maxTilesY);
                Vector2 vex     = new Vector2(randomx, randomy);
                if ((currentPosition.ToVector2() - vex).LengthSquared() > bufferSize * bufferSize)
                {
                    IDGWorldGen.TileRunner(randomx, randomy, (double)UniRand.Next(30, 100), UniRand.Next(15, 45) + i, TileID.Adamantite, false, 0f, 0f, true, true, UniRand);
                }
            }

            Noisegen            = new NoiseGenerator(DimDungeonsProxy.DungeonSeeds);
            Noisegen.Amplitude  = 1;
            Noisegen.Frequency *= 0.50;

            gen = 0;

            mazePainter = new List <MazeRoom>();// HashSet<MazeRoom>();
            mazeRooms   = new List <MazeRoom>();

            MazeGenerator(currentPosition, 0, 20000, prog);

            NoiseGenerator Noisegen2 = new NoiseGenerator(DimDungeonsProxy.DungeonSeeds);

            Noisegen2.Amplitude  = 1;
            Noisegen2.Frequency *= 0.050;

            int adder = 0;
            int noisy = 0;

            for (int x = 0; x < width; x += 1)
            {
                for (int y = 0; y < height; y += 1)
                {
                    Tile tile = Main.tile[x, (height - 1) - y];
                    tile.type = TileID.CobaltBrick;
                    tile.active(false);

                    prog.Value = (((x + (y * x)) / (float)(width * height)) * 1f);
                    float dist = (new Vector2(x, y) - center).LengthSquared();
                    if (!(dist > (height * height) / 8f))
                    {
                        tile.type = (ushort)ModContent.TileType <HardenedFabric>();
                        tile.active(true);
                    }
                    int dister = (height * height) / 5;

                    if (adder == 0)
                    {
                        noisy = (int)(Noisegen2.Noise(x, y) * (1000 * 1000));
                    }

                    adder = (adder + 1) % noiseDetail;

                    if ((tile.wall == WallID.DirtUnsafe || tile.wall == WallID.DirtUnsafe1 || tile.wall == WallID.DirtUnsafe2 || tile.wall == WallID.DirtUnsafe3 || tile.wall == WallID.DirtUnsafe4) || (dist > noisy + (dister + (y * y) / 4f)))
                    {
                        tile.type = (ushort)ModContent.TileType <HardenedFabric>();
                        tile.wall = 0;
                        tile.active(true);
                    }
                }
            }


            MazePainter();

            RoomFiller();

            PokeExits(5);

            BossBox();

            Main.spawnTileX = width / 2;
            Main.spawnTileY = 100;

            //Celular Crap

            /*for(int passes = 0; passes < 5; passes += 1) {
             *  for (int x = 0; x < Main.maxTilesX; x += 1)
             *  {
             *      for (int y = 0; y < Main.maxTilesY; y += 1)
             *      {
             *          if (GetTilesAround(x,y,1)>4)
             *          Main.tile[x, y].active(true);
             *          else
             *          Main.tile[x, y].active(false);
             *      }
             *  }
             * }*/
        }