Ejemplo n.º 1
0
        public Level GenerateNextLevel(int seed, int i)
        {
            //int difficulty;
            seed     = seed + (seed + 1) * i;
            thisSeed = seed;
            Random rand = new Random(seed);

            Level levelNew = levelBase;//Instantiate(levelBase);

            TerrainOptions options = levelNew.terrainBuilder.terrainOptions;

            int[] sizes   = { 20, 30, 40 };
            var   randInd = rand.Next(0, sizes.Length);

            options.width         = options.height = sizes[randInd];
            options.seed          = seed;
            options.mountainCount = rand.Next(2, 6);
            options.waterCount    = rand.Next(1, 5);
            options.maxWaterSize  = rand.Next(10, 40);

            levelNew.enemySpawns.Clear();
            int nbEnnemy = rand.Next(i, i * 2);

            //nbEnnemy = 8;//nbEnnemy > 8 ? 8 : nbEnnemy;

            for (int j = 0; j < nbEnnemy; j++)
            {
                EnemySpawn es = new EnemySpawn();

                es.position = new Vector2(rand.Next(-options.width / 2 + 1, options.width / 2 - 1), rand.Next(-options.height / 2 + 1, options.height / 2 - 1));

                Array values = Enum.GetValues(typeof(EntityType));
                es.entityType = (EntityType)values.GetValue(rand.Next(values.Length));
                es.entityType = SoftEntityType(rand, es.entityType, (i - 2) / 3f);
                levelNew.enemySpawns.Add(es);
            }
            levelList.addLevel(levelNew);
            return(levelNew);
        }