Added som thing so to make the game network compatible
This commit is contained in:
parent
cbd673472f
commit
380492de56
32 changed files with 368 additions and 42 deletions
|
|
@ -24,6 +24,8 @@ public class InGameState extends GameState{
|
||||||
private static InGameMouseInput mouse;
|
private static InGameMouseInput mouse;
|
||||||
private static InGameKeyboardInput keyboard;
|
private static InGameKeyboardInput keyboard;
|
||||||
|
|
||||||
|
protected static boolean network = false;
|
||||||
|
|
||||||
public InGameState(String name){
|
public InGameState(String name){
|
||||||
super(name);
|
super(name);
|
||||||
}
|
}
|
||||||
|
|
@ -97,6 +99,10 @@ public class InGameState extends GameState{
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean isNetwork(){
|
||||||
|
return network;
|
||||||
|
}
|
||||||
|
|
||||||
public static void input(boolean b){
|
public static void input(boolean b){
|
||||||
mouse.setEnabled(b);
|
mouse.setEnabled(b);
|
||||||
keyboard.setEnabled(b);
|
keyboard.setEnabled(b);
|
||||||
|
|
|
||||||
13
src/ei/game/network/EIClient.java
Normal file
13
src/ei/game/network/EIClient.java
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
package ei.game.network;
|
||||||
|
|
||||||
|
import ei.game.gamestate.InGameState;
|
||||||
|
|
||||||
|
public class EIClient extends InGameState{
|
||||||
|
|
||||||
|
public EIClient(String name) {
|
||||||
|
super(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
13
src/ei/game/network/EIClientWorker.java
Normal file
13
src/ei/game/network/EIClientWorker.java
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
package ei.game.network;
|
||||||
|
|
||||||
|
import ei.engine.network.worker.Worker;
|
||||||
|
|
||||||
|
public class EIClientWorker extends Worker{
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void update() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
5
src/ei/game/network/EIServer.java
Normal file
5
src/ei/game/network/EIServer.java
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
package ei.game.network;
|
||||||
|
|
||||||
|
public class EIServer {
|
||||||
|
|
||||||
|
}
|
||||||
70
src/ei/game/network/entities/NetworkBuilding.java
Normal file
70
src/ei/game/network/entities/NetworkBuilding.java
Normal file
|
|
@ -0,0 +1,70 @@
|
||||||
|
package ei.game.network.entities;
|
||||||
|
|
||||||
|
import ei.engine.math.Vector2i;
|
||||||
|
import ei.game.gamestate.InGameState;
|
||||||
|
import ei.game.player.Player;
|
||||||
|
import ei.game.scene.buildings.Building;
|
||||||
|
import ei.game.scene.units.Unit;
|
||||||
|
|
||||||
|
public abstract class NetworkBuilding extends Building{
|
||||||
|
private static int nextId;
|
||||||
|
private int buildingId;
|
||||||
|
|
||||||
|
public NetworkBuilding(int l, Vector2i pos, Player p, int size) {
|
||||||
|
super(l, pos, p, size);
|
||||||
|
buildingId = nextId;
|
||||||
|
nextId++;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getBuildingId(){
|
||||||
|
return buildingId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPos(int x, int y, int size) {
|
||||||
|
if(!InGameState.isNetwork()){
|
||||||
|
super.setPos(x, y, size);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void buildUnit(Unit u){
|
||||||
|
if(!InGameState.isNetwork()){
|
||||||
|
super.buildUnit(u);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeLast(){
|
||||||
|
if(!InGameState.isNetwork()){
|
||||||
|
super.removeLast();
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void remove(){
|
||||||
|
if(!InGameState.isNetwork()){
|
||||||
|
super.remove();
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void update() {
|
||||||
|
if(!InGameState.isNetwork()){
|
||||||
|
super.update();
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
25
src/ei/game/network/entities/NetworkPlayer.java
Normal file
25
src/ei/game/network/entities/NetworkPlayer.java
Normal file
|
|
@ -0,0 +1,25 @@
|
||||||
|
package ei.game.network.entities;
|
||||||
|
|
||||||
|
import ei.game.gamestate.InGameState;
|
||||||
|
import ei.game.player.Player;
|
||||||
|
|
||||||
|
public abstract class NetworkPlayer extends Player{
|
||||||
|
|
||||||
|
public void setKredits(int k){
|
||||||
|
if(!InGameState.isNetwork()){
|
||||||
|
super.setKredits(k);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addKredits(int add){
|
||||||
|
if(!InGameState.isNetwork()){
|
||||||
|
super.addKredits(add);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
82
src/ei/game/network/entities/NetworkUnit.java
Normal file
82
src/ei/game/network/entities/NetworkUnit.java
Normal file
|
|
@ -0,0 +1,82 @@
|
||||||
|
package ei.game.network.entities;
|
||||||
|
|
||||||
|
import ei.engine.math.Vector2i;
|
||||||
|
import ei.game.gamestate.InGameState;
|
||||||
|
import ei.game.player.Player;
|
||||||
|
import ei.game.scene.units.Unit;
|
||||||
|
|
||||||
|
public abstract class NetworkUnit extends Unit{
|
||||||
|
private static int nextId;
|
||||||
|
private int unitId = -1;
|
||||||
|
|
||||||
|
public NetworkUnit(int l, Player p) {
|
||||||
|
super(l, p);
|
||||||
|
unitId = nextId;
|
||||||
|
nextId++;
|
||||||
|
}
|
||||||
|
|
||||||
|
public NetworkUnit(int l, Vector2i pos, Player p) {
|
||||||
|
super(l, pos, p);
|
||||||
|
unitId = nextId;
|
||||||
|
nextId++;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getUnitId(){
|
||||||
|
return unitId;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void move(int x, int y, boolean b) {
|
||||||
|
if(!InGameState.isNetwork()){
|
||||||
|
super.move(x, y, b);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void attack(Vector2i target, boolean play) {
|
||||||
|
if(!InGameState.isNetwork()){
|
||||||
|
super.attack(target, play);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void remove(){
|
||||||
|
if(!InGameState.isNetwork()){
|
||||||
|
super.remove();
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPos(int x, int y) {
|
||||||
|
if(!InGameState.isNetwork()){
|
||||||
|
super.setPos(x, y);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void forcePos(int x, int y){
|
||||||
|
if(!InGameState.isNetwork()){
|
||||||
|
super.forcePos(x, y);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void update() {
|
||||||
|
if(!InGameState.isNetwork()){
|
||||||
|
super.update();
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
31
src/ei/game/network/entities/NetworkWepon.java
Normal file
31
src/ei/game/network/entities/NetworkWepon.java
Normal file
|
|
@ -0,0 +1,31 @@
|
||||||
|
package ei.game.network.entities;
|
||||||
|
|
||||||
|
import ei.engine.math.Vector2f;
|
||||||
|
import ei.engine.math.Vector2i;
|
||||||
|
import ei.game.gamestate.InGameState;
|
||||||
|
import ei.game.scene.weapons.Weapon;
|
||||||
|
|
||||||
|
public abstract class NetworkWepon extends Weapon{
|
||||||
|
|
||||||
|
public NetworkWepon(Vector2f startPos) {
|
||||||
|
super(startPos);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void launch(Vector2i target) {
|
||||||
|
if(!InGameState.isNetwork()){
|
||||||
|
super.launch(target);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void update() {
|
||||||
|
if(!InGameState.isNetwork()){
|
||||||
|
super.update();
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
9
src/ei/game/network/messages/AttackUnitMessage.java
Normal file
9
src/ei/game/network/messages/AttackUnitMessage.java
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
package ei.game.network.messages;
|
||||||
|
|
||||||
|
import ei.engine.network.message.Message;
|
||||||
|
|
||||||
|
public class AttackUnitMessage extends Message{
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
}
|
||||||
9
src/ei/game/network/messages/BuildUnitMessage.java
Normal file
9
src/ei/game/network/messages/BuildUnitMessage.java
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
package ei.game.network.messages;
|
||||||
|
|
||||||
|
import ei.engine.network.message.Message;
|
||||||
|
|
||||||
|
public class BuildUnitMessage extends Message{
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
}
|
||||||
9
src/ei/game/network/messages/KreditsMessage.java
Normal file
9
src/ei/game/network/messages/KreditsMessage.java
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
package ei.game.network.messages;
|
||||||
|
|
||||||
|
import ei.engine.network.message.Message;
|
||||||
|
|
||||||
|
public class KreditsMessage extends Message {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
}
|
||||||
9
src/ei/game/network/messages/MoveUnitMessage.java
Normal file
9
src/ei/game/network/messages/MoveUnitMessage.java
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
package ei.game.network.messages;
|
||||||
|
|
||||||
|
import ei.engine.network.message.Message;
|
||||||
|
|
||||||
|
public class MoveUnitMessage extends Message {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
}
|
||||||
9
src/ei/game/network/messages/NewUnitMessage.java
Normal file
9
src/ei/game/network/messages/NewUnitMessage.java
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
package ei.game.network.messages;
|
||||||
|
|
||||||
|
import ei.engine.network.message.Message;
|
||||||
|
|
||||||
|
public class NewUnitMessage extends Message {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -2,6 +2,7 @@ package ei.game.player;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import ei.game.network.entities.NetworkPlayer;
|
||||||
import ei.game.scene.GameEntity;
|
import ei.game.scene.GameEntity;
|
||||||
import ei.game.scene.buildings.Building;
|
import ei.game.scene.buildings.Building;
|
||||||
import ei.game.scene.buildings.CommandCenter;
|
import ei.game.scene.buildings.CommandCenter;
|
||||||
|
|
@ -14,7 +15,7 @@ import ei.game.scene.units.Tank;
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class AiPlayer extends Player{
|
public class AiPlayer extends NetworkPlayer{
|
||||||
private CommandCenter cc;
|
private CommandCenter cc;
|
||||||
private int timer;
|
private int timer;
|
||||||
private ArrayList<GameEntity> attackingUnits;
|
private ArrayList<GameEntity> attackingUnits;
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
package ei.game.player;
|
package ei.game.player;
|
||||||
|
|
||||||
|
import ei.game.network.entities.NetworkPlayer;
|
||||||
import ei.game.scene.buildings.Building;
|
import ei.game.scene.buildings.Building;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -8,7 +9,7 @@ import ei.game.scene.buildings.Building;
|
||||||
* @author Ziver
|
* @author Ziver
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class GaiaPlayer extends Player{
|
public class GaiaPlayer extends NetworkPlayer{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Building getCC() {
|
public Building getCC() {
|
||||||
|
|
|
||||||
|
|
@ -2,10 +2,11 @@ package ei.game.player;
|
||||||
|
|
||||||
import ei.engine.state.GameStateManager;
|
import ei.engine.state.GameStateManager;
|
||||||
import ei.game.gamestate.EndGameState;
|
import ei.game.gamestate.EndGameState;
|
||||||
|
import ei.game.network.entities.NetworkPlayer;
|
||||||
import ei.game.scene.buildings.Building;
|
import ei.game.scene.buildings.Building;
|
||||||
import ei.game.scene.buildings.CommandCenter;
|
import ei.game.scene.buildings.CommandCenter;
|
||||||
|
|
||||||
public class HumanPlayer extends Player{
|
public class HumanPlayer extends NetworkPlayer{
|
||||||
private CommandCenter cc;
|
private CommandCenter cc;
|
||||||
|
|
||||||
public HumanPlayer(){
|
public HumanPlayer(){
|
||||||
|
|
|
||||||
|
|
@ -22,16 +22,7 @@ public abstract class GameEntity{
|
||||||
public int getLife(){
|
public int getLife(){
|
||||||
return life;
|
return life;
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract boolean isTerrain();
|
|
||||||
|
|
||||||
public abstract Vector2i getPos();
|
|
||||||
|
|
||||||
public abstract boolean isAttacking();
|
|
||||||
|
|
||||||
public abstract boolean isMoving();
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the life
|
* Set the life
|
||||||
* @param l The life to set to
|
* @param l The life to set to
|
||||||
|
|
@ -93,9 +84,8 @@ public abstract class GameEntity{
|
||||||
|
|
||||||
protected abstract SelectBox getSelection();
|
protected abstract SelectBox getSelection();
|
||||||
|
|
||||||
public void move(boolean play, int x, int y) {
|
public void move(boolean play, int x, int y) {}
|
||||||
|
|
||||||
}
|
|
||||||
public abstract void remove();
|
public abstract void remove();
|
||||||
|
|
||||||
public abstract void update();
|
public abstract void update();
|
||||||
|
|
@ -106,6 +96,16 @@ public abstract class GameEntity{
|
||||||
|
|
||||||
public abstract Entity getSprite();
|
public abstract Entity getSprite();
|
||||||
|
|
||||||
public abstract int getMaintenanceCost();
|
public abstract int getMaintenanceCost();
|
||||||
|
|
||||||
|
public abstract void initGraphics();
|
||||||
|
|
||||||
|
public abstract boolean isTerrain();
|
||||||
|
|
||||||
|
public abstract Vector2i getPos();
|
||||||
|
|
||||||
|
public abstract boolean isAttacking();
|
||||||
|
|
||||||
|
public abstract boolean isMoving();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -153,7 +153,7 @@ public class Map {
|
||||||
gaia.addUnit(new Prison(new Vector2i(i,j),gaia));
|
gaia.addUnit(new Prison(new Vector2i(i,j),gaia));
|
||||||
break;
|
break;
|
||||||
case OBJ_WATER:
|
case OBJ_WATER:
|
||||||
gaia.addUnit(new Water(new Vector2i(i,j),gaia, 300));
|
gaia.addUnit(new Water(new Vector2i(i,j),gaia));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -41,6 +41,7 @@ public abstract class Building extends GameEntity{
|
||||||
moveFrom.sub(unitNode.getLocation().getX()-20,unitNode.getLocation().getY());
|
moveFrom.sub(unitNode.getLocation().getX()-20,unitNode.getLocation().getY());
|
||||||
moveTo.sub(unitNode.getLocation().getX(),unitNode.getLocation().getY());
|
moveTo.sub(unitNode.getLocation().getX(),unitNode.getLocation().getY());
|
||||||
|
|
||||||
|
initGraphics();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSelected(Player p,boolean b, boolean playSound) {
|
public void setSelected(Player p,boolean b, boolean playSound) {
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,9 @@ public class CommandCenter extends Building{
|
||||||
|
|
||||||
public CommandCenter(int x, int y, Player p){
|
public CommandCenter(int x, int y, Player p){
|
||||||
super(1000, new Vector2i(x,y), p, 4);
|
super(1000, new Vector2i(x,y), p, 4);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void initGraphics(){
|
||||||
ground = new Sprite("CC_Ground", "data/buildings/cc/cc_ground.png");
|
ground = new Sprite("CC_Ground", "data/buildings/cc/cc_ground.png");
|
||||||
ground.setSize(new Vector2f(200,200));
|
ground.setSize(new Vector2f(200,200));
|
||||||
getNode().add(ground);
|
getNode().add(ground);
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,9 @@ public class Factory extends Building{
|
||||||
|
|
||||||
public Factory(Vector2i pos, Player p) {
|
public Factory(Vector2i pos, Player p) {
|
||||||
super(500, pos, p, 4);
|
super(500, pos, p, 4);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void initGraphics(){
|
||||||
factory = new Sprite("Factory",img[(int)(Math.random()*img.length)]);
|
factory = new Sprite("Factory",img[(int)(Math.random()*img.length)]);
|
||||||
factory.setSize(new Vector2f(200,200));
|
factory.setSize(new Vector2f(200,200));
|
||||||
getNode().add(factory);
|
getNode().add(factory);
|
||||||
|
|
|
||||||
|
|
@ -19,13 +19,16 @@ public class Prison extends Building{
|
||||||
|
|
||||||
public Prison(Vector2i pos, Player p) {
|
public Prison(Vector2i pos, Player p) {
|
||||||
super(2000, pos, p, 6);
|
super(2000, pos, p, 6);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void initGraphics(){
|
||||||
prison = new Sprite("Prison",img[(int)(Math.random()*img.length)]);
|
prison = new Sprite("Prison",img[(int)(Math.random()*img.length)]);
|
||||||
prison.setSize(new Vector2f(300,300));
|
prison.setSize(new Vector2f(300,300));
|
||||||
getNode().add(prison);
|
getNode().add(prison);
|
||||||
|
|
||||||
selectionBox = new SelectBox(0,300,300,getMaxLife());
|
selectionBox = new SelectBox(0,300,300,getMaxLife());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Entity getSprite() {
|
public Entity getSprite() {
|
||||||
return prison;
|
return prison;
|
||||||
|
|
|
||||||
|
|
@ -25,10 +25,12 @@ public class Stone extends MapEntity{
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void init() {
|
public void init() {}
|
||||||
|
|
||||||
|
public void initGraphics(){
|
||||||
stone = new Sprite("Stone",img[(int)(Math.random()*img.length)]);
|
stone = new Sprite("Stone",img[(int)(Math.random()*img.length)]);
|
||||||
stone.setSize(new Vector2f(40,40));
|
stone.setSize(new Vector2f(40,40));
|
||||||
getNode().add(stone);
|
getNode().add(stone);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,6 @@ import ei.engine.math.Vector2i;
|
||||||
import ei.engine.scene.Entity;
|
import ei.engine.scene.Entity;
|
||||||
import ei.engine.scene.Sprite;
|
import ei.engine.scene.Sprite;
|
||||||
import ei.game.player.Player;
|
import ei.game.player.Player;
|
||||||
import ei.game.scene.Map;
|
|
||||||
import ei.game.scene.SelectBox;
|
import ei.game.scene.SelectBox;
|
||||||
import ei.game.scene.buildings.Building;
|
import ei.game.scene.buildings.Building;
|
||||||
|
|
||||||
|
|
@ -15,12 +14,14 @@ public class Water extends Building{
|
||||||
};
|
};
|
||||||
private Sprite water;
|
private Sprite water;
|
||||||
|
|
||||||
public Water(Vector2i pos, Player p, int size) {
|
public Water(Vector2i pos, Player p) {
|
||||||
super(Integer.MAX_VALUE, pos, p, size%Map.POS_SIZE);
|
super(Integer.MAX_VALUE, pos, p, 6);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void initGraphics(){
|
||||||
water = new Sprite("Water",img[(int)(Math.random()*img.length)]);
|
water = new Sprite("Water",img[(int)(Math.random()*img.length)]);
|
||||||
water.setSize(new Vector2f(size, size));
|
water.setSize(new Vector2f(300, 300));
|
||||||
getNode().add(water);
|
getNode().add(water);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ import ei.engine.math.Vector2f;
|
||||||
import ei.engine.math.Vector2i;
|
import ei.engine.math.Vector2i;
|
||||||
import ei.engine.scene.Sprite;
|
import ei.engine.scene.Sprite;
|
||||||
import ei.engine.sound.Sound;
|
import ei.engine.sound.Sound;
|
||||||
|
import ei.game.network.entities.NetworkUnit;
|
||||||
import ei.game.player.Player;
|
import ei.game.player.Player;
|
||||||
import ei.game.scene.SelectBox;
|
import ei.game.scene.SelectBox;
|
||||||
import ei.game.scene.weapons.Explotion;
|
import ei.game.scene.weapons.Explotion;
|
||||||
|
|
@ -16,7 +17,7 @@ import ei.game.scene.weapons.WeaponHandler;
|
||||||
* @author Jesper Lundin
|
* @author Jesper Lundin
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class APU extends Unit{
|
public class APU extends NetworkUnit{
|
||||||
private SelectBox selectionBox;
|
private SelectBox selectionBox;
|
||||||
private Sprite sprite;
|
private Sprite sprite;
|
||||||
|
|
||||||
|
|
@ -34,11 +35,14 @@ public class APU extends Unit{
|
||||||
}
|
}
|
||||||
|
|
||||||
public void init(){
|
public void init(){
|
||||||
|
setBuildTime(200);
|
||||||
|
setPrice(200);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void initGraphics(){
|
||||||
sprite = new Sprite("APU", "data/units/apu/apu0000.png");
|
sprite = new Sprite("APU", "data/units/apu/apu0000.png");
|
||||||
sprite.setSize(new Vector2f(40,40));
|
sprite.setSize(new Vector2f(40,40));
|
||||||
getNode().add(sprite);
|
getNode().add(sprite);
|
||||||
setBuildTime(200);
|
|
||||||
setPrice(200);
|
|
||||||
|
|
||||||
gunSound = new Sound("gunSound", "data/sounds/machinegun.wav");
|
gunSound = new Sound("gunSound", "data/sounds/machinegun.wav");
|
||||||
moveSound = new Sound[2];
|
moveSound = new Sound[2];
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ import ei.engine.math.Vector2i;
|
||||||
import ei.engine.scene.Sprite;
|
import ei.engine.scene.Sprite;
|
||||||
import ei.engine.sound.Sound;
|
import ei.engine.sound.Sound;
|
||||||
import ei.engine.texture.AnimatedTexture;
|
import ei.engine.texture.AnimatedTexture;
|
||||||
|
import ei.game.network.entities.NetworkUnit;
|
||||||
import ei.game.player.Player;
|
import ei.game.player.Player;
|
||||||
import ei.game.scene.SelectBox;
|
import ei.game.scene.SelectBox;
|
||||||
import ei.game.scene.weapons.BomberWeapon;
|
import ei.game.scene.weapons.BomberWeapon;
|
||||||
|
|
@ -17,7 +18,7 @@ import ei.game.scene.weapons.WeaponHandler;
|
||||||
* @author Jesper Lundin
|
* @author Jesper Lundin
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class Bomber extends Unit{
|
public class Bomber extends NetworkUnit{
|
||||||
private SelectBox selectionBox;
|
private SelectBox selectionBox;
|
||||||
private Sprite sprite;
|
private Sprite sprite;
|
||||||
|
|
||||||
|
|
@ -35,6 +36,15 @@ public class Bomber extends Unit{
|
||||||
}
|
}
|
||||||
|
|
||||||
public void init(){
|
public void init(){
|
||||||
|
getNode().add(sprite);
|
||||||
|
setBuildTime(400);
|
||||||
|
setPrice(800);
|
||||||
|
autoAttack(false);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void initGraphics(){
|
||||||
AnimatedTexture tex = new AnimatedTexture("BomberTexture");
|
AnimatedTexture tex = new AnimatedTexture("BomberTexture");
|
||||||
tex.addAnimation("normal", new String[]{
|
tex.addAnimation("normal", new String[]{
|
||||||
"data/units/bomber/bomber0000.png",
|
"data/units/bomber/bomber0000.png",
|
||||||
|
|
@ -45,10 +55,6 @@ public class Bomber extends Unit{
|
||||||
tex.setDelay(5);
|
tex.setDelay(5);
|
||||||
sprite = new Sprite("Bomber",tex);
|
sprite = new Sprite("Bomber",tex);
|
||||||
sprite.setSize(new Vector2f(50,60));
|
sprite.setSize(new Vector2f(50,60));
|
||||||
getNode().add(sprite);
|
|
||||||
setBuildTime(400);
|
|
||||||
setPrice(800);
|
|
||||||
autoAttack(false);
|
|
||||||
|
|
||||||
gunSound = new Sound("gunSound", "data/sounds/bomberweapon.wav");
|
gunSound = new Sound("gunSound", "data/sounds/bomberweapon.wav");
|
||||||
moveSound = new Sound[2];
|
moveSound = new Sound[2];
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ import ei.engine.math.Vector2f;
|
||||||
import ei.engine.math.Vector2i;
|
import ei.engine.math.Vector2i;
|
||||||
import ei.engine.scene.Sprite;
|
import ei.engine.scene.Sprite;
|
||||||
import ei.engine.sound.Sound;
|
import ei.engine.sound.Sound;
|
||||||
|
import ei.game.network.entities.NetworkUnit;
|
||||||
import ei.game.player.Player;
|
import ei.game.player.Player;
|
||||||
import ei.game.scene.SelectBox;
|
import ei.game.scene.SelectBox;
|
||||||
import ei.game.scene.weapons.CannonBall;
|
import ei.game.scene.weapons.CannonBall;
|
||||||
|
|
@ -16,7 +17,7 @@ import ei.game.scene.weapons.WeaponHandler;
|
||||||
* @author Jesper Lundin
|
* @author Jesper Lundin
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class Tank extends Unit{
|
public class Tank extends NetworkUnit{
|
||||||
private SelectBox selectionBox;
|
private SelectBox selectionBox;
|
||||||
private Sprite sprite;
|
private Sprite sprite;
|
||||||
|
|
||||||
|
|
@ -34,11 +35,14 @@ public class Tank extends Unit{
|
||||||
}
|
}
|
||||||
|
|
||||||
public void init(){
|
public void init(){
|
||||||
|
setBuildTime(300);
|
||||||
|
setPrice(400);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void initGraphics(){
|
||||||
sprite = new Sprite("Tank", "data/units/tank/tank0000.png");
|
sprite = new Sprite("Tank", "data/units/tank/tank0000.png");
|
||||||
sprite.setSize(new Vector2f(40,40));
|
sprite.setSize(new Vector2f(40,40));
|
||||||
getNode().add(sprite);
|
getNode().add(sprite);
|
||||||
setBuildTime(300);
|
|
||||||
setPrice(400);
|
|
||||||
|
|
||||||
gunSound = new Sound("gunSound", "data/sounds/tankweapon.wav");
|
gunSound = new Sound("gunSound", "data/sounds/tankweapon.wav");
|
||||||
moveSound = new Sound[2];
|
moveSound = new Sound[2];
|
||||||
|
|
|
||||||
|
|
@ -54,6 +54,7 @@ public abstract class Unit extends GameEntity{
|
||||||
setPos(pos.getX(), pos.getY());
|
setPos(pos.getX(), pos.getY());
|
||||||
autoAttack = true;
|
autoAttack = true;
|
||||||
init();
|
init();
|
||||||
|
initGraphics();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -66,6 +67,7 @@ public abstract class Unit extends GameEntity{
|
||||||
unitNode = new Node("UnitNode");
|
unitNode = new Node("UnitNode");
|
||||||
autoAttack = true;
|
autoAttack = true;
|
||||||
init();
|
init();
|
||||||
|
initGraphics();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSelected(Player p,boolean b,boolean playSound) {
|
public void setSelected(Player p,boolean b,boolean playSound) {
|
||||||
|
|
@ -209,6 +211,7 @@ public abstract class Unit extends GameEntity{
|
||||||
this.target = target;
|
this.target = target;
|
||||||
attack = InGameState.getMap().getPos(target.getX(),target.getY());
|
attack = InGameState.getMap().getPos(target.getX(),target.getY());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void autoAttack(boolean auto) {
|
public void autoAttack(boolean auto) {
|
||||||
autoAttack = auto;
|
autoAttack = auto;
|
||||||
}
|
}
|
||||||
|
|
@ -227,7 +230,6 @@ public abstract class Unit extends GameEntity{
|
||||||
|
|
||||||
public abstract void init();
|
public abstract void init();
|
||||||
|
|
||||||
|
|
||||||
public void remove(){
|
public void remove(){
|
||||||
unitNode.remove(getSprite());
|
unitNode.remove(getSprite());
|
||||||
getPlayer().removeUnit(this);
|
getPlayer().removeUnit(this);
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ import ei.engine.effects.Particles;
|
||||||
import ei.engine.math.Vector2f;
|
import ei.engine.math.Vector2f;
|
||||||
import ei.engine.math.Vector2i;
|
import ei.engine.math.Vector2i;
|
||||||
import ei.game.gamestate.InGameState;
|
import ei.game.gamestate.InGameState;
|
||||||
|
import ei.game.network.entities.NetworkWepon;
|
||||||
import ei.game.scene.Map;
|
import ei.game.scene.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -11,7 +12,7 @@ import ei.game.scene.Map;
|
||||||
* @author Jesper Lundin
|
* @author Jesper Lundin
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class BomberWeapon extends Weapon{
|
public class BomberWeapon extends NetworkWepon{
|
||||||
private Particles part;
|
private Particles part;
|
||||||
private boolean hit;
|
private boolean hit;
|
||||||
private Vector2i position;
|
private Vector2i position;
|
||||||
|
|
|
||||||
|
|
@ -2,12 +2,13 @@ package ei.game.scene.weapons;
|
||||||
|
|
||||||
import ei.engine.effects.Particles;
|
import ei.engine.effects.Particles;
|
||||||
import ei.engine.math.Vector2f;
|
import ei.engine.math.Vector2f;
|
||||||
|
import ei.game.network.entities.NetworkWepon;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Jesper Lundin
|
* @author Jesper Lundin
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class CannonBall extends Weapon{
|
public class CannonBall extends NetworkWepon{
|
||||||
|
|
||||||
public CannonBall(Vector2f startPos) {
|
public CannonBall(Vector2f startPos) {
|
||||||
super(startPos);
|
super(startPos);
|
||||||
|
|
|
||||||
|
|
@ -2,13 +2,14 @@ package ei.game.scene.weapons;
|
||||||
|
|
||||||
import ei.engine.effects.Particles;
|
import ei.engine.effects.Particles;
|
||||||
import ei.engine.math.Vector2f;
|
import ei.engine.math.Vector2f;
|
||||||
|
import ei.game.network.entities.NetworkWepon;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author Ziver
|
* @author Ziver
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class Explotion extends Weapon{
|
public class Explotion extends NetworkWepon{
|
||||||
private Particles part;
|
private Particles part;
|
||||||
|
|
||||||
public Explotion(Vector2f startPos) {
|
public Explotion(Vector2f startPos) {
|
||||||
|
|
|
||||||
|
|
@ -2,13 +2,14 @@ package ei.game.scene.weapons;
|
||||||
|
|
||||||
import ei.engine.effects.Particles;
|
import ei.engine.effects.Particles;
|
||||||
import ei.engine.math.Vector2f;
|
import ei.engine.math.Vector2f;
|
||||||
|
import ei.game.network.entities.NetworkWepon;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author Jesper Lundin
|
* @author Jesper Lundin
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class MachineGun extends Weapon{
|
public class MachineGun extends NetworkWepon{
|
||||||
|
|
||||||
public MachineGun(Vector2f startPos) {
|
public MachineGun(Vector2f startPos) {
|
||||||
super(startPos);
|
super(startPos);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue