Added a main menu and fixed som things. added explotions to and fixed the economy
This commit is contained in:
parent
5bb373573d
commit
88771fad29
56 changed files with 1859 additions and 1999 deletions
|
|
@ -96,5 +96,7 @@ public abstract class GameEntity{
|
|||
public abstract void attack(Vector2i target, boolean play);
|
||||
|
||||
public abstract Entity getSprite();
|
||||
|
||||
public abstract int getMaintenanceCost();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -127,9 +127,9 @@ public abstract class Building extends GameEntity{
|
|||
/**
|
||||
* Updating the unit
|
||||
*/
|
||||
public void update() {
|
||||
|
||||
public void update() {
|
||||
if(getLife()<=0) {
|
||||
destroyed();
|
||||
removeBuilding();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,10 +5,13 @@ import ei.engine.math.Vector2i;
|
|||
import ei.engine.scene.Sprite;
|
||||
import ei.game.player.Player;
|
||||
import ei.game.scene.SelectBox;
|
||||
import ei.game.scene.weapons.Explotion;
|
||||
import ei.game.scene.weapons.WeaponHandler;
|
||||
|
||||
public class CommandCenter extends Building{
|
||||
private SelectBox selectionBox;
|
||||
private Sprite sprite;
|
||||
|
||||
public CommandCenter(Player p) {
|
||||
this(0, 0, p);
|
||||
}
|
||||
|
|
@ -29,7 +32,7 @@ public class CommandCenter extends Building{
|
|||
* This unit type is now destroyed.
|
||||
*/
|
||||
public void destroyed(){
|
||||
|
||||
WeaponHandler.getInstance().addWeapon(new Explotion(new Vector2f(getNode().getLocation().getX(), getNode().getLocation().getY())));
|
||||
}
|
||||
/**
|
||||
* Doesnt matter anyway. Since buildings cant attack.
|
||||
|
|
@ -52,4 +55,9 @@ public class CommandCenter extends Building{
|
|||
public Sprite getSprite() {
|
||||
return this.sprite;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaintenanceCost() {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,4 +31,11 @@ public class Stone extends MapEntity{
|
|||
public Entity getSprite() {
|
||||
return stone;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaintenanceCost() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,8 +6,10 @@ import ei.engine.scene.Sprite;
|
|||
import ei.engine.sound.Sound;
|
||||
import ei.game.player.Player;
|
||||
import ei.game.scene.SelectBox;
|
||||
import ei.game.scene.weapons.Explotion;
|
||||
import ei.game.scene.weapons.MachineGun;
|
||||
import ei.game.scene.weapons.Weapon;
|
||||
import ei.game.scene.weapons.WeaponHandler;
|
||||
|
||||
public class APU extends Unit{
|
||||
private SelectBox selectionBox;
|
||||
|
|
@ -59,7 +61,7 @@ public class APU extends Unit{
|
|||
* This unit type is now destroyed.
|
||||
*/
|
||||
public void destroyed(){
|
||||
|
||||
WeaponHandler.getInstance().addWeapon(new Explotion(new Vector2f(getNode().getLocation().getX(), getNode().getLocation().getY())));
|
||||
}
|
||||
public Sound getGunSound() {
|
||||
return gunSound;
|
||||
|
|
@ -95,4 +97,9 @@ public class APU extends Unit{
|
|||
public Sprite getSprite() {
|
||||
return this.sprite;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaintenanceCost() {
|
||||
return 50;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,7 +8,9 @@ import ei.engine.texture.AnimatedTexture;
|
|||
import ei.game.player.Player;
|
||||
import ei.game.scene.SelectBox;
|
||||
import ei.game.scene.weapons.BomberWeapon;
|
||||
import ei.game.scene.weapons.Explotion;
|
||||
import ei.game.scene.weapons.Weapon;
|
||||
import ei.game.scene.weapons.WeaponHandler;
|
||||
|
||||
public class Bomber extends Unit{
|
||||
private SelectBox selectionBox;
|
||||
|
|
@ -68,7 +70,7 @@ public class Bomber extends Unit{
|
|||
* This unit type is now destroyed.
|
||||
*/
|
||||
public void destroyed(){
|
||||
|
||||
WeaponHandler.getInstance().addWeapon(new Explotion(new Vector2f(getNode().getLocation().getX(), getNode().getLocation().getY())));
|
||||
}
|
||||
public Sound getGunSound() {
|
||||
return gunSound;
|
||||
|
|
@ -104,4 +106,9 @@ public class Bomber extends Unit{
|
|||
public Sprite getSprite() {
|
||||
return this.sprite;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaintenanceCost() {
|
||||
return 50;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,7 +7,9 @@ import ei.engine.sound.Sound;
|
|||
import ei.game.player.Player;
|
||||
import ei.game.scene.SelectBox;
|
||||
import ei.game.scene.weapons.CannonBall;
|
||||
import ei.game.scene.weapons.Explotion;
|
||||
import ei.game.scene.weapons.Weapon;
|
||||
import ei.game.scene.weapons.WeaponHandler;
|
||||
|
||||
public class Tank extends Unit{
|
||||
private SelectBox selectionBox;
|
||||
|
|
@ -71,7 +73,7 @@ public class Tank extends Unit{
|
|||
* This unit type is now destroyed.
|
||||
*/
|
||||
public void destroyed(){
|
||||
|
||||
WeaponHandler.getInstance().addWeapon(new Explotion(new Vector2f(getNode().getLocation().getX(), getNode().getLocation().getY())));
|
||||
}
|
||||
/**
|
||||
* returns the velocity of the unit type.
|
||||
|
|
@ -95,4 +97,9 @@ public class Tank extends Unit{
|
|||
public Sprite getSprite() {
|
||||
return this.sprite;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaintenanceCost() {
|
||||
return 50;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,7 +33,6 @@ public abstract class Unit extends GameEntity{
|
|||
private GameEntity attack;
|
||||
private int buildTime;
|
||||
private int price;
|
||||
private int maintenance;
|
||||
// The wepon reload timer
|
||||
private int weponTimer;
|
||||
// The path to travel
|
||||
|
|
@ -178,6 +177,7 @@ public abstract class Unit extends GameEntity{
|
|||
public void update() {
|
||||
weponTimer++;
|
||||
if(getLife()<=0) {
|
||||
destroyed();
|
||||
removeUnit();
|
||||
}
|
||||
else if(moveTo != null) {
|
||||
|
|
|
|||
43
src/ei/game/scene/weapons/Explotion.java
Normal file
43
src/ei/game/scene/weapons/Explotion.java
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
package ei.game.scene.weapons;
|
||||
|
||||
import ei.engine.effects.Particles;
|
||||
import ei.engine.math.Vector2f;
|
||||
|
||||
public class Explotion extends Weapon{
|
||||
private Particles part;
|
||||
|
||||
public Explotion(Vector2f startPos) {
|
||||
super(startPos);
|
||||
setVelocity(4);
|
||||
setRange(Integer.MIN_VALUE);
|
||||
setDamage(Integer.MIN_VALUE);
|
||||
setReload(Integer.MAX_VALUE);
|
||||
}
|
||||
|
||||
public Particles getWeapon() {
|
||||
part = new Particles("bomber");
|
||||
part = new Particles("weapon");
|
||||
part.MaxSpeedX=700;
|
||||
part.MaxSpeedY=700;
|
||||
part.MaxSpeedZ=0;
|
||||
part.slowdown = 1;
|
||||
part.rainbow = false;
|
||||
part.regenerate = false;
|
||||
part.size=10;
|
||||
float colors[][][]= // Rainbow Of Colors
|
||||
{
|
||||
{{1.0f,1.0f,0.0f},{0.74f,0.74f,0.74f}}
|
||||
|
||||
};
|
||||
part.colors = colors;
|
||||
return part;
|
||||
}
|
||||
|
||||
public void update() {
|
||||
if(part.isDead()) {
|
||||
WeaponHandler.getInstance().removeWeapon(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -11,9 +11,9 @@ import ei.engine.scene.Node;
|
|||
*
|
||||
*/
|
||||
public class WeaponHandler {
|
||||
private static WeaponHandler instance;
|
||||
private Node weaponNode;
|
||||
private ArrayList<Weapon> weapons;
|
||||
private static WeaponHandler instance;
|
||||
|
||||
/**
|
||||
* Created a weaponhandler.
|
||||
|
|
@ -21,9 +21,9 @@ public class WeaponHandler {
|
|||
*/
|
||||
public WeaponHandler() {
|
||||
weapons = new ArrayList<Weapon>();
|
||||
weaponNode = new Node("weapon");
|
||||
|
||||
weaponNode = new Node("weapon");
|
||||
}
|
||||
|
||||
public boolean addWeapon(Weapon w){
|
||||
if(!weapons.contains(w)){
|
||||
weapons.add(w);
|
||||
|
|
@ -35,6 +35,7 @@ public class WeaponHandler {
|
|||
|
||||
/**
|
||||
* Removes a player from the handler
|
||||
*
|
||||
* @param p The player to remove
|
||||
* @return true if succesful else false
|
||||
*/
|
||||
|
|
@ -46,6 +47,7 @@ public class WeaponHandler {
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates all the weapons.
|
||||
*
|
||||
|
|
@ -55,8 +57,10 @@ public class WeaponHandler {
|
|||
weapons.get(i).update();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* return the current weaponNode.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Entity getNode() {
|
||||
|
|
@ -75,7 +79,10 @@ public class WeaponHandler {
|
|||
return instance;
|
||||
}
|
||||
|
||||
|
||||
public void clear(){
|
||||
weapons.clear();
|
||||
weaponNode.clear();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue