From 2e5c1064ac209714d8dd49f5a9db6c69b5bae821 Mon Sep 17 00:00:00 2001 From: Recrown Date: Thu, 10 Aug 2017 17:00:25 -0500 Subject: [PATCH] status bars on sides now work --- .../rhythmbullet/audio/map/GamePlayMap.java | 10 +++++ .../audio/map/RhythmMapAlgorithm.java | 6 +++ .../rhythmbullet/entity/enemies/Pellet.java | 6 ++- .../rhythmbullet/ui/stages/GameHUD.java | 41 ++++++++++++++----- .../rhythmbullet/ui/stages/GamePlayArea.java | 4 ++ .../rhythmbullet/util/ScoreManager.java | 2 + 6 files changed, 57 insertions(+), 12 deletions(-) diff --git a/core/src/zero1hd/rhythmbullet/audio/map/GamePlayMap.java b/core/src/zero1hd/rhythmbullet/audio/map/GamePlayMap.java index 0f4675d..c7325c6 100755 --- a/core/src/zero1hd/rhythmbullet/audio/map/GamePlayMap.java +++ b/core/src/zero1hd/rhythmbullet/audio/map/GamePlayMap.java @@ -12,6 +12,7 @@ public class GamePlayMap { private boolean building; private int index; + private byte[] hudType; /** * GamePlayMap is what the game area will use to generate entities and judge current audio data * @param audioData audio data @@ -19,6 +20,7 @@ public class GamePlayMap { public GamePlayMap(AudioData audioData, int totalWindows) { this.musicData = audioData; spawnList = new MapWindowData[totalWindows]; + hudType = new byte[totalWindows]; } public int setIndex(int index) { @@ -33,6 +35,14 @@ public class GamePlayMap { return previousIndex; } + public void setHUDType(byte data) { + hudType[index] = data; + } + + public byte[] getHudType() { + return hudType; + } + public EntitySpawnInfo addEntity(EntityFrame entityType, CoordinatorFrame coordinator) { if (building) { if (spawnList[index] == null) { diff --git a/core/src/zero1hd/rhythmbullet/audio/map/RhythmMapAlgorithm.java b/core/src/zero1hd/rhythmbullet/audio/map/RhythmMapAlgorithm.java index 65c4607..8ca22aa 100755 --- a/core/src/zero1hd/rhythmbullet/audio/map/RhythmMapAlgorithm.java +++ b/core/src/zero1hd/rhythmbullet/audio/map/RhythmMapAlgorithm.java @@ -137,6 +137,12 @@ public class RhythmMapAlgorithm implements Runnable { progress = MathUtils.round(100f*index/bassPeaks.size); + if (bassPeaks.get(index) > avgBass) { + map.setHUDType((byte) 1); + } else if (umPeaks.get(index) > avgUM) { + map.setHUDType((byte) 2); + } + sender.send(MiniEvents.MAPGEN_ITERATED); } map.endBuild(); diff --git a/core/src/zero1hd/rhythmbullet/entity/enemies/Pellet.java b/core/src/zero1hd/rhythmbullet/entity/enemies/Pellet.java index 9bcc757..d70cfae 100755 --- a/core/src/zero1hd/rhythmbullet/entity/enemies/Pellet.java +++ b/core/src/zero1hd/rhythmbullet/entity/enemies/Pellet.java @@ -7,6 +7,7 @@ import com.badlogic.gdx.graphics.g2d.Sprite; import com.badlogic.gdx.utils.Pool.Poolable; import zero1hd.rhythmbullet.entity.Entity; +import zero1hd.rhythmbullet.entity.ally.PolyjetEntity; public class Pellet extends Entity implements Poolable { @@ -15,6 +16,7 @@ public class Pellet extends Entity implements Poolable { sprite = new Sprite(assets.get("pellet.png", Texture.class)); enemy = true; setSize(0.5f, 0.5f); + sprite.setColor(0.5f, 1f, 1f, 0.5f); super.preInit(); } @@ -32,7 +34,6 @@ public class Pellet extends Entity implements Poolable { setPosition(params.get("x"), params.get("y")); speed = params.get("speed"); angle = params.get("angle"); - super.init(params); } @@ -43,6 +44,9 @@ public class Pellet extends Entity implements Poolable { @Override public void collided(Entity entity) { + if (entity.getClass() == PolyjetEntity.class) { + dead = true; + } super.collided(entity); } diff --git a/core/src/zero1hd/rhythmbullet/ui/stages/GameHUD.java b/core/src/zero1hd/rhythmbullet/ui/stages/GameHUD.java index 797ba03..246f712 100755 --- a/core/src/zero1hd/rhythmbullet/ui/stages/GameHUD.java +++ b/core/src/zero1hd/rhythmbullet/ui/stages/GameHUD.java @@ -34,14 +34,19 @@ public class GameHUD extends Stage { private Texture rightStatTexture; private Image leftStatusBar; private Image rightStatusBar; + private GamePlayArea gpa; private Music music; private ScoreManager sm; + + private Color original, bass, um; public GameHUD(Skin skin, float maxHealth, GamePlayArea gpa) { super(); scoreLabel = new Label("Score: 0", skin, "default-font", Color.WHITE); scoreLabel.setPosition(10f, Gdx.graphics.getHeight()-scoreLabel.getHeight() - 10f); addActor(scoreLabel); this.sm = gpa.score; + this.gpa = gpa; + pause = new ImageButton(skin.getDrawable("pause"), skin.getDrawable("pause-down")); pause.setPosition(Gdx.graphics.getWidth() - pause.getWidth() - 15f, @@ -102,7 +107,11 @@ public class GameHUD extends Stage { addActor(rightStatusBar); rightStatusBar.toBack(); pixmap.dispose(); - setStatusColor(0.0f, 1f, 1f, 0.7f); + + original = new Color(0.6f, 0.8f, 255f, 0.55f); + bass = new Color(0.8f, 0, 1, 0.9f); + um = new Color(1f, 0.6f, 0.4f, 0.9f); + setStatusColor(original); } @Override @@ -110,6 +119,16 @@ public class GameHUD extends Stage { if (sm.checkDifferent()) { setScore(sm.getScore()); } + + if (gpa.getAudioMap() != null && gpa.getAudioMap().getHudType()[gpa.getAudioMap().getIndex()] != 0) { + switch (gpa.getAudioMap().getHudType()[gpa.getAudioMap().getIndex()]) { + case 1: + changeStatusColor(bass, 0.2f, original); + break; + case 2: + changeStatusColor(um, 0.2f, original); + } + } super.act(delta); } @@ -176,25 +195,25 @@ public class GameHUD extends Stage { this.music = music; } - public void setStatusColor(float r, float g, float b, float a) { - leftStatusBar.setColor(r, g, b, a); - rightStatusBar.setColor(r, g, b, a); + public void setStatusColor(Color color) { + leftStatusBar.setColor(color); + rightStatusBar.setColor(color); } - public void setLeftStatusColor(float r, float g, float b, float a) { - leftStatusBar.setColor(r, g, b, a); + public void setLeftStatusColor(Color color) { + leftStatusBar.setColor(color); } - public void setRightStatusColor(float r, float g, float b, float a) { - rightStatusBar.setColor(r, g, b, a); + public void setRightStatusColor(Color color) { + rightStatusBar.setColor(color); } - public void changeStatusColor(Color color, float duration) { + public void changeStatusColor(Color color, float duration, Color endColor) { leftStatusBar.clearActions(); rightStatusBar.clearActions(); - leftStatusBar.addAction(Actions.color(color, duration)); - rightStatusBar.addAction(Actions.color(color, duration)); + leftStatusBar.addAction(Actions.sequence(Actions.color(color, duration*0.8f), Actions.color(endColor, duration))); + rightStatusBar.addAction(Actions.sequence(Actions.color(color, duration*0.8f), Actions.color(endColor, duration))); } public HealthBar getHealthBar() { diff --git a/core/src/zero1hd/rhythmbullet/ui/stages/GamePlayArea.java b/core/src/zero1hd/rhythmbullet/ui/stages/GamePlayArea.java index 1b2af78..140d614 100755 --- a/core/src/zero1hd/rhythmbullet/ui/stages/GamePlayArea.java +++ b/core/src/zero1hd/rhythmbullet/ui/stages/GamePlayArea.java @@ -57,6 +57,10 @@ public class GamePlayArea extends Stage { this.audioMap = audioMap; } + public GamePlayMap getAudioMap() { + return audioMap; + } + /** * needs to be called right after set as screen (should be called in show method). * @param prefs diff --git a/core/src/zero1hd/rhythmbullet/util/ScoreManager.java b/core/src/zero1hd/rhythmbullet/util/ScoreManager.java index 433ab40..942d8d6 100755 --- a/core/src/zero1hd/rhythmbullet/util/ScoreManager.java +++ b/core/src/zero1hd/rhythmbullet/util/ScoreManager.java @@ -6,6 +6,7 @@ public class ScoreManager { public void setScore(int score) { this.score = score; + different = true; } public int getScore() { @@ -14,6 +15,7 @@ public class ScoreManager { public void addScore(int addedScore) { score += addedScore; + different = true; } public boolean checkDifferent() {