/* Turns a random tile on the row into a block to prevent large gaps in the level. */ private void FillOpenRow(int currentColumn, int row) { Random rnd; if (seed.Equals("")) { rnd = new Random(); } else { rnd = new Random(seed.GetHashCode()); } int selectedColumn = rnd.Next(0, world.GetLength(0)); GameService.Instance.EntityGameWorld[selectedColumn, row] = GameEntityFactory.NewBlock(new Vector3((selectedColumn * distanceBetweenColumns), (0), (row * distanceBetweenRows)), AssetManager.Instance.CreateTexture(Color.BlueViolet, gameManager.game.GraphicsDevice), GameEntityFactory.BLOCK); world[selectedColumn, row] = 1; }
/* * For all columns and rows, selects and creates worldgen entities for the world matrix */ private void PopulateWorld(int nColumns, int nRows) { Random rnd; int weightTotal = GetWeightTotal(); WorldgenEntities = WorldgenEntities.OrderBy(o => o.SelectionValue).ToList(); GameService.Instance.EntityGameWorld = new Entity[nColumns, nRows]; if (seed.Equals("")) { rnd = new Random(); } else { rnd = new Random(seed.GetHashCode()); } for (int column = 0; column < nColumns; column++) { for (int row = 0; row < nRows; row++) { if (row == 0) //First row is always filled with blocks as the players start there { GameService.Instance.EntityGameWorld[column, row] = GameEntityFactory.NewBlock(new Vector3((column * distanceBetweenColumns), (0), (row * distanceBetweenRows)), AssetManager.Instance.CreateTexture(Color.BlueViolet, gameManager.game.GraphicsDevice), GameEntityFactory.BLOCK); world[column, row] = 1; } else if (row == nRows - 1) //Last row should always be the goal { GameService.Instance.EntityGameWorld[column, row] = GameEntityFactory.NewGoalBlock(new Vector3((column * distanceBetweenColumns), (0), (row * distanceBetweenRows)), AssetManager.Instance.CreateTexture(Color.Gold, gameManager.game.GraphicsDevice)); world[column, row] = 2; } else { //Create a new random entity for the tile CreateSelectedWorldEntity((float)rnd.NextDouble(), column, row, new Vector3((column * distanceBetweenColumns), (0), (row * distanceBetweenRows))); } } } }
public Entity RunWorldGenEntityCreator(GameManager gameManager, Vector3 position) { return(GameEntityFactory.NewBlock(position, AssetManager.Instance.CreateTexture(Color.BlueViolet, gameManager.game.GraphicsDevice), GameEntityFactory.BLOCK)); }