Ejemplo n.º 1
0
        /// <summary>
        /// The world generation procedure
        /// </summary>
        /// <param name="world">The target world</param>
        /// <param name="progressBar">A progressBar instance to render progress upon</param>
        public void Generate(World world, ProgressBar progressBar = null)
        {
            progressBar.Value = 0;
            world.BlankMap(Field.IdealHeight, Field.IdealTemperature);
            var featureCount = RandomThreadSafe.Next((world.Width + world.Height) / 4, (world.Width + world.Height) * 2);
            var features     = new List <IMapFeature>();

            for (int i = 0; i < featureCount; i++)
            {
                features.Add(availableFeatures[RandomThreadSafe.Next(0, availableFeatures.Count)].CreateSelf(world));
            }

            for (int i = 0; i < featureCount; i++)
            {
                features[i].Effect();
                if (progressBar != null)
                {
                    progressBar.Value = 100 * i / featureCount;
                }
            }
            if (progressBar != null)
            {
                progressBar.Value = 100;
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Generates a gaia in the world
 /// </summary>
 /// <param name="world"></param>
 /// <param name="progressBar"></param>
 public void Generate(World world, ProgressBar progressBar = null)
 {
     world.BlankMap(Field.IdealHeight, Field.IdealTemperature);
     if (progressBar != null)
     {
         progressBar.Value = 100;
     }
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Generates the tiles of a world
        /// </summary>
        /// <param name="world">The world to affect</param>
        /// <param name="progressBar">A progress bar to render the progress upon</param>
        public void Generate(World world, ProgressBar progressBar = null)
        {
            world.BlankMap(0, 0);
            var passes    = RandomThreadSafe.Next((world.Width + world.Height) / 2, (world.Width + world.Height));
            var toAgitate = new List <Coordinate>();

            //For a random ammount of passes
            for (int i = 0; i < passes; i++)
            {
                var drops = RandomThreadSafe.Next(1, (world.Width + world.Height));
                toAgitate.Clear();
                //Do a random ammount of drops based on the field size
                for (int j = 0; j < drops; j++)
                {
                    var x = RandomThreadSafe.Next(0, world.Width);
                    var y = RandomThreadSafe.Next(0, world.Height);
                    //Drop a random ammount of height and / or temperature particles on a given field
                    var doHeight = RandomThreadSafe.Next(0, 2);
                    var doTemp   = RandomThreadSafe.Next(0, 2);
                    world.Fields[x][y].Drop(RandomThreadSafe.Next(64, 255) * doHeight, RandomThreadSafe.Next(64, Field.MaxValue) * doTemp);
                    toAgitate.Add(new Coordinate(x, y));
                }
                foreach (var item in toAgitate)
                {
                    AgitateDrop(world, item.x, item.y);
                }
                if (progressBar != null)
                {
                    progressBar.Value = (i + 1) * 100 / passes;
                }
            }
            if (progressBar != null)
            {
                progressBar.Value = 100;
            }
        }