npm run format

This commit is contained in:
2024-09-28 02:17:51 +02:00
parent 1105a53feb
commit 130df8f144
7 changed files with 79 additions and 73 deletions

View File

@ -22,7 +22,11 @@ import { watch, computed, ref, onMounted, onUnmounted } from 'vue'
import { Container, refObj, RoundRectangle, Sprite, Text } from 'phavuer'
import { calculateIsometricDepth, tileToWorldX, tileToWorldY } from '@/composables/zoneComposable'
enum Direction { POSITIVE, NEGATIVE, UNCHANGED }
enum Direction {
POSITIVE,
NEGATIVE,
UNCHANGED
}
const props = defineProps<{
layer: Phaser.Tilemaps.TilemapLayer
@ -113,13 +117,13 @@ const charTexture = computed(() => {
const updateSprite = () => {
if (props.character.isMoving) {
charSprite.value!.anims.play(charTexture.value, true);
return;
charSprite.value!.anims.play(charTexture.value, true)
return
}
charSprite.value!.anims.stop();
charSprite.value!.setFrame(0);
charSprite.value!.setTexture(charTexture.value);
charSprite.value!.anims.stop()
charSprite.value!.setFrame(0)
charSprite.value!.setTexture(charTexture.value)
}
const createChatBubble = (container: Phaser.GameObjects.Container) => {
@ -138,14 +142,17 @@ const createText = (text: Phaser.GameObjects.Text) => {
text.setFontFamily('Arial')
}
watch(() => props.character, (newChar, oldChar) => {
if (!newChar) return
watch(
() => props.character,
(newChar, oldChar) => {
if (!newChar) return
if (!oldChar || newChar.positionX !== oldChar.positionX || newChar.positionY !== oldChar.positionY) {
const direction = !oldChar ? Direction.POSITIVE : calcDirection(oldChar.positionX, oldChar.positionY, newChar.positionX, newChar.positionY)
updatePosition(newChar.positionX, newChar.positionY, direction)
if (!oldChar || newChar.positionX !== oldChar.positionX || newChar.positionY !== oldChar.positionY) {
const direction = !oldChar ? Direction.POSITIVE : calcDirection(oldChar.positionX, oldChar.positionY, newChar.positionX, newChar.positionY)
updatePosition(newChar.positionX, newChar.positionY, direction)
}
}
})
)
watch(() => props.character.isMoving, updateSprite)
watch(() => props.character.rotation, updateSprite)
@ -169,4 +176,4 @@ onMounted(() => {
onUnmounted(() => {
tween.value?.stop()
})
</script>
</script>