Added a Factory

This commit is contained in:
Ziver Koc 2007-05-07 14:30:36 +00:00
parent ae32a0a298
commit f675011503
5 changed files with 44 additions and 1 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 217 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 280 KiB

View file

@ -15,6 +15,7 @@ import ei.engine.util.MultiPrintStream;
import ei.game.player.GaiaPlayer; import ei.game.player.GaiaPlayer;
import ei.game.player.Player; import ei.game.player.Player;
import ei.game.player.PlayerHandler; import ei.game.player.PlayerHandler;
import ei.game.scene.map.Factory;
import ei.game.scene.map.Stone; import ei.game.scene.map.Stone;
public class Map { public class Map {
@ -24,6 +25,7 @@ public class Map {
public static final int MAP_ASFALT = 3; public static final int MAP_ASFALT = 3;
public static final int OBJ_STONE = 1; public static final int OBJ_STONE = 1;
public static final int OBJ_FACTORY = 2;
public static final int POS_SIZE = 50; public static final int POS_SIZE = 50;
private int width; private int width;
@ -112,6 +114,9 @@ public class Map {
case OBJ_STONE: case OBJ_STONE:
gaia.addUnit(new Stone(new Vector2i(i,j),gaia)); gaia.addUnit(new Stone(new Vector2i(i,j),gaia));
break; break;
case OBJ_FACTORY:
gaia.addUnit(new Factory(new Vector2i(i,j),gaia));
break;
} }
} }
} }

View file

@ -0,0 +1,38 @@
package ei.game.scene.map;
import ei.engine.math.Vector2f;
import ei.engine.math.Vector2i;
import ei.engine.scene.Entity;
import ei.engine.scene.Sprite;
import ei.game.player.Player;
public class Factory extends MapEntity{
private static final String[] img = {
"data/map/factory/factory1.png",
"data/map/factory/factory2.png"
};
private Sprite factory;
public Factory(Vector2i pos, Player p) {
super(500, pos, p);
}
@Override
public void init() {
factory = new Sprite("Factory",img[(int)(Math.random()*img.length)]);
factory.setSize(new Vector2f(50,50));
getNode().add(factory);
}
@Override
public Entity getSprite() {
return factory;
}
@Override
public int getMaintenanceCost() {
return 0;
}
}

View file

@ -21,7 +21,7 @@ public class Stone extends MapEntity{
private Sprite stone; private Sprite stone;
public Stone(Vector2i pos, Player p) { public Stone(Vector2i pos, Player p) {
super(10000, pos, p); super(500, pos, p);
} }
@Override @Override