From d1510d8504e14edc4b21ded60c8b5f0b910806c2 Mon Sep 17 00:00:00 2001 From: fred-boy Date: Tue, 24 Apr 2018 17:48:56 +0700 Subject: [PATCH] Rename GameState.java -> AppState.java --- .../cavecraft/{GameState.java => AppState.java} | 7 +++++-- core/src/ru/deadsoftware/cavecraft/CaveGame.java | 4 ++-- .../ru/deadsoftware/cavecraft/GameScreen.java | 6 +++--- .../deadsoftware/cavecraft/game/GameInput.java | 16 ++++++++-------- .../ru/deadsoftware/cavecraft/game/GameProc.java | 3 ++- .../cavecraft/menu/MenuRenderer.java | 3 ++- 6 files changed, 22 insertions(+), 17 deletions(-) rename core/src/ru/deadsoftware/cavecraft/{GameState.java => AppState.java} (64%) diff --git a/core/src/ru/deadsoftware/cavecraft/GameState.java b/core/src/ru/deadsoftware/cavecraft/AppState.java similarity index 64% rename from core/src/ru/deadsoftware/cavecraft/GameState.java rename to core/src/ru/deadsoftware/cavecraft/AppState.java index 8f11064..e38e701 100644 --- a/core/src/ru/deadsoftware/cavecraft/GameState.java +++ b/core/src/ru/deadsoftware/cavecraft/AppState.java @@ -1,9 +1,12 @@ package ru.deadsoftware.cavecraft; -public enum GameState { - RESTART, +public enum AppState { + GOTO_GAME, GOTO_MENU, + MENU_MAIN, + MENU_GENWORLD, + GAME_PLAY, GAME_CREATIVE_INV } diff --git a/core/src/ru/deadsoftware/cavecraft/CaveGame.java b/core/src/ru/deadsoftware/cavecraft/CaveGame.java index 31b763a..72481c2 100644 --- a/core/src/ru/deadsoftware/cavecraft/CaveGame.java +++ b/core/src/ru/deadsoftware/cavecraft/CaveGame.java @@ -8,7 +8,7 @@ public class CaveGame extends Game { public static final String VERSION = "alpha 0.3-dev"; public static String GAME_FOLDER; - public static GameState STATE; + public static AppState STATE; public static boolean TOUCH; @@ -18,7 +18,7 @@ public class CaveGame extends Game { public CaveGame(boolean touch) { TOUCH = touch; - STATE = GameState.MENU_MAIN; + STATE = AppState.MENU_MAIN; } @Override diff --git a/core/src/ru/deadsoftware/cavecraft/GameScreen.java b/core/src/ru/deadsoftware/cavecraft/GameScreen.java index 52c3dcf..1c6ad79 100644 --- a/core/src/ru/deadsoftware/cavecraft/GameScreen.java +++ b/core/src/ru/deadsoftware/cavecraft/GameScreen.java @@ -53,17 +53,17 @@ public class GameScreen implements Screen { menu(); break; - case RESTART: + case GOTO_GAME: gameProc = new GameProc(); renderer = gameProc.renderer; Gdx.input.setInputProcessor(new InputHandlerGame(gameProc)); - CaveGame.STATE = GameState.GAME_PLAY; + CaveGame.STATE = AppState.GAME_PLAY; break; case GOTO_MENU: renderer = menuRenderer; Gdx.input.setInputProcessor(new InputHandlerMenu(menuRenderer)); - CaveGame.STATE = GameState.MENU_MAIN; + CaveGame.STATE = AppState.MENU_MAIN; break; } renderer.render(); diff --git a/core/src/ru/deadsoftware/cavecraft/game/GameInput.java b/core/src/ru/deadsoftware/cavecraft/game/GameInput.java index f05f563..10e0e43 100644 --- a/core/src/ru/deadsoftware/cavecraft/game/GameInput.java +++ b/core/src/ru/deadsoftware/cavecraft/game/GameInput.java @@ -1,9 +1,9 @@ package ru.deadsoftware.cavecraft.game; -import com.badlogic.gdx.Gdx; import com.badlogic.gdx.Input; import com.badlogic.gdx.utils.TimeUtils; import ru.deadsoftware.cavecraft.*; +import ru.deadsoftware.cavecraft.AppState; public class GameInput { @@ -73,16 +73,16 @@ public class GameInput { break; case Input.Keys.E: - if (CaveGame.STATE == GameState.GAME_PLAY) CaveGame.STATE = GameState.GAME_CREATIVE_INV; - else CaveGame.STATE = GameState.GAME_PLAY; + if (CaveGame.STATE == AppState.GAME_PLAY) CaveGame.STATE = AppState.GAME_CREATIVE_INV; + else CaveGame.STATE = AppState.GAME_PLAY; break; case Input.Keys.N: - CaveGame.STATE = GameState.RESTART; + CaveGame.STATE = AppState.GOTO_GAME; break; case Input.Keys.ESCAPE: case Input.Keys.BACK: - CaveGame.STATE = GameState.GOTO_MENU; + CaveGame.STATE = AppState.GOTO_MENU; break; } } @@ -103,7 +103,7 @@ public class GameInput { } public void touchDown(int screenX, int screenY, int button) { - if (CaveGame.STATE == GameState.GAME_CREATIVE_INV && + if (CaveGame.STATE == AppState.GAME_CREATIVE_INV && screenX>gameProc.renderer.camera.viewportWidth/2-Assets.creativeInv.getRegionWidth()/2 && screenXgameProc.renderer.camera.viewportHeight/2-Assets.creativeInv.getRegionHeight()/2 && @@ -117,8 +117,8 @@ public class GameInput { } gameProc.player.inventory[0] = item; } - } else if (CaveGame.STATE == GameState.GAME_CREATIVE_INV) { - CaveGame.STATE = GameState.GAME_PLAY; + } else if (CaveGame.STATE == AppState.GAME_CREATIVE_INV) { + CaveGame.STATE = AppState.GAME_PLAY; } else { gameProc.touchDownX = screenX; gameProc.touchDownY = screenY; diff --git a/core/src/ru/deadsoftware/cavecraft/game/GameProc.java b/core/src/ru/deadsoftware/cavecraft/game/GameProc.java index a4a6c94..a2107fa 100644 --- a/core/src/ru/deadsoftware/cavecraft/game/GameProc.java +++ b/core/src/ru/deadsoftware/cavecraft/game/GameProc.java @@ -5,6 +5,7 @@ import com.badlogic.gdx.Input; import com.badlogic.gdx.utils.Array; import com.badlogic.gdx.utils.TimeUtils; import ru.deadsoftware.cavecraft.*; +import ru.deadsoftware.cavecraft.AppState; import ru.deadsoftware.cavecraft.game.mobs.Mob; import ru.deadsoftware.cavecraft.game.mobs.Pig; import ru.deadsoftware.cavecraft.game.objects.Player; @@ -121,7 +122,7 @@ public class GameProc { touchDownY< Assets.invBar.getRegionHeight() && touchDownX>renderer.camera.viewportWidth/2-Assets.invBar.getRegionWidth()/2 && touchDownX