9 package micropolisj.engine;
11 import static micropolisj.engine.TileConstants.*;
12 import micropolisj.util.Utilities;
14 class Bulldozer
extends ToolStroke {
16 Bulldozer(Micropolis city,
int xpos,
int ypos) {
17 super(city, MicropolisTool.BULLDOZER, xpos, ypos);
21 protected void applyArea(ToolEffectIfc eff) {
25 for (
int y = 0; y < b.height; y++) {
26 for (
int x = 0; x < b.width; x++) {
28 ToolEffectIfc subEff =
new TranslatedToolEffect(eff, b.x + x, b.y + y);
29 if (city.isTileDozeable(subEff)) {
38 for (
int y = 0; y < b.height; y++) {
39 for (
int x = 0; x < b.width; x++) {
41 if (isZoneCenter(eff.getTile(b.x + x, b.y + y))) {
42 dozeZone(
new TranslatedToolEffect(eff, b.x + x, b.y + y));
49 void dozeZone(ToolEffectIfc eff) {
51 int x = ((TranslatedToolEffect) eff).dx;
52 int y = ((TranslatedToolEffect) eff).dy;
64 if(eff.getPlayerID() != Utilities.getPlayerID((
char)currTile)) {
69 assert isZoneCenter(currTile);
70 currTile &= TileConstants.LOMASK;
72 CityDimension dim = getZoneSizeFor(currTile);
74 assert dim.width >= 3;
75 assert dim.height >= 3;
82 if (dim.width * dim.height < 16) {
83 eff.makeSound(0, 0, Sound.EXPLOSION_HIGH);
84 }
else if (dim.width * dim.height < 36) {
85 eff.makeSound(0, 0, Sound.EXPLOSION_LOW);
87 eff.makeSound(0, 0, Sound.EXPLOSION_BOTH);
90 putRubble(
new TranslatedToolEffect(eff, -1, -1), dim.width, dim.height);
94 void dozeField(ToolEffectIfc eff) {
95 int tile = eff.getTile(0, 0);
100 if (isOverWater(tile)) {
102 eff.setTile(0, 0, RIVER);
105 eff.setTile(0, 0, DIRT);
113 void putRubble(ToolEffectIfc eff,
int w,
int h) {
114 for (
int yy = 0; yy < h; yy++) {
115 for (
int xx = 0; xx < w; xx++) {
116 int tile = eff.getTile(xx, yy);
120 if (tile != RADTILE && tile != DIRT) {
121 int z = inPreview ? 0 : city.PRNG.nextInt(3);
122 int nTile = TINYEXP + z;
123 eff.setTile(xx, yy, nTile);
127 fixBorder(eff, w, h);