Fixed Obstacle-Move-Component bug, when offsets were set
Countdown now played as three seperate sounds, though not perfect yet (neither timing, nor high pitches) Added lv 12
This commit is contained in:
@ -34,12 +34,13 @@ public class Obstacle extends Entity {
|
||||
super.setToTerrain(terrainEdge);
|
||||
if (moveComponent != null && moving) {
|
||||
moveComponent.init(super.getPosition());
|
||||
moveProgress = moveComponent.getStartOffset();
|
||||
moveDirection = moveComponent.getDirection();
|
||||
moveProgress = moveComponent.getStartOffset();
|
||||
//Constant player speed assumed
|
||||
float timeTillPlayerReachesTrigger = player.getSpeed() * ((moveComponent
|
||||
.getLeftmostPosition() - super.getWidth() / 2 - moveComponent
|
||||
.getTriggerDistance()) - player.getRightEdge());
|
||||
float triggerX = super.getPosition().getX() - super.getWidth() / 2 - moveComponent
|
||||
.getTriggerDistance();
|
||||
float timeTillPlayerReachesTrigger = player.getSpeed() * (triggerX - player
|
||||
.getRightEdge());
|
||||
moveDirection *= -1;
|
||||
moveWithMoveComponent(timeTillPlayerReachesTrigger * 1000 * 1000, player.getSpeed());
|
||||
moveDirection *= -1;
|
||||
|
@ -74,10 +74,6 @@ public class MoveComponent {
|
||||
speed /= TRANSITION_VALUE;
|
||||
}
|
||||
|
||||
public float getLeftmostPosition() {
|
||||
return triangleWidth >= 0 ? position.x : position.x + triangleWidth;
|
||||
}
|
||||
|
||||
public Vector getMovementVector(float moveDirection) {
|
||||
return new Vector(triangleWidth, triangleHeight).normalize()
|
||||
.mul(moveDirection * getSpeed() * TRANSITION_VALUE);
|
||||
|
@ -33,7 +33,8 @@ public class SoundManager {
|
||||
public final Sound dieSound;
|
||||
public final Sound collectStarSound;
|
||||
public final Sound collectEnergySound;
|
||||
public final Sound countdownSound;
|
||||
public final Sound countdownSoundSingle;
|
||||
public final Sound countdownSoundLast;
|
||||
public final Sound explosionSound;
|
||||
public final Sound fireworkSound;
|
||||
public final Sound stasisSound;
|
||||
@ -59,7 +60,8 @@ public class SoundManager {
|
||||
dieSound = new Sound(loadSound(R.raw.sound_die));
|
||||
collectStarSound = new Sound(loadSound(R.raw.sound_collect_star), .7f);
|
||||
collectEnergySound = new Sound(loadSound(R.raw.sound_collect_energy));
|
||||
countdownSound = new Sound(loadSound(R.raw.sound_countdown));
|
||||
countdownSoundSingle = new Sound(loadSound(R.raw.sound_countdown_single), .9f);
|
||||
countdownSoundLast = new Sound(loadSound(R.raw.sound_countdown_last), .8f);
|
||||
explosionSound = new Sound(loadSound(R.raw.sound_explosion), 2);
|
||||
fireworkSound = new Sound(loadSound(R.raw.sound_firework));
|
||||
stasisSound = new Sound(loadSound(R.raw.sound_stasis), 1.3f, true);
|
||||
|
@ -36,11 +36,17 @@ public class Countdown {
|
||||
public void update(float delta) {
|
||||
if (running.get()) {
|
||||
time += delta;
|
||||
if (time >= 1000 && currentSeconds == 0)
|
||||
onNextSecondInUiThread(1);
|
||||
if (time >= 2000 && currentSeconds == 1)
|
||||
onNextSecondInUiThread(2);
|
||||
if (time >= 1000 && currentSeconds == 0) {
|
||||
currentSeconds = 1;
|
||||
onNextSecondInUiThread(currentSeconds, true);
|
||||
|
||||
}
|
||||
if (time >= 2000 && currentSeconds == 1) {
|
||||
currentSeconds = 2;
|
||||
onNextSecondInUiThread(currentSeconds, true);
|
||||
}
|
||||
if (time >= 3000 && currentSeconds == 2) {
|
||||
currentSeconds = 3;
|
||||
gameActivity.runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
@ -58,7 +64,7 @@ public class Countdown {
|
||||
running.set(true);
|
||||
textView.setVisibility(View.VISIBLE);
|
||||
soundStream = gameActivity.getSoundManager()
|
||||
.playSound(gameActivity.getSoundManager().countdownSound);
|
||||
.playSound(gameActivity.getSoundManager().countdownSoundSingle);
|
||||
}
|
||||
|
||||
public void stop() {
|
||||
@ -70,14 +76,22 @@ public class Countdown {
|
||||
|
||||
private void reset() {
|
||||
time = 0;
|
||||
onNextSecondInUiThread(0);
|
||||
currentSeconds = 0;
|
||||
onNextSecondInUiThread(0, false);
|
||||
}
|
||||
|
||||
private void onNextSecondInUiThread(final int second) {
|
||||
private void onNextSecondInUiThread(final int second, final boolean playSound) {
|
||||
gameActivity.runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
currentSeconds = second;
|
||||
if(playSound){
|
||||
if(second == 2)
|
||||
soundStream = gameActivity.getSoundManager()
|
||||
.playSound(gameActivity.getSoundManager().countdownSoundLast);
|
||||
else
|
||||
soundStream = gameActivity.getSoundManager()
|
||||
.playSound(gameActivity.getSoundManager().countdownSoundSingle);
|
||||
}
|
||||
textView.setText((3 - second) + "");
|
||||
int color = R.color.countdown1;
|
||||
if (second == 1)
|
||||
|
Reference in New Issue
Block a user