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..16ae0e1 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; diff --git a/src/MockGui.java b/src/MockGui.java index 79e4fce..6b3ddb8 100644 --- a/src/MockGui.java +++ b/src/MockGui.java @@ -6,6 +6,7 @@ import java.awt.event.MouseListener; import java.awt.event.MouseMotionListener; import java.awt.geom.*; +import java.util.Random; public class MockGui extends JPanel{ boolean gameOver; @@ -45,7 +46,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..a4805a7 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"); + return; + } + i++; + } towerarray[quantity] = new TowerMock(quantity, x, y, true); quantity++; }