diff --git a/.DS_Store b/.DS_Store
new file mode 100644
index 0000000..905e3a2
Binary files /dev/null and b/.DS_Store differ
diff --git a/.classpath b/.classpath
new file mode 100644
index 0000000..fceb480
--- /dev/null
+++ b/.classpath
@@ -0,0 +1,6 @@
+
+
+
+
+
+
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..ae3c172
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+/bin/
diff --git a/.project b/.project
new file mode 100644
index 0000000..9b62d4c
--- /dev/null
+++ b/.project
@@ -0,0 +1,17 @@
+
+
+ TowerDefenseWork
+
+
+
+
+
+ org.eclipse.jdt.core.javabuilder
+
+
+
+
+
+ org.eclipse.jdt.core.javanature
+
+
diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 0000000..3a21537
--- /dev/null
+++ b/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,11 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
+org.eclipse.jdt.core.compiler.compliance=1.8
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate
+org.eclipse.jdt.core.compiler.debug.localVariable=generate
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.8
diff --git a/src/.DS_Store b/src/.DS_Store
new file mode 100644
index 0000000..5008ddf
Binary files /dev/null and b/src/.DS_Store differ
diff --git a/src/Main.java b/src/Main.java
new file mode 100644
index 0000000..2662edc
--- /dev/null
+++ b/src/Main.java
@@ -0,0 +1,49 @@
+import java.awt.*;
+import javax.swing.*;
+
+public class Main extends JFrame{
+
+
+ public static void main(String[] args) {
+ JFrame frame = new JFrame("Tower Defense Mock GUI");
+ frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+ frame.setSize(640,640+23);
+ int num = 6;
+ int[][] nodes = new int[num][2];
+ nodes[0][0] = 1;
+ nodes[0][1] = 3;
+ nodes[1][0] = 16;
+ nodes[1][1] = 3;
+ nodes[2][0] = 16;
+ nodes[2][1] = 9;
+ nodes[3][0] = 4;
+ nodes[3][1] = 9;
+ nodes[4][0] = 4;
+ nodes[4][1] = 15;
+ nodes[5][0] = 18;
+ nodes[5][1] = 15;
+ /*nodes[6][0] = 18;
+ nodes[6][1] = 13;
+ nodes[7][0] = 11;
+ nodes[7][1] = 13;
+ nodes[8][0] = 11;
+ nodes[8][1] = 1;*/
+ MockGui mg = new MockGui(640,640,32, num, nodes);
+ MapTowerDefense map = new MapTowerDefense(100, num, nodes, mg);
+ mg.setMap(map);
+ frame.add(mg);
+ frame.setVisible(true);
+ //StatGui sg = new StatGui(100, 640);
+ //sg.setLocation(640, 0);
+
+ //frame.add(sg);
+
+
+ //map.getTF().createBasicTower(14, 8);
+ map.createMinion(0);
+ mg.step();
+
+ }
+
+
+}
diff --git a/src/MapTowerDefense.java b/src/MapTowerDefense.java
new file mode 100644
index 0000000..17749f3
--- /dev/null
+++ b/src/MapTowerDefense.java
@@ -0,0 +1,46 @@
+
+
+
+public class MapTowerDefense {
+
+ private int maxTowers;
+ private int numNodes;
+ private int[][] nodes;
+ private MinionFactory MF;
+ private TowerFactory TF;
+ private MockGui MG;
+
+
+ public MapTowerDefense(int _maxTowers, int _numNodes, int[][] _nodes, MockGui _mg) {
+ maxTowers = _maxTowers;
+ numNodes = _numNodes;
+ nodes = _nodes;
+ MF = new MinionFactory(nodes[0][0], nodes[0][1], this);
+ TF = new TowerFactory(this, maxTowers);
+ MG = _mg;
+ }
+ public MinionFactory getMF() {
+ return MF;
+ }
+ public TowerFactory getTF() {
+ return TF;
+ }
+ public int getNum() {
+ return numNodes;
+ }
+ public int[][] getNodes() {
+ return nodes;
+ }
+ public MockGui getGui() {
+ return MG;
+ }
+ public void createMinion(int type) {
+ MF.createMinion(type);
+ }
+
+
+
+
+
+
+}
\ No newline at end of file
diff --git a/src/Minion.png b/src/Minion.png
new file mode 100644
index 0000000..abcf631
Binary files /dev/null and b/src/Minion.png differ
diff --git a/src/MinionFactory.java b/src/MinionFactory.java
new file mode 100644
index 0000000..544f45d
--- /dev/null
+++ b/src/MinionFactory.java
@@ -0,0 +1,42 @@
+
+public class MinionFactory {
+ private int X, Y;
+ private MapTowerDefense map;
+ private MinionMock[] minions;
+ private int Max;
+ private int id;
+
+ public MinionFactory(int x, int y, MapTowerDefense _map) {
+ X = x;
+ Y = y;
+ map = _map;
+ Max = 100;
+ id = 0;
+ minions = new MinionMock[Max];
+ }
+
+ public void createMinion(int type) {
+ MinionMock m = new MinionMock(type, map);
+ if (id < Max) {
+ minions[id] = m;
+ id++;
+ }
+ }
+ public MinionMock[] getMinions() {
+ return minions;
+ }
+ public int getNum() {
+ return id;
+ }
+
+ public void assignAllDamage() {
+ int i = 0;
+ while (i < id) {
+ if (minions[i].isAlive()) {
+ minions[i].minionTakeDamage();
+ }
+ i++;
+ }
+ }
+
+}
diff --git a/src/MinionMock.java b/src/MinionMock.java
new file mode 100644
index 0000000..b1dc1ef
--- /dev/null
+++ b/src/MinionMock.java
@@ -0,0 +1,98 @@
+
+public class MinionMock {
+ int type;
+ MapTowerDefense map;
+ int x;
+ int y;
+ int speed;
+ int visits;
+ boolean alive;
+ int health;
+
+ public MinionMock(int _type, MapTowerDefense _map) {
+ type = _type;
+ map = _map;
+ int[] unhashed = map.getGui().hash(map.getNodes()[0][0], map.getNodes()[0][1]);
+ x = unhashed[0];
+ y = unhashed[1];
+ speed = 1;
+ visits = 1;
+ alive = true;
+ health = 255;
+ }
+ public int getX() {
+ return x;
+ }
+ public int getY() {
+ return y;
+ }
+ 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-=speed;
+ }
+ if (direction == 1) {
+ x+=speed;
+ }
+ if (direction == 2) {
+ y+=speed;
+ }
+ if (direction == 3) {
+ x-=speed;
+ }
+ 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
new file mode 100644
index 0000000..01402b2
--- /dev/null
+++ b/src/MockGui.java
@@ -0,0 +1,225 @@
+import javax.swing.*;
+
+import java.awt.*;
+import java.awt.event.MouseAdapter;
+import java.awt.event.MouseEvent;
+import java.awt.event.MouseListener;
+import java.awt.event.MouseMotionListener;
+import java.awt.geom.*;
+
+public class MockGui extends JPanel{
+ boolean gameEnd;
+ private int X, Y, GRIDSIZE, NUMNODES;
+ private int[][] NODES;
+ private MapTowerDefense map;
+
+
+ public MockGui(int x, int y, int gridSize, int numNodes, int[][] nodes) {
+ X = x;
+ Y = y;
+ gameEnd = false;
+ GRIDSIZE = gridSize;
+ NUMNODES = numNodes;
+ NODES = nodes;
+ TowerPlacer TP = new TowerPlacer();
+ this.addMouseListener(TP);
+ this.addMouseMotionListener(TP);
+
+ repaint();
+ }
+
+ public void setMap(MapTowerDefense _map) {
+ map = _map;
+ }
+
+ public void step() {
+ int i = 0;
+ while (!gameEnd) {
+ try {
+ Thread.sleep(10);
+ repaint();
+ i++;
+ //map.getMF().getMinions()[0].minionTakeDamage();
+ map.getMF().assignAllDamage();
+
+ if (i > 63) {
+ map.createMinion(0);
+ i = 0;
+ }
+ } catch (InterruptedException e) {
+ //e.printStackTrace();
+ }
+ }
+ }
+
+ public void paint(Graphics g) {
+ setBackground(new Color(99, 209, 62));
+ drawGrid(X, Y, GRIDSIZE, g);
+ //drawMinion(96,96,0,g);
+ colorPath(g);
+ drawAllMinions(map.getMF(), g);
+ drawAllTowers(map.getTF(), g);
+ drawHealth(g);
+ }
+ public void drawGrid(int x, int y, int gridSize, Graphics g) {
+ g.setColor(Color.BLACK);
+ int i = 0;
+ while (i < x-gridSize) {
+ i+= gridSize;
+ g.drawLine(i, gridSize, i, y-gridSize);
+ }
+ i = 0;
+ while (i < y-gridSize) {
+ i+= gridSize;
+ g.drawLine(gridSize, i, x-gridSize, i);
+ }
+ }
+ public int[] hash (int x, int y) {
+ // Convert x y on grid to pixel
+ int[] result = new int[2];
+ result[0] = x*GRIDSIZE;
+ result[1] = y*GRIDSIZE;
+ return result;
+ }
+ public int[] unhash(int x, int y) {
+ int[] result = new int[2];
+ result[0] = x/GRIDSIZE;
+ result[1] = y/GRIDSIZE;
+ return result;
+ }
+
+ public void colorBlock(int x, int y, Graphics g) {
+ int[] coords = hash(x,y);
+ g.fillRect(coords[0], coords[1], GRIDSIZE, GRIDSIZE);
+ }
+ public void colorBlocks(int x1, int y1, int x2, int y2, Graphics g) {
+ if (x1 == x2) {
+ // Vertically
+ if (y1 < y2) {
+ while (y1 <= y2) {
+ colorBlock(x1, y1, g);
+ y1+=1;
+ }
+ } else {
+ while (y2 <= y1) {
+ colorBlock(x1, y2, g);
+ y2+=1;
+ }
+ }
+ } else {
+ // Horizontally
+ if (x1 < x2) {
+ while (x1 <= x2) {
+ colorBlock(x1, y1, g);
+ x1+=1;
+ }
+ } else {
+ while (x2 <= x1) {
+ colorBlock(x2, y1, g);
+ x2+=1;
+ }
+ }
+ }
+ }
+ public void colorPath(Graphics g) {
+ int i = 1;
+ g.setColor(new Color(213,196,161));
+ while (i < NUMNODES) {
+ colorBlocks(NODES[i-1][0], NODES[i-1][1], NODES[i][0], NODES[i][1], g);
+ i++;
+ }
+ }
+ public void drawAllMinions(MinionFactory MF, Graphics g) {
+ int i = 0;
+ while (i < MF.getNum()) {
+ if (MF.getMinions()[i].isAlive()) {
+ drawMinion(MF.getMinions()[i].getX(), MF.getMinions()[i].getY(), MF.getMinions()[i].getHealth(), g);
+ if (MF.getMinions()[i].go())
+ {
+ gameEnd = true;
+
+ }
+ }
+ i++;
+ }
+ }
+
+ public void drawHealth(Graphics g) {
+ int health = map.getTF().getTowerArray()[0].getHealth();
+ g.setColor(new Color(0,255,0));
+ colorBlocks(19, 0, 19, health, g);
+ g.setColor(new Color(255,0,0));
+ colorBlocks(19, 20, 19, health, g);
+ }
+
+ public void drawMinion(int x, int y, int health, Graphics g) {
+ g.setColor(new Color(255-health, 100, 100));
+ g.fillOval(x, y, 32, 32);
+ }
+
+ public void drawAllTowers(TowerFactory TF, Graphics g) {
+ int i = 0;
+ while (i < TF.getNum()) {
+ int[] local = hash(TF.getTowerArray()[i].getTowerXlocation(), TF.getTowerArray()[i].getTowerYlocation());
+ drawBasicTower(local[0], local[1], g);
+ i++;
+ }
+ }
+
+ public void drawBasicTower(int x, int y, Graphics g){
+ g.setColor(new Color(24,24,24));
+ g.fillRect(x, y, 32, 32);
+ }
+
+ private class TowerPlacer implements MouseListener, MouseMotionListener{
+
+ @Override
+ public void mouseDragged(MouseEvent e) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void mouseMoved(MouseEvent e) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void mouseClicked(MouseEvent e) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void mousePressed(MouseEvent e) {
+ int x = e.getX();
+ int y = e.getY();
+ System.out.println("x; " + x + " y: " + y);
+ int[] local = unhash(x,y);
+
+ map.getTF().createBasicTower(local[0], local[1]);
+ }
+
+ @Override
+ public void mouseReleased(MouseEvent e) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void mouseEntered(MouseEvent e) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void mouseExited(MouseEvent e) {
+ // TODO Auto-generated method stub
+
+ }
+
+ }
+
+
+}
diff --git a/src/StatGui.java b/src/StatGui.java
new file mode 100644
index 0000000..4835b53
--- /dev/null
+++ b/src/StatGui.java
@@ -0,0 +1,12 @@
+import javax.swing.JPanel;
+
+
+public class StatGui extends JPanel {
+ private int X, Y;
+
+ public StatGui (int x, int y) {
+ X = x;
+ Y = y;
+ }
+
+}
diff --git a/src/TowerFactory.java b/src/TowerFactory.java
new file mode 100644
index 0000000..59212d2
--- /dev/null
+++ b/src/TowerFactory.java
@@ -0,0 +1,53 @@
+
+public class TowerFactory {
+
+ int xloc, yloc;
+ MapTowerDefense _map;
+ TowerMock[] towerarray;
+ int quantity;
+ int _max;
+
+ public TowerFactory(MapTowerDefense amap, int max){
+ _map = amap;
+ _max = max;
+ towerarray = new TowerMock[_max];
+ createNexus();
+ quantity = 1;
+ }
+ public int assignTotalDamage(int x, int y) {
+ int i = 1;
+ int total = 0;
+ while (i < quantity) {
+ total += towerarray[i].dealDamage(x, y);
+ i++;
+ }
+ return total;
+ }
+
+
+ public TowerMock[] getTowerArray() {
+ return towerarray;
+ }
+ public int getNum() {
+ return quantity;
+ }
+
+
+
+
+
+
+ public void createNexus(){
+ int[] local = _map.getNodes()[_map.getNum()-1];
+ int x = local[0];
+ int y = local[1];
+ towerarray[0] = new TowerMock(0, x, y, false);
+ }
+
+ public void createBasicTower(int x, int y){
+ if (quantity < _max) {
+ towerarray[quantity] = new TowerMock(quantity, x, y, true);
+ quantity++;
+ }
+ }
+}
diff --git a/src/TowerMock.java b/src/TowerMock.java
new file mode 100644
index 0000000..1acdcf9
--- /dev/null
+++ b/src/TowerMock.java
@@ -0,0 +1,125 @@
+
+public class TowerMock{
+ public int _xlocation, _ylocation, _value, _cost, _upgradecost, _towerid;
+ public int _level = 1;
+ public int _range = 96;
+ public int _power = 1;
+ public double _firerate = 1.0;
+
+ public int health; // (FOR NEXUS ONLY)
+
+ public boolean _isTower; //false is Nexus
+ public String Description = "Basic Tower with generic stats, no special abilities or "
+ + "mods. Stats are initialized in the constructor. Targets 1 minion at a time.";
+
+ public MinionMock currenttarget;
+
+ //baseline stats: range - radius of 10. firerate - 1 shot/s. power - 1 damage
+ public TowerMock(int id, int xloc, int yloc, boolean isTower){
+ _towerid = id;
+ _xlocation = xloc;
+ _ylocation = yloc;
+ _isTower = isTower;
+ if (!isTower) {
+ health = 20;
+ }
+ }
+
+ public int dealDamage(int x, int y) {
+ int deltax = (32*_xlocation - x);
+ int deltay = (32*_ylocation - y);
+ int dist2 = deltax*deltax + deltay*deltay;
+ if (dist2 > _range*_range) {
+ return 0;
+ } else {
+ return 1;
+ }
+
+ }
+
+ public boolean takeDamage() {
+ health--;
+ System.out.println(health);
+ if (health <= 0) {
+ return true;
+ // LOSE GAME TERMINATE
+ } else {
+ return false;
+ }
+ }
+ public int getHealth() {
+ return health;
+ }
+
+
+
+
+
+ public int getTowerXlocation() {
+ return _xlocation;
+ }
+
+ public int getTowerYlocation() {
+ return _ylocation;
+ }
+
+ public int getRange() {
+ return _range;
+ }
+
+ public double getFireRate() {
+ return _firerate;
+ }
+
+ public int getPower() {
+ return _power;
+ }
+
+ //get overall resale value of towers, at half of purchase cost
+ public int getSellValue() {
+ return (int) (_range + (_power * 10)+ (_firerate * 10))/2;
+ }
+
+ //get cost this tower was purchased for
+ public int getCost() {
+ _cost = (int) (_range + ( _power * 10) + (_firerate * 10));
+ return _cost;
+ }
+
+ //get upgrade cost to upgrade tower, double the price of last cost
+ public int getupgradeCost() {
+ _upgradecost = _cost * 2;
+ return _upgradecost;
+ }
+
+ public void upgrade(){
+ _cost = _upgradecost;
+ _level = _level + 1;
+ this._range = this._range + 1;
+ this._firerate= this._firerate + 0.3;
+ this._power = this._power + 1;
+ }
+
+ public int getLevel() {
+ return _level;
+ }
+
+ public boolean isActuallyTower() {
+ return _isTower;
+ }
+
+ public String getDescription() {
+ return Description;
+ }
+
+ public void setTarget(MinionMock aminion){
+ currenttarget = aminion;
+ }
+
+ public int getID() {
+ return _towerid;
+ }
+
+
+
+}