Added a main menu and fixed som things. added explotions to and fixed the economy

This commit is contained in:
Ziver Koc 2007-04-28 22:09:39 +00:00
parent 5bb373573d
commit 88771fad29
56 changed files with 1859 additions and 1999 deletions

View file

@ -10,6 +10,10 @@ public class PlayerHandler {
// The player list
private ArrayList<Player> players;
private Node playerNode;
// economy stuff
private static final int fundsDelay = 60*30;
private static final int funds = 1000;
private int fundsTimmer;
/**
* Creates a PlayerHandler
@ -18,6 +22,7 @@ public class PlayerHandler {
public PlayerHandler(){
players = new ArrayList<Player>();
playerNode = new Node("PlayerNode");
fundsTimmer = 0;
}
/**
@ -59,6 +64,22 @@ public class PlayerHandler {
}
public void update(){
// sends the funds to the players
fundsTimmer++;
if(fundsTimmer >= fundsDelay){
for(int i=0; i<players.size() ;i++){
int maintenance = 0;
for(int j=0; j<players.get(i).unitCount() ;j++){
maintenance += players.get(i).getUnit(j).getMaintenanceCost();
}
int kredit = funds - maintenance;
if(kredit > 0){
players.get(i).addKredits(kredit);
}
}
fundsTimmer = 0;
}
// updates the players
for(int i=0; i<players.size() ;i++){
players.get(i).update();
}
@ -75,4 +96,10 @@ public class PlayerHandler {
}
return instance;
}
public void clear(){
players.clear();
playerNode.clear();
fundsTimmer = 0;
}
}