new entity management and hit detection concepts, began implementing in game play area

This commit is contained in:
2017-05-30 16:23:08 -05:00
parent 562dbb8117
commit 4894d6eea8
9 changed files with 174 additions and 115 deletions

View File

@@ -0,0 +1,82 @@
package zero1hd.polyjet.entity;
import com.badlogic.gdx.assets.AssetManager;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
import com.badlogic.gdx.utils.Array;
import com.badlogic.gdx.utils.Pool;
import zero1hd.polyjet.entity.ally.Laser;
import zero1hd.polyjet.entity.enemies.VoidCircle;
public class EntityController {
AssetManager assets;
ShapeRenderer shapes;
public final Array<Entity> ACTIVE_ALLIES;
public final Array<Entity> ACTIVE_ENEMIES;
//Enemy pool declaration;
private final Pool<VoidCircle> VOID_CIRCLE_POOL;
//Ally pool declaration;
private final Pool<Laser> LASER_POOL;
public EntityController(ShapeRenderer shapeRenderer, AssetManager assetManager) {
ACTIVE_ALLIES = new Array<Entity>();
ACTIVE_ENEMIES = new Array<Entity>();
//Enemy pool initialization;
VOID_CIRCLE_POOL = new Pool<VoidCircle>() {
@Override
protected VoidCircle newObject() {
return new VoidCircle(shapes);
}
};
//Ally pool initialization;
LASER_POOL = new Pool<Laser>() {
@Override
protected Laser newObject() {
return new Laser(assets.get("laser.png", Texture.class));
}
};
}
public Entity retrieveEntity(Entities entity) {
switch (entity) {
case VOID_CIRCLE:
VoidCircle voidCircle = VOID_CIRCLE_POOL.obtain();
ACTIVE_ENEMIES.add(voidCircle);
return voidCircle;
case BAR_BEAT:
return null;
case SHARDS:
return null;
case LASER:
Laser laser = LASER_POOL.obtain();
ACTIVE_ALLIES.add(laser);
return laser;
default:
return null;
}
}
public void free(Entity entity, Entities type) {
switch (type) {
case BAR_BEAT:
break;
case SHARDS:
break;
case VOID_CIRCLE:
ACTIVE_ENEMIES.removeValue(entity, true);
VOID_CIRCLE_POOL.free((VoidCircle) entity);
break;
case LASER:
ACTIVE_ALLIES.removeValue(entity, true);
LASER_POOL.free((Laser) entity);
break;
default:
break;
}
}
}