basic ground work for entity coordinators added
This commit is contained in:
parent
bb5782a34f
commit
a72bd104f0
@ -2,24 +2,27 @@ package zero1hd.rhythmbullet.audio.map;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import zero1hd.rhythmbullet.entity.EntityIndex;
|
||||
import zero1hd.rhythmbullet.entity.Entity;
|
||||
import zero1hd.rhythmbullet.entity.EntityFrame;
|
||||
import zero1hd.rhythmbullet.entity.coordinator.Coordinator;
|
||||
import zero1hd.rhythmbullet.entity.coordinator.CoordinatorFrame;
|
||||
|
||||
public class EntitySpawnInfo {
|
||||
private EntityIndex entityType;
|
||||
// private float[] parameters;
|
||||
private EntityFrame<? extends Entity> entityToSpawn;
|
||||
private CoordinatorFrame<? extends Coordinator> entityCoordinator;
|
||||
public HashMap<String, Float> parameters;
|
||||
|
||||
public EntitySpawnInfo(EntityIndex entityType) {
|
||||
this.entityType = entityType;
|
||||
|
||||
public EntitySpawnInfo(EntityFrame<? extends Entity> entityToSpawn, CoordinatorFrame<? extends Coordinator> coordinator) {
|
||||
this.entityToSpawn = entityToSpawn;
|
||||
parameters = new HashMap<>();
|
||||
}
|
||||
|
||||
public EntityIndex getEntityType() {
|
||||
return entityType;
|
||||
public EntityFrame<? extends Entity> getEntityToSpawn() {
|
||||
return entityToSpawn;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return entityType.name() + ": " + parameters.size();
|
||||
public CoordinatorFrame<? extends Coordinator> getEntityCoordinator() {
|
||||
return entityCoordinator;
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,10 @@
|
||||
package zero1hd.rhythmbullet.audio.map;
|
||||
|
||||
import zero1hd.rhythmbullet.audio.AudioData;
|
||||
import zero1hd.rhythmbullet.entity.EntityIndex;
|
||||
import zero1hd.rhythmbullet.entity.Entity;
|
||||
import zero1hd.rhythmbullet.entity.EntityFrame;
|
||||
import zero1hd.rhythmbullet.entity.coordinator.Coordinator;
|
||||
import zero1hd.rhythmbullet.entity.coordinator.CoordinatorFrame;
|
||||
|
||||
public class GamePlayMap {
|
||||
private AudioData musicData;
|
||||
@ -30,12 +33,12 @@ public class GamePlayMap {
|
||||
return previousIndex;
|
||||
}
|
||||
|
||||
public EntitySpawnInfo addEntity(EntityIndex entityType) {
|
||||
public EntitySpawnInfo addEntity(EntityFrame<? extends Entity> entityType, CoordinatorFrame<? extends Coordinator> coordinator) {
|
||||
if (building) {
|
||||
if (spawnList[index] == null) {
|
||||
spawnList[index] = new MapWindowData();
|
||||
}
|
||||
EntitySpawnInfo esi = new EntitySpawnInfo(entityType);
|
||||
EntitySpawnInfo esi = new EntitySpawnInfo(entityType, coordinator);
|
||||
spawnList[index].addEntity(esi);
|
||||
return esi;
|
||||
} else {
|
||||
|
@ -7,13 +7,17 @@ import com.badlogic.gdx.utils.FloatArray;
|
||||
|
||||
import zero1hd.rhythmbullet.RhythmBullet;
|
||||
import zero1hd.rhythmbullet.audio.AudioAnalyzer;
|
||||
import zero1hd.rhythmbullet.entity.EntityIndex;
|
||||
import zero1hd.rhythmbullet.entity.EntityManager;
|
||||
import zero1hd.rhythmbullet.entity.coordinator.CoordinatorManager;
|
||||
import zero1hd.rhythmbullet.util.MiniEvents;
|
||||
import zero1hd.rhythmbullet.util.MiniSender;
|
||||
|
||||
public class RhythmMapAlgorithm implements Runnable {
|
||||
private MiniSender sender;
|
||||
|
||||
private EntityManager em;
|
||||
private CoordinatorManager cm;
|
||||
|
||||
private FloatArray bassPeaks;
|
||||
private FloatArray mPeaks;
|
||||
private FloatArray umPeaks;
|
||||
@ -30,7 +34,10 @@ public class RhythmMapAlgorithm implements Runnable {
|
||||
private float windowPerSecond;
|
||||
|
||||
private volatile int progress;
|
||||
public RhythmMapAlgorithm(AudioAnalyzer analyzer, float speedMod, float healthMod, float difficultyMod) {
|
||||
public RhythmMapAlgorithm(EntityManager em, CoordinatorManager cm, AudioAnalyzer analyzer, float speedMod, float healthMod, float difficultyMod) {
|
||||
this.cm = cm;
|
||||
this.em = em;
|
||||
|
||||
sender = new MiniSender();
|
||||
|
||||
bassPeaks = analyzer.getBassPeaks();
|
||||
@ -67,7 +74,7 @@ public class RhythmMapAlgorithm implements Runnable {
|
||||
float waitTime = 1.5f;
|
||||
float endRadius = (bassPeaks.get(index)/bassMax)*(RhythmBullet.GAME_AREA_HEIGHT/4f);
|
||||
|
||||
esi = map.addEntity(EntityIndex.VOID_CIRCLE);
|
||||
esi = map.addEntity(em.voidCircle, null);
|
||||
esi.parameters.put("warningTime", waitTime);
|
||||
esi.parameters.put("endRadius", endRadius);
|
||||
esi.parameters.put("growthRate", endRadius/(avgSPB*0.8f));
|
||||
@ -85,14 +92,14 @@ public class RhythmMapAlgorithm implements Runnable {
|
||||
//If upper midrange peaks are greater than average, the:
|
||||
int spawnLocations = (RhythmBullet.GAME_AREA_WIDTH-8)/8;
|
||||
|
||||
esi = map.addEntity(EntityIndex.BAR);
|
||||
esi = map.addEntity(em.bar, null);
|
||||
esi.parameters.put("x", (float) (MathUtils.round(rand.nextFloat()*spawnLocations)*8));
|
||||
esi.parameters.put("rate", (8f/avgSPB)*speedMod);
|
||||
|
||||
} else {
|
||||
float xSpawnLocation = (rand.nextFloat()*(RhythmBullet.GAME_AREA_WIDTH-2))+1;
|
||||
|
||||
esi = map.addEntity(EntityIndex.PELLET);
|
||||
esi = map.addEntity(em.pellet, null);
|
||||
esi.parameters.put("x", xSpawnLocation);
|
||||
esi.parameters.put("y", RhythmBullet.GAME_AREA_HEIGHT-0.25f);
|
||||
esi.parameters.put("angle", 140*rand.nextFloat()+200f);
|
||||
@ -130,4 +137,8 @@ public class RhythmMapAlgorithm implements Runnable {
|
||||
public MiniSender getSender() {
|
||||
return sender;
|
||||
}
|
||||
|
||||
public EntityManager getEm() {
|
||||
return em;
|
||||
}
|
||||
}
|
||||
|
@ -18,6 +18,7 @@ public class CollisionDetector {
|
||||
|
||||
AssetManager assets;
|
||||
Preferences prefs;
|
||||
|
||||
//Particle pools;
|
||||
ParticleEffectPool explosionEffectPool;
|
||||
Array<PooledEffect> effects = new Array<>();
|
||||
@ -68,7 +69,7 @@ public class CollisionDetector {
|
||||
|
||||
|
||||
/**
|
||||
* draws the explosion particles where necessecary.
|
||||
* draws the explosion particles where necessary.
|
||||
* @param batch the batch used to draw the said particles
|
||||
* @param cleanBatch whether this method should call begin and end on the batch.
|
||||
*/
|
||||
|
@ -13,12 +13,15 @@ import com.badlogic.gdx.math.Vector2;
|
||||
import com.badlogic.gdx.scenes.scene2d.Actor;
|
||||
import com.badlogic.gdx.utils.Pool.Poolable;
|
||||
|
||||
import zero1hd.rhythmbullet.entity.coordinator.Coordinator;
|
||||
|
||||
public class Entity extends Actor implements Poolable {
|
||||
private Coordinator coordinator;
|
||||
private EntityFrame<?> ef;
|
||||
|
||||
protected AssetManager assets;
|
||||
protected Preferences prefs;
|
||||
protected EntityController ec;
|
||||
protected EntityManager ec;
|
||||
|
||||
protected boolean enemy;
|
||||
protected boolean simple = true;
|
||||
@ -29,15 +32,15 @@ public class Entity extends Actor implements Poolable {
|
||||
protected Sprite sprite;
|
||||
protected Vector2 rotRatios;
|
||||
protected Vector2 center;
|
||||
protected float angle;
|
||||
protected float speed;
|
||||
public float angle;
|
||||
public float speed;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* called by the entity frame and only once (when this object is created).
|
||||
*/
|
||||
protected void setup(EntityController ec, EntityFrame<?> ef) {
|
||||
protected void setup(EntityManager ec, EntityFrame<?> ef) {
|
||||
this.ec = ec;
|
||||
this.ef = ef;
|
||||
assets = ec.getAssets();
|
||||
@ -45,6 +48,7 @@ public class Entity extends Actor implements Poolable {
|
||||
rotRatios = new Vector2();
|
||||
center = new Vector2();
|
||||
hitbox = new Rectangle();
|
||||
|
||||
preInit();
|
||||
}
|
||||
|
||||
@ -90,29 +94,17 @@ public class Entity extends Actor implements Poolable {
|
||||
@Override
|
||||
public void act(float delta) {
|
||||
if (!nonStnrd) {
|
||||
coordinator.coordinate(delta);
|
||||
|
||||
if (move) {
|
||||
move(delta, false);
|
||||
move(delta, true);
|
||||
}
|
||||
|
||||
if (simple) {
|
||||
sprite.setPosition(getX(), getY());
|
||||
hitbox.setPosition(getX(), getY());
|
||||
sprite.setSize(getWidth(), getHeight());
|
||||
hitbox.setSize(getWidth(), getHeight());
|
||||
} else {
|
||||
sprite.setCenter(center.x, center.y);
|
||||
hitbox.setCenter(center);
|
||||
sprite.setOriginCenter();
|
||||
sprite.setRotation(angle);
|
||||
}
|
||||
|
||||
super.act(delta);
|
||||
|
||||
if (isDead()) {
|
||||
ef.recycleEntity(this);
|
||||
}
|
||||
}
|
||||
|
||||
super.act(delta);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -146,18 +138,23 @@ public class Entity extends Actor implements Poolable {
|
||||
if (simple) {
|
||||
sprite.setPosition(getX(), getY());
|
||||
hitbox.setPosition(getX(), getY());
|
||||
sprite.setSize(getWidth(), getHeight());
|
||||
hitbox.setSize(getWidth(), getHeight());
|
||||
} else {
|
||||
sprite.setCenter(center.x, center.y);
|
||||
hitbox.setCenter(center);
|
||||
sprite.setOriginCenter();
|
||||
sprite.setRotation(angle);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reset() {
|
||||
coordinator.clean();
|
||||
coordinator = null;
|
||||
rotRatios.set(0, 0);
|
||||
hitbox.set(0, 0, 0, 0);
|
||||
sprite.setPosition(0, 0);
|
||||
hitbox.set(0, 0, 0, 0);
|
||||
sprite.setRotation(0);
|
||||
setPosition(0, 0);
|
||||
center.set(0, 0);
|
||||
@ -180,4 +177,8 @@ public class Entity extends Actor implements Poolable {
|
||||
public float getSpeed() {
|
||||
return speed;
|
||||
}
|
||||
|
||||
public void setCoordinator(Coordinator coordinator) {
|
||||
this.coordinator = coordinator;
|
||||
}
|
||||
}
|
||||
|
@ -4,11 +4,10 @@ import com.badlogic.gdx.utils.Pool;
|
||||
|
||||
public class EntityFrame<T extends Entity> {
|
||||
private Pool<T> pool;
|
||||
private EntityController ec;
|
||||
private EntityManager ec;
|
||||
Class<T> ct;
|
||||
EntityFrame<T> ef;
|
||||
public EntityFrame(EntityController entityController, Class<T> classType) {
|
||||
ct = classType;
|
||||
public EntityFrame(EntityManager entityController) {
|
||||
ef = this;
|
||||
ec = entityController;
|
||||
pool = new Pool<T>() {
|
||||
@ -44,7 +43,7 @@ public class EntityFrame<T extends Entity> {
|
||||
* Free the entity if no longer used.
|
||||
* @param entity to be freed.
|
||||
*/
|
||||
public void recycleEntity(Entity entity) {
|
||||
protected void recycleEntity(Entity entity) {
|
||||
if (entity.enemy) {
|
||||
ec.activeEnemies.removeValue(entity, true);
|
||||
} else {
|
||||
|
@ -1,8 +1,5 @@
|
||||
package zero1hd.rhythmbullet.entity;
|
||||
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import com.badlogic.gdx.Preferences;
|
||||
import com.badlogic.gdx.assets.AssetManager;
|
||||
import com.badlogic.gdx.scenes.scene2d.Stage;
|
||||
@ -15,7 +12,7 @@ import zero1hd.rhythmbullet.entity.enemies.Pellet;
|
||||
import zero1hd.rhythmbullet.entity.enemies.Shard;
|
||||
import zero1hd.rhythmbullet.entity.enemies.VoidCircle;
|
||||
|
||||
public class EntityController {
|
||||
public class EntityManager {
|
||||
private AssetManager assets;
|
||||
private Preferences prefs;
|
||||
private Stage stage;
|
||||
@ -31,9 +28,7 @@ public class EntityController {
|
||||
|
||||
public EntityFrame<Laser> laser;
|
||||
|
||||
private HashMap<EntityIndex, EntityFrame<? extends Entity>> index = new HashMap<>();
|
||||
|
||||
public EntityController(AssetManager assetManager, Preferences preferences, Stage stage) {
|
||||
public EntityManager(AssetManager assetManager, Preferences preferences, Stage stage) {
|
||||
activeAllies = new Array<Entity>();
|
||||
activeEnemies = new Array<Entity>();
|
||||
this.assets = assetManager;
|
||||
@ -44,17 +39,13 @@ public class EntityController {
|
||||
}
|
||||
|
||||
private void setup() {
|
||||
index.put(EntityIndex.VOID_CIRCLE, (voidCircle = new EntityFrame<>(this, VoidCircle.class)));
|
||||
index.put(EntityIndex.PELLET, pellet = new EntityFrame<>(this, Pellet.class));
|
||||
index.put(EntityIndex.SHARD, shard = new EntityFrame<>(this, Shard.class));
|
||||
index.put(EntityIndex.BAR, bar = new EntityFrame<>(this, Bar.class));
|
||||
index.put(EntityIndex.FLAKE, flake = new EntityFrame<>(this, Flake.class));
|
||||
voidCircle = new EntityFrame<>(this);
|
||||
pellet = new EntityFrame<>(this);
|
||||
shard = new EntityFrame<>(this);
|
||||
bar = new EntityFrame<>(this);
|
||||
flake = new EntityFrame<>(this);
|
||||
laser = new EntityFrame<>(this);
|
||||
|
||||
index.put(EntityIndex.LASER, laser = new EntityFrame<>(this, Laser.class));
|
||||
}
|
||||
|
||||
public HashMap<EntityIndex, EntityFrame<? extends Entity>> getIndex() {
|
||||
return index;
|
||||
}
|
||||
|
||||
public Stage getStage() {
|
@ -46,6 +46,7 @@ public class PolyJetEntity extends Entity {
|
||||
thrust.update(delta);
|
||||
teleportCloak.setPosition(getX() +(getWidth()-1)/2, getY() + (getHeight()-1)/2);
|
||||
|
||||
hitbox.setPosition(getX(), getY());
|
||||
|
||||
//Movement!
|
||||
if (accelerate) {
|
||||
|
33
core/src/zero1hd/rhythmbullet/entity/coordinator/Coordinator.java
Executable file
33
core/src/zero1hd/rhythmbullet/entity/coordinator/Coordinator.java
Executable file
@ -0,0 +1,33 @@
|
||||
package zero1hd.rhythmbullet.entity.coordinator;
|
||||
|
||||
import com.badlogic.gdx.utils.Pool.Poolable;
|
||||
|
||||
import zero1hd.rhythmbullet.entity.Entity;
|
||||
import zero1hd.rhythmbullet.entity.EntityManager;
|
||||
|
||||
public class Coordinator implements Poolable {
|
||||
private CoordinatorFrame<? extends Coordinator> cf;
|
||||
protected EntityManager em;
|
||||
protected Entity entity;
|
||||
|
||||
public void setup(EntityManager em, CoordinatorFrame<? extends Coordinator> cf) {
|
||||
this.em = em;
|
||||
this.cf = cf;
|
||||
}
|
||||
|
||||
public void init(Entity entity) {
|
||||
this.entity = entity;
|
||||
}
|
||||
|
||||
public void coordinate(float delta) {
|
||||
}
|
||||
|
||||
public void clean() {
|
||||
cf.recycleCoordinator(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reset() {
|
||||
entity = null;
|
||||
}
|
||||
}
|
39
core/src/zero1hd/rhythmbullet/entity/coordinator/CoordinatorFrame.java
Executable file
39
core/src/zero1hd/rhythmbullet/entity/coordinator/CoordinatorFrame.java
Executable file
@ -0,0 +1,39 @@
|
||||
package zero1hd.rhythmbullet.entity.coordinator;
|
||||
|
||||
import com.badlogic.gdx.utils.Pool;
|
||||
|
||||
import zero1hd.rhythmbullet.entity.EntityManager;
|
||||
|
||||
public class CoordinatorFrame<T extends Coordinator> {
|
||||
private Pool<T> pool;
|
||||
private EntityManager em;
|
||||
CoordinatorFrame<T> cf;
|
||||
Class<T> coordinatorType;
|
||||
public CoordinatorFrame(EntityManager entityManager) {
|
||||
this.em = entityManager;
|
||||
cf = this;
|
||||
pool = new Pool<T>() {
|
||||
@Override
|
||||
protected T newObject() {
|
||||
try {
|
||||
T coordinator = coordinatorType.newInstance();
|
||||
coordinator.setup(em, cf);
|
||||
return coordinator;
|
||||
} catch (InstantiationException | IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public T buildCoordinator() {
|
||||
T coordinator = pool.obtain();
|
||||
return coordinator;
|
||||
}
|
||||
|
||||
protected void recycleCoordinator(Coordinator coordinator) {
|
||||
pool.free(coordinatorType.cast(coordinator));
|
||||
}
|
||||
|
||||
}
|
5
core/src/zero1hd/rhythmbullet/entity/coordinator/CoordinatorIndex.java
Executable file
5
core/src/zero1hd/rhythmbullet/entity/coordinator/CoordinatorIndex.java
Executable file
@ -0,0 +1,5 @@
|
||||
package zero1hd.rhythmbullet.entity.coordinator;
|
||||
|
||||
public enum CoordinatorIndex {
|
||||
SLOW_RIGHT, SLOW_LEFT;
|
||||
}
|
20
core/src/zero1hd/rhythmbullet/entity/coordinator/CoordinatorManager.java
Executable file
20
core/src/zero1hd/rhythmbullet/entity/coordinator/CoordinatorManager.java
Executable file
@ -0,0 +1,20 @@
|
||||
package zero1hd.rhythmbullet.entity.coordinator;
|
||||
|
||||
import zero1hd.rhythmbullet.entity.EntityManager;
|
||||
|
||||
public class CoordinatorManager {
|
||||
private EntityManager em;
|
||||
|
||||
public CoordinatorFrame<SlowLeftCoordinator> slowLeft;
|
||||
public CoordinatorFrame<SlowRightCoordinator> slowRight;
|
||||
|
||||
public CoordinatorManager(EntityManager em) {
|
||||
this.em = em;
|
||||
setup();
|
||||
}
|
||||
|
||||
private void setup() {
|
||||
slowLeft = new CoordinatorFrame<>(em);
|
||||
slowRight = new CoordinatorFrame<>(em);
|
||||
}
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
package zero1hd.rhythmbullet.entity.coordinator;
|
||||
|
||||
public class SlowLeftCoordinator extends Coordinator {
|
||||
@Override
|
||||
public void coordinate(float delta) {
|
||||
entity.angle -= 8*delta;
|
||||
super.coordinate(delta);
|
||||
}
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
package zero1hd.rhythmbullet.entity.coordinator;
|
||||
|
||||
public class SlowRightCoordinator extends Coordinator {
|
||||
@Override
|
||||
public void coordinate(float delta) {
|
||||
entity.angle += 8*delta;
|
||||
super.coordinate(delta);
|
||||
}
|
||||
}
|
@ -21,7 +21,7 @@ public class GameScreen extends ScreenAdapter {
|
||||
private GamePlayArea gameArea;
|
||||
private GameHUD gameHUD;
|
||||
|
||||
public InputMultiplexer inputs;
|
||||
private InputMultiplexer inputs;
|
||||
|
||||
public RhythmBullet core;
|
||||
|
||||
@ -31,8 +31,8 @@ public class GameScreen extends ScreenAdapter {
|
||||
private ShaderProgram bgShader;
|
||||
private Texture background;
|
||||
|
||||
public GameScreen(RhythmBullet polyJet, GamePlayMap gpm) {
|
||||
core = polyJet;
|
||||
public GameScreen(RhythmBullet core) {
|
||||
this.core = core;
|
||||
|
||||
// Overlay stuff
|
||||
ImageButton pause = new ImageButton(core.getDefaultSkin().getDrawable("pause"),
|
||||
@ -46,11 +46,8 @@ public class GameScreen extends ScreenAdapter {
|
||||
}
|
||||
});
|
||||
|
||||
music = gpm.getMusicData();
|
||||
|
||||
gameArea = new GamePlayArea(polyJet.getAssetManager(), core.getPrefs());
|
||||
gameArea.setAudioMap(gpm);
|
||||
gameHUD = new GameHUD(polyJet.getDefaultSkin(), gpm.getMusicData().getPlaybackMusic(), gameArea.getMaxHealth());
|
||||
gameArea = new GamePlayArea(core.getAssetManager(), core.getPrefs());
|
||||
gameHUD = new GameHUD(core.getDefaultSkin(), gameArea.getMaxHealth());
|
||||
|
||||
inputs = new InputMultiplexer();
|
||||
inputs.addProcessor(gameHUD);
|
||||
@ -77,8 +74,15 @@ public class GameScreen extends ScreenAdapter {
|
||||
}
|
||||
}
|
||||
|
||||
public void setGamePlayMap(GamePlayMap gpm) {
|
||||
music = gpm.getMusicData();
|
||||
gameArea.setAudioMap(gpm);
|
||||
gameHUD.setMusic(gpm.getMusicData().getPlaybackMusic());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void show() {
|
||||
if (music == null) new NullPointerException("Idiot, you can't have a music game not have music on the gameplay screen...");
|
||||
Gdx.input.setInputProcessor(inputs);
|
||||
gameArea.loadShaders(core.getPrefs());
|
||||
|
||||
@ -155,5 +159,8 @@ public class GameScreen extends ScreenAdapter {
|
||||
|
||||
super.resize(width, height);
|
||||
}
|
||||
|
||||
|
||||
public GamePlayArea getGameArea() {
|
||||
return gameArea;
|
||||
}
|
||||
}
|
@ -55,7 +55,8 @@ public class AnalyzePage extends Page implements MiniListener {
|
||||
private long startTime, endTime;
|
||||
|
||||
private Thread mapGenThread;
|
||||
|
||||
private GameScreen gameScreen;
|
||||
|
||||
|
||||
private RhythmBullet core;
|
||||
public AnalyzePage(RhythmBullet core) {
|
||||
@ -236,7 +237,7 @@ public class AnalyzePage extends Page implements MiniListener {
|
||||
public void clearAudioData() {
|
||||
music = null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void handle(MiniEvents ID) {
|
||||
switch (ID) {
|
||||
@ -261,7 +262,8 @@ public class AnalyzePage extends Page implements MiniListener {
|
||||
case MUSIC_DATA_CLEANED:
|
||||
info[3].setText("data cleaning done.");
|
||||
info[4].addAction(Actions.color(Color.BLACK, 0.75f));
|
||||
mapGenAlgorithm = new RhythmMapAlgorithm(audioAnalyzer, speedModifier.getValue(), healthModifier.getValue(), sensitivityRating.getValue());
|
||||
gameScreen = new GameScreen(core);
|
||||
mapGenAlgorithm = new RhythmMapAlgorithm(gameScreen.getGameArea().em, gameScreen.getGameArea().cm, audioAnalyzer, speedModifier.getValue(), healthModifier.getValue(), sensitivityRating.getValue());
|
||||
mapGenAlgorithm.getSender().addListener(this);
|
||||
mapGenThread = new Thread(mapGenAlgorithm);
|
||||
mapGenThread.start();
|
||||
@ -277,11 +279,11 @@ public class AnalyzePage extends Page implements MiniListener {
|
||||
Gdx.app.postRunnable(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
final GameScreen gameScreen = new GameScreen(core, mapGenAlgorithm.getMap());
|
||||
beginButton.addListener(new ChangeListener() {
|
||||
|
||||
@Override
|
||||
public void changed(ChangeEvent event, Actor actor) {
|
||||
gameScreen.setGamePlayMap(mapGenAlgorithm.getMap());
|
||||
core.setScreen(gameScreen);
|
||||
}
|
||||
});
|
||||
|
@ -56,7 +56,7 @@ public class CreativeHUD extends Stage implements MiniListener {
|
||||
bassUMgraphWindow = new BassUMGraphWindow("Bass/UM Peak Values", core.getDefaultSkin());
|
||||
mGraphWindow = new MGraphWindow("Midrange Peak Values", core.getDefaultSkin());
|
||||
volumeWindow = new VolumeWindow("Volume adjustments", core.getDefaultSkin(), core.getPrefs());
|
||||
spawnerWindow = new SpawnerWindow("Spawn Tool", core.getDefaultSkin(), gpa.ec, gpa);
|
||||
spawnerWindow = new SpawnerWindow("Spawn Tool", core.getDefaultSkin(), gpa.em, gpa);
|
||||
diffWindow = new DifficultyWindow(core.getDefaultSkin());
|
||||
|
||||
//Back button
|
||||
@ -255,7 +255,7 @@ public class CreativeHUD extends Stage implements MiniListener {
|
||||
break;
|
||||
case MUSIC_DATA_CLEANED:
|
||||
if (analyzer != null && analyzer.isFinalized()) {
|
||||
mapGen = new RhythmMapAlgorithm(analyzer, diffWindow.getSpeedModifier(), diffWindow.getHealthModifier(), diffWindow.getSensitivityVal());
|
||||
mapGen = new RhythmMapAlgorithm(gpa.em, gpa.cm, analyzer, diffWindow.getSpeedModifier(), diffWindow.getHealthModifier(), diffWindow.getSensitivityVal());
|
||||
mapGen.getSender().addListener(this);
|
||||
Thread mapGenThread = new Thread(mapGen);
|
||||
mapGenThread.start();
|
||||
|
@ -25,10 +25,8 @@ public class GameHUD extends Stage {
|
||||
|
||||
private Music music;
|
||||
|
||||
public GameHUD(Skin skin, Music music, int maxHealth) {
|
||||
public GameHUD(Skin skin, int maxHealth) {
|
||||
super();
|
||||
this.music = music;
|
||||
|
||||
score = new Label("Score: 0", skin, "default-font", Color.WHITE);
|
||||
score.setPosition(10f, Gdx.graphics.getHeight()-score.getHeight() - 10f);
|
||||
addActor(score);
|
||||
@ -127,4 +125,7 @@ public class GameHUD extends Stage {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void setMusic(Music music) {
|
||||
this.music = music;
|
||||
}
|
||||
}
|
||||
|
@ -18,17 +18,18 @@ import zero1hd.rhythmbullet.audio.map.MapWindowData;
|
||||
import zero1hd.rhythmbullet.controls.KeyMap;
|
||||
import zero1hd.rhythmbullet.entity.CollisionDetector;
|
||||
import zero1hd.rhythmbullet.entity.Entity;
|
||||
import zero1hd.rhythmbullet.entity.EntityController;
|
||||
import zero1hd.rhythmbullet.entity.EntityIndex;
|
||||
import zero1hd.rhythmbullet.entity.EntityManager;
|
||||
import zero1hd.rhythmbullet.entity.ally.Laser;
|
||||
import zero1hd.rhythmbullet.entity.ally.PolyJetEntity;
|
||||
import zero1hd.rhythmbullet.entity.coordinator.CoordinatorManager;
|
||||
|
||||
|
||||
public class GamePlayArea extends Stage {
|
||||
public PolyJetEntity polyjet;
|
||||
private GamePlayMap audioMap;
|
||||
|
||||
public EntityController ec;
|
||||
public CoordinatorManager cm;
|
||||
public EntityManager em;
|
||||
private CollisionDetector collisionDetector;
|
||||
|
||||
private int maxHealth = 100;
|
||||
@ -47,9 +48,10 @@ public class GamePlayArea extends Stage {
|
||||
Gdx.app.debug("Game Area", "new area created");
|
||||
|
||||
polyjet = new PolyJetEntity(assetManager, 25f, 25f, "standard");
|
||||
ec = new EntityController(assetManager, prefs, this);
|
||||
collisionDetector = new CollisionDetector(ec.activeEnemies, ec.activeAllies, assetManager, prefs);
|
||||
ec.activeAllies.add(polyjet);
|
||||
em = new EntityManager(assetManager, prefs, this);
|
||||
cm = new CoordinatorManager(em);
|
||||
collisionDetector = new CollisionDetector(em.activeEnemies, em.activeAllies, assetManager, prefs);
|
||||
em.activeAllies.add(polyjet);
|
||||
addActor(polyjet);
|
||||
}
|
||||
|
||||
@ -127,7 +129,10 @@ public class GamePlayArea extends Stage {
|
||||
EntitySpawnInfo[] currentSpawnInfo = mwd.getArray();
|
||||
if (currentSpawnInfo != null) {
|
||||
for (int i = 0; i < currentSpawnInfo.length; i++) {
|
||||
Entity entity = ec.getIndex().get(currentSpawnInfo[i].getEntityType()).buildEntity();
|
||||
Entity entity = currentSpawnInfo[i].getEntityToSpawn().buildEntity();
|
||||
if (currentSpawnInfo[i].getEntityCoordinator() != null) {
|
||||
entity.setCoordinator(currentSpawnInfo[i].getEntityCoordinator().buildCoordinator());
|
||||
}
|
||||
entity.init(currentSpawnInfo[i].parameters);
|
||||
addActor(entity);
|
||||
}
|
||||
@ -210,7 +215,7 @@ public class GamePlayArea extends Stage {
|
||||
}
|
||||
|
||||
if (keycode == KeyMap.shoot) {
|
||||
Laser laser = (Laser) ec.getIndex().get(EntityIndex.LASER).buildEntity();
|
||||
Laser laser = em.laser.buildEntity();
|
||||
laser.init(polyjet.getX() + polyjet.getWidth()/2f, polyjet.getY() + polyjet.getHeight()+1f, 60f);
|
||||
addActor(laser);
|
||||
}
|
||||
|
@ -10,8 +10,7 @@ import com.badlogic.gdx.scenes.scene2d.ui.Skin;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Slider;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Window;
|
||||
|
||||
import zero1hd.rhythmbullet.entity.Entity;
|
||||
import zero1hd.rhythmbullet.entity.EntityController;
|
||||
import zero1hd.rhythmbullet.entity.EntityManager;
|
||||
import zero1hd.rhythmbullet.entity.EntityIndex;
|
||||
import zero1hd.rhythmbullet.entity.ally.Laser;
|
||||
import zero1hd.rhythmbullet.entity.enemies.Bar;
|
||||
@ -21,7 +20,7 @@ import zero1hd.rhythmbullet.entity.enemies.Shard;
|
||||
import zero1hd.rhythmbullet.entity.enemies.VoidCircle;
|
||||
|
||||
public class SpawnerWindow extends Window {
|
||||
private EntityController ec;
|
||||
private EntityManager ec;
|
||||
private Stage stage;
|
||||
|
||||
private List<EntityIndex> listOfEntities;
|
||||
@ -32,7 +31,7 @@ public class SpawnerWindow extends Window {
|
||||
private Slider mod3;
|
||||
private Slider mod4;
|
||||
|
||||
public SpawnerWindow(String title, Skin skin, EntityController ec, Stage stageForEntities) {
|
||||
public SpawnerWindow(String title, Skin skin, EntityManager ec, Stage stageForEntities) {
|
||||
super(title, skin, "tinted");
|
||||
this.ec = ec;
|
||||
stage = stageForEntities;
|
||||
@ -67,41 +66,38 @@ public class SpawnerWindow extends Window {
|
||||
stage.screenToStageCoordinates(coords);
|
||||
|
||||
|
||||
if (ec.getIndex().get(listOfEntities.getSelected()) != null) {
|
||||
Entity entity = ec.getIndex().get(listOfEntities.getSelected()).buildEntity();
|
||||
switch(entity.getEntityType()) {
|
||||
case LASER:
|
||||
Laser laser = (Laser) entity;
|
||||
laser.init(coords.x, coords.y, mod1.getValue());
|
||||
stage.addActor(laser);
|
||||
break;
|
||||
case PELLET:
|
||||
Pellet pellet = (Pellet) entity;
|
||||
pellet.init(coords.x, coords.y, mod2.getValue()/mod2.getMaxValue()*360f, mod1.getValue());
|
||||
stage.addActor(pellet);
|
||||
break;
|
||||
case VOID_CIRCLE:
|
||||
VoidCircle voidCircle = (VoidCircle) entity;
|
||||
voidCircle.init(mod2.getValue(), coords.x, coords.y, mod1.getValue(), mod3.getValue());
|
||||
stage.addActor(voidCircle);
|
||||
break;
|
||||
case SHARD:
|
||||
Shard shard = (Shard) entity;
|
||||
shard.init(coords.x, coords.y, mod2.getValue()/mod2.getMaxValue()*360f, mod1.getValue(), (int) mod3.getValue());
|
||||
stage.addActor(shard);
|
||||
break;
|
||||
case BAR:
|
||||
Bar bar = (Bar) entity;
|
||||
bar.init(coords.x, mod1.getValue());
|
||||
stage.addActor(bar);
|
||||
break;
|
||||
case FLAKE:
|
||||
Flake flake = (Flake) entity;
|
||||
flake.init(coords.x, coords.y, mod1.getValue(), mod3.getValue(), mod2.getValue()/mod2.getMaxValue()*360f, (int) mod4.getValue());
|
||||
stage.addActor(flake);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
switch(listOfEntities.getSelected()) {
|
||||
case LASER:
|
||||
Laser laser = ec.laser.buildEntity();
|
||||
laser.init(coords.x, coords.y, mod1.getValue());
|
||||
stage.addActor(laser);
|
||||
break;
|
||||
case PELLET:
|
||||
Pellet pellet = ec.pellet.buildEntity();
|
||||
pellet.init(coords.x, coords.y, mod2.getValue()/mod2.getMaxValue()*360f, mod1.getValue());
|
||||
stage.addActor(pellet);
|
||||
break;
|
||||
case VOID_CIRCLE:
|
||||
VoidCircle voidCircle = ec.voidCircle.buildEntity();
|
||||
voidCircle.init(mod2.getValue(), coords.x, coords.y, mod1.getValue(), mod3.getValue());
|
||||
stage.addActor(voidCircle);
|
||||
break;
|
||||
case SHARD:
|
||||
Shard shard = ec.shard.buildEntity();
|
||||
shard.init(coords.x, coords.y, mod2.getValue()/mod2.getMaxValue()*360f, mod1.getValue(), (int) mod3.getValue());
|
||||
stage.addActor(shard);
|
||||
break;
|
||||
case BAR:
|
||||
Bar bar = ec.bar.buildEntity();
|
||||
bar.init(coords.x, mod1.getValue());
|
||||
stage.addActor(bar);
|
||||
break;
|
||||
case FLAKE:
|
||||
Flake flake = ec.flake.buildEntity();
|
||||
flake.init(coords.x, coords.y, mod1.getValue(), mod3.getValue(), mod2.getValue()/mod2.getMaxValue()*360f, (int) mod4.getValue());
|
||||
stage.addActor(flake);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
super.act(delta);
|
||||
|
@ -8,7 +8,7 @@ import zero1hd.rhythmbullet.RhythmBullet;
|
||||
public class DesktopLauncher {
|
||||
public static void main (String[] arg) {
|
||||
LwjglApplicationConfiguration config = new LwjglApplicationConfiguration();
|
||||
config.title = "Polyjet";
|
||||
config.title = "Rhythm Bullet";
|
||||
config.width = 800;
|
||||
config.height = 480;
|
||||
config.resizable = false;
|
||||
|
Loading…
Reference in New Issue
Block a user