From 9d774bcb1872a7a8650f4e876fa1b14759427c07 Mon Sep 17 00:00:00 2001 From: Dennis Postma Date: Fri, 18 Oct 2024 02:48:27 +0200 Subject: [PATCH] Removed redundant code , refactor event tile code --- .../gameMaster/zoneEditor/EventTiles.vue | 87 ++++++++++++++++--- .../gameMaster/zoneEditor/Objects.vue | 8 +- .../gameMaster/zoneEditor/Tiles.vue | 6 +- src/screens/Game.vue | 3 - src/screens/ZoneEditor.vue | 1 - 5 files changed, 84 insertions(+), 21 deletions(-) diff --git a/src/components/gameMaster/zoneEditor/EventTiles.vue b/src/components/gameMaster/zoneEditor/EventTiles.vue index 6c45e35..f2be33b 100644 --- a/src/components/gameMaster/zoneEditor/EventTiles.vue +++ b/src/components/gameMaster/zoneEditor/EventTiles.vue @@ -1,14 +1,81 @@ - + diff --git a/src/components/gameMaster/zoneEditor/Objects.vue b/src/components/gameMaster/zoneEditor/Objects.vue index 4b0bd97..8219a50 100644 --- a/src/components/gameMaster/zoneEditor/Objects.vue +++ b/src/components/gameMaster/zoneEditor/Objects.vue @@ -48,16 +48,16 @@ function addZoneObject(pointer: Phaser.Input.Pointer) { // Check if draw mode is object if (zoneEditorStore.drawMode !== 'object') return + // Check if there is a selected object + if (!zoneEditorStore.selectedObject) return + // Check if left mouse button is pressed if (!pointer.isDown) return - // Check if there is a tile @TODO chekc if props.tilemap words + // Check if there is a tile const tile = getTile(props.tilemap, pointer.worldX, pointer.worldY) if (!tile) return - // Check if there is a selected object - if (!zoneEditorStore.selectedObject) return - // Check if object already exists on position const existingObject = zoneEditorStore.zone?.zoneObjects.find((object) => object.positionX === tile.x && object.positionY === tile.y) if (existingObject) return diff --git a/src/components/gameMaster/zoneEditor/Tiles.vue b/src/components/gameMaster/zoneEditor/Tiles.vue index 77e898d..20cf2ae 100644 --- a/src/components/gameMaster/zoneEditor/Tiles.vue +++ b/src/components/gameMaster/zoneEditor/Tiles.vue @@ -58,6 +58,9 @@ function handleTileClick(pointer: Phaser.Input.Pointer) { // Check if draw mode is tile if (zoneEditorStore.drawMode !== 'tile') return + // Check if there is a selected tile + if (!zoneEditorStore.selectedTile) return + // Check if left mouse button is pressed if (!pointer.isDown) return @@ -65,9 +68,6 @@ function handleTileClick(pointer: Phaser.Input.Pointer) { const tile = getTile(tiles, pointer.worldX, pointer.worldY) if (!tile) return - // Check if there is a selected tile - if (!zoneEditorStore.selectedTile) return - placeTile(zoneTilemap, tiles, tile.x, tile.y, zoneEditorStore.selectedTile.id) } diff --git a/src/screens/Game.vue b/src/screens/Game.vue index 0a76733..d02666f 100644 --- a/src/screens/Game.vue +++ b/src/screens/Game.vue @@ -111,10 +111,7 @@ const preloadScene = async (scene: Phaser.Scene) => { /** * Load the base assets into the Phaser scene */ - scene.load.image('BLOCK', '/assets/zone/bt_tile.png') - scene.load.image('TELEPORT', '/assets/zone/tp_tile.png') scene.load.image('blank_tile', '/assets/zone/blank_tile.png') - scene.load.image('blank_object', '/assets/zone/blank_tile.png') scene.load.image('waypoint', '/assets/waypoint.png') /** diff --git a/src/screens/ZoneEditor.vue b/src/screens/ZoneEditor.vue index ba77bc6..475c595 100644 --- a/src/screens/ZoneEditor.vue +++ b/src/screens/ZoneEditor.vue @@ -97,7 +97,6 @@ const preloadScene = async (scene: Phaser.Scene) => { scene.load.image('BLOCK', '/assets/zone/bt_tile.png') scene.load.image('TELEPORT', '/assets/zone/tp_tile.png') scene.load.image('blank_tile', '/assets/zone/blank_tile.png') - scene.load.image('blank_object', '/assets/zone/blank_tile.png') scene.load.image('waypoint', '/assets/waypoint.png') /**