Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
TowerDefense/src/MinionFactory.java
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
63 lines (55 sloc)
1.02 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Random; | |
public class MinionFactory { | |
private int X, Y; | |
private MapTowerDefense map; | |
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; | |
Y = y; | |
map = _map; | |
Max = 100; | |
id = 0; | |
minions = new MinionMock[Max]; | |
rand = new Random(); | |
types = MinionTypes.values(); | |
} | |
public void createMinion(MinionTypes type) { | |
MinionMock m = new MinionMock(type, map); | |
if (id < Max) { | |
minions[id] = m; | |
id++; | |
} | |
} | |
public void createRandominion() | |
{ | |
this.createMinion(types[rand.nextInt(types.length)]); | |
} | |
public MinionMock[] getMinions() { | |
return minions; | |
} | |
public int getNum() { | |
return id; | |
} | |
public int getX() { | |
return X; | |
} | |
public int getY() { | |
return Y; | |
} | |
public int getMax() { | |
return Max; | |
} | |
public void assignAllDamage() { | |
int i = 0; | |
while (i < id) { | |
if (minions[i].isAlive()) { | |
minions[i].minionTakeDamage(); | |
} | |
i++; | |
} | |
} | |
} |