Ejemplo n.º 1
0
            private static void InfectArea(GenerationProgress progress)
            {
                var area   = BiomeManager.Get <Epicenter>().Area;
                var widthL = SurfaceWidth / 2f; // The left side of the biome's width.
                var widthR = SurfaceWidth / 2f; // The right side of the biome's width.
                var j      = area.Top;          // The current iterator. We iterate from top to bottom via rows.

                // Just a shortcut function :P
                void InfectRow()
                {
                    for (int i = area.Center.X - (int)widthL; i < area.Center.X + (int)widthR; i++)
                    {
                        TileExtensions.Infect(i, j);
                    }
                }

                float GetJPercent() => (j - area.Top) / (float)area.Height;

                // Initial surface. Skinny.
                for (; GetJPercent() < 0.1 && widthL + widthR < area.Width; j++)
                {
                    widthL += Rand(-1, 1);
                    widthR += Rand(-1, 1);
                    InfectRow();
                }
                progress.Value = 0.3f;

                float inc = 1f; // How the shape of the biome should expand/

                // Expansion. The underground is a lot larger than the above ground.
                for (; GetJPercent() < 0.5 && widthL + widthR < area.Width; j++)
                {
                    inc    += 0.01f;
                    widthL += Rand(-inc / 3, inc);
                    widthR += Rand(-inc / 3, inc);
                    InfectRow();
                }
                progress.Value = 0.5f;

                // The more jagged edges of the bottom of the biome's bottom
                inc = 0f;
                for (; GetJPercent() < 0.8; j++)
                {
                    inc    += 0.02f;
                    widthL += Rand(-inc, inc);
                    widthR += Rand(-inc, inc);
                    InfectRow();
                }
                progress.Value = 0.7f;

                // Finally, close the bottom of the biome
                for (; GetJPercent() < 1 && widthL + widthR > 0 && inc > 0; j++)
                {
                    inc    -= 0.065f;
                    widthL += Rand(-inc - 1, inc / 2);
                    widthR += Rand(-inc - 1, inc / 2);
                    InfectRow();
                }
                progress.Value = 0.9f;
            }
Ejemplo n.º 2
0
        public override void RandomUpdate(int i, int j)
        {
            // Choose a random point to infect
            Point offset  = (WorldGen.genRand.NextFloat().ToRotationVector2() * WorldGen.genRand.Next(InfectiousTile.Range)).ToPoint();
            Point tilePos = new Point(i + offset.X, j + offset.Y);

            TileExtensions.Infect(tilePos.X, tilePos.Y);
        }