This repository has been archived on 2025-02-21. You can view files and clone it, but cannot push or open issues or pull requests.
citylimitsj/src/micropolisj/engine/Tiles.java
jason@long.name 0c497aa434 tile animation: use tiles.rc to control termination of coal plant smoke
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
2013-07-20 21:35:05 +00:00

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;
}
}
}