Pause menu shows also when countdown was running -> is stopped
This commit is contained in:
parent
f1b20d97e8
commit
b4783cdb17
@ -1,6 +1,5 @@
|
||||
package com.example.julian.endlessroll.main.game;
|
||||
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
|
||||
@ -17,15 +16,15 @@ import com.example.julian.endlessroll.entities.tools.ToolType;
|
||||
import com.example.julian.endlessroll.levels.Level;
|
||||
import com.example.julian.endlessroll.levels.LevelManager;
|
||||
import com.example.julian.endlessroll.levels.LevelPack;
|
||||
import com.example.julian.endlessroll.main.tutorial.BreakPoint;
|
||||
import com.example.julian.endlessroll.main.tutorial.Tutorial;
|
||||
import com.example.julian.endlessroll.user.LevelUpBounties;
|
||||
import com.example.julian.endlessroll.main.DataStorageHandler;
|
||||
import com.example.julian.endlessroll.main.GameHandler;
|
||||
import com.example.julian.endlessroll.main.GameLog;
|
||||
import com.example.julian.endlessroll.main.screens.Screen;
|
||||
import com.example.julian.endlessroll.main.tutorial.BreakPoint;
|
||||
import com.example.julian.endlessroll.main.tutorial.Tutorial;
|
||||
import com.example.julian.endlessroll.rendering.Rendering;
|
||||
import com.example.julian.endlessroll.sounds.SoundManager;
|
||||
import com.example.julian.endlessroll.user.LevelUpBounties;
|
||||
import com.example.julian.endlessroll.user.User;
|
||||
import com.example.julian.endlessroll.views.MessageType;
|
||||
import com.example.julian.endlessroll.views.ToolButton;
|
||||
@ -56,7 +55,7 @@ public class Game extends Rendering<GameScene> {
|
||||
private Physics physics;
|
||||
private CollisionManager collisionManager;
|
||||
private Timer timer;
|
||||
private GameState gameState = GameState.PAUSED;
|
||||
private GameState gameState = GameState.COUNTDOWN;
|
||||
|
||||
private Level level;
|
||||
private List<Integer> collectedStars = new ArrayList<>();
|
||||
@ -103,7 +102,8 @@ public class Game extends Rendering<GameScene> {
|
||||
this.level = level;
|
||||
this.levelPack = levelPack;
|
||||
if (scene != null) {
|
||||
currentTutorial = new Tutorial(new BreakPoint(5,R.layout.tutorial_test));
|
||||
gameState = GameState.COUNTDOWN;
|
||||
currentTutorial = new Tutorial(new BreakPoint(5, R.layout.tutorial_test));
|
||||
collectedStars.clear();
|
||||
energyCollected = false;
|
||||
particleSystem.deleteAllSources();
|
||||
@ -156,7 +156,7 @@ public class Game extends Rendering<GameScene> {
|
||||
scene.update(timer);
|
||||
collisionManager.update(physics, scene);
|
||||
currentTutorial.update(playerProgress);
|
||||
if(currentTutorial.isOverNewBreakPoint()){
|
||||
if (currentTutorial.isOverNewBreakPoint()) {
|
||||
gameState = GameState.PAUSED;
|
||||
handler.showTutorialScreen(currentTutorial.getCurrentBreakPoint());
|
||||
}
|
||||
@ -186,6 +186,7 @@ public class Game extends Rendering<GameScene> {
|
||||
|
||||
public void continueGame() {
|
||||
viewManager.hideShortMenu();
|
||||
gameState = GameState.COUNTDOWN;
|
||||
viewManager.startCountdown();
|
||||
}
|
||||
|
||||
@ -206,16 +207,14 @@ public class Game extends Rendering<GameScene> {
|
||||
currentTool = toolType;
|
||||
}
|
||||
|
||||
public void pause() {
|
||||
public void tryToPause() {
|
||||
viewManager.showShortMenu();
|
||||
if (gameState == GameState.RUNNING) {
|
||||
gameState = GameState.PAUSED;
|
||||
} else {
|
||||
if (gameState == GameState.COUNTDOWN)
|
||||
viewManager.stopCountdown();
|
||||
}
|
||||
gameState = GameState.PAUSED;
|
||||
}
|
||||
|
||||
public void setRunning(){
|
||||
public void setRunning() {
|
||||
gameState = GameState.RUNNING;
|
||||
}
|
||||
|
||||
@ -250,7 +249,7 @@ public class Game extends Rendering<GameScene> {
|
||||
}
|
||||
}
|
||||
|
||||
if(energyCollected) {
|
||||
if (energyCollected) {
|
||||
level.setEnergyCollected(true);
|
||||
user.onEnergyCollected();
|
||||
}
|
||||
@ -277,7 +276,7 @@ public class Game extends Rendering<GameScene> {
|
||||
collectedStars.add(star.getIndex());
|
||||
}
|
||||
|
||||
public void onEnergyCollision(Energy energy){
|
||||
public void onEnergyCollision(Energy energy) {
|
||||
scene.onEnergyCollision(energy);
|
||||
energyCollected = true;
|
||||
}
|
||||
|
@ -5,6 +5,6 @@ package com.example.julian.endlessroll.main.game;
|
||||
*/
|
||||
public enum GameState {
|
||||
|
||||
RUNNING, PAUSED, GAME_OVER, LEVEL_FINISHED
|
||||
RUNNING, PAUSED, GAME_OVER, LEVEL_FINISHED, COUNTDOWN
|
||||
|
||||
}
|
||||
|
@ -9,9 +9,7 @@ import com.example.julian.endlessroll.main.GameActivity;
|
||||
import com.example.julian.endlessroll.main.GameHandler;
|
||||
import com.example.julian.endlessroll.main.MyGlSurfaceView;
|
||||
import com.example.julian.endlessroll.main.game.Game;
|
||||
import com.example.julian.endlessroll.main.game.GameState;
|
||||
import com.example.julian.endlessroll.main.tutorial.BreakPoint;
|
||||
import com.example.julian.endlessroll.main.tutorial.Tutorial;
|
||||
import com.example.julian.endlessroll.views.TopBarData;
|
||||
|
||||
/**
|
||||
@ -36,7 +34,7 @@ public class GameScreen extends GLScreen<RelativeLayout> {
|
||||
}
|
||||
|
||||
public void onPause() {
|
||||
game.pause();
|
||||
game.tryToPause();
|
||||
}
|
||||
|
||||
public void onResume(){
|
||||
@ -45,8 +43,7 @@ public class GameScreen extends GLScreen<RelativeLayout> {
|
||||
|
||||
@Override
|
||||
public void onBackKeyDown() {
|
||||
if (game.getGameState() == GameState.RUNNING)
|
||||
game.pause();
|
||||
game.tryToPause();
|
||||
}
|
||||
|
||||
public void startGame(LevelPack levelPack, Level level) {
|
||||
|
@ -11,7 +11,6 @@ import com.example.julian.endlessroll.R;
|
||||
import com.example.julian.endlessroll.data.Vector;
|
||||
import com.example.julian.endlessroll.main.GameHandler;
|
||||
import com.example.julian.endlessroll.main.game.Game;
|
||||
import com.example.julian.endlessroll.main.game.GameState;
|
||||
import com.example.julian.endlessroll.main.game.Timer;
|
||||
|
||||
/**
|
||||
@ -63,8 +62,7 @@ public class ViewManager implements View.OnClickListener {
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (game.getGameState() == GameState.RUNNING)
|
||||
game.pause();
|
||||
game.tryToPause();
|
||||
}
|
||||
|
||||
public void resetViews() {
|
||||
@ -102,7 +100,7 @@ public class ViewManager implements View.OnClickListener {
|
||||
countdown.start();
|
||||
}
|
||||
|
||||
public void stopCountdown() {
|
||||
public void stopCountdown(){
|
||||
countdown.stop();
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user