9 package micropolisj.engine;
12 import java.nio.charset.Charset;
19 static final Charset UTF8 = Charset.forName(
"UTF-8");
21 static Map<String, TileSpec> tilesByName =
new HashMap<String, TileSpec>();
27 catch(IOException e) {
28 throw new RuntimeException(e);
32 static void readTiles()
throws IOException {
33 ArrayList<TileSpec> tilesList =
new ArrayList<TileSpec>();
35 Properties tilesRc =
new Properties();
36 tilesRc.load(
new InputStreamReader(
Tiles.class.getResourceAsStream(
"/tiles.rc"), UTF8));
38 for(
int i = 0;; i++) {
39 String tileName = Integer.toString(i);
40 String rawSpec = tilesRc.getProperty(tileName);
46 tilesByName.put(tileName, ts);
49 tiles = tilesList.toArray(
new TileSpec[0]);
51 for(
int i = 0; i < tiles.length; i++) {
52 tiles[i].resolveReferences(tilesByName);
56 for(
int j = 0; j < bi.members.length; j++) {
57 int tid = bi.members[j];
58 int offx = (bi.width >= 3 ? -1 : 0) + j % bi.width;
59 int offy = (bi.height >= 3 ? -1 : 0) + j / bi.width;
61 if(tiles[tid].owner == null && (offx != 0 || offy != 0)) {
62 tiles[tid].
owner = tiles[i];
78 if(tileNumber >= 0 && tileNumber < tiles.length) {
79 return tiles[tileNumber];
86 static void checkTiles() {
87 for(
int i = 0; i < tiles.length; i++) {