diff --git a/src/MinionMock.java b/src/MinionMock.java index 3826ae4..8c0fe01 100644 --- a/src/MinionMock.java +++ b/src/MinionMock.java @@ -2,11 +2,13 @@ public class MinionMock { - private int x, y, speed, visits, health, attackDamage; + private int x, y, speed, visits, health, attackDamage, maxHealth; private MinionTypes type; private boolean alive; private MapTowerDefense map; private BufferedImage sprite; + private int value; + private String name; public MinionMock(MinionTypes type, MapTowerDefense map) { this.type = type; @@ -15,9 +17,12 @@ public MinionMock(MinionTypes type, MapTowerDefense map) { x = unhashed[0]; y = unhashed[1]; health = type.getHealth(); + maxHealth = health; + name = type.getName(); attackDamage = type.getAttackDamage(); speed = type.getMovementSpeed(); sprite = type.getSprite(); + value = type.getValue(); visits = 1; alive = true; } @@ -71,7 +76,7 @@ public boolean go() { int direction = findDirection(); if (direction == -1) { alive = false; - return map.getTF().getTowerArray()[0].takeDamage(); + return map.getTF().getTowerArray()[0].takeDamage(attackDamage); } if (direction == 0) { y-=speed; @@ -94,11 +99,27 @@ public boolean isAlive() { public int getHealth() { return health; } + public int getMaxHealth() { + return maxHealth; + } + public String getName() { + return name; + } + public int getValue() { + return value; + } + public int getAttackDamage() { + return attackDamage; + } + public void minionTakeDamage() { int dam = map.getTF().assignTotalDamage(x, y); health-=dam; if (health <= 0) { - alive = false; + if (alive == true) { + map.getStatGui().payDay(value); + alive = false; + } } } diff --git a/src/MinionTypes.java b/src/MinionTypes.java index f726289..4b6472c 100644 --- a/src/MinionTypes.java +++ b/src/MinionTypes.java @@ -5,20 +5,27 @@ import javax.imageio.ImageIO; public enum MinionTypes { - //NAME (Health, Attack, Speed) - WEAKLING(100, 1, 1, "Basic Minion.png"), - BASIC (255, 1, 1, "Basic Minion.png"), - SPEEDO (100, 1, 4, "Basic Minion.png"), - SUPERSPEEDO (255, 1, 4, "Basic Minion.png"); + //NAME (Health, Attack, Speed, goldValue) + WEAKLING(100, 1, 1, "Basic Minion.png", 1), + BASIC (255, 1, 1, "Basic Minion.png", 2), + SPEEDO (100, 1, 4, "Basic Minion.png", 3), + SUPERSPEEDO (255, 1, 4, "Basic Minion.png", 5), + JUGGERNAUT (1000, 1, 1, "Basic Minion.png", 10), + UNKILLABLE (10000,1,1, "Basic Minion.png", 100), + DOUBLEBASIC(255, 2, 1, "Basic Minion.png", 12), + SUPERKILLER(10, 20, 8, "Basic Minion.png", 100), + MONEYBAGS(350, 1, 2, "Basic Minion.png", 50); - private int health, attackDamage, movementSpeed; + + private int health, attackDamage, movementSpeed, value; private BufferedImage sprite; private static final String SPRITE_FILE_DIR = "src/"; - MinionTypes(int health, int attackDamage, int movementSpeed, String spriteFileName) { + MinionTypes(int health, int attackDamage, int movementSpeed, String spriteFileName, int value) { this.health = health; this.attackDamage = attackDamage; this.movementSpeed = movementSpeed; + this.value = value; try { this.sprite = ImageIO.read(new File(SPRITE_FILE_DIR.concat(spriteFileName))); } catch (IOException ex) { @@ -34,10 +41,16 @@ public int getAttackDamage() { return attackDamage; } + public String getName() { + return this.toString(); + } + public int getMovementSpeed() { return movementSpeed; } - + public int getValue() { + return value; + } public BufferedImage getSprite() { return sprite; diff --git a/src/MockGui.java b/src/MockGui.java index 1e932ba..f13cb88 100644 --- a/src/MockGui.java +++ b/src/MockGui.java @@ -76,9 +76,8 @@ public void paint(Graphics g) { drawGrid(x, y, gridsize, g); //drawMinion(96,96,0,g); colorPath(g); - - drawAllMinions(map.getMF(), g); drawAllTowers(map.getTF(), g); + drawAllMinions(map.getMF(), g); drawPlayerHealth(g); } public void drawGrid(int x, int y, int gridSize, Graphics g) { @@ -173,14 +172,19 @@ public void drawPlayerHealth(Graphics g) { } public void drawMinion(int x, int y, int health, Graphics g) { - g.drawImage(image, x,y, null); } + // IS THIS METHOD STILL CALLED? + public void drawMinion(MinionMock m, Graphics g) { g.drawImage(m.getSprite(), m.getX(), m.getY(), null); - + String h = "[" + m.getHealth() + "/" + m.getMaxHealth() +"]"; + g.setColor(Color.RED); + g.drawString(h, m.getX()-15, m.getY()-10); + //g.drawString(m.getName(), m.getX()-15, m.getY()+45); + //g.drawString(("V: " + m.getValue() + "\nD: " + m.getAttackDamage()), m.getX(), m.getY()+46); } public void drawAllTowers(TowerFactory TF, Graphics g) { diff --git a/src/StatGui.java b/src/StatGui.java index 0daf4fe..f570e15 100644 --- a/src/StatGui.java +++ b/src/StatGui.java @@ -16,6 +16,30 @@ public StatGui (int x, int y) { Y = y; } + public int getMoney() { + return playermoney; + } + public boolean canAfford(int cost) { + if (playermoney >= cost) { + return true; + } else { + return false; + } + } + + public boolean spendMoney(int cost) { + if (canAfford(cost)) { + playermoney -= cost; + return true; + } else { + return false; + } + } + + public boolean payDay(int value) { + playermoney += value; + return true; + } public void setMap(MapTowerDefense map){ this.map=map; diff --git a/src/TowerFactory.java b/src/TowerFactory.java index 25d3032..86118dd 100644 --- a/src/TowerFactory.java +++ b/src/TowerFactory.java @@ -6,6 +6,7 @@ public class TowerFactory { TowerMock[] towerarray; int quantity; int _max; + int cost; public TowerFactory(MapTowerDefense amap, int max){ _map = amap; @@ -13,6 +14,7 @@ public TowerFactory(MapTowerDefense amap, int max){ towerarray = new TowerMock[_max]; createNexus(); quantity = 1; + cost = 100; } public int assignTotalDamage(int x, int y) { int i = 1; @@ -47,6 +49,9 @@ public void createNexus(){ public void createBasicTower(int x, int y){ //Checks if there's already a tower here //TODO make this better + if (!_map.getStatGui().spendMoney(cost)) { + return; + } if (quantity < _max) { int i = 0; while (i < quantity) { diff --git a/src/TowerMock.java b/src/TowerMock.java index 1acdcf9..3d590ca 100644 --- a/src/TowerMock.java +++ b/src/TowerMock.java @@ -36,6 +36,14 @@ public int dealDamage(int x, int y) { } } + public boolean takeDamage(int i) { + if (i > 1) { + takeDamage(); + return takeDamage(i-1); + } else { + return takeDamage(); + } + } public boolean takeDamage() { health--;