npm run format
This commit is contained in:
parent
1105a53feb
commit
130df8f144
@ -59,7 +59,7 @@ const scrollToBottom = () => {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
gameStore.connection?.on('chat:message', (data: ChatMessage) => {
|
gameStore.connection?.on('chat:message', (data: ChatMessage) => {
|
||||||
chats.value.push(data)
|
chats.value.push(data)
|
||||||
scrollToBottom()
|
scrollToBottom()
|
||||||
|
|
||||||
@ -74,20 +74,20 @@ const scrollToBottom = () => {
|
|||||||
|
|
||||||
function calculateTextWidth(text: string, font: string, fontSize: number): number {
|
function calculateTextWidth(text: string, font: string, fontSize: number): number {
|
||||||
// Create a canvas element
|
// Create a canvas element
|
||||||
const canvas = document.createElement('canvas');
|
const canvas = document.createElement('canvas')
|
||||||
const context = canvas.getContext('2d');
|
const context = canvas.getContext('2d')
|
||||||
|
|
||||||
if (!context) {
|
if (!context) {
|
||||||
throw new Error('Unable to create canvas context');
|
throw new Error('Unable to create canvas context')
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set the font
|
// Set the font
|
||||||
context.font = `${fontSize}px ${font}`;
|
context.font = `${fontSize}px ${font}`
|
||||||
|
|
||||||
// Measure the text width
|
// Measure the text width
|
||||||
const metrics = context.measureText(text);
|
const metrics = context.measureText(text)
|
||||||
|
|
||||||
return metrics.width;
|
return metrics.width
|
||||||
}
|
}
|
||||||
|
|
||||||
chatBubble.width = calculateTextWidth(data.message, 'Arial', 13) + 10
|
chatBubble.width = calculateTextWidth(data.message, 'Arial', 13) + 10
|
||||||
@ -111,8 +111,8 @@ const scrollToBottom = () => {
|
|||||||
|
|
||||||
// Store the timer on the container itself
|
// Store the timer on the container itself
|
||||||
charChatContainer.setData('hideTimer', hideTimer)
|
charChatContainer.setData('hideTimer', hideTimer)
|
||||||
})
|
})
|
||||||
scrollToBottom()
|
scrollToBottom()
|
||||||
|
|
||||||
onBeforeUnmount(() => {
|
onBeforeUnmount(() => {
|
||||||
gameStore.connection?.off('chat:message')
|
gameStore.connection?.off('chat:message')
|
||||||
|
@ -22,7 +22,11 @@ import { watch, computed, ref, onMounted, onUnmounted } from 'vue'
|
|||||||
import { Container, refObj, RoundRectangle, Sprite, Text } from 'phavuer'
|
import { Container, refObj, RoundRectangle, Sprite, Text } from 'phavuer'
|
||||||
import { calculateIsometricDepth, tileToWorldX, tileToWorldY } from '@/composables/zoneComposable'
|
import { calculateIsometricDepth, tileToWorldX, tileToWorldY } from '@/composables/zoneComposable'
|
||||||
|
|
||||||
enum Direction { POSITIVE, NEGATIVE, UNCHANGED }
|
enum Direction {
|
||||||
|
POSITIVE,
|
||||||
|
NEGATIVE,
|
||||||
|
UNCHANGED
|
||||||
|
}
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
layer: Phaser.Tilemaps.TilemapLayer
|
layer: Phaser.Tilemaps.TilemapLayer
|
||||||
@ -113,13 +117,13 @@ const charTexture = computed(() => {
|
|||||||
|
|
||||||
const updateSprite = () => {
|
const updateSprite = () => {
|
||||||
if (props.character.isMoving) {
|
if (props.character.isMoving) {
|
||||||
charSprite.value!.anims.play(charTexture.value, true);
|
charSprite.value!.anims.play(charTexture.value, true)
|
||||||
return;
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
charSprite.value!.anims.stop();
|
charSprite.value!.anims.stop()
|
||||||
charSprite.value!.setFrame(0);
|
charSprite.value!.setFrame(0)
|
||||||
charSprite.value!.setTexture(charTexture.value);
|
charSprite.value!.setTexture(charTexture.value)
|
||||||
}
|
}
|
||||||
|
|
||||||
const createChatBubble = (container: Phaser.GameObjects.Container) => {
|
const createChatBubble = (container: Phaser.GameObjects.Container) => {
|
||||||
@ -138,14 +142,17 @@ const createText = (text: Phaser.GameObjects.Text) => {
|
|||||||
text.setFontFamily('Arial')
|
text.setFontFamily('Arial')
|
||||||
}
|
}
|
||||||
|
|
||||||
watch(() => props.character, (newChar, oldChar) => {
|
watch(
|
||||||
|
() => props.character,
|
||||||
|
(newChar, oldChar) => {
|
||||||
if (!newChar) return
|
if (!newChar) return
|
||||||
|
|
||||||
if (!oldChar || newChar.positionX !== oldChar.positionX || newChar.positionY !== oldChar.positionY) {
|
if (!oldChar || newChar.positionX !== oldChar.positionX || newChar.positionY !== oldChar.positionY) {
|
||||||
const direction = !oldChar ? Direction.POSITIVE : calcDirection(oldChar.positionX, oldChar.positionY, newChar.positionX, newChar.positionY)
|
const direction = !oldChar ? Direction.POSITIVE : calcDirection(oldChar.positionX, oldChar.positionY, newChar.positionX, newChar.positionY)
|
||||||
updatePosition(newChar.positionX, newChar.positionY, direction)
|
updatePosition(newChar.positionX, newChar.positionY, direction)
|
||||||
}
|
}
|
||||||
})
|
}
|
||||||
|
)
|
||||||
|
|
||||||
watch(() => props.character.isMoving, updateSprite)
|
watch(() => props.character.isMoving, updateSprite)
|
||||||
watch(() => props.character.rotation, updateSprite)
|
watch(() => props.character.rotation, updateSprite)
|
||||||
|
@ -18,7 +18,7 @@ export function useCameraControls(scene: Phaser.Scene): any {
|
|||||||
watch(
|
watch(
|
||||||
() => zoneStore.characterLoaded,
|
() => zoneStore.characterLoaded,
|
||||||
(characterLoaded) => {
|
(characterLoaded) => {
|
||||||
if(!characterLoaded) return;
|
if (!characterLoaded) return
|
||||||
// scene.cameras.main.startFollow(scene.children.getByName(gameStore.character!.name) as Phaser.GameObjects.Container);
|
// scene.cameras.main.startFollow(scene.children.getByName(gameStore.character!.name) as Phaser.GameObjects.Container);
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
@ -5,7 +5,7 @@ export const useZoneStore = defineStore('zone', {
|
|||||||
state: () => ({
|
state: () => ({
|
||||||
zone: null as Zone | null,
|
zone: null as Zone | null,
|
||||||
characters: [] as ExtendedCharacter[],
|
characters: [] as ExtendedCharacter[],
|
||||||
characterLoaded: false,
|
characterLoaded: false
|
||||||
}),
|
}),
|
||||||
getters: {
|
getters: {
|
||||||
getCharacterById: (state) => {
|
getCharacterById: (state) => {
|
||||||
@ -42,8 +42,7 @@ export const useZoneStore = defineStore('zone', {
|
|||||||
},
|
},
|
||||||
reset() {
|
reset() {
|
||||||
this.zone = null
|
this.zone = null
|
||||||
this.characters = [],
|
;(this.characters = []), (this.characterLoaded = false)
|
||||||
this.characterLoaded = false
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user