Added Tauri config, updated character hair location logic (WIP)
This commit is contained in:
@ -1,9 +1,9 @@
|
||||
import config from '@/application/config'
|
||||
import { Direction } from '@/application/enums'
|
||||
import { type MapCharacter } from '@/application/types'
|
||||
import { type MapCharacter, type SpriteAction } from '@/application/types'
|
||||
import { calculateIsometricDepth, tileToWorldX, tileToWorldY } from '@/services/mapService'
|
||||
import { loadSpriteTextures } from '@/services/textureService'
|
||||
import { CharacterTypeStorage } from '@/storage/storages'
|
||||
import { CharacterTypeStorage, SpriteStorage } from '@/storage/storages'
|
||||
import { refObj } from 'phavuer'
|
||||
import { computed, ref } from 'vue'
|
||||
|
||||
@ -72,7 +72,7 @@ export function useCharacterSpriteComposable(scene: Phaser.Scene, tilemap: Phase
|
||||
// Add new listener
|
||||
characterSprite.value.on(Phaser.Animations.Events.ANIMATION_COMPLETE, () => {
|
||||
characterSprite.value!.setFrame(0)
|
||||
characterSprite.value!.setTexture(charTexture.value)
|
||||
characterSprite.value!.setTexture(spriteSpriteActionId.value)
|
||||
})
|
||||
|
||||
characterSprite.value.anims.play(
|
||||
@ -96,11 +96,27 @@ export function useCharacterSpriteComposable(scene: Phaser.Scene, tilemap: Phase
|
||||
return [0, 6].includes(mapCharacter.character.rotation ?? 0) ? 'left_up' : 'right_down'
|
||||
})
|
||||
|
||||
const getSpriteHeightByAction = async (action: string = '') => {
|
||||
if (!characterSpriteId.value) return 0
|
||||
const spriteStorage = new SpriteStorage()
|
||||
const sprite = await spriteStorage.getById(characterSpriteId.value)
|
||||
let actionWithDirection = `${currentAction.value}_${currentDirection.value}`
|
||||
if (action) actionWithDirection = action
|
||||
|
||||
return sprite?.spriteActions?.find(
|
||||
(spriteAction: SpriteAction) => spriteAction.action === actionWithDirection
|
||||
)?.frameHeight ?? 0
|
||||
}
|
||||
|
||||
const spriteHeight = computed(() =>
|
||||
getSpriteHeightByAction(currentAction.value)
|
||||
)
|
||||
|
||||
const currentAction = computed(() => {
|
||||
return mapCharacter.isMoving ? 'walk' : 'idle'
|
||||
})
|
||||
|
||||
const charTexture = computed(() => {
|
||||
const spriteSpriteActionId = computed(() => {
|
||||
const spriteId = characterSpriteId.value ?? 'idle_right_down'
|
||||
return `${spriteId}-${currentAction.value}_${currentDirection.value}`
|
||||
})
|
||||
@ -109,11 +125,11 @@ export function useCharacterSpriteComposable(scene: Phaser.Scene, tilemap: Phase
|
||||
if (!characterSprite.value) return
|
||||
|
||||
if (mapCharacter.isMoving) {
|
||||
characterSprite.value.anims.play(charTexture.value, true)
|
||||
characterSprite.value.anims.play(spriteSpriteActionId.value, true)
|
||||
} else {
|
||||
characterSprite.value.anims.stop()
|
||||
characterSprite.value.setFrame(0)
|
||||
characterSprite.value.setTexture(charTexture.value)
|
||||
characterSprite.value.setTexture(spriteSpriteActionId.value)
|
||||
}
|
||||
}
|
||||
|
||||
@ -130,7 +146,7 @@ export function useCharacterSpriteComposable(scene: Phaser.Scene, tilemap: Phase
|
||||
}
|
||||
|
||||
if (characterSprite.value) {
|
||||
characterSprite.value.setTexture(charTexture.value)
|
||||
characterSprite.value.setTexture(spriteSpriteActionId.value)
|
||||
characterSprite.value.setFlipX(isFlippedX.value)
|
||||
}
|
||||
|
||||
@ -146,10 +162,15 @@ export function useCharacterSpriteComposable(scene: Phaser.Scene, tilemap: Phase
|
||||
characterContainer,
|
||||
characterSpriteId,
|
||||
characterSprite,
|
||||
spriteHeight,
|
||||
currentAction,
|
||||
spriteSpriteActionId,
|
||||
currentPositionX,
|
||||
currentPositionY,
|
||||
currentDirection,
|
||||
isometricDepth,
|
||||
isFlippedX,
|
||||
getSpriteHeightByAction,
|
||||
updatePosition,
|
||||
playAnimation,
|
||||
calcDirection,
|
||||
|
Reference in New Issue
Block a user