diff --git a/src/MinionFactory.java b/src/MinionFactory.java index 964aa84..50de7d9 100644 --- a/src/MinionFactory.java +++ b/src/MinionFactory.java @@ -1,3 +1,4 @@ +import java.util.Random; public class MinionFactory { private int X, Y; @@ -5,6 +6,8 @@ public class MinionFactory { private MinionMock[] minions; private int Max; private int id; + private Random rand; + private MinionTypes[] types; public MinionFactory(int x, int y, MapTowerDefense _map) { X = x; @@ -13,6 +16,8 @@ public MinionFactory(int x, int y, MapTowerDefense _map) { Max = 100; id = 0; minions = new MinionMock[Max]; + rand = new Random(); + types = MinionTypes.values(); } public void createMinion(MinionTypes type) { @@ -22,6 +27,11 @@ public void createMinion(MinionTypes type) { id++; } } + public void createRandominion() + { + this.createMinion(types[rand.nextInt(types.length)]); + } + public MinionMock[] getMinions() { return minions; } diff --git a/src/MinionTypes.java b/src/MinionTypes.java index a4e6a91..6f76bb8 100644 --- a/src/MinionTypes.java +++ b/src/MinionTypes.java @@ -1,7 +1,10 @@ public enum MinionTypes { - - BASIC (255, 1, 1); + //NAME (Health, Attack, Speed) + WEAKLING(100, 1, 1), + BASIC (255, 1, 1), + SPEEDO (100, 1, 4), + SUPERSPEEDO (255, 1, 4); private int health, attackDamage, movementSpeed; @@ -22,82 +25,4 @@ public int getAttackDamage() { public int getMovementSpeed() { return movementSpeed; } - - /* - public int getType() { - return type; - } - */ - - /* - public int findDirection() { - if (visits == map.getNum()) { - // CALL TO MAKE NEXUS LOSE HEALTH - return -1; - } else { - int xGoal = map.getNodes()[visits][0]; - int yGoal = map.getNodes()[visits][1]; - int[] Goals = map.getGui().hash(xGoal, yGoal); - xGoal = Goals[0]; - yGoal = Goals[1]; - if (x == xGoal) { - if (y == yGoal) { - visits++; - return findDirection(); - } - if (yGoal > y) { - // MOVE DOWN - return 2; - } else { - return 0; - } - } else { - if (x > xGoal) { - return 3; - } else { - return 1; - } - } - } - } - - - - public boolean go() { - int direction = findDirection(); - if (direction == -1) { - alive = false; - return map.getTF().getTowerArray()[0].takeDamage(); - } - if (direction == 0) { - y-=movespeed; - } - if (direction == 1) { - x+=movespeed; - } - if (direction == 2) { - y+=movespeed; - } - if (direction == 3) { - x-=movespeed; - } - return false; - } - - - public boolean isAlive() { - return alive; - } - public int getHealth() { - return health; - } - public void minionTakeDamage() { - int dam = map.getTF().assignTotalDamage(x, y); - health-=dam; - if (health <= 0) { - alive = false; - } - - } - */ } diff --git a/src/MockGui.java b/src/MockGui.java index a2e067e..ae722f0 100644 --- a/src/MockGui.java +++ b/src/MockGui.java @@ -16,6 +16,7 @@ import java.util.logging.Level; import java.util.logging.Logger; import javax.imageio.ImageIO; +import java.util.Random; @@ -60,7 +61,7 @@ public void step() { map.getMF().assignAllDamage(); if (i > 63) { - map.createMinion(MinionTypes.BASIC); + map.getMF().createRandominion(); i = 0; } // diff --git a/src/TowerFactory.java b/src/TowerFactory.java index 59212d2..25d3032 100644 --- a/src/TowerFactory.java +++ b/src/TowerFactory.java @@ -45,7 +45,17 @@ public void createNexus(){ } public void createBasicTower(int x, int y){ + //Checks if there's already a tower here + //TODO make this better if (quantity < _max) { + int i = 0; + while (i < quantity) { + if ((towerarray[i].getTowerXlocation() == x) && (towerarray[i].getTowerYlocation() == y)) { + System.out.println("CONSEQUENCES WILL NEVER BE THE SAME"); //informal logging + return; + } + i++; + } towerarray[quantity] = new TowerMock(quantity, x, y, true); quantity++; }