diff --git a/res/.tmp/cache.dat b/res/.tmp/cache.dat new file mode 100644 index 0000000..89cf132 --- /dev/null +++ b/res/.tmp/cache.dat @@ -0,0 +1 @@ +by25:minecraftia_regular_6.fntaoy3:veri1y4:timei1707771858y4:hashy40:985b62563507866445c3c81a04f7e6645d90dad5y3:outy33:.tmp%2Fminecraftia_regular_6.bfntghy40:font%2Fpixel_unicode%2FPixel-UniCode.fntaoR1i1R2i1707784556R3y40:bc4073da70385f93ae70e391a786e346daac2b1fR5y48:.tmp%2Ffont%2Fpixel_unicode%2FPixel-UniCode.bfntghy32:font%2Fminecraftia_regular_6.fntaoR1i1R2i1707771858R3R4R5y40:.tmp%2Ffont%2Fminecraftia_regular_6.bfntghh \ No newline at end of file diff --git a/res/.tmp/font/minecraftia_regular_6.bfnt b/res/.tmp/font/minecraftia_regular_6.bfnt new file mode 100644 index 0000000..f459af7 Binary files /dev/null and b/res/.tmp/font/minecraftia_regular_6.bfnt differ diff --git a/res/.tmp/font/pixel_unicode/Pixel-UniCode.bfnt b/res/.tmp/font/pixel_unicode/Pixel-UniCode.bfnt new file mode 100644 index 0000000..df2898e Binary files /dev/null and b/res/.tmp/font/pixel_unicode/Pixel-UniCode.bfnt differ diff --git a/res/.tmp/minecraftia_regular_6.bfnt b/res/.tmp/minecraftia_regular_6.bfnt new file mode 100644 index 0000000..f459af7 Binary files /dev/null and b/res/.tmp/minecraftia_regular_6.bfnt differ diff --git a/res/rewild.tiled-project b/res/rewild.tiled-project new file mode 100644 index 0000000..d0eb592 --- /dev/null +++ b/res/rewild.tiled-project @@ -0,0 +1,14 @@ +{ + "automappingRulesFile": "", + "commands": [ + ], + "compatibilityVersion": 1100, + "extensionsPath": "extensions", + "folders": [ + "." + ], + "properties": [ + ], + "propertyTypes": [ + ] +} diff --git a/res/rewild.tiled-session b/res/rewild.tiled-session new file mode 100644 index 0000000..56530ce --- /dev/null +++ b/res/rewild.tiled-session @@ -0,0 +1,45 @@ +{ + "activeFile": "map.tmx", + "expandedProjectPaths": [ + ], + "fileStates": { + "/home/f/Projects/Rewild/references/ld28/res/map.tmx": { + "scale": 1.5684895833333334, + "selectedLayer": 6, + "viewCenter": { + "x": 191.90436659472022, + "y": 144.08766395483977 + } + }, + "/home/f/Projects/Rewild/references/ld28/res/map.tmx#tiles": { + "scaleInDock": 1 + }, + "/home/f/Projects/Rewild/references/ld28/res/spaaace.tsx": { + "scaleInEditor": 1 + }, + "map.tmx": { + "expandedObjectLayers": [ + 3 + ], + "scale": 0.75, + "selectedLayer": 1, + "viewCenter": { + "x": 479.3333333333333, + "y": 320 + } + }, + "map.tmx#tiles": { + "scaleInDock": 1 + } + }, + "openFiles": [ + "map.tmx", + "/home/f/Projects/Rewild/references/ld28/res/map.tmx" + ], + "project": "rewild.tiled-project", + "recentFiles": [ + "/home/f/Projects/Rewild/references/ld28/res/map.tmx", + "map.tmx", + "/home/f/Projects/Rewild/references/ld28/res/spaaace.tsx" + ] +} diff --git a/res/text/intro.yarn b/res/text/intro.yarn index 817712b..7fa78bb 100644 --- a/res/text/intro.yarn +++ b/res/text/intro.yarn @@ -11,5 +11,13 @@ You: Let's have another look around... === title: Room:quarters --- -It's the crew quarters +You: It's the crew quarters +=== +title: Room:hangar +--- +You: The **hangar** seems eerily deserted +=== +title: Room not open +--- +You: Hmm, that part of the ship is still inaccessible. I wonder how to get in? === diff --git a/src/Game.hx b/src/Game.hx index f9ab794..5d72652 100644 --- a/src/Game.hx +++ b/src/Game.hx @@ -17,6 +17,8 @@ import dialogue.event.OptionSelected; import dialogue.event.DialogueComplete; import dialogue.event.NextLine; +import dialogue.command.OpenRoomCommand; + @:uiComp("game-container") class GameContainer extends h2d.Flow implements h2d.domkit.Object { static var SRC = @@ -95,6 +97,7 @@ class Game extends hxd.App { globalEventBus.subscribe(OptionsShown, renderOptions); globalEventBus.subscribe(OptionSelected, onOptionSelected); globalEventBus.subscribe(DialogueComplete, onDialogueComplete); + dialogueManager.addCommandHandler(new OpenRoomCommand(globalEventBus)); #if debug setGameScene(new WorldMapScene(root)); diff --git a/src/dialogue/DialogueManager.hx b/src/dialogue/DialogueManager.hx index db1c5f6..203c048 100644 --- a/src/dialogue/DialogueManager.hx +++ b/src/dialogue/DialogueManager.hx @@ -12,6 +12,7 @@ import hxyarn.compiler.Compiler; import hxyarn.compiler.CompilationJob; import event.EventBus; +import dialogue.command.ICommandHandler; import dialogue.event.LineShown; import dialogue.event.OptionsShown; import dialogue.event.OptionsShown.OptionChoice; @@ -26,6 +27,7 @@ class DialogueManager { var storage = new MemoryVariableStore(); var dialogue:Dialogue; var stringTable:Map; + var commandHandlers = new Map(); public var waitingForOption:Bool = false; @@ -118,6 +120,25 @@ class DialogueManager { } public function commandHandler(command:Command) { + var parts = command.text.split(' '); + var key = parts.shift(); + if (commandHandlers.exists(key)) { + if (commandHandlers.get(key).handleCommand(parts)) { + resume(); + return; + } + } + + resume(); + } + + public function addCommandHandler(handler:ICommandHandler) { + if (handler.commandName == null || handler.commandName == "") { + trace("Command handler has no command name"); + return; + } + + commandHandlers.set(handler.commandName, handler); } public function nodeCompleteHandler(nodeName:String) {} diff --git a/src/dialogue/command/ICommandHandler.hx b/src/dialogue/command/ICommandHandler.hx new file mode 100644 index 0000000..3e533b3 --- /dev/null +++ b/src/dialogue/command/ICommandHandler.hx @@ -0,0 +1,6 @@ +package dialogue.command; + +interface ICommandHandler { + var commandName:String; + function handleCommand(args:Array):Bool; +} diff --git a/src/dialogue/command/OpenRoomCommand.hx b/src/dialogue/command/OpenRoomCommand.hx new file mode 100644 index 0000000..3f7d091 --- /dev/null +++ b/src/dialogue/command/OpenRoomCommand.hx @@ -0,0 +1,19 @@ +package dialogue.command; + +import event.EventBus; +import event.OpenRoomEvent; + +class OpenRoomCommand implements ICommandHandler { + public var commandName:String = "room"; + + var eventBus:EventBus; + + public function new(eventBus:EventBus) { + this.eventBus = eventBus; + } + + public function handleCommand(args:Array):Bool { + eventBus.publishEvent(new OpenRoomEvent(args[0])); + return true; + } +} diff --git a/src/event/OpenRoomEvent.hx b/src/event/OpenRoomEvent.hx new file mode 100644 index 0000000..91273c5 --- /dev/null +++ b/src/event/OpenRoomEvent.hx @@ -0,0 +1,9 @@ +package event; + +class OpenRoomEvent implements IEvent { + public var roomName:String; + + public function new(rn:String) { + this.roomName = rn; + } +} diff --git a/src/scene/WorldMapScene.hx b/src/scene/WorldMapScene.hx index 64c5e12..c8cb6df 100644 --- a/src/scene/WorldMapScene.hx +++ b/src/scene/WorldMapScene.hx @@ -1,13 +1,22 @@ package scene; import dialogue.event.StartDialogueNode; +import event.OpenRoomEvent; import TilemapLayer; +typedef Room = { + rect:h2d.Graphics, + area:h2d.Interactive, + isOpen:Bool +} + @:uiComp("world-map-scene") class WorldMapScene extends h2d.Flow implements GameScene implements h2d.domkit.Object { public var width:Int; public var height:Int; + var rooms:Map = new Map(); + public function new(?parent) { super(parent); initComponent(); @@ -16,6 +25,8 @@ class WorldMapScene extends h2d.Flow implements GameScene implements h2d.domkit. var map = Game.loader.loadTMX("map.tmx"); + Game.current.globalEventBus.subscribe(OpenRoomEvent, openRoom); + for (layer in (map.layers)) { switch(layer.kind) { case TTileLayer: @@ -32,8 +43,14 @@ class WorldMapScene extends h2d.Flow implements GameScene implements h2d.domkit. area.y = obj.y; area.onClick = function(_) { trace("Room:" + obj.name); - Game.current.globalEventBus.publishEvent(new StartDialogueNode("Room:" + obj.name)); + var room = rooms.get(obj.name); + if (room.isOpen) { + Game.current.globalEventBus.publishEvent(new StartDialogueNode("Room:" + obj.name)); + } else { + Game.current.globalEventBus.publishEvent(new StartDialogueNode("Room not open")); + } }; + rooms.set(obj.name, {rect: rect, area: area, isOpen: false}); } case TImageLayer: case TGroup: @@ -42,10 +59,17 @@ class WorldMapScene extends h2d.Flow implements GameScene implements h2d.domkit. #if debug trace('skipping intro dialogue'); + Game.current.globalEventBus.publishEvent(new OpenRoomEvent("hangar")); #else Game.current.globalEventBus.publishEvent(new StartDialogueNode("Intro")); #end } + + public function openRoom(event:OpenRoomEvent) { + var room = rooms.get(event.roomName); + room.isOpen = true; + room.area.alpha = 0; + } public function getH2dObject() { return this;