1
0
forked from noxious/client

npm run format

This commit is contained in:
2024-08-20 02:16:18 +02:00
parent a32d62417a
commit ed28a3213f
11 changed files with 198 additions and 200 deletions

View File

@ -1,26 +1,10 @@
<template>
<Container
v-if="props.character"
:x="currentX"
:y="currentY"
>
<Text
@create="createText"
:text="props.character.name"
:origin-x="0.5"
:origin-y="9"
/>
<Container v-if="props.character" :x="currentX" :y="currentY">
<Text @create="createText" :text="props.character.name" :origin-x="0.5" :origin-y="9" />
<RoundRectangle :origin-x="0.5" :origin-y="18.5" :fillColor="0xffffff" :width="74" :height="6" :radius="5" />
<RoundRectangle :origin-x="0.5" :origin-y="36.4" :fillColor="0x09ad19" :width="70" :height="3" :radius="5" />
<RoundRectangle :origin-x="0.5" :origin-y="36.4" :fillColor="0x00b3b3" :width="70" :height="3" :radius="5" />
<Image v-if="!props.character.characterType" texture="character" :origin-y="1" />
<Sprite
v-else
:texture="charTexture"
:play="props.character.isMoving ? charTexture : undefined"
:origin-y="1"
:flipX="props.character.rotation === 6 || props.character.rotation === 4"
:flipY="false"
/>
<Sprite v-else :texture="charTexture" :play="props.character.isMoving ? charTexture : undefined" :origin-y="1" :flipX="props.character.rotation === 6 || props.character.rotation === 4" :flipY="false" />
</Container>
</template>
@ -71,17 +55,21 @@ const updatePosition = (x: number, y: number) => {
onUpdate: (tween) => {
currentX.value = tween.targets[0].x ?? 0
currentY.value = tween.targets[0].y ?? 0
},
}
})
}
watch(() => props.character, (newChar, oldChar) => {
if (newChar) {
if (!oldChar || newChar.position_x !== oldChar.position_x || newChar.position_y !== oldChar.position_y) {
updatePosition(newChar.position_x, newChar.position_y)
watch(
() => props.character,
(newChar, oldChar) => {
if (newChar) {
if (!oldChar || newChar.position_x !== oldChar.position_x || newChar.position_y !== oldChar.position_y) {
updatePosition(newChar.position_x, newChar.position_y)
}
}
}
}, { immediate: true, deep: true })
},
{ immediate: true, deep: true }
)
const charTexture = computed(() => {
if (!props.character?.characterType?.sprite) {
@ -102,6 +90,7 @@ const charTexture = computed(() => {
})
const createText = (text: Phaser.GameObjects.Text) => {
text.setColor('#ffffff')
text.setFontSize(13)
text.setFontFamily('Arial')
}
@ -117,4 +106,4 @@ onUnmounted(() => {
tween.value.stop()
}
})
</script>
</script>