summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorilotterytea <iltsu@alright.party>2024-05-29 21:56:42 +0500
committerilotterytea <iltsu@alright.party>2024-05-29 21:56:42 +0500
commitefac9a5bc2470167bd9744b95aaa45d3fab4e75d (patch)
tree707613f65b93286435c0cd0ea1596a8df4a3bcc7 /core
parent66b52800b45d389d2c2cb9340e5e31ff75f8fa9c (diff)
feat: update points and multiplier labels
Diffstat (limited to 'core')
-rw-r--r--core/src/com/ilotterytea/maxoning/screens/GameScreen.java12
-rw-r--r--core/src/com/ilotterytea/maxoning/screens/game/shop/ShopUI.java22
2 files changed, 25 insertions, 9 deletions
diff --git a/core/src/com/ilotterytea/maxoning/screens/GameScreen.java b/core/src/com/ilotterytea/maxoning/screens/GameScreen.java
index 738fad9..db24b23 100644
--- a/core/src/com/ilotterytea/maxoning/screens/GameScreen.java
+++ b/core/src/com/ilotterytea/maxoning/screens/GameScreen.java
@@ -81,7 +81,11 @@ public class GameScreen implements Screen, InputProcessor {
private ArrayList<Decal> decals;
private DecalPlayer decalPlayer;
+ private final MaxonSavegame savegame;
+
public GameScreen(MaxonGame game, MaxonSavegame sav, int slotId) throws IOException, ClassNotFoundException {
+ this.savegame = sav;
+
this.game = game;
this.slotId = slotId;
this.playTimestamp = System.currentTimeMillis();
@@ -287,6 +291,8 @@ public class GameScreen implements Screen, InputProcessor {
stage.act(delta);
stage.draw();
+
+ shopUI.render();
}
@Override
@@ -537,12 +543,12 @@ public class GameScreen implements Screen, InputProcessor {
this.skin = this.game.assetManager.get("MainSpritesheet.skin", Skin.class);
this.mainAtlas = this.game.assetManager.get("MainSpritesheet.atlas", TextureAtlas.class);
- this.shopUI = new ShopUI(this.stage, this.skin, this.mainAtlas);
+ this.shopUI = new ShopUI(savegame, this.stage, this.skin, this.mainAtlas);
shopUI.createShopTitleUI();
shopUI.createShopControlUI();
- shopUI.createShopListUI(this.player);
- shopUI.createSavegameUI(this.player);
+ shopUI.createShopListUI();
+ shopUI.createSavegameUI();
}
@Override
diff --git a/core/src/com/ilotterytea/maxoning/screens/game/shop/ShopUI.java b/core/src/com/ilotterytea/maxoning/screens/game/shop/ShopUI.java
index 442705c..2f87bad 100644
--- a/core/src/com/ilotterytea/maxoning/screens/game/shop/ShopUI.java
+++ b/core/src/com/ilotterytea/maxoning/screens/game/shop/ShopUI.java
@@ -24,7 +24,12 @@ public class ShopUI {
private ShopMode mode;
private ShopMultiplier multiplier;
- public ShopUI(Stage stage, Skin skin, TextureAtlas atlas) {
+ private final MaxonSavegame savegame;
+ private Label pointsLabel, multiplierLabel;
+
+ public ShopUI(final MaxonSavegame savegame, Stage stage, Skin skin, TextureAtlas atlas) {
+ this.savegame = savegame;
+
this.skin = skin;
this.atlas = atlas;
this.mode = ShopMode.BUY;
@@ -42,7 +47,7 @@ public class ShopUI {
stage.addActor(mainTable);
}
- public void createSavegameUI(final MaxonSavegame player) {
+ public void createSavegameUI() {
Table table = new Table(this.skin);
table.align(Align.center | Align.left);
@@ -52,7 +57,7 @@ public class ShopUI {
Table pointsTable = new Table();
Image pointsImage = new Image(this.atlas.findRegion("points"));
- Label pointsLabel = new Label(String.valueOf(player.points), this.skin);
+ this.pointsLabel = new Label(String.valueOf(savegame.points), this.skin);
pointsTable.add(pointsImage);
pointsTable.add(pointsLabel).padLeft(15f);
@@ -63,7 +68,7 @@ public class ShopUI {
Table multiplierTable = new Table();
Image multiplierImage = new Image(this.atlas.findRegion("multiplier"));
- Label multiplierLabel = new Label(String.format("%s/s", player.multiplier), this.skin);
+ this.multiplierLabel = new Label(String.format("%s/s", savegame.multiplier), this.skin);
multiplierTable.add(multiplierImage);
multiplierTable.add(multiplierLabel).padLeft(15f);
@@ -158,12 +163,12 @@ public class ShopUI {
this.table.add(table).grow().row();
}
- public void createShopListUI(final MaxonSavegame player) {
+ public void createShopListUI() {
Table table = new Table(this.skin);
table.setBackground("shop_list");
for (final MaxonItem item : this.items) {
- int amount = (int) player.inv.stream().filter(c -> c == item.id).count();
+ int amount = (int) savegame.inv.stream().filter(c -> c == item.id).count();
double price = item.price * java.lang.Math.pow(1.15f, amount + this.multiplier.getMultiplier());
item.price = (float) price;
@@ -183,6 +188,11 @@ public class ShopUI {
this.table.add(scrollPaneTable).grow().row();
}
+ public void render() {
+ this.pointsLabel.setText(String.valueOf(savegame.points));
+ this.multiplierLabel.setText(String.format("%s/s", savegame.multiplier));
+ }
+
public void update() {
this.mainTable.clear();
this.mainTable.add(this.table).growY().width(Math.percentFromValue(30f, Gdx.graphics.getWidth()));