Work for teleports

This commit is contained in:
2024-08-23 20:15:58 +02:00
parent 43d5e0614e
commit ad096d4ce3
13 changed files with 303 additions and 168 deletions

View File

@ -12,7 +12,7 @@
<Hud />
</div>
</div>
<World v-if="isLoaded" :key="gameStore.character?.zoneId" />
<Zone v-if="isLoaded" :key="zoneStore.zone?.id ?? 0" />
<div class="fixed inset-x-0 bottom-0 flex justify-between gap-5 items-end py-10 px-5 xxs:p-10 pointer-events-none max-md:flex-wrap max-md:flex-col-reverse">
<div class="pointer-events-auto w-full">
<Chat />
@ -37,31 +37,29 @@
<script setup lang="ts">
import config from '@/config'
import 'phaser'
import { watch, ref, onBeforeUnmount } from 'vue'
import { watch, ref, onBeforeUnmount, onBeforeMount } from 'vue'
import { storeToRefs } from 'pinia'
import { Game, Scene } from 'phavuer'
import { useGameStore } from '@/stores/game'
import { useZoneEditorStore } from '@/stores/zoneEditor'
import { useAssetStore } from '@/stores/assets'
import World from '@/components/World.vue'
import { useZoneStore } from '@/stores/zone'
import Hud from '@/components/gui/Hud.vue'
import Zone from '@/components/Zone.vue'
import Chat from '@/components/gui/Chat.vue'
import Menubar from '@/components/gui/Menu.vue'
import GmTools from '@/components/utilities/GmTools.vue'
import ZoneEditor from '@/components/utilities/zoneEditor/ZoneEditor.vue'
import GmPanel from '@/components/utilities/GmPanel.vue'
import Inventory from '@/components/utilities/inventory/Inventory.vue'
// import Inventory from '@/components/utilities/inventory/Inventory.vue'
const gameStore = useGameStore()
const zoneStore = useZoneStore()
const zoneEditorStore = useZoneEditorStore()
const assetStore = useAssetStore()
const isLoaded = ref(false)
const { assets } = storeToRefs(assetStore)
onBeforeUnmount(() => {
gameStore.disconnectSocket()
})
const gameConfig = {
name: 'New Quest',
width: window.innerWidth,
@ -161,10 +159,19 @@ const createScene = (scene: Phaser.Scene) => {
})
scene.load.start()
scene.load.once('complete', () => {
console.log('assets re-loaded')
})
// scene.load.once('complete', () => {})
})
}
gameStore.connection?.on('disconnect', () => {
game.scale.resize(window.innerWidth, window.innerHeight)
})
onBeforeMount(() => {
gameStore.connection?.emit('character:zone:request', { zoneId: gameStore.character?.zoneId })
})
onBeforeUnmount(() => {
gameStore.disconnectSocket()
})
</script>