/// <summary> /// Perform smoothing with or without dithering. /// </summary> /// <param name="srcMap">Source map.</param> /// <param name="destMap">Destination map.</param> /// <param name="ditherFlag">Function should apply dithering.</param> private void smoothDitherMap(MapByte2 srcMap, MapByte2 destMap, bool ditherFlag) { if (ditherFlag) { int x, y = 0, z = 0, dir = 1; for (x = 0; x < srcMap.MAP_W; x++) { for (; y != srcMap.MAP_H && y != -1; y += dir) { z += srcMap.get((x == 0) ? x : (x - 1), y) + srcMap.get((x == srcMap.MAP_W - 1) ? x : (x + 1), y) + srcMap.get(x, (y == 0) ? (0) : (y - 1)) + srcMap.get(x, (y == (srcMap.MAP_H - 1)) ? y : (y + 1)) + srcMap.get(x, y); destMap.set(x, y, (byte)(z / 4)); z &= 3; } dir = -dir; y += dir; } } else { short x, y, z; for (x = 0; x < srcMap.MAP_W; x++) { for (y = 0; y < srcMap.MAP_H; y++) { z = 0; if (x > 0) { z += srcMap.get(x - 1, y); } if (x < srcMap.MAP_W - 1) { z += srcMap.get(x + 1, y); } if (y > 0) { z += srcMap.get(x, y - 1); } if (y < (srcMap.MAP_H - 1)) { z += srcMap.get(x, y + 1); } z = (short)((z + srcMap.get(x, y)) >> 2); if (z > 255) { z = 255; } destMap.set(x, y, (byte)z); } } } }
/// <summary> /// Simualtor constructor. /// </summary> public Micropolis() { populationDensityMap = new MapByte2(0); trafficDensityMap = new MapByte2(0); pollutionDensityMap = new MapByte2(0); landValueMap = new MapByte2(0); crimeRateMap = new MapByte2(0); terrainDensityMap = new MapByte4(0); tempMap1 = new MapByte2(0); tempMap2 = new MapByte2(0); tempMap3 = new MapByte4(0); powerGridMap = new MapByte1(0); rateOfGrowthMap = new MapShort8(0); fireStationMap = new MapShort8(0); fireStationEffectMap = new MapShort8(0); policeStationMap = new MapShort8(0); policeStationEffectMap = new MapShort8(0); comRateMap = new MapShort8(0); init(); }