tools: define size/cost of tool as regular properties of the tool
rather than using a giant switch block to determine size/cost git-svn-id: https://micropolis.googlecode.com/svn/trunk/micropolis-java@913 d9718cc8-9f43-0410-858b-315f434eb58c
This commit is contained in:
parent
2d8e8ba86d
commit
2a77ddb26c
1 changed files with 33 additions and 59 deletions
|
@ -16,46 +16,35 @@ import static micropolisj.engine.TileConstants.*;
|
||||||
*/
|
*/
|
||||||
public enum MicropolisTool
|
public enum MicropolisTool
|
||||||
{
|
{
|
||||||
BULLDOZER,
|
BULLDOZER(1, 1),
|
||||||
WIRE,
|
WIRE(1, 5), //cost=25 for underwater
|
||||||
ROADS,
|
ROADS(1, 10), //cost=50 for over water
|
||||||
RAIL,
|
RAIL(1, 20), //cost=100 for underwater
|
||||||
RESIDENTIAL,
|
RESIDENTIAL(3, 100),
|
||||||
COMMERCIAL,
|
COMMERCIAL(3, 100),
|
||||||
INDUSTRIAL,
|
INDUSTRIAL(3, 100),
|
||||||
FIRE,
|
FIRE(3, 500),
|
||||||
POLICE,
|
POLICE(3, 500),
|
||||||
STADIUM,
|
STADIUM(4, 5000),
|
||||||
PARK,
|
PARK(1, 10),
|
||||||
SEAPORT,
|
SEAPORT(4, 3000),
|
||||||
POWERPLANT,
|
POWERPLANT(4, 3000),
|
||||||
NUCLEAR,
|
NUCLEAR(4, 5000),
|
||||||
AIRPORT,
|
AIRPORT(6, 10000),
|
||||||
QUERY;
|
QUERY(1, 0);
|
||||||
|
|
||||||
|
int size;
|
||||||
|
int cost;
|
||||||
|
|
||||||
|
private MicropolisTool(int size, int cost)
|
||||||
|
{
|
||||||
|
this.size = size;
|
||||||
|
this.cost = cost;
|
||||||
|
}
|
||||||
|
|
||||||
public int getWidth()
|
public int getWidth()
|
||||||
{
|
{
|
||||||
switch(this)
|
return size;
|
||||||
{
|
|
||||||
case RESIDENTIAL:
|
|
||||||
case COMMERCIAL:
|
|
||||||
case INDUSTRIAL:
|
|
||||||
case FIRE:
|
|
||||||
case POLICE:
|
|
||||||
return 3;
|
|
||||||
|
|
||||||
case STADIUM:
|
|
||||||
case SEAPORT:
|
|
||||||
case POWERPLANT:
|
|
||||||
case NUCLEAR:
|
|
||||||
return 4;
|
|
||||||
|
|
||||||
case AIRPORT:
|
|
||||||
return 6;
|
|
||||||
|
|
||||||
default:
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getHeight()
|
public int getHeight()
|
||||||
|
@ -83,29 +72,14 @@ public enum MicropolisTool
|
||||||
return beginStroke(engine, xpos, ypos).apply();
|
return beginStroke(engine, xpos, ypos).apply();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is the cost displayed in the GUI when the tool is selected.
|
||||||
|
* It does not necessarily reflect the cost charged when a tool is
|
||||||
|
* applied, as extra may be charged for clearing land or building
|
||||||
|
* over or through water.
|
||||||
|
*/
|
||||||
public int getToolCost()
|
public int getToolCost()
|
||||||
{
|
{
|
||||||
switch (this)
|
return cost;
|
||||||
{
|
|
||||||
case BULLDOZER: return 1;
|
|
||||||
case WIRE: return 5; //25 for underwater
|
|
||||||
case ROADS: return 10; //50 for over water
|
|
||||||
case RAIL: return 20; //100 for underwater
|
|
||||||
case RESIDENTIAL: return 100;
|
|
||||||
case COMMERCIAL: return 100;
|
|
||||||
case INDUSTRIAL: return 100;
|
|
||||||
case FIRE: return 500;
|
|
||||||
case POLICE: return 500;
|
|
||||||
case STADIUM: return 5000;
|
|
||||||
case PARK: return 10;
|
|
||||||
case SEAPORT: return 3000;
|
|
||||||
case POWERPLANT: return 3000;
|
|
||||||
case NUCLEAR: return 5000;
|
|
||||||
case AIRPORT: return 10000;
|
|
||||||
case QUERY: return 0;
|
|
||||||
default:
|
|
||||||
assert false;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue