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