From 8be7c18d4f876753c6bb200811523d0d0c6959df Mon Sep 17 00:00:00 2001 From: 3wc <3wc@doesthisthing.work> Date: Fri, 16 Feb 2024 03:52:16 -0300 Subject: [PATCH] 4matting --- src/Game.hx | 25 +- src/TilemapLayer.hx | 408 +++++++++++++++++--------------- src/dialogue/DialogueManager.hx | 219 +++++++++-------- src/scene/GameScene.hx | 2 +- src/scene/TitleScene.hx | 7 +- src/scene/WorldMapScene.hx | 16 +- 6 files changed, 348 insertions(+), 329 deletions(-) diff --git a/src/Game.hx b/src/Game.hx index 74e5c8b..6e5055e 100644 --- a/src/Game.hx +++ b/src/Game.hx @@ -1,23 +1,19 @@ import h2d.Layers; import h2d.Console; import h3d.Vector4; - import scene.TitleScene; import scene.WorldMapScene; import scene.GameScene; import event.EventBus; import event.ChangeSceneEvent; - import Const; import dialogue.DialogueBox; import dialogue.DialogueManager; - import dialogue.event.LineShown; import dialogue.event.OptionsShown; import dialogue.event.OptionSelected; import dialogue.event.DialogueComplete; import dialogue.event.NextLine; - import dialogue.command.OpenRoomCommand; @:uiComp("game-container") @@ -41,11 +37,14 @@ class Game extends hxd.App { public var dialogueManager:DialogueManager; public var globalEventBus:EventBus; - public static var current:Game; // Current Game (singleton) + + public static var current:Game; // Current Game (singleton) var layer:Layers; + public var root:GameContainer; public var console:Console; + var style = null; public static var loader = new tiled.Tiled(); @@ -86,14 +85,8 @@ class Game extends hxd.App { dialogueManager = new DialogueManager(globalEventBus); - var yarnText = [ - hxd.Res.text.intro.entry.getText(), - hxd.Res.text.rooms.entry.getText(), - ]; - var yarnFileNames = [ - hxd.Res.text.intro.entry.name, - hxd.Res.text.rooms.entry.name, - ]; + var yarnText = [hxd.Res.text.intro.entry.getText(), hxd.Res.text.rooms.entry.getText(),]; + var yarnFileNames = [hxd.Res.text.intro.entry.name, hxd.Res.text.rooms.entry.name,]; dialogueManager.load(yarnText, yarnFileNames); globalEventBus.subscribe(LineShown, dialogue); @@ -155,7 +148,7 @@ class Game extends hxd.App { return g; } - function addOption(o: String, enabled : Bool, callback: () -> Void) { + function addOption(o:String, enabled:Bool, callback:() -> Void) { var spr = newPanel(Const.W, 60); curDialogue.addChild(spr); var tf = new h2d.Text(font, spr); @@ -169,13 +162,13 @@ class Game extends hxd.App { spr.y = 100 + options.length * 60; var int = new h2d.Interactive(spr.width, spr.height, spr); int.onClick = function(_) { - callback(); + callback(); } int.cursor = Button; options.push(spr); return spr; } - + function onOptionSelected(event:OptionSelected) { for (o in options) { o.remove(); diff --git a/src/TilemapLayer.hx b/src/TilemapLayer.hx index fe0b3b8..76fe938 100644 --- a/src/TilemapLayer.hx +++ b/src/TilemapLayer.hx @@ -1,197 +1,229 @@ import h2d.col.Point; import h2d.Object; import h2d.SpriteBatch; - import tiled.types.TmxLayer; import tiled.types.TmxMap; + using tiled.TiledTools; class TilemapLayer extends h2d.TileGroup { - - public var map:TmxMap; - public var layer:TmxLayer; - - public function new (map:TmxMap, layer:TmxLayer, ?parent:Object) { - this.map = map; - this.layer = layer; - super(parent); - for (c in layer.tileChunks) { - addChunk(c); - } - // TODO: Animations - } - - // public function gidAt(x:Int, y:Int):Int { - // if (x < 0 || x >= layer.width || y < 0 || y >= layer.height) return 0; - // return layer.data.tiles[y * layer.width + x].gid; - // } - public function addChunk(chunk:TileChunk) { - var tw = map.tileWidth; - var th = map.tileHeight; - var ix = 0, iy = 0; - var tiles = chunk.tiles, i = 0; - var tsets = map.tilesets; - switch (map.orientation) { - case Orthogonal: - var cx = chunk.x * tw + layer.offsetX; - var cy = chunk.y * th + layer.offsetY; - while (i < tiles.length) { - var gid = tiles[i++]; - if (gid != 0) { - var t = tsets.getImage(gid); - var x = cx + ix * tw; - var y = cy + iy * th + th - t.height; - if (gid.flippedHorizontally) addTransform(x + t.width, y, -1, 1, 0, t); - else if (gid.flippedVertically) addTransform(x, y + t.height, 1, -1, 0, t); - else if (gid.flippedDiagonally) addTransform(x + t.width, y + t.height, -1, -1, 0, t); - else add(x, y, t); - } - if (++ix == chunk.width) { iy++; ix = 0; } - } - case Isometric: - var isoW = tw >> 1; - var isoH = th >> 1; - - var cx = (chunk.x - chunk.y) * isoW + layer.offsetX; - var cy = (chunk.x + chunk.y) * isoH + layer.offsetY; - while (i < tiles.length) { - var gid = tiles[i++]; - if (gid != 0) { - var t = tsets.getImage(gid); - var x = cx + (ix - iy) * isoW; - var y = cy + (ix + iy) * isoH + th - t.height; - if (gid.flippedHorizontally) addTransform(x + t.width, y, -1, 1, 0, t); - else if (gid.flippedVertically) addTransform(x, y + t.height, 1, -1, 0, t); - else if (gid.flippedDiagonally) addTransform(x + t.width, y + t.height, -1, -1, 0, t); - else add(x, y, t); - } - if (++ix == chunk.width) { iy++; ix = 0; } - } - case Staggered(staggerYAxis, staggerIndexOdd): - var staggerX = 0, staggerY = 0, stepX = tw >> 1, stepY = th >> 1; - var cx = chunk.x * stepX + layer.offsetX; - var cy = chunk.y * stepY + layer.offsetY; - if (staggerYAxis) { - if (staggerIndexOdd) { - staggerX = tw >> 1; - } else { - staggerX = -(tw >> 1); - cx -= staggerX; - } - } else { - if (staggerIndexOdd) { - staggerY = th >> 1; - } else { - staggerY = -(tw >> 1); - cy -= staggerY; - } - } - cx += (chunk.x % 2) * staggerX; - cy += (chunk.y % 2) * staggerY; - while (i < tiles.length) { - var gid = tiles[i++]; - if (gid != 0) { - var t = tsets.getImage(gid); - var x = cx + ix * stepX + staggerX * (ix % 1); - var y = cy + iy * stepY + th - t.height; - if (gid.flippedHorizontally) addTransform(x + t.width, y, -1, 1, 0, t); - else if (gid.flippedVertically) addTransform(x, y + t.height, 1, -1, 0, t); - else if (gid.flippedDiagonally) addTransform(x + t.width, y + t.height, -1, -1, 0, t); - else add(x, y, t); - } - if (++ix == chunk.width) { iy++; ix = 0; } - } - case Hexagonal(sideLength, staggerYAxis, staggerIndexOdd): - // TODO: Fix - var staggerX = 0, staggerY = 0, stepX, stepY; - var cx, cy; - if (staggerYAxis) { - stepX = tw; - stepY = (th + sideLength) >> 1; - cx = chunk.x * stepX + layer.offsetX; - cy = chunk.y * stepY + layer.offsetY; - if (staggerIndexOdd) { - staggerX = tw >> 1; - } else { - staggerX = -(tw >> 1); - cx -= staggerX; - } - } else { - stepX = (tw + sideLength) >> 1; - stepY = th; - cx = chunk.x * stepX + layer.offsetX; - cy = chunk.y * stepY + layer.offsetY; - if (staggerIndexOdd) { - staggerY = th >> 1; - } else { - staggerY = -(tw >> 1); - cy -= staggerY; - } - } - while (i < tiles.length) { - var gid = tiles[i++]; - if (gid != 0) { - var t = tsets.getImage(gid); - var x = cx + ix * stepX; - var y = cy + iy * stepY + th - t.height; - if (gid.flippedHorizontally) addTransform(x + t.width, y, -1, 1, 0, t); - else if (gid.flippedVertically) addTransform(x, y + t.height, 1, -1, 0, t); - else if (gid.flippedDiagonally) addTransform(x + t.width, y + t.height, -1, -1, 0, t); - else add(x, y, t); - } - if (++ix == chunk.width) { iy++; ix = 0; } - } - } - } - - - public function addTile(tx:Int, ty:Int, ox:Float, oy:Float, gid:TmxTileIndex) { - if (gid == 0) return; - var t = map.tilesets.getImage(gid); - if (t != null) { - var x, y; - switch (map.orientation) { - case Orthogonal: - x = tx * map.tileWidth + ox; - y = ty * map.tileHeight + oy; - case Isometric: - x = (tx - ty) * (map.tileWidth >> 1) + ox; - y = (tx + ty) * (map.tileHeight >> 1) + oy; - case Staggered(staggerYAxis, staggerIndexOdd): - if (staggerYAxis) { - y = ty * (map.tileHeight >> 1); - if (staggerIndexOdd) - x = tx * map.tileWidth + (tx % 2) * (map.tileWidth >> 1); - else - x = tx * map.tileWidth + ((tx + 1) % 2) * (map.tileWidth >> 1); - } else { - x = tx * (map.tileWidth >> 1); - if (staggerIndexOdd) - y = ty * map.tileHeight + (tx % 2) * (map.tileHeight >> 1); - else - y = ty * map.tileHeight + ((tx + 1) % 2) * (map.tileHeight >> 1); - } - case Hexagonal(sideLength, staggerYAxis, staggerIndexOdd): - if (staggerYAxis) { - y = ty * ((map.tileHeight + sideLength) >> 1); - if (staggerIndexOdd) - x = tx * map.tileWidth + (tx % 2) * (map.tileWidth >> 1); - else - x = tx * map.tileWidth + ((tx + 1) % 2) * (map.tileWidth >> 1); - } else { - x = tx * ((map.tileWidth + sideLength) >> 1); - if (staggerIndexOdd) - y = ty * map.tileHeight + (tx % 2) * (map.tileHeight >> 1); - else - y = ty * map.tileHeight + ((tx + 1) % 2) * (map.tileHeight >> 1); - } - } - if (gid.flippedHorizontally) addTransform(x + t.width, y, -1, 1, 0, t); - else if (gid.flippedVertically) addTransform(x, y + t.height, 1, -1, 0, t); - else if (gid.flippedDiagonally) addTransform(x + t.width, y + t.height, -1, -1, 0, t); - else add(x, y, t); - } - } - - + public var map:TmxMap; + public var layer:TmxLayer; + + public function new(map:TmxMap, layer:TmxLayer, ?parent:Object) { + this.map = map; + this.layer = layer; + super(parent); + for (c in layer.tileChunks) { + addChunk(c); + } + // TODO: Animations + } + + // public function gidAt(x:Int, y:Int):Int { + // if (x < 0 || x >= layer.width || y < 0 || y >= layer.height) return 0; + // return layer.data.tiles[y * layer.width + x].gid; + // } + public function addChunk(chunk:TileChunk) { + var tw = map.tileWidth; + var th = map.tileHeight; + var ix = 0, iy = 0; + var tiles = chunk.tiles, i = 0; + var tsets = map.tilesets; + switch (map.orientation) { + case Orthogonal: + var cx = chunk.x * tw + layer.offsetX; + var cy = chunk.y * th + layer.offsetY; + while (i < tiles.length) { + var gid = tiles[i++]; + if (gid != 0) { + var t = tsets.getImage(gid); + var x = cx + ix * tw; + var y = cy + iy * th + th - t.height; + if (gid.flippedHorizontally) + addTransform(x + t.width, y, -1, 1, 0, t); + else if (gid.flippedVertically) + addTransform(x, y + t.height, 1, -1, 0, t); + else if (gid.flippedDiagonally) + addTransform(x + t.width, y + t.height, -1, -1, 0, t); + else + add(x, y, t); + } + if (++ix == chunk.width) { + iy++; + ix = 0; + } + } + case Isometric: + var isoW = tw >> 1; + var isoH = th >> 1; + + var cx = (chunk.x - chunk.y) * isoW + layer.offsetX; + var cy = (chunk.x + chunk.y) * isoH + layer.offsetY; + while (i < tiles.length) { + var gid = tiles[i++]; + if (gid != 0) { + var t = tsets.getImage(gid); + var x = cx + (ix - iy) * isoW; + var y = cy + (ix + iy) * isoH + th - t.height; + if (gid.flippedHorizontally) + addTransform(x + t.width, y, -1, 1, 0, t); + else if (gid.flippedVertically) + addTransform(x, y + t.height, 1, -1, 0, t); + else if (gid.flippedDiagonally) + addTransform(x + t.width, y + t.height, -1, -1, 0, t); + else + add(x, y, t); + } + if (++ix == chunk.width) { + iy++; + ix = 0; + } + } + case Staggered(staggerYAxis, staggerIndexOdd): + var staggerX = 0, + staggerY = 0, + stepX = tw >> 1, + stepY = th >> 1; + var cx = chunk.x * stepX + layer.offsetX; + var cy = chunk.y * stepY + layer.offsetY; + if (staggerYAxis) { + if (staggerIndexOdd) { + staggerX = tw >> 1; + } else { + staggerX = -(tw >> 1); + cx -= staggerX; + } + } else { + if (staggerIndexOdd) { + staggerY = th >> 1; + } else { + staggerY = -(tw >> 1); + cy -= staggerY; + } + } + cx += (chunk.x % 2) * staggerX; + cy += (chunk.y % 2) * staggerY; + while (i < tiles.length) { + var gid = tiles[i++]; + if (gid != 0) { + var t = tsets.getImage(gid); + var x = cx + ix * stepX + staggerX * (ix % 1); + var y = cy + iy * stepY + th - t.height; + if (gid.flippedHorizontally) + addTransform(x + t.width, y, -1, 1, 0, t); + else if (gid.flippedVertically) + addTransform(x, y + t.height, 1, -1, 0, t); + else if (gid.flippedDiagonally) + addTransform(x + t.width, y + t.height, -1, -1, 0, t); + else + add(x, y, t); + } + if (++ix == chunk.width) { + iy++; + ix = 0; + } + } + case Hexagonal(sideLength, staggerYAxis, staggerIndexOdd): + // TODO: Fix + var staggerX = 0, staggerY = 0, stepX, stepY; + var cx, cy; + if (staggerYAxis) { + stepX = tw; + stepY = (th + sideLength) >> 1; + cx = chunk.x * stepX + layer.offsetX; + cy = chunk.y * stepY + layer.offsetY; + if (staggerIndexOdd) { + staggerX = tw >> 1; + } else { + staggerX = -(tw >> 1); + cx -= staggerX; + } + } else { + stepX = (tw + sideLength) >> 1; + stepY = th; + cx = chunk.x * stepX + layer.offsetX; + cy = chunk.y * stepY + layer.offsetY; + if (staggerIndexOdd) { + staggerY = th >> 1; + } else { + staggerY = -(tw >> 1); + cy -= staggerY; + } + } + while (i < tiles.length) { + var gid = tiles[i++]; + if (gid != 0) { + var t = tsets.getImage(gid); + var x = cx + ix * stepX; + var y = cy + iy * stepY + th - t.height; + if (gid.flippedHorizontally) + addTransform(x + t.width, y, -1, 1, 0, t); + else if (gid.flippedVertically) + addTransform(x, y + t.height, 1, -1, 0, t); + else if (gid.flippedDiagonally) + addTransform(x + t.width, y + t.height, -1, -1, 0, t); + else + add(x, y, t); + } + if (++ix == chunk.width) { + iy++; + ix = 0; + } + } + } + } + + public function addTile(tx:Int, ty:Int, ox:Float, oy:Float, gid:TmxTileIndex) { + if (gid == 0) + return; + var t = map.tilesets.getImage(gid); + if (t != null) { + var x, y; + switch (map.orientation) { + case Orthogonal: + x = tx * map.tileWidth + ox; + y = ty * map.tileHeight + oy; + case Isometric: + x = (tx - ty) * (map.tileWidth >> 1) + ox; + y = (tx + ty) * (map.tileHeight >> 1) + oy; + case Staggered(staggerYAxis, staggerIndexOdd): + if (staggerYAxis) { + y = ty * (map.tileHeight >> 1); + if (staggerIndexOdd) + x = tx * map.tileWidth + (tx % 2) * (map.tileWidth >> 1); + else + x = tx * map.tileWidth + ((tx + 1) % 2) * (map.tileWidth >> 1); + } else { + x = tx * (map.tileWidth >> 1); + if (staggerIndexOdd) + y = ty * map.tileHeight + (tx % 2) * (map.tileHeight >> 1); + else + y = ty * map.tileHeight + ((tx + 1) % 2) * (map.tileHeight >> 1); + } + case Hexagonal(sideLength, staggerYAxis, staggerIndexOdd): + if (staggerYAxis) { + y = ty * ((map.tileHeight + sideLength) >> 1); + if (staggerIndexOdd) + x = tx * map.tileWidth + (tx % 2) * (map.tileWidth >> 1); + else + x = tx * map.tileWidth + ((tx + 1) % 2) * (map.tileWidth >> 1); + } else { + x = tx * ((map.tileWidth + sideLength) >> 1); + if (staggerIndexOdd) + y = ty * map.tileHeight + (tx % 2) * (map.tileHeight >> 1); + else + y = ty * map.tileHeight + ((tx + 1) % 2) * (map.tileHeight >> 1); + } + } + if (gid.flippedHorizontally) + addTransform(x + t.width, y, -1, 1, 0, t); + else if (gid.flippedVertically) + addTransform(x, y + t.height, 1, -1, 0, t); + else if (gid.flippedDiagonally) + addTransform(x + t.width, y + t.height, -1, -1, 0, t); + else + add(x, y, t); + } + } } diff --git a/src/dialogue/DialogueManager.hx b/src/dialogue/DialogueManager.hx index 203c048..b37c6c7 100644 --- a/src/dialogue/DialogueManager.hx +++ b/src/dialogue/DialogueManager.hx @@ -10,7 +10,6 @@ import hxyarn.dialogue.OptionSet; import hxyarn.dialogue.markup.MarkupParseResult; import hxyarn.compiler.Compiler; import hxyarn.compiler.CompilationJob; - import event.EventBus; import dialogue.command.ICommandHandler; import dialogue.event.LineShown; @@ -22,146 +21,144 @@ import dialogue.event.StartDialogueNode; import dialogue.event.DialogueComplete; class DialogueManager { - public var eventBus:EventBus; + public var eventBus:EventBus; - var storage = new MemoryVariableStore(); - var dialogue:Dialogue; - var stringTable:Map; - var commandHandlers = new Map(); + var storage = new MemoryVariableStore(); + var dialogue:Dialogue; + var stringTable:Map; + var commandHandlers = new Map(); - public var waitingForOption:Bool = false; + public var waitingForOption:Bool = false; - public function new(eventBus:EventBus) { - this.eventBus = eventBus; - dialogue = new Dialogue(new MemoryVariableStore()); + public function new(eventBus:EventBus) { + this.eventBus = eventBus; + dialogue = new Dialogue(new MemoryVariableStore()); - dialogue.logDebugMessage = this.logDebugMessage; - dialogue.logErrorMessage = this.logErrorMessage; - dialogue.lineHandler = this.lineHandler; - dialogue.optionsHandler = this.optionsHandler; - dialogue.commandHandler = this.commandHandler; - dialogue.nodeCompleteHandler = this.nodeCompleteHandler; - dialogue.nodeStartHandler = this.nodeStartHandler; - dialogue.dialogueCompleteHandler = this.dialogueCompleteHandler; + dialogue.logDebugMessage = this.logDebugMessage; + dialogue.logErrorMessage = this.logErrorMessage; + dialogue.lineHandler = this.lineHandler; + dialogue.optionsHandler = this.optionsHandler; + dialogue.commandHandler = this.commandHandler; + dialogue.nodeCompleteHandler = this.nodeCompleteHandler; + dialogue.nodeStartHandler = this.nodeStartHandler; + dialogue.dialogueCompleteHandler = this.dialogueCompleteHandler; - eventBus.subscribe(NextLine, this.nextLine); - eventBus.subscribe(OptionSelected, this.optionSelected); - eventBus.subscribe(StartDialogueNode, function(event) { - this.runNode(event.node); - }); - } + eventBus.subscribe(NextLine, this.nextLine); + eventBus.subscribe(OptionSelected, this.optionSelected); + eventBus.subscribe(StartDialogueNode, function(event) { + this.runNode(event.node); + }); + } - public function load(text:Array, fileNames:Array) { - var job = CompilationJob.createFromStrings(text, fileNames, dialogue.library); - var compiler = Compiler.compile(job); - stringTable = compiler.stringTable; + public function load(text:Array, fileNames:Array) { + var job = CompilationJob.createFromStrings(text, fileNames, dialogue.library); + var compiler = Compiler.compile(job); + stringTable = compiler.stringTable; - dialogue.addProgram(compiler.program); - } + dialogue.addProgram(compiler.program); + } - public function runNode(nodeName:String) { - dialogue.setNode(nodeName); - dialogue.resume(); - } + public function runNode(nodeName:String) { + dialogue.setNode(nodeName); + dialogue.resume(); + } - public function unload() { - dialogue.unloadAll(); - } + public function unload() { + dialogue.unloadAll(); + } - public function resume() { - dialogue.resume(); - } + public function resume() { + dialogue.resume(); + } - public function logDebugMessage(message:String):Void { - } + public function logDebugMessage(message:String):Void {} - public function logErrorMessage(message:String):Void { - } + public function logErrorMessage(message:String):Void {} - public function nextLine(event:NextLine) { - if ((dialogue.isActive()) && (!waitingForOption)) - dialogue.resume(); - } + public function nextLine(event:NextLine) { + if ((dialogue.isActive()) && (!waitingForOption)) + dialogue.resume(); + } - public function lineHandler(line:Line):Void { - var text = getComposedTextForLine(line); - eventBus.publishEvent(new LineShown(text)); - } + public function lineHandler(line:Line):Void { + var text = getComposedTextForLine(line); + eventBus.publishEvent(new LineShown(text)); + } - public function optionSelected(event:OptionSelected) { - dialogue.setSelectedOption(event.index); - dialogue.resume(); - waitingForOption = false; - } + public function optionSelected(event:OptionSelected) { + dialogue.setSelectedOption(event.index); + dialogue.resume(); + waitingForOption = false; + } - public function optionsHandler(options:OptionSet) { - var optionCount = options.options.length; - var optionChoices = new Array(); + public function optionsHandler(options:OptionSet) { + var optionCount = options.options.length; + var optionChoices = new Array(); - for (i => option in options.options) { - var markup = getComposedTextForLine(option.line); - optionChoices.push({ - text: markup.text, - index: i, - enabled: option.enabled, - markup: markup - }); - } + for (i => option in options.options) { + var markup = getComposedTextForLine(option.line); + optionChoices.push({ + text: markup.text, + index: i, + enabled: option.enabled, + markup: markup + }); + } - eventBus.publishEvent(new OptionsShown(optionChoices)); + eventBus.publishEvent(new OptionsShown(optionChoices)); - waitingForOption = true; - } + waitingForOption = true; + } - public function getComposedTextForLine(line:Line):MarkupParseResult { - var substitutedText = Dialogue.expandSubstitutions(stringTable[line.id].text, line.substitutions); + public function getComposedTextForLine(line:Line):MarkupParseResult { + var substitutedText = Dialogue.expandSubstitutions(stringTable[line.id].text, line.substitutions); - return dialogue.parseMarkup(substitutedText); - } + return dialogue.parseMarkup(substitutedText); + } + + 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; + } + } - 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; + } - public function addCommandHandler(handler:ICommandHandler) { - if (handler.commandName == null || handler.commandName == "") { - trace("Command handler has no command name"); - return; + commandHandlers.set(handler.commandName, handler); } - commandHandlers.set(handler.commandName, handler); - } + public function nodeCompleteHandler(nodeName:String) {} - public function nodeCompleteHandler(nodeName:String) {} + public function nodeStartHandler(nodeName:String) {} - public function nodeStartHandler(nodeName:String) {} + public function dialogueCompleteHandler() { + eventBus.publishEvent(new DialogueComplete("")); + } - public function dialogueCompleteHandler() { - eventBus.publishEvent(new DialogueComplete("")); - } + public function getNodeNames(?includesTag = "") { + var nodeNames = []; + for (nodeName in dialogue.allNodes) { + if (includesTag == "") { + nodeNames.push(nodeName); + continue; + } - public function getNodeNames(?includesTag = "") { - var nodeNames = []; - for (nodeName in dialogue.allNodes) { - if (includesTag == "") { - nodeNames.push(nodeName); - continue; - } - - var tags = dialogue.getTagsForNode(nodeName); - if (tags.contains(includesTag)) { - nodeNames.push(nodeName); - } - } - return nodeNames; - } + var tags = dialogue.getTagsForNode(nodeName); + if (tags.contains(includesTag)) { + nodeNames.push(nodeName); + } + } + return nodeNames; + } } diff --git a/src/scene/GameScene.hx b/src/scene/GameScene.hx index 7f5f6bd..441d1fe 100644 --- a/src/scene/GameScene.hx +++ b/src/scene/GameScene.hx @@ -1,5 +1,5 @@ package scene; interface GameScene { - function getH2dObject():h2d.Object; + function getH2dObject():h2d.Object; } diff --git a/src/scene/TitleScene.hx b/src/scene/TitleScene.hx index 40e3d9d..9084ba5 100644 --- a/src/scene/TitleScene.hx +++ b/src/scene/TitleScene.hx @@ -1,9 +1,7 @@ package scene; import scene.WorldMapScene; - import event.ChangeSceneEvent; - import components.MenubuttonComponent; @:uiComp("heading") @@ -41,12 +39,11 @@ class TitleScene extends h2d.Flow implements GameScene implements h2d.domkit.Obj } #if hl btnQuit.onClick = function() { - Sys.exit(0); + Sys.exit(0); } #else - btnQuit.remove(); + btnQuit.remove(); #end - } public function getH2dObject() { diff --git a/src/scene/WorldMapScene.hx b/src/scene/WorldMapScene.hx index 6b2abde..7e8eac8 100644 --- a/src/scene/WorldMapScene.hx +++ b/src/scene/WorldMapScene.hx @@ -5,9 +5,9 @@ import event.OpenRoomEvent; import TilemapLayer; typedef Room = { - rect:h2d.Graphics, - area:h2d.Interactive, - isOpen:Bool + rect:h2d.Graphics, + area:h2d.Interactive, + isOpen:Bool } @:uiComp("world-map-scene") @@ -15,7 +15,7 @@ class WorldMapScene extends h2d.Flow implements GameScene implements h2d.domkit. public var width:Int; public var height:Int; - var rooms:Map = new Map(); + var rooms:Map = new Map(); public function new(?parent) { super(parent); @@ -28,9 +28,9 @@ class WorldMapScene extends h2d.Flow implements GameScene implements h2d.domkit. Game.current.globalEventBus.subscribe(OpenRoomEvent, openRoom); for (layer in (map.layers)) { - switch(layer.kind) { + switch (layer.kind) { case TTileLayer: - var l = new TilemapLayer(map, layer, root); + var l = new TilemapLayer(map, layer, root); case TObjectGroup: for (obj in layer.objects) { var rect = new h2d.Graphics(root); @@ -59,7 +59,7 @@ class WorldMapScene extends h2d.Flow implements GameScene implements h2d.domkit. #if debug trace('skipping intro dialogue'); Game.current.globalEventBus.publishEvent(new OpenRoomEvent("quarters")); - #else + #else Game.current.globalEventBus.publishEvent(new StartDialogueNode("Intro")); #end } @@ -69,7 +69,7 @@ class WorldMapScene extends h2d.Flow implements GameScene implements h2d.domkit. room.isOpen = true; room.rect.alpha = 0; } - + public function getH2dObject() { return this; }