diff --git a/animations/c8883e76-ae93-4673-8893-d2ec72c1e199.png b/animations/c8883e76-ae93-4673-8893-d2ec72c1e199.png new file mode 100644 index 0000000..1092de4 Binary files /dev/null and b/animations/c8883e76-ae93-4673-8893-d2ec72c1e199.png differ diff --git a/data.sql b/data.sql index fb1c2ac..d0e65dc 100644 --- a/data.sql +++ b/data.sql @@ -101,14 +101,16 @@ INSERT INTO "PUBLIC"."ENEMY_DROP" VALUES (9, 'skeleton_archer', 'ranged:wooden_bow', 0.3, '1'), (10, 'skeleton_archer', 'ammo:wooden_arrow', 0.7, '1d4+3'), (11, 'deku', 'junk:eye', 0.7, '1d2'); -CREATE MEMORY TABLE "PUBLIC"."START_GAME"( - "ID" SMALLINT NOT NULL, - "START_POINT" VARCHAR NOT NULL -); -ALTER TABLE "PUBLIC"."START_GAME" ADD CONSTRAINT "PUBLIC"."CONSTRAINT_C0" PRIMARY KEY("ID"); --- 1 +/- SELECT COUNT(*) FROM PUBLIC.START_GAME; -INSERT INTO "PUBLIC"."START_GAME" VALUES -(1, 'Forrest,Main,1,12'); +CREATE MEMORY TABLE "PUBLIC"."CONFIG"( + "KEY" VARCHAR NOT NULL, + "VALUE" VARCHAR +); +ALTER TABLE "PUBLIC"."CONFIG" ADD CONSTRAINT "PUBLIC"."CONSTRAINT_7" PRIMARY KEY("KEY"); +-- 3 +/- SELECT COUNT(*) FROM PUBLIC.CONFIG; +INSERT INTO "PUBLIC"."CONFIG" VALUES +('start_game', 'Hero Home,Main,Start'), +('screen', '1000x800'), +('camera_scale', '2'); CREATE MEMORY TABLE "PUBLIC"."LEVELS"( "LEVEL" INT DEFAULT NEXT VALUE FOR "PUBLIC"."SYSTEM_SEQUENCE_704587BB_DC0E_44AB_A7F0_3DE0CA44FE3F" NOT NULL NULL_TO_DEFAULT SEQUENCE "PUBLIC"."SYSTEM_SEQUENCE_704587BB_DC0E_44AB_A7F0_3DE0CA44FE3F", "MAX_HP" VARCHAR NOT NULL @@ -132,9 +134,10 @@ CREATE MEMORY TABLE "PUBLIC"."THROWING_WEAPON"( "ICON" VARCHAR NOT NULL ); ALTER TABLE "PUBLIC"."THROWING_WEAPON" ADD CONSTRAINT "PUBLIC"."CONSTRAINT_40" PRIMARY KEY("ID"); --- 1 +/- SELECT COUNT(*) FROM PUBLIC.THROWING_WEAPON; +-- 2 +/- SELECT COUNT(*) FROM PUBLIC.THROWING_WEAPON; INSERT INTO "PUBLIC"."THROWING_WEAPON" VALUES -('deku_arrow', 'Deku''s arrow', 500, '2d4', 'Arrow', 'Arrow', '5d4', 'Punch', 'Arrow punch', 'Poof', 'Arrow punch', 'Generic,8,10'); +('deku_arrow', 'Deku''s arrow', 500, '2d4', 'Arrow', 'Arrow', '5d4', 'Punch', 'Arrow punch', 'Poof', 'Arrow punch', 'Generic,8,10'), +('shuriken', 'Shuriken', 100, '3d6', 'Shuriken', 'Arrow', '5d4', 'Punch', 'Arrow punch', 'Poof', 'Arrow punch', 'Generic,9,2'); CREATE MEMORY TABLE "PUBLIC"."ENEMY"( "ID" VARCHAR NOT NULL, "NAME" VARCHAR NOT NULL, diff --git a/maps/8fbb151f-682a-4357-ba92-157e4097898f.dat b/maps/8fbb151f-682a-4357-ba92-157e4097898f.dat index 29511e1..759d592 100644 --- a/maps/8fbb151f-682a-4357-ba92-157e4097898f.dat +++ b/maps/8fbb151f-682a-4357-ba92-157e4097898f.dat @@ -7,8 +7,19 @@ $04ac5ad8-4100-4016-97b3-a51a728ca49d Water> $fc294b9e-105a-4120-8caa-393d78fdf414!?(2G Objects belowF -$413e09cf-ba41-4fe8-ac47-9697b5ad0245<=<=PPPPKSTST[PPPPPP9lm;|}IstSTQRjkstz{QR9STIZWXYiPPPPyst]I]YPPNN``I``<=`WXQRYIJQRjk`]z{ST`STEFQRSTQRQRUVopIWXlmGH|}KUVQRABWXY[STQRIWXQRST^NNNQRABGHSTSTQRstWXJiWXWXy:WXEFQRQRUVABstQRGHY9STQRWXPPNNNNNNAB:WXQRlmQR|}2> -Main">2D +$413e09cf-ba41-4fe8-ac47-9697b5ad0245<=<=PPPPKSTST[PPPPPP9lm;|}IstSTQRjkstz{QR9STIZWXYiPPPPyst]I]YPPNN``I``<=`WXQRYIJQRjk`]z{ST`STEFQRSTQRQRUVopIWXlmGH|}KUVQRABWXY[STQRIWXQRST^NNNQRABGHSTSTQRstWXJiWXWXy:WXEFQRQRUVABstQRGHY9STQRWXPPNNNNNNAB:WXQRlmQR|}2B +Main"B /* + * Following final parameters are available to use: + * x: int - the x coordinate of tile the object has been created on + * y: int - the y coordinate of tile the object has been created on + * layer: ObjectLayer - current object layer + * map: GameMap - current map + * handler: ForrestHandler - current map handler + * runner: DemoRunner - the game runner of the project + * context: Context - the game context + */ +handler.warp(here, A.maps.hero_house.main.forrest);" +house 2D Objects aboveD $413e09cf-ba41-4fe8-ac47-9697b5ad02453434CDCD3434CDCD34cd34CD34stcdCDCD12cdAB3434cdcdCDCD78ststGH12abABqrcdcdstcdst78abGHcdqrabcdstqrstcd34st34CD56cd34CD12abcd56EF78stCDABqrstEFGHcd56cdstcdabcd34EFstqr12stcdCDcd78ab34ABststGHcdcdqrCDababqrabqr34qr341278cd78cdCDCDABcdGHstGHst78cdst56cdGHstab56EFstqrEF12cdcdcdAB34st12st56cdst78CDABcdEFstGH78abstUV12cd12GHqrcdABstABst2@ Border forrest@ diff --git a/maps/b602601a-e9b0-44bf-bc0d-5f31c9964ba1.dat b/maps/b602601a-e9b0-44bf-bc0d-5f31c9964ba1.dat index 0cf89b7..b452410 100644 Binary files a/maps/b602601a-e9b0-44bf-bc0d-5f31c9964ba1.dat and b/maps/b602601a-e9b0-44bf-bc0d-5f31c9964ba1.dat differ diff --git a/maps/d1b85d85-c52a-46f5-b81e-444847f8ddae.dat b/maps/d1b85d85-c52a-46f5-b81e-444847f8ddae.dat index 15e3756..ef3ecfc 100644 Binary files a/maps/d1b85d85-c52a-46f5-b81e-444847f8ddae.dat and b/maps/d1b85d85-c52a-46f5-b81e-444847f8ddae.dat differ diff --git a/project.bep b/project.bep index 08c4ba2..7398f42 100644 Binary files a/project.bep and b/project.bep differ diff --git a/src/main/java/com/bartlomiejpluta/demo/entity/Chest.java b/src/main/java/com/bartlomiejpluta/demo/entity/Chest.java index ca98056..0f88794 100644 --- a/src/main/java/com/bartlomiejpluta/demo/entity/Chest.java +++ b/src/main/java/com/bartlomiejpluta/demo/entity/Chest.java @@ -4,6 +4,9 @@ import com.bartlomiejpluta.demo.world.item.Item; import lombok.Getter; import lombok.NonNull; +import java.util.Arrays; +import java.util.Collection; +import java.util.Random; import java.util.concurrent.CompletableFuture; public class Chest extends MapObject { @@ -29,4 +32,30 @@ public class Chest extends MapObject { throw new IllegalStateException("Chest is full!"); } + + public Chest addItem(Item item, int slot) { + if(slot >= content.length) { + throw new IllegalStateException("The [" + slot + "] slot exceeds the chest size (" + content.length + ")!"); + } + + if (content[slot] != null) { + throw new IllegalStateException("The [" + slot + "] slot is already filled!"); + } + + content[slot] = item; + + return this; + } + + public Chest shuffle() { + var random = new Random(); + for(int i = content.length - 1; i > 0; --i) { + var index = random.nextInt(i + 1); + var tmp = content[index]; + content[index] = content[i]; + content[i] = tmp; + } + + return this; + } } diff --git a/src/main/java/com/bartlomiejpluta/demo/entity/Door.java b/src/main/java/com/bartlomiejpluta/demo/entity/Door.java index 554aebd..a680d47 100644 --- a/src/main/java/com/bartlomiejpluta/demo/entity/Door.java +++ b/src/main/java/com/bartlomiejpluta/demo/entity/Door.java @@ -1,6 +1,7 @@ package com.bartlomiejpluta.demo.entity; import A.maps; +import com.bartlomiejpluta.base.api.map.layer.object.MapPin; import com.bartlomiejpluta.demo.runner.DemoRunner; import lombok.NonNull; @@ -13,12 +14,23 @@ public class Door extends MapObject { private final int layerId; private final Player player; + public Door(@NonNull MapPin label, @NonNull String id) { + super(id); + this.mapUid = label.getMap(); + this.layerId = label.getLayer(); + this.targetX = label.getX(); + this.targetY = label.getY(); + player = DemoRunner.instance().getPlayer(); + setPositionOffset(0, 16); + } + public Door(@NonNull String mapName, @NonNull String layerName, int targetX, int targetY, @NonNull String id) { super(id); - this.mapUid = maps.get(mapName).uid; + var map = maps.byName(mapName); + this.mapUid = map.$; this.targetX = targetX; this.targetY = targetY; - this.layerId = maps.getLayer(mapName, layerName); + this.layerId = map.layer(layerName).$; player = DemoRunner.instance().getPlayer(); setPositionOffset(0, 16); } diff --git a/src/main/java/com/bartlomiejpluta/demo/entity/Enemy.java b/src/main/java/com/bartlomiejpluta/demo/entity/Enemy.java index 74703bb..2888660 100644 --- a/src/main/java/com/bartlomiejpluta/demo/entity/Enemy.java +++ b/src/main/java/com/bartlomiejpluta/demo/entity/Enemy.java @@ -49,7 +49,7 @@ public class Enemy extends Creature implements NPC { } public Enemy(@NonNull DB.model.EnemyModel template) { - super(ContextHolder.INSTANCE.getContext().createCharacter(A.charsets.get(template.getCharset()).uid)); + super(ContextHolder.INSTANCE.getContext().createCharacter(A.charsets.byName(template.getCharset()).$)); this.template = template; name = template.getName(); maxHp = DiceRoller.roll(template.getHp()); @@ -78,7 +78,7 @@ public class Enemy extends Creature implements NPC { this.throwingWeapon = new ThrowingWeapon(split[0], DiceRoller.roll(split[1])); } - this.dieAnimation = new SimpleAnimationRunner(A.animations.get(template.getDieAnimation()).uid); + this.dieAnimation = new SimpleAnimationRunner(A.animations.byName(template.getDieAnimation()).$); } @Override @@ -94,7 +94,7 @@ public class Enemy extends Creature implements NPC { @Override public void die() { super.die(); - changeCharacterSet(A.charsets.get(template.getDeadCharset()).uid); + changeCharacterSet(A.charsets.byName(template.getDeadCharset()).$); setScale(0.5f); setBlocking(false); setZIndex(-1); @@ -102,7 +102,7 @@ public class Enemy extends Creature implements NPC { ai = NoopAI.INSTANCE; dieAnimation.run(context, getLayer(), this); - context.playSound(A.sounds.get(template.getDieSound()).uid); + context.playSound(A.sounds.byName(template.getDieSound()).$); context.fireEvent(new EnemyDiedEvent(this)); LootGenerator.generate(template.getId(), loot); diff --git a/src/main/java/com/bartlomiejpluta/demo/entity/MapObject.java b/src/main/java/com/bartlomiejpluta/demo/entity/MapObject.java index 3f51bd3..c541a5e 100644 --- a/src/main/java/com/bartlomiejpluta/demo/entity/MapObject.java +++ b/src/main/java/com/bartlomiejpluta/demo/entity/MapObject.java @@ -22,11 +22,11 @@ public abstract class MapObject extends com.bartlomiejpluta.base.util.world.MapO } public MapObject(@NonNull DB.model.ObjectModel template) { - super(ContextHolder.INSTANCE.getContext().createCharacter(A.charsets.get(template.getCharset()).uid), template.getFrame()); + super(ContextHolder.INSTANCE.getContext().createCharacter(A.charsets.byName(template.getCharset()).$), template.getFrame()); this.context = ContextHolder.INSTANCE.getContext(); this.runner = DemoRunner.instance(); this.name = template.getName(); - this.interactSound = A.sounds.get(template.getInteractSound()).uid; + this.interactSound = A.sounds.byName(template.getInteractSound()).$; } @Override diff --git a/src/main/java/com/bartlomiejpluta/demo/entity/Player.java b/src/main/java/com/bartlomiejpluta/demo/entity/Player.java index f37557d..a3381fb 100644 --- a/src/main/java/com/bartlomiejpluta/demo/entity/Player.java +++ b/src/main/java/com/bartlomiejpluta/demo/entity/Player.java @@ -28,7 +28,7 @@ public class Player extends Creature { this.hp = this.maxHp; alive = true; - changeCharacterSet(A.charsets.luna.uid); + changeCharacterSet(A.charsets.luna.$); setScale(1f); setSpeed(4f); setAnimationSpeed(1f); diff --git a/src/main/java/com/bartlomiejpluta/demo/gui/EquipmentWindow.java b/src/main/java/com/bartlomiejpluta/demo/gui/EquipmentWindow.java index 9dfcf69..10b9edb 100644 --- a/src/main/java/com/bartlomiejpluta/demo/gui/EquipmentWindow.java +++ b/src/main/java/com/bartlomiejpluta/demo/gui/EquipmentWindow.java @@ -58,7 +58,7 @@ public class EquipmentWindow extends DecoratedWindow { public EquipmentWindow(Context context, GUI gui, Map refs) { super(context, gui, refs); this.player = DemoRunner.instance().getPlayer(); - this.popupMenuWindow = gui.inflateWindow(A.widgets.eq_item_menu.uid); + this.popupMenuWindow = gui.inflateWindow(A.widgets.eq_item_menu.$); this.popupMenu = popupMenuWindow.reference("menu", VOptionChoice.class); this.useBtn = popupMenuWindow.reference("use", Button.class); this.dropBtn = popupMenuWindow.reference("drop", Button.class); diff --git a/src/main/java/com/bartlomiejpluta/demo/gui/ItemIconView.java b/src/main/java/com/bartlomiejpluta/demo/gui/ItemIconView.java index 007cada..be9d4c8 100644 --- a/src/main/java/com/bartlomiejpluta/demo/gui/ItemIconView.java +++ b/src/main/java/com/bartlomiejpluta/demo/gui/ItemIconView.java @@ -81,7 +81,7 @@ public class ItemIconView extends IconView { @Attribute(value = "placeholder", separator = ",") public void setPlaceholderIcon(String icon, int row, int column) { this.placeholderIconPaint = gui.createPaint(); - this.placeholderIconSet = gui.getIconSet(A.iconsets.get(icon).uid); + this.placeholderIconSet = gui.getIconSet(A.iconsets.byName(icon).$); this.placeholderIconSetRow = row; this.placeholderIconSetColumn = column; } @@ -121,7 +121,7 @@ public class ItemIconView extends IconView { if (item != null && item instanceof ItemStack stack) { gui.beginPath(); - gui.setFontFace(fonts.roboto_regular.uid); + gui.setFontFace(fonts.roboto_regular.$); gui.setFontSize(17); gui.putText(x + 15, y + 5, String.valueOf(stack.getCount())); gui.setFillColor(textColor); diff --git a/src/main/java/com/bartlomiejpluta/demo/map/BaseMapHandler.java b/src/main/java/com/bartlomiejpluta/demo/map/BaseMapHandler.java index 067e46e..793d8f1 100644 --- a/src/main/java/com/bartlomiejpluta/demo/map/BaseMapHandler.java +++ b/src/main/java/com/bartlomiejpluta/demo/map/BaseMapHandler.java @@ -1,13 +1,16 @@ package com.bartlomiejpluta.demo.map; +import A.maps; import com.bartlomiejpluta.base.api.camera.Camera; import com.bartlomiejpluta.base.api.context.Context; +import com.bartlomiejpluta.base.api.entity.Entity; import com.bartlomiejpluta.base.api.gui.Window; import com.bartlomiejpluta.base.api.gui.WindowPosition; import com.bartlomiejpluta.base.api.icon.Icon; import com.bartlomiejpluta.base.api.input.Input; import com.bartlomiejpluta.base.api.input.Key; import com.bartlomiejpluta.base.api.map.handler.MapHandler; +import com.bartlomiejpluta.base.api.map.layer.object.MapPin; import com.bartlomiejpluta.base.api.map.layer.object.ObjectLayer; import com.bartlomiejpluta.base.api.map.model.GameMap; import com.bartlomiejpluta.base.api.move.Direction; @@ -87,63 +90,42 @@ public abstract class BaseMapHandler implements MapHandler { return guiManager.showDialog(message, WindowPosition.BOTTOM); } - public Enemy enemy(@NonNull String id) { - return new Enemy(id); + protected T addEntity(T entity, MapPin tile) { + entity.setCoordinates(tile.getX(), tile.getY()); + map.getObjectLayer(tile.getLayer()).addEntity(entity); + return entity; } - public Enemy enemy(ObjectLayer layer, int x, int y, @NonNull String id) { - var enemy = new Enemy(id); - enemy.setCoordinates(x, y); - layer.addEntity(enemy); - return enemy; + public Enemy enemy(@NonNull MapPin tile, @NonNull String id) { + return addEntity(new Enemy(id), tile); } - public Chest chest(ObjectLayer layer, int x, int y, @NonNull String id) { - var chest = new Chest(id); - chest.setCoordinates(x, y); - layer.addEntity(chest); - return chest; + public Chest chest(@NonNull MapPin tile, @NonNull String id) { + return addEntity(new Chest(id), tile); } - public Door door(ObjectLayer layer, int x, int y, @NonNull String mapName, @NonNull String layerName, int targetX, int targetY, @NonNull String id) { - var door = new Door(mapName, layerName, targetX, targetY, id); - door.setCoordinates(x, y); - layer.addEntity(door); - return door; + public Door door(@NonNull MapPin tile, @NonNull MapPin target, @NonNull String id) { + return addEntity(new Door(target, id), tile); } - public CharacterSpawner spawner(ObjectLayer layer, int x, int y) { - var spawner = new CharacterSpawner().trackEntities(EnemyDiedEvent.TYPE); - spawner.setCoordinates(x, y); - layer.addEntity(spawner); - return spawner; + public CharacterSpawner spawner(@NonNull MapPin tile) { + return addEntity(new CharacterSpawner().trackEntities(EnemyDiedEvent.TYPE), tile); } - public Medicament medicament(@NonNull String id, int count) { - return new Medicament(id, count); + public Medicament medicament(@NonNull MapPin tile, @NonNull String id, int count) { + return addEntity(new Medicament(id, count), tile); } - public Medicament medicament(ObjectLayer layer, int x, int y, @NonNull String id, int count) { - var medicament = new Medicament(id, count); - medicament.setCoordinates(x, y); - layer.addEntity(medicament); - return medicament; - } - - public Icon icon(ObjectLayer layer, int x, int y, String iconSetUid, int row, int column) { + public Icon icon(@NonNull MapPin tile, String iconSetUid, int row, int column) { var icon = context.createIcon(iconSetUid, row, column); icon.setScale(1f); icon.setZIndex(-1); - icon.setCoordinates(x, y); - layer.addEntity(icon); - return icon; + return addEntity(icon, tile); } - public Warp warp(ObjectLayer layer, int x, int y, String targetMap, String targetLayer, int targetX, int targetY) { - var warp = new Warp(A.maps.get(targetMap).uid, A.maps.getLayer(targetMap, targetLayer), targetX, targetY); + public Warp warp(@NonNull MapPin tile, MapPin target) { + var warp = new Warp(target); warp.setEntity(player); - warp.setCoordinates(x, y); - layer.addEntity(warp); - return warp; + return addEntity(warp, tile); } } \ No newline at end of file diff --git a/src/main/java/com/bartlomiejpluta/demo/menu/GuiManager.java b/src/main/java/com/bartlomiejpluta/demo/menu/GuiManager.java index f0603c2..b398fdb 100644 --- a/src/main/java/com/bartlomiejpluta/demo/menu/GuiManager.java +++ b/src/main/java/com/bartlomiejpluta/demo/menu/GuiManager.java @@ -36,20 +36,20 @@ public class GuiManager { this.gui.setRoot(this.manager); - this.startMenu = gui.inflateWindow(A.widgets.start_menu.uid, StartMenuWindow.class); + this.startMenu = gui.inflateWindow(A.widgets.start_menu.$, StartMenuWindow.class); this.startMenu.reference("new_game", Button.class).setAction(runner::newGame); this.startMenu.reference("exit", Button.class).setAction(runner::exit); - this.equipment = gui.inflateWindow(A.widgets.equipment.uid, EquipmentWindow.class); + this.equipment = gui.inflateWindow(A.widgets.equipment.$, EquipmentWindow.class); - this.gameMenu = gui.inflateWindow(A.widgets.game_menu.uid, GameMenuWindow.class); + this.gameMenu = gui.inflateWindow(A.widgets.game_menu.$, GameMenuWindow.class); this.gameMenu.reference("resume_game", Button.class).setAction(this::resumeGame); this.gameMenu.reference("equipment", Button.class).setAction(() -> manager.open(equipment)); this.gameMenu.reference("start_menu", Button.class).setAction(runner::returnToStartMenu); this.gameMenu.reference("exit", Button.class).setAction(runner::exit); - this.dialog = gui.inflateWindow(A.widgets.dialog.uid, DialogWindow.class); - this.loot = gui.inflateWindow(widgets.loot_menu.uid, LootWindow.class); + this.dialog = gui.inflateWindow(A.widgets.dialog.$, DialogWindow.class); + this.loot = gui.inflateWindow(widgets.loot_menu.$, LootWindow.class); } private void handleGameMenuKeyEvent(KeyEvent event) { diff --git a/src/main/java/com/bartlomiejpluta/demo/runner/DemoRunner.java b/src/main/java/com/bartlomiejpluta/demo/runner/DemoRunner.java index dcf895e..981e2c3 100644 --- a/src/main/java/com/bartlomiejpluta/demo/runner/DemoRunner.java +++ b/src/main/java/com/bartlomiejpluta/demo/runner/DemoRunner.java @@ -1,5 +1,7 @@ package com.bartlomiejpluta.demo.runner; +import A.maps; +import DB.ConfigDAO; import DB.dao; import com.bartlomiejpluta.base.api.context.Context; import com.bartlomiejpluta.base.api.gui.GUI; @@ -34,12 +36,15 @@ public class DemoRunner implements GameRunner { private void configureScreen() { var resolution = screen.getCurrentResolution(); - screen.setSize(800, 600); - screen.setPosition((resolution.x() - 1800) / 2, (resolution.y() - 1000) / 2); + var config = dao.config.find("screen").getValue().split("x"); + var width = Integer.parseInt(config[0]); + var height = Integer.parseInt(config[1]); + screen.setSize(width, height); + screen.setPosition((resolution.x() - width) / 2, (resolution.y() - height) / 2); } private void configureCamera() { - context.getCamera().setScale(2.5f); + context.getCamera().setScale(Float.parseFloat(dao.config.find("camera_scale").getValue())); } private void initMenu() { @@ -49,12 +54,12 @@ public class DemoRunner implements GameRunner { private void initHUD() { hud = context.newGUI(); hud.hide(); - var hudComponent = hud.inflateComponent(A.widgets.hud.uid); + var hudComponent = hud.inflateComponent(A.widgets.hud.$); hud.setRoot(hudComponent); } private void initPlayer() { - this.player = new Player(context.createCharacter(A.charsets.luna.uid)); + this.player = new Player(context.createCharacter(A.charsets.luna.$)); } public void newGame() { @@ -62,13 +67,19 @@ public class DemoRunner implements GameRunner { guiManager.closeAll(); guiManager.enableGameMenu(); player.reset(); - var start = dao.start_game.find((short) 1); - var startPoint = start.getStartPoint().split(","); - context.openMap(A.maps.get(startPoint[0]).uid); - context.getMap().getObjectLayer(A.maps.getLayer(startPoint[0], startPoint[1])).addEntity(this.player); - player.setCoordinates(parseInt(startPoint[2]), parseInt(startPoint[3])); + var start = dao.config.find("start_game").getValue().split(","); + + var map = A.maps.byName(start[0]); + var layer = map.layer(start[1]); + var label = layer.label(start[2]); + + context.openMap(map.$); + context.getMap().getObjectLayer(layer.$).addEntity(this.player); + player.setCoordinates(label.getX(), label.getY()); context.resume(); hud.show(); + + var x = A.maps.hero_home.main.entry; } public void returnToStartMenu() { diff --git a/src/main/java/com/bartlomiejpluta/demo/util/IconUtil.java b/src/main/java/com/bartlomiejpluta/demo/util/IconUtil.java index c8db851..266dd53 100644 --- a/src/main/java/com/bartlomiejpluta/demo/util/IconUtil.java +++ b/src/main/java/com/bartlomiejpluta/demo/util/IconUtil.java @@ -6,6 +6,6 @@ import com.bartlomiejpluta.base.api.icon.Icon; public class IconUtil { public static Icon parseIcon(String iconDefinition) { var parts = iconDefinition.split(","); - return ContextHolder.INSTANCE.getContext().createIcon(A.iconsets.get(parts[0]).uid, Integer.parseInt(parts[1]), Integer.parseInt(parts[2])); + return ContextHolder.INSTANCE.getContext().createIcon(A.iconsets.byName(parts[0]).$, Integer.parseInt(parts[1]), Integer.parseInt(parts[2])); } } diff --git a/src/main/java/com/bartlomiejpluta/demo/world/weapon/MeleeWeapon.java b/src/main/java/com/bartlomiejpluta/demo/world/weapon/MeleeWeapon.java index 0b5c660..25102d6 100644 --- a/src/main/java/com/bartlomiejpluta/demo/world/weapon/MeleeWeapon.java +++ b/src/main/java/com/bartlomiejpluta/demo/world/weapon/MeleeWeapon.java @@ -37,8 +37,8 @@ public class MeleeWeapon extends BaseItem implements Weapon { this.name = template.getName(); this.dmgRoller = DiceRoller.of(template.getDamage()); this.cooldown = template.getCooldown(); - this.animation = new RandomAnimationsRunner(2).nRange(0, 2f).nScale(0.2f, 0.15f).uAnimationSpeed(0.5f, 1f).nRotation(0, 10).offset(0, -10).uDelay(250, 500).with(A.animations.get(template.getAnimation()).uid); - this.sound = A.sounds.get(template.getSound()).uid; + this.animation = new RandomAnimationsRunner(2).nRange(0, 2f).nScale(0.2f, 0.15f).uAnimationSpeed(0.5f, 1f).nRotation(0, 10).offset(0, -10).uDelay(250, 500).with(A.animations.byName(template.getAnimation()).$); + this.sound = A.sounds.byName(template.getSound()).$; } @Override diff --git a/src/main/java/com/bartlomiejpluta/demo/world/weapon/RangedWeapon.java b/src/main/java/com/bartlomiejpluta/demo/world/weapon/RangedWeapon.java index edc62d5..f91662a 100644 --- a/src/main/java/com/bartlomiejpluta/demo/world/weapon/RangedWeapon.java +++ b/src/main/java/com/bartlomiejpluta/demo/world/weapon/RangedWeapon.java @@ -52,12 +52,12 @@ public class RangedWeapon extends BaseItem implements Weapon { this.dmgRoller = DiceRoller.of(template.getDamage()); this.rangeRoller = DiceRoller.of(template.getRange()); this.cooldown = template.getCooldown(); - this.animation = new BulletAnimationRunner(A.animations.get(template.getAnimation()).uid).infinite().offset(0, -15).onHit(this::onHit).onMiss(this::onMiss).speed(7f).animationSpeed(4f).scale(0.6f); - this.sound = A.sounds.get(template.getSound()).uid; - this.punchAnimation = new SimpleAnimationRunner(A.animations.get(template.getPunchAnimation()).uid); - this.punchSound = A.sounds.get(template.getPunchSound()).uid; - this.missAnimation = new SimpleAnimationRunner(A.animations.get(template.getMissAnimation()).uid).scale(0.4f); - this.missSound = A.sounds.get(template.getMissSound()).uid; + this.animation = new BulletAnimationRunner(A.animations.byName(template.getAnimation()).$).infinite().offset(0, -15).onHit(this::onHit).onMiss(this::onMiss).speed(7f).animationSpeed(4f).scale(0.6f); + this.sound = A.sounds.byName(template.getSound()).$; + this.punchAnimation = new SimpleAnimationRunner(A.animations.byName(template.getPunchAnimation()).$); + this.punchSound = A.sounds.byName(template.getPunchSound()).$; + this.missAnimation = new SimpleAnimationRunner(A.animations.byName(template.getMissAnimation()).$).scale(0.4f); + this.missSound = A.sounds.byName(template.getMissSound()).$; } private void onHit(Movable attacker, Entity target) { diff --git a/src/main/java/com/bartlomiejpluta/demo/world/weapon/ThrowingWeapon.java b/src/main/java/com/bartlomiejpluta/demo/world/weapon/ThrowingWeapon.java index 4019ade..cd437cd 100644 --- a/src/main/java/com/bartlomiejpluta/demo/world/weapon/ThrowingWeapon.java +++ b/src/main/java/com/bartlomiejpluta/demo/world/weapon/ThrowingWeapon.java @@ -57,12 +57,12 @@ public class ThrowingWeapon extends StackableItem implements Weapon { this.dmgRoller = DiceRoller.of(template.getDamage()); this.rangeRoller = DiceRoller.of(template.getRange()); this.cooldown = template.getCooldown(); - this.animation = new BulletAnimationRunner(A.animations.get(template.getAnimation()).uid).infinite().offset(0, -15).onHit(this::onHit).onMiss(this::onMiss).speed(7f).animationSpeed(4f).scale(0.6f); - this.sound = A.sounds.get(template.getSound()).uid; - this.punchAnimation = new SimpleAnimationRunner(A.animations.get(template.getPunchAnimation()).uid); - this.punchSound = A.sounds.get(template.getPunchSound()).uid; - this.missAnimation = new SimpleAnimationRunner(A.animations.get(template.getMissAnimation()).uid).scale(0.4f); - this.missSound = A.sounds.get(template.getMissSound()).uid; + this.animation = new BulletAnimationRunner(A.animations.byName(template.getAnimation()).$).infinite().offset(0, -15).onHit(this::onHit).onMiss(this::onMiss).speed(7f).animationSpeed(4f).scale(0.6f); + this.sound = A.sounds.byName(template.getSound()).$; + this.punchAnimation = new SimpleAnimationRunner(A.animations.byName(template.getPunchAnimation()).$); + this.punchSound = A.sounds.byName(template.getPunchSound()).$; + this.missAnimation = new SimpleAnimationRunner(A.animations.byName(template.getMissAnimation()).$).scale(0.4f); + this.missSound = A.sounds.byName(template.getMissSound()).$; } private void onHit(Movable attacker, Entity target) { diff --git a/widgets/00bd0625-b3b8-4abf-97b7-91f42bce28ec.xml b/widgets/00bd0625-b3b8-4abf-97b7-91f42bce28ec.xml index f7e5464..e4623ca 100644 --- a/widgets/00bd0625-b3b8-4abf-97b7-91f42bce28ec.xml +++ b/widgets/00bd0625-b3b8-4abf-97b7-91f42bce28ec.xml @@ -23,7 +23,7 @@ diff --git a/widgets/1c2b2ba2-66bf-40ee-97bf-6e5065b7b420.xml b/widgets/1c2b2ba2-66bf-40ee-97bf-6e5065b7b420.xml index 0da7877..39e8ae4 100644 --- a/widgets/1c2b2ba2-66bf-40ee-97bf-6e5065b7b420.xml +++ b/widgets/1c2b2ba2-66bf-40ee-97bf-6e5065b7b420.xml @@ -7,7 +7,7 @@ margin="20f" width="900f" height="auto"> - \ No newline at end of file diff --git a/widgets/53ca3e54-0f8d-44fa-8281-acd9c5bba743.xml b/widgets/53ca3e54-0f8d-44fa-8281-acd9c5bba743.xml index d01c39c..efa9ac2 100644 --- a/widgets/53ca3e54-0f8d-44fa-8281-acd9c5bba743.xml +++ b/widgets/53ca3e54-0f8d-44fa-8281-acd9c5bba743.xml @@ -10,7 +10,7 @@