From a72bd104f0a677d9f8b01cf85a8107f69c2f98f3 Mon Sep 17 00:00:00 2001 From: Recrown Date: Wed, 2 Aug 2017 02:05:16 -0500 Subject: [PATCH] basic ground work for entity coordinators added --- .../audio/map/EntitySpawnInfo.java | 23 +++--- .../rhythmbullet/audio/map/GamePlayMap.java | 9 ++- .../audio/map/RhythmMapAlgorithm.java | 21 ++++-- .../entity/CollisionDetector.java | 3 +- .../zero1hd/rhythmbullet/entity/Entity.java | 43 +++++------ .../rhythmbullet/entity/EntityFrame.java | 7 +- ...tityController.java => EntityManager.java} | 25 ++----- .../entity/ally/PolyJetEntity.java | 1 + .../entity/coordinator/Coordinator.java | 33 +++++++++ .../entity/coordinator/CoordinatorFrame.java | 39 ++++++++++ .../entity/coordinator/CoordinatorIndex.java | 5 ++ .../coordinator/CoordinatorManager.java | 20 +++++ .../coordinator/SlowLeftCoordinator.java | 9 +++ .../coordinator/SlowRightCoordinator.java | 9 +++ .../rhythmbullet/screens/GameScreen.java | 25 ++++--- .../rhythmbullet/ui/pages/AnalyzePage.java | 10 ++- .../rhythmbullet/ui/stages/CreativeHUD.java | 4 +- .../rhythmbullet/ui/stages/GameHUD.java | 7 +- .../rhythmbullet/ui/stages/GamePlayArea.java | 21 ++++-- .../ui/windows/SpawnerWindow.java | 74 +++++++++---------- .../rhythmbullet/desktop/DesktopLauncher.java | 2 +- 21 files changed, 263 insertions(+), 127 deletions(-) rename core/src/zero1hd/rhythmbullet/entity/{EntityController.java => EntityManager.java} (58%) create mode 100755 core/src/zero1hd/rhythmbullet/entity/coordinator/Coordinator.java create mode 100755 core/src/zero1hd/rhythmbullet/entity/coordinator/CoordinatorFrame.java create mode 100755 core/src/zero1hd/rhythmbullet/entity/coordinator/CoordinatorIndex.java create mode 100755 core/src/zero1hd/rhythmbullet/entity/coordinator/CoordinatorManager.java create mode 100755 core/src/zero1hd/rhythmbullet/entity/coordinator/SlowLeftCoordinator.java create mode 100755 core/src/zero1hd/rhythmbullet/entity/coordinator/SlowRightCoordinator.java diff --git a/core/src/zero1hd/rhythmbullet/audio/map/EntitySpawnInfo.java b/core/src/zero1hd/rhythmbullet/audio/map/EntitySpawnInfo.java index 405e9c3..5f09b77 100755 --- a/core/src/zero1hd/rhythmbullet/audio/map/EntitySpawnInfo.java +++ b/core/src/zero1hd/rhythmbullet/audio/map/EntitySpawnInfo.java @@ -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 entityToSpawn; + private CoordinatorFrame entityCoordinator; public HashMap parameters; - public EntitySpawnInfo(EntityIndex entityType) { - this.entityType = entityType; + + public EntitySpawnInfo(EntityFrame entityToSpawn, CoordinatorFrame coordinator) { + this.entityToSpawn = entityToSpawn; parameters = new HashMap<>(); } - public EntityIndex getEntityType() { - return entityType; + public EntityFrame getEntityToSpawn() { + return entityToSpawn; } - @Override - public String toString() { - return entityType.name() + ": " + parameters.size(); + public CoordinatorFrame getEntityCoordinator() { + return entityCoordinator; } } diff --git a/core/src/zero1hd/rhythmbullet/audio/map/GamePlayMap.java b/core/src/zero1hd/rhythmbullet/audio/map/GamePlayMap.java index 376dbda..0f4675d 100755 --- a/core/src/zero1hd/rhythmbullet/audio/map/GamePlayMap.java +++ b/core/src/zero1hd/rhythmbullet/audio/map/GamePlayMap.java @@ -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 entityType, CoordinatorFrame 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 { diff --git a/core/src/zero1hd/rhythmbullet/audio/map/RhythmMapAlgorithm.java b/core/src/zero1hd/rhythmbullet/audio/map/RhythmMapAlgorithm.java index 5446c49..7e7712f 100755 --- a/core/src/zero1hd/rhythmbullet/audio/map/RhythmMapAlgorithm.java +++ b/core/src/zero1hd/rhythmbullet/audio/map/RhythmMapAlgorithm.java @@ -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; + } } diff --git a/core/src/zero1hd/rhythmbullet/entity/CollisionDetector.java b/core/src/zero1hd/rhythmbullet/entity/CollisionDetector.java index 2badd26..0ac69ae 100755 --- a/core/src/zero1hd/rhythmbullet/entity/CollisionDetector.java +++ b/core/src/zero1hd/rhythmbullet/entity/CollisionDetector.java @@ -18,6 +18,7 @@ public class CollisionDetector { AssetManager assets; Preferences prefs; + //Particle pools; ParticleEffectPool explosionEffectPool; Array 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. */ diff --git a/core/src/zero1hd/rhythmbullet/entity/Entity.java b/core/src/zero1hd/rhythmbullet/entity/Entity.java index b206bd9..b412e2e 100755 --- a/core/src/zero1hd/rhythmbullet/entity/Entity.java +++ b/core/src/zero1hd/rhythmbullet/entity/Entity.java @@ -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; + } } diff --git a/core/src/zero1hd/rhythmbullet/entity/EntityFrame.java b/core/src/zero1hd/rhythmbullet/entity/EntityFrame.java index ec33a21..d5deeef 100755 --- a/core/src/zero1hd/rhythmbullet/entity/EntityFrame.java +++ b/core/src/zero1hd/rhythmbullet/entity/EntityFrame.java @@ -4,11 +4,10 @@ import com.badlogic.gdx.utils.Pool; public class EntityFrame { private Pool pool; - private EntityController ec; + private EntityManager ec; Class ct; EntityFrame ef; - public EntityFrame(EntityController entityController, Class classType) { - ct = classType; + public EntityFrame(EntityManager entityController) { ef = this; ec = entityController; pool = new Pool() { @@ -44,7 +43,7 @@ public class EntityFrame { * 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 { diff --git a/core/src/zero1hd/rhythmbullet/entity/EntityController.java b/core/src/zero1hd/rhythmbullet/entity/EntityManager.java similarity index 58% rename from core/src/zero1hd/rhythmbullet/entity/EntityController.java rename to core/src/zero1hd/rhythmbullet/entity/EntityManager.java index 24b500d..b992c09 100755 --- a/core/src/zero1hd/rhythmbullet/entity/EntityController.java +++ b/core/src/zero1hd/rhythmbullet/entity/EntityManager.java @@ -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; - private HashMap> index = new HashMap<>(); - - public EntityController(AssetManager assetManager, Preferences preferences, Stage stage) { + public EntityManager(AssetManager assetManager, Preferences preferences, Stage stage) { activeAllies = new Array(); activeEnemies = new Array(); 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> getIndex() { - return index; } public Stage getStage() { diff --git a/core/src/zero1hd/rhythmbullet/entity/ally/PolyJetEntity.java b/core/src/zero1hd/rhythmbullet/entity/ally/PolyJetEntity.java index b4e797b..44f59f7 100755 --- a/core/src/zero1hd/rhythmbullet/entity/ally/PolyJetEntity.java +++ b/core/src/zero1hd/rhythmbullet/entity/ally/PolyJetEntity.java @@ -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) { diff --git a/core/src/zero1hd/rhythmbullet/entity/coordinator/Coordinator.java b/core/src/zero1hd/rhythmbullet/entity/coordinator/Coordinator.java new file mode 100755 index 0000000..dd90f53 --- /dev/null +++ b/core/src/zero1hd/rhythmbullet/entity/coordinator/Coordinator.java @@ -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 cf; + protected EntityManager em; + protected Entity entity; + + public void setup(EntityManager em, CoordinatorFrame 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; + } +} diff --git a/core/src/zero1hd/rhythmbullet/entity/coordinator/CoordinatorFrame.java b/core/src/zero1hd/rhythmbullet/entity/coordinator/CoordinatorFrame.java new file mode 100755 index 0000000..24bff3d --- /dev/null +++ b/core/src/zero1hd/rhythmbullet/entity/coordinator/CoordinatorFrame.java @@ -0,0 +1,39 @@ +package zero1hd.rhythmbullet.entity.coordinator; + +import com.badlogic.gdx.utils.Pool; + +import zero1hd.rhythmbullet.entity.EntityManager; + +public class CoordinatorFrame { + private Pool pool; + private EntityManager em; + CoordinatorFrame cf; + Class coordinatorType; + public CoordinatorFrame(EntityManager entityManager) { + this.em = entityManager; + cf = this; + pool = new Pool() { + @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)); + } + +} diff --git a/core/src/zero1hd/rhythmbullet/entity/coordinator/CoordinatorIndex.java b/core/src/zero1hd/rhythmbullet/entity/coordinator/CoordinatorIndex.java new file mode 100755 index 0000000..355b48f --- /dev/null +++ b/core/src/zero1hd/rhythmbullet/entity/coordinator/CoordinatorIndex.java @@ -0,0 +1,5 @@ +package zero1hd.rhythmbullet.entity.coordinator; + +public enum CoordinatorIndex { + SLOW_RIGHT, SLOW_LEFT; +} diff --git a/core/src/zero1hd/rhythmbullet/entity/coordinator/CoordinatorManager.java b/core/src/zero1hd/rhythmbullet/entity/coordinator/CoordinatorManager.java new file mode 100755 index 0000000..6cfac4f --- /dev/null +++ b/core/src/zero1hd/rhythmbullet/entity/coordinator/CoordinatorManager.java @@ -0,0 +1,20 @@ +package zero1hd.rhythmbullet.entity.coordinator; + +import zero1hd.rhythmbullet.entity.EntityManager; + +public class CoordinatorManager { + private EntityManager em; + + public CoordinatorFrame slowLeft; + public CoordinatorFrame slowRight; + + public CoordinatorManager(EntityManager em) { + this.em = em; + setup(); + } + + private void setup() { + slowLeft = new CoordinatorFrame<>(em); + slowRight = new CoordinatorFrame<>(em); + } +} diff --git a/core/src/zero1hd/rhythmbullet/entity/coordinator/SlowLeftCoordinator.java b/core/src/zero1hd/rhythmbullet/entity/coordinator/SlowLeftCoordinator.java new file mode 100755 index 0000000..d3525de --- /dev/null +++ b/core/src/zero1hd/rhythmbullet/entity/coordinator/SlowLeftCoordinator.java @@ -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); + } +} diff --git a/core/src/zero1hd/rhythmbullet/entity/coordinator/SlowRightCoordinator.java b/core/src/zero1hd/rhythmbullet/entity/coordinator/SlowRightCoordinator.java new file mode 100755 index 0000000..e9bd933 --- /dev/null +++ b/core/src/zero1hd/rhythmbullet/entity/coordinator/SlowRightCoordinator.java @@ -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); + } +} diff --git a/core/src/zero1hd/rhythmbullet/screens/GameScreen.java b/core/src/zero1hd/rhythmbullet/screens/GameScreen.java index 235711c..0faffa4 100755 --- a/core/src/zero1hd/rhythmbullet/screens/GameScreen.java +++ b/core/src/zero1hd/rhythmbullet/screens/GameScreen.java @@ -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; + } } \ No newline at end of file diff --git a/core/src/zero1hd/rhythmbullet/ui/pages/AnalyzePage.java b/core/src/zero1hd/rhythmbullet/ui/pages/AnalyzePage.java index 3bee419..8690ad8 100755 --- a/core/src/zero1hd/rhythmbullet/ui/pages/AnalyzePage.java +++ b/core/src/zero1hd/rhythmbullet/ui/pages/AnalyzePage.java @@ -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); } }); diff --git a/core/src/zero1hd/rhythmbullet/ui/stages/CreativeHUD.java b/core/src/zero1hd/rhythmbullet/ui/stages/CreativeHUD.java index 7d26372..d0dfefe 100755 --- a/core/src/zero1hd/rhythmbullet/ui/stages/CreativeHUD.java +++ b/core/src/zero1hd/rhythmbullet/ui/stages/CreativeHUD.java @@ -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(); diff --git a/core/src/zero1hd/rhythmbullet/ui/stages/GameHUD.java b/core/src/zero1hd/rhythmbullet/ui/stages/GameHUD.java index 690135c..70c1db5 100755 --- a/core/src/zero1hd/rhythmbullet/ui/stages/GameHUD.java +++ b/core/src/zero1hd/rhythmbullet/ui/stages/GameHUD.java @@ -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; + } } diff --git a/core/src/zero1hd/rhythmbullet/ui/stages/GamePlayArea.java b/core/src/zero1hd/rhythmbullet/ui/stages/GamePlayArea.java index 545058c..1a9a39f 100755 --- a/core/src/zero1hd/rhythmbullet/ui/stages/GamePlayArea.java +++ b/core/src/zero1hd/rhythmbullet/ui/stages/GamePlayArea.java @@ -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); } diff --git a/core/src/zero1hd/rhythmbullet/ui/windows/SpawnerWindow.java b/core/src/zero1hd/rhythmbullet/ui/windows/SpawnerWindow.java index 0e9593d..106ed6b 100755 --- a/core/src/zero1hd/rhythmbullet/ui/windows/SpawnerWindow.java +++ b/core/src/zero1hd/rhythmbullet/ui/windows/SpawnerWindow.java @@ -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 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); diff --git a/desktop/src/zero1hd/rhythmbullet/desktop/DesktopLauncher.java b/desktop/src/zero1hd/rhythmbullet/desktop/DesktopLauncher.java index a9b7493..7d3fef9 100755 --- a/desktop/src/zero1hd/rhythmbullet/desktop/DesktopLauncher.java +++ b/desktop/src/zero1hd/rhythmbullet/desktop/DesktopLauncher.java @@ -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;