public MapBattle GenerateBasicGrasslands(UInt16 dimensionX, UInt16 dimensionY) { MapBattle newMap = new MapBattle(_randomator, dimensionX, dimensionY); LinkMapToDrawerAndInterface(newMap); for (int i = 0; i < dimensionX; ++i) { for (int j = 0; j < dimensionY; ++j) { // Move the constant parameters to constants UInt32 dicethrow = _randomator.NSidedDice(20, 1); Coords currentCoords = new Coords(i, j); if (dicethrow == 1) { newMap.SetTile(currentCoords, new Tile(newMap, currentCoords, Constants.TileGeneratorSwamp)); } else if (dicethrow <= 2) { newMap.SetTile(currentCoords, new Tile(newMap, currentCoords, Constants.TileGeneratorWallStone)); } else if (dicethrow <= 5) { newMap.SetTile(currentCoords, new Tile(newMap, currentCoords, Constants.TileGeneratorForest)); } // the rest is grass by default. throw items and monsters onto it. } } newMap.AnalyzeTileAccessibility(); PopulateMapWithItems(newMap); PopulateMapWithMonsters(newMap); return(newMap); }
private Coords RandomAccessibleHex(MoveRangeCalculator range) { List <Coords> possibleMoves = new List <Coords>(); BitArray[] rangeMap = range.CurrentRangeMap; for (int i = 0; i < rangeMap.Length; ++i) { for (int j = 0; j < rangeMap[i].Count; ++j) { if (rangeMap[i][j]) { possibleMoves.Add(new Coords(i, j)); } } } RandomStuff randomator = _owner.MapGeneral.Randomator; return(possibleMoves[(Int32)(randomator.NSidedDice((UInt16)possibleMoves.Count, 1) - 1)]); }