Revisión | 9ae73c42e14ddd7add72673032c93f75f4bf6fe0 (tree) |
---|---|
Tiempo | 2022-04-07 22:55:42 |
Autor | sebastian_bugiu |
Commiter | sebastian_bugiu |
Added buy menu when demo mode is enabled and score limit is reached.
@@ -0,0 +1,95 @@ | ||
1 | +package com.headwayent.spacerocket; | |
2 | + | |
3 | +import com.badlogic.gdx.Gdx; | |
4 | +import com.badlogic.gdx.ScreenAdapter; | |
5 | +import com.badlogic.gdx.scenes.scene2d.Actor; | |
6 | +import com.badlogic.gdx.scenes.scene2d.Stage; | |
7 | +import com.badlogic.gdx.scenes.scene2d.ui.Label; | |
8 | +import com.badlogic.gdx.scenes.scene2d.ui.ScrollPane; | |
9 | +import com.badlogic.gdx.scenes.scene2d.ui.Skin; | |
10 | +import com.badlogic.gdx.scenes.scene2d.ui.Table; | |
11 | +import com.badlogic.gdx.scenes.scene2d.ui.TextButton; | |
12 | +import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener; | |
13 | +import com.badlogic.gdx.utils.Align; | |
14 | +import com.badlogic.gdx.utils.ScreenUtils; | |
15 | +import com.badlogic.gdx.utils.viewport.ScreenViewport; | |
16 | +import com.headwayent.spacerocket.old.ExtendedCanvas; | |
17 | + | |
18 | +public class FullAccessActivity extends ScreenAdapter { | |
19 | + | |
20 | + private final Stage stage; | |
21 | + private Label titleLabel; | |
22 | + private Label buyLabel; | |
23 | + | |
24 | + public FullAccessActivity() { | |
25 | + stage = new Stage(new ScreenViewport()); | |
26 | + } | |
27 | + | |
28 | + @Override | |
29 | + public void show() { | |
30 | + super.show(); | |
31 | + | |
32 | + stage.clear(); | |
33 | + Table table = new Table(); | |
34 | +// table.setFillParent(true); | |
35 | + table.setWidth(ExtendedCanvas.getScreenWidth()); | |
36 | + table.setY(40.0f); | |
37 | + table.setHeight(ExtendedCanvas.getScreenHeight() - 80.0f); | |
38 | + //table.setDebug(true); | |
39 | + stage.addActor(table); | |
40 | + | |
41 | + Gdx.input.setInputProcessor(stage); | |
42 | + | |
43 | + Skin skin = SpaceRocket.getGame().getSkin(); | |
44 | + | |
45 | + titleLabel = new Label("Options", skin); | |
46 | + titleLabel.setAlignment(Align.center); | |
47 | + buyLabel = new Label("Sound enabled", skin); | |
48 | + String buyString = "You are playing the demo version.\n" + | |
49 | + "If you want to bypass the score limitation " + | |
50 | + "please buy the full version of the game."; | |
51 | + titleLabel.setText("Buy full game"); | |
52 | + buyLabel.setText(buyString); | |
53 | + buyLabel.setWrap(true); | |
54 | + | |
55 | + ScrollPane scrollPane = new ScrollPane(buyLabel, skin); | |
56 | + scrollPane.setScrollingDisabled(true, false); | |
57 | + | |
58 | + TextButton buy = Utility.createTextButton("Buy full version", skin); | |
59 | + final TextButton backButton = Utility.createTextButton("Done", skin); // the extra argument here "small" is used to set the button to the smaller version instead of the big default version | |
60 | + | |
61 | + buy.addListener(new ChangeListener() { | |
62 | + @Override | |
63 | + public void changed(ChangeEvent event, Actor actor) { | |
64 | + MainMenuActivity.buyFullGame(stage); | |
65 | + } | |
66 | + }); | |
67 | + | |
68 | + backButton.addListener(new ChangeListener() { | |
69 | + @Override | |
70 | + public void changed(ChangeEvent event, Actor actor) { | |
71 | + SpaceRocket.getGame().changeScreen(SpaceRocket.Screen.HIGH_SCORE); | |
72 | + } | |
73 | + }); | |
74 | + | |
75 | + table.add(titleLabel).fillX().uniformX(); | |
76 | + table.row().pad(10, 20, 10, 20); | |
77 | + table.add(scrollPane).expandX().fillX(); | |
78 | + if (SpaceRocket.getGame().getPurchaseManager() != null) { | |
79 | + table.row().pad(10, 20, 0, 20); | |
80 | + table.add(buy).fillX().uniformX(); | |
81 | + } | |
82 | + table.row().pad(10, 20, 10, 20); | |
83 | + table.add(backButton).fillX().uniformX(); | |
84 | + } | |
85 | + | |
86 | + @Override | |
87 | + public void render(float delta) { | |
88 | + super.render(delta); | |
89 | + ScreenUtils.clear(0, 0, 0, 1); | |
90 | + | |
91 | + // tell our stage to do actions and draw itself | |
92 | + stage.act(Math.min(Gdx.graphics.getDeltaTime(), 1 / 30f)); | |
93 | + stage.draw(); | |
94 | + } | |
95 | +} |
@@ -69,12 +69,12 @@ | ||
69 | 69 | table.add(help).fillX().uniformX(); |
70 | 70 | table.row().pad(10, 20, 0, 20); |
71 | 71 | table.add(credits).fillX().uniformX(); |
72 | - table.row().pad(10, 20, 0, 20); | |
73 | - table.add(buy).fillX().uniformX(); | |
74 | 72 | if (SpaceRocket.getGame().getPurchaseManager() != null) { |
75 | 73 | table.row().pad(10, 20, 0, 20); |
76 | - table.add(exit).fillX().uniformX(); | |
74 | + table.add(buy).fillX().uniformX(); | |
77 | 75 | } |
76 | + table.row().pad(10, 20, 0, 20); | |
77 | + table.add(exit).fillX().uniformX(); | |
78 | 78 | |
79 | 79 | // create button listeners |
80 | 80 | exit.addListener(new ChangeListener() { |
@@ -130,13 +130,17 @@ | ||
130 | 130 | buy.addListener(new ChangeListener() { |
131 | 131 | @Override |
132 | 132 | public void changed(ChangeEvent event, Actor actor) { |
133 | - new IAPShop(skin).show(stage); | |
133 | + buyFullGame(stage); | |
134 | 134 | } |
135 | 135 | }); |
136 | 136 | |
137 | 137 | // SpaceRocket.getGame().changeScreen(SpaceRocket.Screen.SELECT_DIFFICULTY); |
138 | 138 | } |
139 | 139 | |
140 | + public static void buyFullGame(Stage stage) { | |
141 | + new IAPShop(SpaceRocket.getGame().getSkin()).show(stage); | |
142 | + } | |
143 | + | |
140 | 144 | @Override |
141 | 145 | public void render(float delta) { |
142 | 146 | super.render(delta); |
@@ -46,6 +46,7 @@ | ||
46 | 46 | private MultiplayerJoinGameActivity multiplayerJoinGameActivity; |
47 | 47 | private MultiplayerLobbyActivity multiplayerLobbyActivity; |
48 | 48 | private FinalResultsActivity finalResultsActivity; |
49 | + private FullAccessActivity fullAccessActivity; | |
49 | 50 | private Skin skin; |
50 | 51 | private AssetManager assetManager; |
51 | 52 |
@@ -65,7 +66,7 @@ | ||
65 | 66 | IN_GAME, MAIN_MENU, SELECT_DIFFICULTY, HIGH_SCORE, |
66 | 67 | OPTIONS, HELP, CREDITS, MULTIPLAYER_LOGIN, MULTIPLAYER_LOGGED_IN, |
67 | 68 | MULTIPLAYER_CREATE_GAME, MULTIPLAYER_JOIN_GAME, MULTIPLAYER_LOBBY, |
68 | - MULTIPLAYER_ADD_FRIEND, FINAL_RESULTS | |
69 | + MULTIPLAYER_ADD_FRIEND, FINAL_RESULTS, FULL_ACCESS | |
69 | 70 | } |
70 | 71 | |
71 | 72 | public SpaceRocket(PurchaseManager purchaseManager) { |
@@ -218,6 +219,12 @@ | ||
218 | 219 | } |
219 | 220 | setScreen(finalResultsActivity); |
220 | 221 | break; |
222 | + case FULL_ACCESS: | |
223 | + if (fullAccessActivity == null) { | |
224 | + fullAccessActivity = new FullAccessActivity(); | |
225 | + } | |
226 | + setScreen(fullAccessActivity); | |
227 | + break; | |
221 | 228 | } |
222 | 229 | } |
223 | 230 |
@@ -277,7 +277,10 @@ | ||
277 | 277 | if(System.currentTimeMillis() - gameOverTime > 3000) { |
278 | 278 | setGameOver(); |
279 | 279 | getStatus().setShowHighScore(true); |
280 | - SpaceRocket.getGame().changeScreen(SpaceRocket.Screen.HIGH_SCORE); | |
280 | + SpaceRocket.getGame().changeScreen( | |
281 | + Preferences.getInstance().isFullAccess() ? | |
282 | + SpaceRocket.Screen.HIGH_SCORE : | |
283 | + SpaceRocket.Screen.FULL_ACCESS); | |
281 | 284 | } |
282 | 285 | } |
283 | 286 | } |
@@ -2,5 +2,5 @@ | ||
2 | 2 | app.id=com.headwayent.spacerocket |
3 | 3 | app.mainclass=com.headwayent.spacerocket.IOSLauncher |
4 | 4 | app.executable=IOSLauncher |
5 | -app.build=18 | |
5 | +app.build=19 | |
6 | 6 | app.name=Hotshot 2D |