implemented all sounds and music

This commit is contained in:
=
2018-01-19 17:41:05 +01:00
parent 53b9b6bb14
commit 2c19e3dcb5
52 changed files with 686 additions and 379 deletions

View File

@ -1,7 +1,6 @@
package de.frajul.endlessroll.views;
import android.graphics.Typeface;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.AnimationSet;
import android.view.animation.AnimationUtils;
@ -9,6 +8,8 @@ import android.widget.TextView;
import de.frajul.endlessroll.R;
import de.frajul.endlessroll.main.game.Game;
import de.frajul.endlessroll.sounds.SoundManager;
import de.frajul.endlessroll.sounds.SoundStream;
/**
* Created by Julian on 31.07.2016.
@ -18,26 +19,35 @@ public class Countdown implements Animation.AnimationListener {
private Game game;
private AnimationSet animations;
private TextView textView;
private SoundManager soundManager;
private SoundStream soundStream;
private boolean firstHalfRepeated = true;
private int repeatCount = 0;
public Countdown(Game game, Typeface typeface, TextView textView) {
public Countdown(Game game, SoundManager soundManager, Typeface typeface, TextView textView) {
this.game = game;
this.soundManager = soundManager;
this.textView = textView;
this.textView.setTypeface(typeface);
animations = (AnimationSet) AnimationUtils.loadAnimation(game.getContext(), R.anim.countdown);
animations = (AnimationSet) AnimationUtils
.loadAnimation(game.getContext(), R.anim.countdown);
for (Animation animation : animations.getAnimations())
animation.setAnimationListener(this);
}
public void start() {
reset();
textView.startAnimation(animations);
if (textView.getAnimation() == null || !textView.getAnimation().isInitialized()) {
reset();
textView.startAnimation(animations);
soundStream = soundManager.playSound(soundManager.countdownSound);
}
}
public void stop() {
textView.clearAnimation();
if (soundStream != null)
soundManager.stopSound(soundStream);
}
private void reset() {
@ -59,6 +69,7 @@ public class Countdown implements Animation.AnimationListener {
public void onAnimationRepeat(Animation animation) {
if (!firstHalfRepeated)
repeatCount++;
firstHalfRepeated = !firstHalfRepeated;
textView.setText((3 - repeatCount) + "");
if (repeatCount == 1) {

View File

@ -18,6 +18,7 @@ import de.frajul.endlessroll.main.screens.Screen;
public class GameOverMessage implements View.OnClickListener {
private Animation fadeIn;
private GameActivity gameActivity;
private Game game;
private View layout;
@ -27,6 +28,7 @@ public class GameOverMessage implements View.OnClickListener {
public GameOverMessage(Game game, GameActivity gameActivity, View layout) {
this.game = game;
this.gameActivity = gameActivity;
this.layout = layout;
layout.setVisibility(View.GONE);
Typeface typeface = gameActivity.getTypeface();
@ -61,6 +63,7 @@ public class GameOverMessage implements View.OnClickListener {
private void hide() {
layout.clearAnimation();
layout.setVisibility(View.GONE);
gameActivity.getSoundManager().stopAllSounds();
}
@Override

View File

@ -87,6 +87,7 @@ public class GoalMessage implements GoalMessageLevelButtonOnClickListener, View.
private void hide() {
layout.clearAnimation();
layout.setVisibility(View.GONE);
gameActivity.getSoundManager().stopAllSounds();
}
@Override

View File

@ -51,7 +51,7 @@ public class ViewManager implements View.OnClickListener {
gameOverMessage = new GameOverMessage(game, gameActivity,
layout.findViewById(R.id.game_game_over_message));
goalMessage = new GoalMessage(game, gameActivity, layout.findViewById(R.id.game_goal_message));
countdown = new Countdown(game, gameActivity.getTypeface(),
countdown = new Countdown(game, gameActivity.getSoundManager(), gameActivity.getTypeface(),
(TextView) layout.findViewById(R.id.game_countdown));
}
});