tools: limit tools for most buildings to a single building at a time
buildings like power plants, stadiums, etc. must be placed one at a time now
This commit is contained in:
parent
122517d743
commit
060222a9c1
3 changed files with 77 additions and 28 deletions
60
src/micropolisj/engine/BuildingTool.java
Normal file
60
src/micropolisj/engine/BuildingTool.java
Normal file
|
@ -0,0 +1,60 @@
|
|||
// This file is part of MicropolisJ.
|
||||
// Copyright (C) 2013 Jason Long
|
||||
// Portions Copyright (C) 1989-2007 Electronic Arts Inc.
|
||||
//
|
||||
// MicropolisJ is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU GPLv3, with additional terms.
|
||||
// See the README file, included in this distribution, for details.
|
||||
|
||||
package micropolisj.engine;
|
||||
|
||||
import static micropolisj.engine.TileConstants.*;
|
||||
|
||||
class BuildingTool extends ToolStroke
|
||||
{
|
||||
public BuildingTool(Micropolis engine, MicropolisTool tool, int xpos, int ypos)
|
||||
{
|
||||
super(engine, tool, xpos, ypos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dragTo(int xdest, int ydest)
|
||||
{
|
||||
this.xpos = xdest;
|
||||
this.ypos = ydest;
|
||||
this.xdest = xdest;
|
||||
this.ydest = ydest;
|
||||
}
|
||||
|
||||
@Override
|
||||
boolean apply1(ToolEffectIfc eff)
|
||||
{
|
||||
switch (tool)
|
||||
{
|
||||
case FIRE:
|
||||
return applyZone(eff, FIRESTATION);
|
||||
|
||||
case POLICE:
|
||||
return applyZone(eff, POLICESTATION);
|
||||
|
||||
case POWERPLANT:
|
||||
return applyZone(eff, POWERPLANT);
|
||||
|
||||
case STADIUM:
|
||||
return applyZone(eff, STADIUM);
|
||||
|
||||
case SEAPORT:
|
||||
return applyZone(eff, PORT);
|
||||
|
||||
case NUCLEAR:
|
||||
return applyZone(eff, NUCLEAR);
|
||||
|
||||
case AIRPORT:
|
||||
return applyZone(eff, AIRPORT);
|
||||
|
||||
default:
|
||||
// not expected
|
||||
throw new Error("unexpected tool: "+tool);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -54,15 +54,25 @@ public enum MicropolisTool
|
|||
|
||||
public ToolStroke beginStroke(Micropolis engine, int xpos, int ypos)
|
||||
{
|
||||
if (this == BULLDOZER) {
|
||||
switch (this) {
|
||||
case BULLDOZER:
|
||||
return new Bulldozer(engine, xpos, ypos);
|
||||
}
|
||||
else if (this == WIRE ||
|
||||
this == ROADS ||
|
||||
this == RAIL) {
|
||||
|
||||
case WIRE:
|
||||
case ROADS:
|
||||
case RAIL:
|
||||
return new RoadLikeTool(engine, this, xpos, ypos);
|
||||
}
|
||||
else {
|
||||
|
||||
case FIRE:
|
||||
case POLICE:
|
||||
case STADIUM:
|
||||
case SEAPORT:
|
||||
case POWERPLANT:
|
||||
case NUCLEAR:
|
||||
case AIRPORT:
|
||||
return new BuildingTool(engine, this, xpos, ypos);
|
||||
|
||||
default:
|
||||
return new ToolStroke(engine, this, xpos, ypos);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -77,27 +77,6 @@ public class ToolStroke
|
|||
case INDUSTRIAL:
|
||||
return applyZone(eff, INDCLR);
|
||||
|
||||
case FIRE:
|
||||
return applyZone(eff, FIRESTATION);
|
||||
|
||||
case POLICE:
|
||||
return applyZone(eff, POLICESTATION);
|
||||
|
||||
case POWERPLANT:
|
||||
return applyZone(eff, POWERPLANT);
|
||||
|
||||
case STADIUM:
|
||||
return applyZone(eff, STADIUM);
|
||||
|
||||
case SEAPORT:
|
||||
return applyZone(eff, PORT);
|
||||
|
||||
case NUCLEAR:
|
||||
return applyZone(eff, NUCLEAR);
|
||||
|
||||
case AIRPORT:
|
||||
return applyZone(eff, AIRPORT);
|
||||
|
||||
default:
|
||||
// not expected
|
||||
throw new Error("unexpected tool: "+tool);
|
||||
|
|
Reference in a new issue