Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
only way to update Stat Gui head
  • Loading branch information
jrb10014 authored and ssl10003 committed Apr 21, 2015
1 parent 931edba commit fcb259c
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 8 deletions.
6 changes: 6 additions & 0 deletions src/MinionMock.java
Expand Up @@ -112,6 +112,12 @@ public class MinionMock {
return attackDamage;
}



public void minionTakeHit(int damage) {
health-=damage;
}

public void minionTakeDamage() {
int dam = map.getTF().assignTotalDamage(x, y);
health-=dam;
Expand Down
1 change: 1 addition & 0 deletions src/MinionTypes.java
Expand Up @@ -14,6 +14,7 @@ public enum MinionTypes {
// UNKILLABLE (10000, 1, 1, 100, "Unkillable Minion.png"),
DOUBLEBASIC (255, 2, 1, 12, "Double Basic Minion.png"),
// SUPERKILLER (10, 20, 8, 100, "Superkiller Minion.png"),
HEALTH (2000, -1, 1, -50, "Basic Minion.png"),
MONEYBAGS (350, 1, 2, 50, "Moneybags Minion.png");


Expand Down
2 changes: 1 addition & 1 deletion src/MockGui.java
Expand Up @@ -53,8 +53,8 @@ public class MockGui extends JPanel{
repaint();
i++;
//
map.getTF().basicTotalDamage();
map.getMF().getMinions()[0].minionTakeDamage();

map.getStatGui().updateHealth();
map.getStatGui().updateMoney();
map.getStatGui().updateNumTowers();
Expand Down
20 changes: 17 additions & 3 deletions src/TowerFactory.java
Expand Up @@ -16,11 +16,25 @@ public class TowerFactory {
quantity = 1;
cost = 100;
}


public void basicTotalDamage() {
int i = 1;
while (i < quantity) {
if (0 == (towerarray[i].type.compareTo(TowerTypes.BASIC))) {
towerarray[i].basicDealDamage();
}
i++;
}
}

public int assignTotalDamage(int x, int y) {
int i = 1;
int total = 0;
while (i < quantity) {
total += towerarray[i].dealDamage(x, y);
if (0 == (towerarray[i].type.compareTo(TowerTypes.AOE))) {
total += towerarray[i].dealDamage(x, y);
}
i++;
}
return total;
Expand All @@ -40,7 +54,7 @@ public class TowerFactory {
int[] local = _map.getNodes()[_map.getNum()-1];
int x = local[0];
int y = local[1];
towerarray[0] = new TowerMock(0, x, y, false, TowerTypes.NEXUS);
towerarray[0] = new TowerMock(0, x, y, false, TowerTypes.NEXUS, _map);
}

public void createBasicTower(int x, int y, TowerTypes type){
Expand All @@ -58,7 +72,7 @@ public class TowerFactory {
}
i++;
}
towerarray[quantity] = new TowerMock(quantity, x, y, true, type);
towerarray[quantity] = new TowerMock(quantity, x, y, true, type, _map);
quantity++;
}
}
Expand Down
53 changes: 49 additions & 4 deletions src/TowerMock.java
Expand Up @@ -9,11 +9,11 @@ public class TowerMock{
private BufferedImage _sprite;
public TowerTypes type;
public int health; // (FOR NEXUS ONLY)

private MapTowerDefense _map;
public boolean _isTower; //false is Nexus
public String Description = "Tower lol.";

public MinionMock currenttarget;
public MinionMock currentTarget;

/*
public TowerMock(int id, int xloc, int yloc, boolean isTower){
Expand All @@ -27,8 +27,9 @@ public class TowerMock{
}
*/

public TowerMock(int id, int xloc, int yloc, boolean isTower, TowerTypes type){
public TowerMock(int id, int xloc, int yloc, boolean isTower, TowerTypes type, MapTowerDefense map){
_towerid = id;
_map = map;
_xlocation = xloc;
_ylocation = yloc;
_isTower = isTower;
Expand All @@ -47,6 +48,48 @@ public class TowerMock{
return _sprite;
}

public int basicAttack() {
if (findMinion()) {

}
return 0;
}



public boolean basicDealDamage() {
if (findMinion()) {
currentTarget.minionTakeHit(1);
return true;
} else {
return false;
}


}



public boolean findMinion() {
int i = 0;
while (i < 100) {
MinionMock m = _map.getMF().getMinions()[i];
if (m == null) {
return false;
}
if (m.isAlive()) {
if (1 == dealDamage(m.getX(), m.getY())) {
currentTarget = m;
return true;
}
}
i++;
}
return false;
}



public int dealDamage(int x, int y) {
int deltax = (32*_xlocation - x);
int deltay = (32*_ylocation - y);
Expand All @@ -58,6 +101,8 @@ public class TowerMock{
}

}


public boolean takeDamage(int damage) {
if (this.health <= damage)
{
Expand Down Expand Up @@ -137,7 +182,7 @@ public class TowerMock{
}

public void setTarget(MinionMock aminion){
currenttarget = aminion;
currentTarget = aminion;
}

public int getID() {
Expand Down

0 comments on commit fcb259c

Please sign in to comment.