diff options
| -rw-r--r-- | assets/sfx/extra/honk.ogg | bin | 0 -> 12888 bytes | |||
| -rw-r--r-- | assets/sprites/merchant/merchant.png | bin | 0 -> 617838 bytes | |||
| -rw-r--r-- | assets/sprites/merchant/merchant_mobile_background.png | bin | 0 -> 9586 bytes | |||
| -rw-r--r-- | core/src/kz/ilotterytea/maxon/screens/game/GameScreen.java | 5 | ||||
| -rw-r--r-- | core/src/kz/ilotterytea/maxon/screens/game/shop/ShopMerchant.java | 58 | ||||
| -rw-r--r-- | core/src/kz/ilotterytea/maxon/screens/game/shop/ShopUI.java | 24 |
6 files changed, 79 insertions, 8 deletions
diff --git a/assets/sfx/extra/honk.ogg b/assets/sfx/extra/honk.ogg Binary files differnew file mode 100644 index 0000000..dea505c --- /dev/null +++ b/assets/sfx/extra/honk.ogg diff --git a/assets/sprites/merchant/merchant.png b/assets/sprites/merchant/merchant.png Binary files differnew file mode 100644 index 0000000..356d22c --- /dev/null +++ b/assets/sprites/merchant/merchant.png diff --git a/assets/sprites/merchant/merchant_mobile_background.png b/assets/sprites/merchant/merchant_mobile_background.png Binary files differnew file mode 100644 index 0000000..efc9210 --- /dev/null +++ b/assets/sprites/merchant/merchant_mobile_background.png diff --git a/core/src/kz/ilotterytea/maxon/screens/game/GameScreen.java b/core/src/kz/ilotterytea/maxon/screens/game/GameScreen.java index dbdcba1..b43cba8 100644 --- a/core/src/kz/ilotterytea/maxon/screens/game/GameScreen.java +++ b/core/src/kz/ilotterytea/maxon/screens/game/GameScreen.java @@ -184,7 +184,7 @@ public class GameScreen implements Screen, InputProcessor { public void resize(int width, int height) { this.stage.getViewport().update(width, height, true); sceneManager.updateViewport(width, height); - this.shopUI.update(); + this.shopUI.resize(stage.getWidth()); } @Override public void pause() {} @@ -304,7 +304,8 @@ public class GameScreen implements Screen, InputProcessor { shopUI.createSavegameUI(); } - shopUI.createShopTitleUI(); + if (OsUtils.isMobile) shopUI.createShopTitleUI(); + shopUI.createShopMerchant(); shopUI.createShopControlUI(); shopUI.createShopListUI(); diff --git a/core/src/kz/ilotterytea/maxon/screens/game/shop/ShopMerchant.java b/core/src/kz/ilotterytea/maxon/screens/game/shop/ShopMerchant.java new file mode 100644 index 0000000..85c2bbe --- /dev/null +++ b/core/src/kz/ilotterytea/maxon/screens/game/shop/ShopMerchant.java @@ -0,0 +1,58 @@ +package kz.ilotterytea.maxon.screens.game.shop; + +import com.badlogic.gdx.audio.Sound; +import com.badlogic.gdx.graphics.Texture; +import com.badlogic.gdx.graphics.g2d.TextureRegion; +import com.badlogic.gdx.scenes.scene2d.InputEvent; +import com.badlogic.gdx.scenes.scene2d.ui.Image; +import com.badlogic.gdx.scenes.scene2d.ui.Stack; +import com.badlogic.gdx.scenes.scene2d.ui.Table; +import com.badlogic.gdx.scenes.scene2d.utils.ClickListener; +import com.badlogic.gdx.utils.Align; +import kz.ilotterytea.maxon.MaxonGame; +import kz.ilotterytea.maxon.anim.SpriteUtils; +import kz.ilotterytea.maxon.ui.AnimatedImage; +import kz.ilotterytea.maxon.utils.OsUtils; + +import java.util.ArrayList; + +public class ShopMerchant extends Stack { + public ShopMerchant() { + super(); + MaxonGame game = MaxonGame.getInstance(); + + // Background + Table backgroundTable = new Table(); + backgroundTable.setFillParent(true); + + Image backgroundImage = new Image(game.assetManager.get("sprites/merchant/merchant_mobile_background.png", Texture.class)); + backgroundTable.add(backgroundImage).grow(); + + super.add(backgroundTable); + + // Merchant + ArrayList<TextureRegion> regions = SpriteUtils.splitToTextureRegions(game.assetManager.get("sprites/merchant/merchant.png"), 150, 100); + AnimatedImage merchantImage = new AnimatedImage(regions, 5); + + Table merchantTable = new Table(); + merchantTable.setFillParent(true); + merchantTable.align(Align.bottom); + + float size = OsUtils.isMobile ? 3f : 1.25f; + + merchantTable.add(merchantImage).size(merchantImage.getWidth() * size, merchantImage.getHeight() * size); + + super.add(merchantTable); + + // Merchant sound + Sound sound = game.assetManager.get("sfx/extra/honk.ogg"); + + merchantImage.addListener(new ClickListener() { + @Override + public void clicked(InputEvent event, float x, float y) { + super.clicked(event, x, y); + sound.play(game.prefs.getInteger("sfx", 10) / 10f); + } + }); + } +} diff --git a/core/src/kz/ilotterytea/maxon/screens/game/shop/ShopUI.java b/core/src/kz/ilotterytea/maxon/screens/game/shop/ShopUI.java index b0b6d77..1213794 100644 --- a/core/src/kz/ilotterytea/maxon/screens/game/shop/ShopUI.java +++ b/core/src/kz/ilotterytea/maxon/screens/game/shop/ShopUI.java @@ -22,6 +22,7 @@ import java.util.ArrayList; public class ShopUI { private final Table table, mainTable; private Table controlTable, shopListTable; + private ShopMerchant merchant; private final Skin skin; private final TextureAtlas atlas; @@ -41,6 +42,8 @@ public class ShopUI { private final String styleName = OsUtils.isMobile ? "defaultMobile" : "default"; + private float stageWidth; + public ShopUI(final Savegame savegame, Stage stage, Skin skin, TextureAtlas atlas) { this.savegame = savegame; MaxonGame game = MaxonGame.getInstance(); @@ -50,6 +53,8 @@ public class ShopUI { this.sellSound = game.assetManager.get("sfx/shop/sell.ogg", Sound.class); this.soundVolume = game.prefs.getInteger("sfx", 10) / 10f; + this.stageWidth = stage.getWidth(); + this.skin = skin; this.atlas = atlas; this.mode = ShopMode.BUY; @@ -66,12 +71,17 @@ public class ShopUI { mainTable.add(this.table).growX(); } else { mainTable.align(Align.center | Align.left); - mainTable.add(this.table).growY().width(Math.percentFromValue(25f, Gdx.graphics.getWidth())); + mainTable.add(this.table).growY().width(Math.percentFromValue(25f, (int) stageWidth)); } stage.addActor(mainTable); } + public void createShopMerchant() { + this.merchant = new ShopMerchant(); + if (!OsUtils.isMobile) this.table.add(merchant).growX().row(); + } + public void createSavegameUI() { Table table = new Table(this.skin); @@ -136,9 +146,11 @@ public class ShopUI { isShopListOpened = !isShopListOpened; if (isShopListOpened) { + table.add(merchant).growX().row(); table.add(controlTable).grow().row(); table.add(shopListTable).grow().row(); } else { + table.removeActor(merchant); table.removeActor(controlTable); table.removeActor(shopListTable); } @@ -368,13 +380,13 @@ public class ShopUI { updatePurchaseItems(); } - public void update() { - if (OsUtils.isMobile) { - return; - } + public void resize(float width) { + if (OsUtils.isMobile) return; + + this.stageWidth = width; this.mainTable.clear(); - this.mainTable.add(this.table).growY().width(Math.percentFromValue(30f, Gdx.graphics.getWidth())); + this.mainTable.add(this.table).growY().width(Math.percentFromValue(30f, (int) stageWidth)); } public boolean isShopListOpened() { |
