How to make extendible ArrayList?
At the moment I'm working on a game and things are going pretty good. What
keeps me busy at the moment, is making a mob spawner which spawns mobs in
a certain area.
The big problem is right now, I'm not really sure how to keep track of all
the mobs being spawned by the spawner, as there are different inheritances
of mobs.
This is my MobSpawner class:
public class MobSpawner {
protected List<Mob> mobs;
protected Level level;
protected int timer = 0;
protected int spawnTime = 0;
protected int maxMobs = 0;
public MobSpawner(Level level) {
this.level = level;
}
}
And this is my RoachSpawner class:
public class RoachSpawner extends MobSpawner {
public RoachSpawner(Level level) {
super(level);
mobs = new ArrayList<Roach>();
}
}
This is not gonna work because the List and ArrayList must be of the same
type.
So the question is, does anyone have any other ideas how to do this?
Thanks in advance!
No comments:
Post a Comment