Minor fix and format
This commit is contained in:
parent
f83e2bf8c8
commit
8bf67ab168
@ -82,7 +82,6 @@ const scrollToBottom = () => {
|
|||||||
gameStore.connection?.on(SocketEvent.CHAT_MESSAGE, (data: { character: string; message: string }) => {
|
gameStore.connection?.on(SocketEvent.CHAT_MESSAGE, (data: { character: string; message: string }) => {
|
||||||
if (!data.character || !data.message) return
|
if (!data.character || !data.message) return
|
||||||
|
|
||||||
|
|
||||||
chats.value.push({ character: data.character, message: data.message })
|
chats.value.push({ character: data.character, message: data.message })
|
||||||
scrollToBottom()
|
scrollToBottom()
|
||||||
|
|
||||||
|
@ -5,18 +5,16 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
import type { MapEventTile, Map as MapT, PlacedMapObject as PlacedMapObjectT } from '@/application/types'
|
||||||
import MapEventTiles from '@/components/gameMaster/mapEditor/mapPartials/MapEventTiles.vue'
|
import MapEventTiles from '@/components/gameMaster/mapEditor/mapPartials/MapEventTiles.vue'
|
||||||
import MapTiles from '@/components/gameMaster/mapEditor/mapPartials/MapTiles.vue'
|
import MapTiles from '@/components/gameMaster/mapEditor/mapPartials/MapTiles.vue'
|
||||||
import PlacedMapObjects from '@/components/gameMaster/mapEditor/mapPartials/PlacedMapObjects.vue'
|
import PlacedMapObjects from '@/components/gameMaster/mapEditor/mapPartials/PlacedMapObjects.vue'
|
||||||
import { useMapEditorComposable } from '@/composables/useMapEditorComposable'
|
import { useMapEditorComposable } from '@/composables/useMapEditorComposable'
|
||||||
import { cloneArray, createTileArray, createTileLayer, createTileMap, placeTiles } from '@/services/mapService'
|
import { cloneArray, createTileArray, createTileLayer, createTileMap, placeTiles } from '@/services/mapService'
|
||||||
import { TileStorage } from '@/storage/storages'
|
import { TileStorage } from '@/storage/storages'
|
||||||
import { useScene } from 'phavuer'
|
|
||||||
|
|
||||||
import { onBeforeUnmount, onMounted, onUnmounted, ref, shallowRef, useTemplateRef, watch } from 'vue'
|
|
||||||
import type { PlacedMapObject as PlacedMapObjectT, Map as MapT, MapEventTile } from '@/application/types'
|
|
||||||
import { useManualRefHistory, useRefHistory } from '@vueuse/core'
|
import { useManualRefHistory, useRefHistory } from '@vueuse/core'
|
||||||
|
import { useScene } from 'phavuer'
|
||||||
|
import { onBeforeUnmount, onMounted, onUnmounted, ref, shallowRef, useTemplateRef, watch } from 'vue'
|
||||||
|
|
||||||
const tileMap = shallowRef<Phaser.Tilemaps.Tilemap>()
|
const tileMap = shallowRef<Phaser.Tilemaps.Tilemap>()
|
||||||
const tileMapLayer = shallowRef<Phaser.Tilemaps.TilemapLayer>()
|
const tileMapLayer = shallowRef<Phaser.Tilemaps.TilemapLayer>()
|
||||||
@ -29,14 +27,14 @@ const mapObjects = useTemplateRef('mapObjects')
|
|||||||
const eventTiles = useTemplateRef('eventTiles')
|
const eventTiles = useTemplateRef('eventTiles')
|
||||||
|
|
||||||
//Record of commands
|
//Record of commands
|
||||||
let commandStack: (EditorCommand | number) [] = []
|
let commandStack: (EditorCommand | number)[] = []
|
||||||
let commandIndex = ref(0)
|
let commandIndex = ref(0)
|
||||||
|
|
||||||
let originTiles: string[][] = []
|
let originTiles: string[][] = []
|
||||||
let originEventTiles: MapEventTile[] = []
|
let originEventTiles: MapEventTile[] = []
|
||||||
let originObjects = ref<PlacedMapObjectT[]>(mapEditor.currentMap.value.placedMapObjects)
|
let originObjects = ref<PlacedMapObjectT[]>(mapEditor.currentMap.value.placedMapObjects)
|
||||||
|
|
||||||
const {undo, redo, commit, pause, resume, canUndo, canRedo} = useRefHistory(originObjects, {deep:true, capacity:9})
|
const { undo, redo, commit, pause, resume, canUndo, canRedo } = useRefHistory(originObjects, { deep: true, capacity: 9 })
|
||||||
|
|
||||||
//Command Pattern basic interface, extended to store what elements have been changed by each edit
|
//Command Pattern basic interface, extended to store what elements have been changed by each edit
|
||||||
export interface EditorCommand {
|
export interface EditorCommand {
|
||||||
@ -81,12 +79,10 @@ function update(commands: (EditorCommand | number)[]) {
|
|||||||
originEventTiles = base.apply(originEventTiles) as MapEventTile[]
|
originEventTiles = base.apply(originEventTiles) as MapEventTile[]
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
commandStack.shift()
|
commandStack.shift()
|
||||||
}
|
}
|
||||||
}
|
} else if (typeof commandStack[0] === 'number') {
|
||||||
else if (typeof commandStack[0] === 'number') {
|
|
||||||
commandStack.shift()
|
commandStack.shift()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -124,7 +120,7 @@ function addCommand(command: EditorCommand) {
|
|||||||
|
|
||||||
function undoEdit() {
|
function undoEdit() {
|
||||||
if (commandIndex.value > 0) {
|
if (commandIndex.value > 0) {
|
||||||
if (typeof(commandStack[--commandIndex.value]) === 'number' && canUndo) {
|
if (typeof commandStack[--commandIndex.value] === 'number' && canUndo) {
|
||||||
undo()
|
undo()
|
||||||
}
|
}
|
||||||
update(commandStack.slice(0, commandIndex.value))
|
update(commandStack.slice(0, commandIndex.value))
|
||||||
@ -133,7 +129,7 @@ function undoEdit() {
|
|||||||
|
|
||||||
function redoEdit() {
|
function redoEdit() {
|
||||||
if (commandIndex.value <= 9 && commandIndex.value < commandStack.length) {
|
if (commandIndex.value <= 9 && commandIndex.value < commandStack.length) {
|
||||||
if (typeof(commandStack[commandIndex.value++]) === 'number' && canRedo) {
|
if (typeof commandStack[commandIndex.value++] === 'number' && canRedo) {
|
||||||
redo()
|
redo()
|
||||||
}
|
}
|
||||||
update(commandStack.slice(0, commandIndex.value))
|
update(commandStack.slice(0, commandIndex.value))
|
||||||
@ -185,7 +181,7 @@ function handlePointerMove(pointer: Phaser.Input.Pointer) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function handlePointerUp(pointer: Phaser.Input.Pointer) {
|
function handlePointerUp(pointer: Phaser.Input.Pointer) {
|
||||||
switch(mapEditor.drawMode.value) {
|
switch (mapEditor.drawMode.value) {
|
||||||
case 'tile':
|
case 'tile':
|
||||||
mapTiles.value!.finalizeCommand()
|
mapTiles.value!.finalizeCommand()
|
||||||
break
|
break
|
||||||
|
@ -3,17 +3,16 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
|
||||||
import { MapEventTileType, type MapEventTile, type Map as MapT, type UUID } from '@/application/types'
|
import { MapEventTileType, type MapEventTile, type Map as MapT, type UUID } from '@/application/types'
|
||||||
import { uuidv4 } from '@/application/utilities'
|
import { uuidv4 } from '@/application/utilities'
|
||||||
|
import { type EditorCommand } from '@/components/gameMaster/mapEditor/Map.vue'
|
||||||
import { useMapEditorComposable } from '@/composables/useMapEditorComposable'
|
import { useMapEditorComposable } from '@/composables/useMapEditorComposable'
|
||||||
import { cloneArray, getTile, tileToWorldX, tileToWorldY } from '@/services/mapService'
|
import { cloneArray, getTile, tileToWorldX, tileToWorldY } from '@/services/mapService'
|
||||||
import { Image } from 'phavuer'
|
import { Image } from 'phavuer'
|
||||||
import { type EditorCommand } from '@/components/gameMaster/mapEditor/Map.vue'
|
|
||||||
|
|
||||||
const mapEditor = useMapEditorComposable()
|
const mapEditor = useMapEditorComposable()
|
||||||
|
|
||||||
defineExpose({ handlePointer, finalizeCommand, clearTiles})
|
defineExpose({ handlePointer, finalizeCommand, clearTiles })
|
||||||
|
|
||||||
const emit = defineEmits(['createCommand'])
|
const emit = defineEmits(['createCommand'])
|
||||||
|
|
||||||
@ -21,7 +20,6 @@ const props = defineProps<{
|
|||||||
tileMap: Phaser.Tilemaps.Tilemap
|
tileMap: Phaser.Tilemaps.Tilemap
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
|
|
||||||
// *** COMMAND STATE ***
|
// *** COMMAND STATE ***
|
||||||
|
|
||||||
let currentCommand: EventTileCommand | null = null
|
let currentCommand: EventTileCommand | null = null
|
||||||
@ -35,11 +33,9 @@ class EventTileCommand implements EditorCommand {
|
|||||||
let tileVersion = cloneArray(elements) as MapEventTile[]
|
let tileVersion = cloneArray(elements) as MapEventTile[]
|
||||||
if (this.operation === 'draw') {
|
if (this.operation === 'draw') {
|
||||||
tileVersion = tileVersion.concat(this.affectedTiles)
|
tileVersion = tileVersion.concat(this.affectedTiles)
|
||||||
}
|
} else if (this.operation === 'erase') {
|
||||||
else if (this.operation === 'erase') {
|
|
||||||
tileVersion = tileVersion.filter((v) => !this.affectedTiles.includes(v))
|
tileVersion = tileVersion.filter((v) => !this.affectedTiles.includes(v))
|
||||||
}
|
} else if (this.operation === 'clear') {
|
||||||
else if (this.operation === 'clear') {
|
|
||||||
tileVersion = []
|
tileVersion = []
|
||||||
}
|
}
|
||||||
return tileVersion
|
return tileVersion
|
||||||
@ -69,10 +65,8 @@ function finalizeCommand() {
|
|||||||
currentCommand = null
|
currentCommand = null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// *** HANDLERS ***
|
// *** HANDLERS ***
|
||||||
|
|
||||||
|
|
||||||
function getImageProps(tile: MapEventTile) {
|
function getImageProps(tile: MapEventTile) {
|
||||||
return {
|
return {
|
||||||
x: tileToWorldX(props.tileMap, tile.positionX, tile.positionY),
|
x: tileToWorldX(props.tileMap, tile.positionX, tile.positionY),
|
||||||
@ -159,5 +153,4 @@ function clearTiles() {
|
|||||||
createCommandUpdate(null, 'clear')
|
createCommandUpdate(null, 'clear')
|
||||||
finalizeCommand()
|
finalizeCommand()
|
||||||
}
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
@ -3,11 +3,11 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
import { type EditorCommand } from '@/components/gameMaster/mapEditor/Map.vue'
|
||||||
import Controls from '@/components/utilities/Controls.vue'
|
import Controls from '@/components/utilities/Controls.vue'
|
||||||
import { useMapEditorComposable } from '@/composables/useMapEditorComposable'
|
import { useMapEditorComposable } from '@/composables/useMapEditorComposable'
|
||||||
import { cloneArray, createTileArray, getTile, placeTile, placeTiles } from '@/services/mapService'
|
import { cloneArray, createTileArray, getTile, placeTile, placeTiles } from '@/services/mapService'
|
||||||
import { onMounted, ref, watch } from 'vue'
|
import { onMounted, ref, watch } from 'vue'
|
||||||
import { type EditorCommand } from '@/components/gameMaster/mapEditor/Map.vue'
|
|
||||||
|
|
||||||
const mapEditor = useMapEditorComposable()
|
const mapEditor = useMapEditorComposable()
|
||||||
|
|
||||||
@ -34,8 +34,7 @@ class TileCommand implements EditorCommand {
|
|||||||
let tileVersion
|
let tileVersion
|
||||||
if (this.operation === 'clear') {
|
if (this.operation === 'clear') {
|
||||||
tileVersion = createTileArray(props.tileMapLayer.width, props.tileMapLayer.height, 'blank_tile')
|
tileVersion = createTileArray(props.tileMapLayer.width, props.tileMapLayer.height, 'blank_tile')
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
tileVersion = cloneArray(elements) as string[][]
|
tileVersion = cloneArray(elements) as string[][]
|
||||||
for (const position of this.affectedTiles) {
|
for (const position of this.affectedTiles) {
|
||||||
tileVersion[position[1]][position[0]] = this.tileName
|
tileVersion[position[1]][position[0]] = this.tileName
|
||||||
@ -69,10 +68,8 @@ function finalizeCommand() {
|
|||||||
currentCommand = null
|
currentCommand = null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// *** HANDLERS ***
|
// *** HANDLERS ***
|
||||||
|
|
||||||
|
|
||||||
function draw(pointer: Phaser.Input.Pointer, tileName: string) {
|
function draw(pointer: Phaser.Input.Pointer, tileName: string) {
|
||||||
let map = mapEditor.currentMap.value
|
let map = mapEditor.currentMap.value
|
||||||
if (!map) return
|
if (!map) return
|
||||||
@ -84,7 +81,7 @@ function draw(pointer: Phaser.Input.Pointer, tileName: string) {
|
|||||||
// Place tile
|
// Place tile
|
||||||
placeTile(props.tileMap, props.tileMapLayer, tile.x, tile.y, tileName)
|
placeTile(props.tileMap, props.tileMapLayer, tile.x, tile.y, tileName)
|
||||||
|
|
||||||
createCommandUpdate(tile.x, tile.y, tileName, tileName === 'blank_tile' ? 'erase': 'draw')
|
createCommandUpdate(tile.x, tile.y, tileName, tileName === 'blank_tile' ? 'erase' : 'draw')
|
||||||
|
|
||||||
// Adjust mapEditorStore.map.tiles
|
// Adjust mapEditorStore.map.tiles
|
||||||
map.tiles[tile.y][tile.x] = tileName
|
map.tiles[tile.y][tile.x] = tileName
|
||||||
@ -147,7 +144,7 @@ function handlePointer(pointer: Phaser.Input.Pointer) {
|
|||||||
function clearTiles() {
|
function clearTiles() {
|
||||||
const tileArray = createTileArray(props.tileMap.width, props.tileMap.height, 'blank_tile')
|
const tileArray = createTileArray(props.tileMap.width, props.tileMap.height, 'blank_tile')
|
||||||
placeTiles(props.tileMap, props.tileMapLayer, tileArray)
|
placeTiles(props.tileMap, props.tileMapLayer, tileArray)
|
||||||
createCommandUpdate(0,0,"blank_tile",'clear')
|
createCommandUpdate(0, 0, 'blank_tile', 'clear')
|
||||||
finalizeCommand()
|
finalizeCommand()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@ import SelectedPlacedMapObjectComponent from '@/components/gameMaster/mapEditor/
|
|||||||
import { useMapEditorComposable } from '@/composables/useMapEditorComposable'
|
import { useMapEditorComposable } from '@/composables/useMapEditorComposable'
|
||||||
import { getTile } from '@/services/mapService'
|
import { getTile } from '@/services/mapService'
|
||||||
import { useScene } from 'phavuer'
|
import { useScene } from 'phavuer'
|
||||||
import { computed, onMounted, onUnmounted, ref } from 'vue'
|
import {computed, onMounted, onUnmounted, ref, watch} from 'vue'
|
||||||
|
|
||||||
import Tilemap = Phaser.Tilemaps.Tilemap
|
import Tilemap = Phaser.Tilemaps.Tilemap
|
||||||
import TilemapLayer = Phaser.Tilemaps.TilemapLayer
|
import TilemapLayer = Phaser.Tilemaps.TilemapLayer
|
||||||
@ -27,7 +27,7 @@ const scene = useScene()
|
|||||||
const mapEditor = useMapEditorComposable()
|
const mapEditor = useMapEditorComposable()
|
||||||
const map = computed(() => mapEditor.currentMap.value!)
|
const map = computed(() => mapEditor.currentMap.value!)
|
||||||
|
|
||||||
const emit = defineEmits<{(e: 'update', map: MapT): void, (e: 'updateAndCommit', map: MapT): void, (e:'pauseObjectTracking'), (e:'resumeObjectTracking')}>()
|
const emit = defineEmits<{ (e: 'update', map: MapT): void; (e: 'updateAndCommit', map: MapT): void; (e: 'pauseObjectTracking'): void; (e: 'resumeObjectTracking'): void }>()
|
||||||
|
|
||||||
defineExpose({ handlePointer })
|
defineExpose({ handlePointer })
|
||||||
|
|
||||||
@ -37,10 +37,9 @@ const props = defineProps<{
|
|||||||
}>()
|
}>()
|
||||||
|
|
||||||
const previewPosition = ref({ x: 0, y: 0 })
|
const previewPosition = ref({ x: 0, y: 0 })
|
||||||
|
|
||||||
const previewPlacedMapObject = computed(() => ({
|
const previewPlacedMapObject = computed(() => ({
|
||||||
id: mapEditor.selectedMapObject.value!.id,
|
id: mapEditor.selectedMapObject.value!.id,
|
||||||
mapObject: mapEditor.selectedMapObject.value!,
|
mapObject: mapEditor.selectedMapObject.value!.id,
|
||||||
isRotated: false,
|
isRotated: false,
|
||||||
positionX: previewPosition.value.x,
|
positionX: previewPosition.value.x,
|
||||||
positionY: previewPosition.value.y
|
positionY: previewPosition.value.y
|
||||||
@ -54,7 +53,6 @@ function updatePreviewPosition(pointer: Phaser.Input.Pointer) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function pencil(pointer: Phaser.Input.Pointer, map: MapT) {
|
function pencil(pointer: Phaser.Input.Pointer, map: MapT) {
|
||||||
|
|
||||||
emit('pauseObjectTracking')
|
emit('pauseObjectTracking')
|
||||||
const tile = getTile(props.tileMap, pointer.worldX, pointer.worldY)
|
const tile = getTile(props.tileMap, pointer.worldX, pointer.worldY)
|
||||||
if (!tile) return
|
if (!tile) return
|
||||||
@ -136,7 +134,8 @@ function moveMapObject(id: string, map: MapT) {
|
|||||||
if (placed.id === id) {
|
if (placed.id === id) {
|
||||||
placed.positionX = tile.x
|
placed.positionX = tile.x
|
||||||
placed.positionY = tile.y
|
placed.positionY = tile.y
|
||||||
}})
|
}
|
||||||
|
})
|
||||||
|
|
||||||
mapEditor.movingPlacedObject.value = null
|
mapEditor.movingPlacedObject.value = null
|
||||||
|
|
||||||
@ -147,11 +146,11 @@ function moveMapObject(id: string, map: MapT) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function rotatePlacedMapObject(id: string, map: MapT) {
|
function rotatePlacedMapObject(id: string, map: MapT) {
|
||||||
|
|
||||||
map.placedMapObjects.map((placed) => {
|
map.placedMapObjects.map((placed) => {
|
||||||
if (placed.id === id) {
|
if (placed.id === id) {
|
||||||
placed.isRotated = !placed.isRotated
|
placed.isRotated = !placed.isRotated
|
||||||
}})
|
}
|
||||||
|
})
|
||||||
|
|
||||||
emit('updateAndCommit', map)
|
emit('updateAndCommit', map)
|
||||||
}
|
}
|
||||||
|
@ -41,13 +41,13 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
import { SocketEvent } from '@/application/enums'
|
||||||
import type { MapObject, Map as MapT, PlacedMapObject } from '@/application/types'
|
import type { MapObject, Map as MapT, PlacedMapObject } from '@/application/types'
|
||||||
import Modal from '@/components/utilities/Modal.vue'
|
import Modal from '@/components/utilities/Modal.vue'
|
||||||
import { useMapEditorComposable } from '@/composables/useMapEditorComposable'
|
import { useMapEditorComposable } from '@/composables/useMapEditorComposable'
|
||||||
import { MapObjectStorage } from '@/storage/storages'
|
import { MapObjectStorage } from '@/storage/storages'
|
||||||
import { useGameStore } from '@/stores/gameStore'
|
import { useGameStore } from '@/stores/gameStore'
|
||||||
import { onMounted, ref } from 'vue'
|
import { onMounted, ref } from 'vue'
|
||||||
import {SocketEvent} from "@/application/enums";
|
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
placedMapObject: PlacedMapObject
|
placedMapObject: PlacedMapObject
|
||||||
|
@ -150,7 +150,7 @@ function handleClick(tool: string) {
|
|||||||
mapEditor.setTool(tool)
|
mapEditor.setTool(tool)
|
||||||
selectPencilOpen.value = tool === 'pencil' ? !selectPencilOpen.value : false
|
selectPencilOpen.value = tool === 'pencil' ? !selectPencilOpen.value : false
|
||||||
selectEraserOpen.value = tool === 'eraser' ? !selectEraserOpen.value : false
|
selectEraserOpen.value = tool === 'eraser' ? !selectEraserOpen.value : false
|
||||||
if (mapEditor.drawMode.value === 'teleport') emit("open-teleport")
|
if (mapEditor.drawMode.value === 'teleport') emit('open-teleport')
|
||||||
}
|
}
|
||||||
|
|
||||||
function cycleToolMode(tool: 'pencil' | 'eraser') {
|
function cycleToolMode(tool: 'pencil' | 'eraser') {
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
<div v-if="!isLoaded" class="absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 text-white text-3xl font-ui">Loading...</div>
|
<div v-if="!isLoaded" class="absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 text-white text-3xl font-ui">Loading...</div>
|
||||||
<div v-else>
|
<div v-else>
|
||||||
<Map v-if="mapEditor.currentMap.value" :key="mapEditor.currentMap.value?.id" />
|
<Map v-if="mapEditor.currentMap.value" :key="mapEditor.currentMap.value?.id" />
|
||||||
<Toolbar ref="toolbar" @save="save" @clear="clear" @open-maps="mapModal?.open" @open-settings="mapSettingsModal?.open" @open-teleport="teleportModal?.open"/>
|
<Toolbar ref="toolbar" @save="save" @clear="clear" @open-maps="mapModal?.open" @open-settings="mapSettingsModal?.open" @open-teleport="teleportModal?.open" />
|
||||||
<MapList ref="mapModal" @open-create-map="mapSettingsModal?.open" />
|
<MapList ref="mapModal" @open-create-map="mapSettingsModal?.open" />
|
||||||
<TileList />
|
<TileList />
|
||||||
<MapObjectList />
|
<MapObjectList />
|
||||||
|
@ -62,18 +62,13 @@ export function createTileArray(width: number, height: number, tile: string = 'b
|
|||||||
return Array.from({ length: height }, () => Array.from({ length: width }, () => tile))
|
return Array.from({ length: height }, () => Array.from({ length: width }, () => tile))
|
||||||
}
|
}
|
||||||
|
|
||||||
export const calculateIsometricDepth = (
|
export const calculateIsometricDepth = (positionX: number, positionY: number, width: number = 0, height: number = 0, isCharacter: boolean = false) => {
|
||||||
positionX: number,
|
const baseDepth = positionX + positionY
|
||||||
positionY: number,
|
if (isCharacter) {
|
||||||
objectWidth: number = 0,
|
return baseDepth
|
||||||
objectHeight: number = 0
|
}
|
||||||
): number => {
|
return baseDepth + (width + height) / (2 * config.tile_size.width)
|
||||||
const tileWidth = config.tile_size.width;
|
}
|
||||||
const tileHeight = config.tile_size.height;
|
|
||||||
const tileSize = Math.max(tileWidth, tileHeight);
|
|
||||||
const objectSize = Math.max(objectWidth, objectHeight);
|
|
||||||
return Math.floor(positionY * tileSize + positionX * objectSize);
|
|
||||||
};
|
|
||||||
|
|
||||||
async function loadTileTextures(tiles: TileT[], scene: Phaser.Scene) {
|
async function loadTileTextures(tiles: TileT[], scene: Phaser.Scene) {
|
||||||
// Load each tile into the scene
|
// Load each tile into the scene
|
||||||
|
@ -5,7 +5,7 @@ export const useMapStore = defineStore('map', {
|
|||||||
state: () => {
|
state: () => {
|
||||||
return {
|
return {
|
||||||
mapId: '',
|
mapId: '',
|
||||||
characters: [] as MapCharacter[],
|
characters: [] as MapCharacter[]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
getters: {
|
getters: {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user