when the coal plant is killed Also, this sets up a framework to handle industrial zones in the same way. git-svn-id: https://micropolis.googlecode.com/svn/trunk/micropolis-java@759 d9718cc8-9f43-0410-858b-315f434eb58c
68 lines
1.4 KiB
Java
68 lines
1.4 KiB
Java
package micropolisj.engine;
|
|
|
|
import java.io.*;
|
|
import java.nio.charset.Charset;
|
|
import java.util.*;
|
|
|
|
public class Tiles
|
|
{
|
|
static final Charset UTF8 = Charset.forName("UTF-8");
|
|
static TileSpec [] tiles = new TileSpec[960];
|
|
static {
|
|
try {
|
|
readTiles();
|
|
}
|
|
catch (IOException e) {
|
|
throw new RuntimeException(e);
|
|
}
|
|
}
|
|
|
|
static void readTiles()
|
|
throws IOException
|
|
{
|
|
tiles = new TileSpec[960];
|
|
|
|
Properties tilesRc = new Properties();
|
|
tilesRc.load(
|
|
new InputStreamReader(
|
|
Tiles.class.getResourceAsStream("/tiles.rc"),
|
|
UTF8
|
|
)
|
|
);
|
|
|
|
for (int i = 0; i < tiles.length; i++) {
|
|
String tileName = Integer.toString(i);
|
|
String rawSpec = tilesRc.getProperty(tileName);
|
|
if (rawSpec == null) {
|
|
continue;
|
|
}
|
|
|
|
tiles[i] = TileSpec.parse(i, rawSpec, tilesRc);
|
|
}
|
|
|
|
for (int i = 0; i < tiles.length; i++) {
|
|
String tmp = tiles[i].getAttribute("becomes");
|
|
if (tmp != null) {
|
|
tiles[i].animNext = get(Integer.parseInt(tmp));
|
|
}
|
|
tmp = tiles[i].getAttribute("onpower");
|
|
if (tmp != null) {
|
|
tiles[i].onPower = get(Integer.parseInt(tmp));
|
|
}
|
|
tmp = tiles[i].getAttribute("onshutdown");
|
|
if (tmp != null) {
|
|
tiles[i].onShutdown = get(Integer.parseInt(tmp));
|
|
}
|
|
}
|
|
}
|
|
|
|
public static TileSpec get(int tileNumber)
|
|
{
|
|
if (tileNumber >= 0 && tileNumber < tiles.length) {
|
|
return tiles[tileNumber];
|
|
}
|
|
else {
|
|
return null;
|
|
}
|
|
}
|
|
}
|