1
0
forked from noxious/client

Fixed modal fullscreen icons, made types compatible with server changes made for #174, npm update, npm run format, minor improvements

This commit is contained in:
2024-11-13 13:22:20 +01:00
parent 48fef2313b
commit 1888521762
11 changed files with 192 additions and 198 deletions

View File

@ -6,7 +6,7 @@
</Container>
<!-- Character name and health -->
<Container :depth="999" :x="currentX" :y="currentY">
<Text @create="createNicknameText" :text="character.name" />
<Text @create="createNicknameText" :text="props.zoneCharacter.character.name" />
<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="0x00b3b3" :width="70" :height="3" :radius="5" />
</Container>
@ -18,7 +18,7 @@
<script lang="ts" setup>
import config from '@/config'
import { type ExtendedCharacter, type Sprite as SpriteT } from '@/types'
import { type Sprite as SpriteT, type ZoneCharacter } from '@/types'
import { useGameStore } from '@/stores/gameStore'
import { useZoneStore } from '@/stores/zoneStore'
import { watch, computed, ref, onMounted, onUnmounted } from 'vue'
@ -34,7 +34,7 @@ enum Direction {
const props = defineProps<{
layer: Phaser.Tilemaps.TilemapLayer
character: ExtendedCharacter
zoneCharacter: ZoneCharacter
}>()
const charChatContainer = refObj<Phaser.GameObjects.Container>()
@ -110,19 +110,19 @@ const calcDirection = (oldX: number, oldY: number, newX: number, newY: number):
return Direction.UNCHANGED
}
const isFlippedX = computed(() => [6, 4].includes(props.character.rotation ?? 0))
const isFlippedX = computed(() => [6, 4].includes(props.zoneCharacter.character.rotation ?? 0))
const charTexture = computed(() => {
const { rotation, characterType, isMoving } = props.character
const { rotation, characterType } = props.zoneCharacter.character
const spriteId = characterType?.sprite?.id ?? 'idle_right_down'
const action = isMoving ? 'walk' : 'idle'
const action = props.zoneCharacter.isMoving ? 'walk' : 'idle'
const direction = [0, 6].includes(rotation) ? 'left_up' : 'right_down'
return `${spriteId}-${action}_${direction}`
})
const updateSprite = () => {
if (props.character.isMoving) {
if (props.zoneCharacter.isMoving) {
charSprite.value!.anims.play(charTexture.value, true)
return
}
@ -133,11 +133,11 @@ const updateSprite = () => {
}
const createChatBubble = (container: Phaser.GameObjects.Container) => {
container.setName(`${props.character.name}_chatBubble`)
container.setName(`${props.zoneCharacter.character.name}_chatBubble`)
}
const createChatText = (text: Phaser.GameObjects.Text) => {
text.setName(`${props.character.name}_chatText`)
text.setName(`${props.zoneCharacter.character.name}_chatText`)
text.setFontSize(13)
text.setFontFamily('Arial')
text.setOrigin(0.5, 10.9)
@ -168,7 +168,7 @@ const createNicknameText = (text: Phaser.GameObjects.Text) => {
}
watch(
() => props.character,
() => props.zoneCharacter.character,
(newChar, oldChar) => {
if (!newChar) return
@ -179,10 +179,9 @@ watch(
}
)
watch(() => props.character.isMoving, updateSprite)
watch(() => props.character.rotation, updateSprite)
watch(() => props.zoneCharacter, updateSprite)
loadSpriteTextures(scene, props.character.characterType?.sprite as SpriteT)
loadSpriteTextures(scene, props.zoneCharacter.character.characterType?.sprite as SpriteT)
.then(() => {
charSprite.value!.setTexture(charTexture.value)
charSprite.value!.setFlipX(isFlippedX.value)
@ -192,11 +191,11 @@ loadSpriteTextures(scene, props.character.characterType?.sprite as SpriteT)
})
onMounted(() => {
charChatContainer.value!.setName(`${props.character!.name}_chatContainer`)
charChatContainer.value!.setName(`${props.zoneCharacter.character!.name}_chatContainer`)
charChatContainer.value!.setVisible(false)
charContainer.value!.setName(props.character!.name)
charContainer.value!.setName(props.zoneCharacter.character!.name)
if (props.character.id === gameStore.character!.id) {
if (props.zoneCharacter.character.id === gameStore.character!.id) {
zoneStore.setCharacterLoaded(true)
// #146 : Set camera position to character, need to be improved still
@ -204,7 +203,7 @@ onMounted(() => {
scene.cameras.main.stopFollow()
}
updatePosition(props.character.positionX, props.character.positionY, props.character.rotation)
updatePosition(props.zoneCharacter.character.positionX, props.zoneCharacter.character.positionY, props.zoneCharacter.character.rotation)
})
onUnmounted(() => {