Esempio n. 1
0
        public void Generate()
        {
            CryptoRandom rnd = new CryptoRandom();

            for (int y = 0; y < blockArray.GetLength(1); y++)
            {

                for (int x = 0; x < blockArray.GetLength(0); x++)
                {

                    Point blockLocation = new Point(x * 25, y * 25);

                    if (y < 12 || y == 199) //no random generation at this level
                    {

                        if (y <= 10)
                        {
                            //sky blocks at levels one to ten
                            addNewBlock(new Block_air(blockLocation), x, y);
                        }

                        if (y == 11)
                        {

                            Block_dirt b = new Block_dirt(blockLocation, textures.assets["grass"]);
                           // b.setGrassState(true);
                            addNewBlock(b, x, y);
                        }

                        if (y == 199) {

                            Block_bedrock b = new Block_bedrock(blockLocation, textures.assets["bedrock"]);
                            addNewBlock(b, x, y);

                        }

                    }
                    else
                    {
                        //begin probability calculations
                        int blockRnd;

                        Block newBlock = new Block_dirt(blockLocation, textures.assets["dirt"]);

                        if (y > 20)
                        {
                            //stone will start spawning at 20 blocks
                            blockRnd = rnd.Next(0, 100);

                            if (y + (blockRnd / 5) > 35)
                            {

                                newBlock = new Block_stone(blockLocation, textures.assets["stone"]);

                            }
                        }

                        if (y >= 25 && y <= 52)
                        {
                            //7% chance
                            blockRnd = rnd.Next(0, 100);
                            if (blockRnd <= 7)
                            {

                                newBlock = new Block_scrapMetal(blockLocation, textures.assets["scrapmetal"]);

                            }
                        }

                        if (y >= 45 && y <= 75) {

                            //5% chance
                            blockRnd = rnd.Next(0, 125);

                            if (blockRnd <= 5) {

                                newBlock = new Block_coal(blockLocation, textures.assets["coal"]);

                            }
                        }

                        if (y >= 60 && y <= 100) {

                            //5% chance
                            blockRnd = rnd.Next(0, 150);
                            if (blockRnd <= 5)
                            {

                                newBlock = new Block_bronze(blockLocation, textures.assets["bronze"]);

                            }
                        }

                        if (y >= 90 && y <= 130)
                        {
                            //3% chance

                            blockRnd = rnd.Next(0, 200);
                            if (blockRnd <= 3)
                            {

                               newBlock = new Block_iron(blockLocation, textures.assets["iron"]);

                            }
                        }

                        if (y > 125) {
                            //2 %
                            blockRnd = rnd.Next(0, 250);
                            if (blockRnd <= 2)
                            {

                                newBlock = new Block_gold(blockLocation, textures.assets["gold"]);

                            }
                        }

                        if (y > 150) {

                            blockRnd = rnd.Next(0, 500);
                            if (blockRnd <= 2)
                            {

                                newBlock = new Block_diamond(blockLocation, textures.assets["diamond"]);

                            }

                        }

                        if (y > 175)
                        {

                            blockRnd = rnd.Next(0, 1000);
                            if (blockRnd <= 2)
                            {

                                newBlock = new Block_varnium(blockLocation, textures.assets["varnium"]);

                            }

                        }

                        //add whatever the randomly determined block was

                        addNewBlock(newBlock, x, y);
                    }
                } // end for x
            } // end for y
        }
Esempio n. 2
0
        public void Generate()
        {
            CryptoRandom rnd = new CryptoRandom();

            for (int y = 0; y < blockArray.GetLength(1); y++)
            {
                for (int x = 0; x < blockArray.GetLength(0); x++)
                {
                    Point blockLocation = new Point(x * 25, y * 25);

                    if (y < 12 || y == 199) //no random generation at this level
                    {
                        if (y <= 10)
                        {
                            //sky blocks at levels one to ten
                            addNewBlock(new Block_air(blockLocation), x, y);
                        }

                        if (y == 11)
                        {
                            Block_dirt b = new Block_dirt(blockLocation, textures.assets["grass"]);
                            // b.setGrassState(true);
                            addNewBlock(b, x, y);
                        }

                        if (y == 199)
                        {
                            Block_bedrock b = new Block_bedrock(blockLocation, textures.assets["bedrock"]);
                            addNewBlock(b, x, y);
                        }
                    }
                    else
                    {
                        //begin probability calculations
                        int blockRnd;

                        Block newBlock = new Block_dirt(blockLocation, textures.assets["dirt"]);

                        if (y > 20)
                        {
                            //stone will start spawning at 20 blocks
                            blockRnd = rnd.Next(0, 100);

                            if (y + (blockRnd / 5) > 35)
                            {
                                newBlock = new Block_stone(blockLocation, textures.assets["stone"]);
                            }
                        }

                        if (y >= 25 && y <= 52)
                        {
                            //7% chance
                            blockRnd = rnd.Next(0, 100);
                            if (blockRnd <= 7)
                            {
                                newBlock = new Block_scrapMetal(blockLocation, textures.assets["scrapmetal"]);
                            }
                        }

                        if (y >= 45 && y <= 75)
                        {
                            //5% chance
                            blockRnd = rnd.Next(0, 125);

                            if (blockRnd <= 5)
                            {
                                newBlock = new Block_coal(blockLocation, textures.assets["coal"]);
                            }
                        }

                        if (y >= 60 && y <= 100)
                        {
                            //5% chance
                            blockRnd = rnd.Next(0, 150);
                            if (blockRnd <= 5)
                            {
                                newBlock = new Block_bronze(blockLocation, textures.assets["bronze"]);
                            }
                        }

                        if (y >= 90 && y <= 130)
                        {
                            //3% chance

                            blockRnd = rnd.Next(0, 200);
                            if (blockRnd <= 3)
                            {
                                newBlock = new Block_iron(blockLocation, textures.assets["iron"]);
                            }
                        }

                        if (y > 125)
                        {
                            //2 %
                            blockRnd = rnd.Next(0, 250);
                            if (blockRnd <= 2)
                            {
                                newBlock = new Block_gold(blockLocation, textures.assets["gold"]);
                            }
                        }

                        if (y > 150)
                        {
                            blockRnd = rnd.Next(0, 500);
                            if (blockRnd <= 2)
                            {
                                newBlock = new Block_diamond(blockLocation, textures.assets["diamond"]);
                            }
                        }

                        if (y > 175)
                        {
                            blockRnd = rnd.Next(0, 1000);
                            if (blockRnd <= 2)
                            {
                                newBlock = new Block_varnium(blockLocation, textures.assets["varnium"]);
                            }
                        }



                        //add whatever the randomly determined block was

                        addNewBlock(newBlock, x, y);
                    }
                } // end for x
            }     // end for y
        }         // end method