status bars on sides now work
This commit is contained in:
parent
bed23303e4
commit
2e5c1064ac
@ -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<? extends Entity> entityType, CoordinatorFrame<? extends Coordinator> coordinator) {
|
||||
if (building) {
|
||||
if (spawnList[index] == null) {
|
||||
|
@ -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();
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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() {
|
||||
|
@ -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
|
||||
|
@ -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() {
|
||||
|
Loading…
Reference in New Issue
Block a user