private void SpawnMiningBlocks() { if (_validIndexes == null) { return; } HexCellularAutomataIndependent miningAutomata = new HexCellularAutomataIndependent(_mapWidth, _mapHeight, _rnd); miningAutomata.RandomFillMap(); miningAutomata.PlaceWalls_1D5678(1); //miningAutomata.PlaceWalls_1D5678_2D12(2); //<= GOOD miningAutomata.PlaceWalls_1D5678_2D1(1); //<= GOOD for (int i = 0; i < _size1D; i++) { if (Scene._grid[i].BasicValue == BasicValues.Ground /* && Scene._grid[i].ItemValue == 0*/) // _map { if (miningAutomata.Map[i].BasicValue == BasicValues.Ground) { Scene._grid[i].ItemValue = ItemValues.MiningBlock; } } } }
private void SpawnWaterLavaMultiple() { //Get a random number of water spots: int waterSpots = _rnd.Next(4, 15); int lavaSpots = _rnd.Next(3, 10); int sizeX; int sizeY; int posX; int posY; //Setup a random cellular automata for each spot: HexCellularAutomataIndependent[] water = new HexCellularAutomataIndependent[waterSpots]; HexCellularAutomataIndependent[] lava = new HexCellularAutomataIndependent[lavaSpots]; #region Water for (int i = 0; i < waterSpots; i++) { //Get a random size for the cellular automata: //sizeX = _rnd.Next(4, 11); sizeY = _rnd.Next(8, 15); sizeX = sizeY + _rnd.Next(0, 5); water[i] = new HexCellularAutomataIndependent(sizeX, sizeY, _rnd); water[i].RandomFillMap(); water[i].PlaceWalls_1D5678_2D1(3); //Select a random position for the water in the actual grid: posX = _rnd.Next(0, _mapWidth - sizeX); posY = _rnd.Next(0, _mapHeight - sizeY); //Merge the water map and the current map: for (int x = 0; x < water[i].MapWidth; x++) { for (int y = 0; y < water[i].MapHeight; y++) { if (water[i].Map[x + y * water[i].MapHeight].BasicValue == BasicValues.Ground) { Scene._grid[(posX + x) + (posY + y) * _mapHeight].BasicValue = BasicValues.Water; } } } } #endregion #region Lava for (int i = 0; i < lavaSpots; i++) { //Get a random size for the cellular automata: //sizeX = _rnd.Next(4, 11); sizeY = _rnd.Next(5, 15); sizeX = sizeY + _rnd.Next(1, 6); lava[i] = new HexCellularAutomataIndependent(sizeX, sizeY, _rnd); lava[i].RandomFillMap(); lava[i].PlaceWalls_1D5678_2D1(3); //Select a random position for the water in the actual grid: posX = _rnd.Next(0, _mapWidth - sizeX); posY = _rnd.Next(0, _mapHeight - sizeY); //Merge the water map and the current map: for (int x = 0; x < lava[i].MapWidth; x++) { for (int y = 0; y < lava[i].MapHeight; y++) { if (lava[i].Map[x + y * lava[i].MapHeight].BasicValue == BasicValues.Ground) { Scene._grid[(posX + x) + (posY + y) * _mapHeight].BasicValue = BasicValues.Lava; } } } } #endregion }
private void SpawnMiningBlocks() { if (_validIndexes == null) return; HexCellularAutomataIndependent miningAutomata = new HexCellularAutomataIndependent(_mapWidth, _mapHeight, _rnd); miningAutomata.RandomFillMap(); miningAutomata.PlaceWalls_1D5678(1); //miningAutomata.PlaceWalls_1D5678_2D12(2); //<= GOOD miningAutomata.PlaceWalls_1D5678_2D1(1); //<= GOOD for (int i = 0; i < _size1D; i++) { if (Scene._grid[i].BasicValue == BasicValues.Ground/* && Scene._grid[i].ItemValue == 0*/) // _map { if (miningAutomata.Map[i].BasicValue == BasicValues.Ground) Scene._grid[i].ItemValue = ItemValues.MiningBlock; } } }