LOL
This commit is contained in:
parent
2cf489403d
commit
515281351c
10 changed files with 64 additions and 17 deletions
|
|
@ -127,14 +127,29 @@ public class InGameMouseInput extends MouseInput{
|
||||||
//unit action.
|
//unit action.
|
||||||
else if(event==RIGHT_MOUSE_BUTTON) {
|
else if(event==RIGHT_MOUSE_BUTTON) {
|
||||||
if(!map.isPosEmpty(pos.getX(), pos.getY())){
|
if(!map.isPosEmpty(pos.getX(), pos.getY())){
|
||||||
|
int rand = (int)(Math.random()*selected.size());
|
||||||
for(int i=0; i<selected.size(); i++) {
|
for(int i=0; i<selected.size(); i++) {
|
||||||
selected.get(i).attack(new Vector2i(pos.getX(), pos.getY()));
|
if(rand==i) {
|
||||||
|
selected.get(i).attack(new Vector2i(pos.getX(), pos.getY()), true);
|
||||||
|
}
|
||||||
|
|
||||||
|
else{
|
||||||
|
selected.get(i).attack(new Vector2i(pos.getX(), pos.getY()), false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
//MultiPrintStream.out.println("Moving: "+pos.getX()+", "+pos.getY());
|
//MultiPrintStream.out.println("Moving: "+pos.getX()+", "+pos.getY());
|
||||||
|
int rand = (int)(Math.random()*selected.size());
|
||||||
for(int i=0; i<selected.size() ;i++){
|
for(int i=0; i<selected.size() ;i++){
|
||||||
selected.get(i).move(pos.getX(),pos.getY());
|
if(rand==i) {
|
||||||
|
selected.get(i).move(true, pos.getX(),pos.getY());
|
||||||
|
}
|
||||||
|
|
||||||
|
else{
|
||||||
|
selected.get(i).move(false, pos.getX(),pos.getY());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -85,7 +85,7 @@ public abstract class GameEntity{
|
||||||
|
|
||||||
protected abstract SelectBox getSelection();
|
protected abstract SelectBox getSelection();
|
||||||
|
|
||||||
public void move(int x, int y) {
|
public void move(boolean play, int x, int y) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -93,7 +93,7 @@ public abstract class GameEntity{
|
||||||
|
|
||||||
public abstract Entity getNode();
|
public abstract Entity getNode();
|
||||||
|
|
||||||
public abstract void attack(Vector2i target);
|
public abstract void attack(Vector2i target, boolean play);
|
||||||
|
|
||||||
public abstract Entity getSprite();
|
public abstract Entity getSprite();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,11 @@ import ei.game.scene.GameEntity;
|
||||||
import ei.game.scene.Map;
|
import ei.game.scene.Map;
|
||||||
import ei.game.scene.units.Unit;
|
import ei.game.scene.units.Unit;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Building class, handles buildings, this case CommandCenter class.
|
||||||
|
* @author Jesper Lundin
|
||||||
|
*
|
||||||
|
*/
|
||||||
public abstract class Building extends GameEntity{
|
public abstract class Building extends GameEntity{
|
||||||
private Queue<Unit> buildQueue;
|
private Queue<Unit> buildQueue;
|
||||||
private int buildTime;
|
private int buildTime;
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@ public class CommandCenter extends Building{
|
||||||
/**
|
/**
|
||||||
* Doesnt matter anyway. Since buildings cant attack.
|
* Doesnt matter anyway. Since buildings cant attack.
|
||||||
*/
|
*/
|
||||||
public void attack(Vector2i target) {
|
public void attack(Vector2i target, boolean play) {
|
||||||
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,9 @@ public abstract class MapEntity extends Unit{
|
||||||
removeUnit();
|
removeUnit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public void move(int x, int y){
|
public void move(boolean play, int x, int y){
|
||||||
|
}
|
||||||
|
public void attack(Vector2i target, boolean play) {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void move(int x, int y, boolean b) {}
|
protected void move(int x, int y, boolean b) {}
|
||||||
|
|
|
||||||
|
|
@ -23,10 +23,12 @@ public class APU extends Unit{
|
||||||
}
|
}
|
||||||
|
|
||||||
public APU(int x, int y, Player p){
|
public APU(int x, int y, Player p){
|
||||||
super(100, new Vector2i(x,y), p);
|
super(70, new Vector2i(x,y), p);
|
||||||
this.sprite = new Sprite("APU", "data/units/apu/apu0000.png");
|
this.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(20);
|
||||||
|
setPrice(200);
|
||||||
|
|
||||||
gunSound = new Sound("gunSound", "data/sounds/machinegun.wav");
|
gunSound = new Sound("gunSound", "data/sounds/machinegun.wav");
|
||||||
moveSound[0] = new Sound("moveSound", "data/sounds/APUmove1.wav");
|
moveSound[0] = new Sound("moveSound", "data/sounds/APUmove1.wav");
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,8 @@ public class Bomber extends Unit{
|
||||||
this.sprite = new Sprite("Bomber", "data/units/bomber/bomber0000.png");
|
this.sprite = new Sprite("Bomber", "data/units/bomber/bomber0000.png");
|
||||||
sprite.setSize(new Vector2f(50,60));
|
sprite.setSize(new Vector2f(50,60));
|
||||||
getNode().add(sprite);
|
getNode().add(sprite);
|
||||||
|
setBuildTime(40);
|
||||||
|
setPrice(800);
|
||||||
|
|
||||||
gunSound = new Sound("gunSound", "data/sounds/bomberweapon.wav");
|
gunSound = new Sound("gunSound", "data/sounds/bomberweapon.wav");
|
||||||
moveSound[0] = new Sound("moveSound", "data/sounds/BOMBERmove1.wav");
|
moveSound[0] = new Sound("moveSound", "data/sounds/BOMBERmove1.wav");
|
||||||
|
|
@ -76,7 +78,7 @@ public class Bomber extends Unit{
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public float getVelocity() {
|
public float getVelocity() {
|
||||||
return 2;
|
return 2.5f;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Manages the sprite connected to this unit.
|
* Manages the sprite connected to this unit.
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,8 @@ public class Tank extends Unit{
|
||||||
this.sprite = new Sprite("Tank", "data/units/tank/tank0000.png");
|
this.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(30);
|
||||||
|
setPrice(400);
|
||||||
|
|
||||||
gunSound = new Sound("gunSound", "data/sounds/tankweapon.wav");
|
gunSound = new Sound("gunSound", "data/sounds/tankweapon.wav");
|
||||||
moveSound[0] = new Sound("moveSound", "data/sounds/TANKmove1.wav");
|
moveSound[0] = new Sound("moveSound", "data/sounds/TANKmove1.wav");
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,6 @@ package ei.game.scene.units;
|
||||||
|
|
||||||
|
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
|
|
||||||
import ei.engine.math.Vector2f;
|
import ei.engine.math.Vector2f;
|
||||||
import ei.engine.math.Vector2i;
|
import ei.engine.math.Vector2i;
|
||||||
import ei.engine.math.Vector3f;
|
import ei.engine.math.Vector3f;
|
||||||
|
|
@ -32,6 +31,9 @@ public abstract class Unit extends GameEntity{
|
||||||
// Order variables
|
// Order variables
|
||||||
private Vector2f moveTo;
|
private Vector2f moveTo;
|
||||||
private GameEntity attack;
|
private GameEntity attack;
|
||||||
|
private int buildTime;
|
||||||
|
private int price;
|
||||||
|
private int maintenance;
|
||||||
// The wepon reload timer
|
// The wepon reload timer
|
||||||
private int weponTimer;
|
private int weponTimer;
|
||||||
// The path to travel
|
// The path to travel
|
||||||
|
|
@ -95,15 +97,30 @@ public abstract class Unit extends GameEntity{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Moving a unit to the given pos
|
* Moving a unit to the given pos
|
||||||
*
|
* @param play if play, play sound
|
||||||
* @param x The x pos to move to
|
* @param x The x pos to move to
|
||||||
* @param y The y pos to move to
|
* @param y The y pos to move to
|
||||||
*/
|
*/
|
||||||
public void move(int x, int y){
|
public void move(boolean play, int x, int y){
|
||||||
getMoveSound().play();
|
if(play){
|
||||||
|
getMoveSound().play();
|
||||||
|
}
|
||||||
move(x,y,true);
|
move(x,y,true);
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* Specifies a building time for this unit
|
||||||
|
* @param time, time to build.
|
||||||
|
*/
|
||||||
|
public void setBuildTime(int time) {
|
||||||
|
this.buildTime = time;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Specifies a price for this unit.
|
||||||
|
* @param price, the cost.
|
||||||
|
*/
|
||||||
|
public void setPrice(int price) {
|
||||||
|
this.price = price;
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* Moving a unit to the given pos
|
* Moving a unit to the given pos
|
||||||
*
|
*
|
||||||
|
|
@ -128,8 +145,10 @@ public abstract class Unit extends GameEntity{
|
||||||
/**
|
/**
|
||||||
* Lets a unit attack another unit or object in the world;
|
* Lets a unit attack another unit or object in the world;
|
||||||
*/
|
*/
|
||||||
public void attack(Vector2i target) {
|
public void attack(Vector2i target, boolean play) {
|
||||||
getAttackSound().play();
|
if(play){
|
||||||
|
getAttackSound().play();
|
||||||
|
}
|
||||||
this.target = target;
|
this.target = target;
|
||||||
attack = InGameState.getMap().getPos(target.getX(),target.getY());
|
attack = InGameState.getMap().getPos(target.getX(),target.getY());
|
||||||
}
|
}
|
||||||
|
|
@ -241,7 +260,7 @@ public abstract class Unit extends GameEntity{
|
||||||
setPos(temp.getX(), temp.getY());
|
setPos(temp.getX(), temp.getY());
|
||||||
}
|
}
|
||||||
else if(!path.isEmpty()){
|
else if(!path.isEmpty()){
|
||||||
move(path.getLast().getX(), path.getLast().getY());
|
move(false, path.getLast().getX(), path.getLast().getY());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ public class CannonBall extends Weapon{
|
||||||
super(startPos);
|
super(startPos);
|
||||||
setVelocity(4);
|
setVelocity(4);
|
||||||
setRange(500);
|
setRange(500);
|
||||||
setDamage(5);
|
setDamage(15);
|
||||||
setReload(100);
|
setReload(100);
|
||||||
}
|
}
|
||||||
public Particles getWeapon() {
|
public Particles getWeapon() {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue