diff --git a/scene/package.json b/scene/package.json index 63857c8..6a8906e 100644 --- a/scene/package.json +++ b/scene/package.json @@ -34,4 +34,4 @@ "dependencies": { "typescript": "^5.3.2" } -} \ No newline at end of file +} diff --git a/scene/src/effects/allEffects.ts b/scene/src/effects/allEffects.ts new file mode 100644 index 0000000..3fa7c05 --- /dev/null +++ b/scene/src/effects/allEffects.ts @@ -0,0 +1,668 @@ +import { + Animator, + AudioSource, + GltfContainer, + Transform, + engine +} from '@dcl/sdk/ecs' +import { Quaternion, Vector3 } from '@dcl/sdk/math' +import * as utils from '@dcl-sdk/utils' + +export const applyFullOrangeSkillEffectToLocation = ( + position: Vector3, + duration: number +): void => { + const area = engine.addEntity() + Transform.create(area, { + position, + rotation: Quaternion.create(0, 0, 0, 1), + scale: Vector3.create(1, 1, 1) + }) + GltfContainer.create(area, { + src: 'assets/models/Skill_FX/Orange_circle.glb' + }) + Animator.createOrReplace(area, { + states: [ + { + clip: 'idle', + playing: true, + loop: true + }, + { + clip: 'action', + playing: false, + loop: true + } + ] + }) + Animator.playSingleAnimation(area, 'action') + AudioSource.playSound(area, 'assets/sounds/attack.mp3') + utils.timers.setTimeout(() => { + engine.removeEntity(area) + }, duration) +} + +export const applyFullBlueSkillEffectToLocation = ( + position: Vector3, + duration: number +): void => { + const area = engine.addEntity() + Transform.create(area, { + position, + rotation: Quaternion.create(0, 0, 0, 1), + scale: Vector3.create(1, 1, 1) + }) + GltfContainer.create(area, { src: 'assets/models/Skill_FX/Blue_circle.glb' }) + Animator.createOrReplace(area, { + states: [ + { + clip: 'idle', + playing: true, + loop: true + }, + { + clip: 'action', + playing: false, + loop: true + } + ] + }) + Animator.playSingleAnimation(area, 'action') + AudioSource.playSound(area, 'assets/sounds/attack.mp3') + utils.timers.setTimeout(() => { + engine.removeEntity(area) + }, duration) +} + +export const applyFullRedSkillEffectToLocation = ( + position: Vector3, + duration: number +): void => { + const area = engine.addEntity() + Transform.create(area, { + position, + rotation: Quaternion.create(0, 0, 0, 1), + scale: Vector3.create(1, 1, 1) + }) + GltfContainer.create(area, { src: 'assets/models/Skill_FX/test.glb' }) + Animator.createOrReplace(area, { + states: [ + { + clip: 'idle', + playing: true, + loop: true + }, + { + clip: 'action', + playing: false, + loop: true + } + ] + }) + Animator.playSingleAnimation(area, 'action') + AudioSource.playSound(area, 'assets/sounds/attack.mp3') + utils.timers.setTimeout(() => { + engine.removeEntity(area) + }, duration) +} + +export const applyFullWhiteSkillEffectToLocation = ( + position: Vector3, + duration: number +): void => { + const area = engine.addEntity() + Transform.create(area, { + position, + rotation: Quaternion.create(0, 0, 0, 1), + scale: Vector3.create(1, 1, 1) + }) + GltfContainer.create(area, { src: 'assets/models/Skill_FX/white_circle.glb' }) + Animator.createOrReplace(area, { + states: [ + { + clip: 'idle', + playing: true, + loop: true + }, + { + clip: 'action', + playing: false, + loop: true + } + ] + }) + Animator.playSingleAnimation(area, 'action') + AudioSource.playSound(area, 'assets/sounds/attack.mp3') + utils.timers.setTimeout(() => { + engine.removeEntity(area) + }, duration) +} + +export const applyFullYellowSkillEffectToLocation = ( + position: Vector3, + duration: number +): void => { + const area = engine.addEntity() + Transform.create(area, { + position, + rotation: Quaternion.create(0, 0, 0, 1), + scale: Vector3.create(1, 1, 1) + }) + GltfContainer.create(area, { + src: 'assets/models/Skill_FX/Yellow_Circle.glb' + }) + Animator.createOrReplace(area, { + states: [ + { + clip: 'idle', + playing: true, + loop: true + }, + { + clip: 'action', + playing: false, + loop: true + } + ] + }) + Animator.playSingleAnimation(area, 'action') + AudioSource.playSound(area, 'assets/sounds/attack.mp3') + utils.timers.setTimeout(() => { + engine.removeEntity(area) + }, duration) +} + +export const applyFullGreenSkillEffectToLocation = ( + position: Vector3, + duration: number +): void => { + const area = engine.addEntity() + Transform.create(area, { + position, + rotation: Quaternion.create(0, 0, 0, 1), + scale: Vector3.create(1, 1, 1) + }) + GltfContainer.create(area, { + src: 'assets/models/Skill_FX/CharacterSelect.glb' + }) + Animator.createOrReplace(area, { + states: [ + { + clip: 'idle', + playing: true, + loop: true + }, + { + clip: 'action', + playing: false, + loop: true + } + ] + }) + Animator.playSingleAnimation(area, 'action') + AudioSource.playSound(area, 'assets/sounds/attack.mp3') + utils.timers.setTimeout(() => { + engine.removeEntity(area) + }, duration) +} + +export const applyRedSkillEffectToLocation = ( + position: Vector3, + duration: number +): void => { + const area = engine.addEntity() + Transform.create(area, { + position, + rotation: Quaternion.create(0, 0, 0, 1), + scale: Vector3.create(1, 1, 1) + }) + GltfContainer.create(area, { + src: 'assets/models/Skill_FX/EnemySelect.glb' + }) + Animator.createOrReplace(area, { + states: [ + { + clip: 'idle', + playing: true, + loop: true + }, + { + clip: 'action', + playing: false, + loop: true + } + ] + }) + Animator.playSingleAnimation(area, 'action') + AudioSource.playSound(area, 'assets/sounds/attack.mp3') + utils.timers.setTimeout(() => { + engine.removeEntity(area) + }, duration) +} + +export const applyEnemyAOESkillEffectToLocation = ( + position: Vector3, + duration: number +): void => { + const area = engine.addEntity() + Transform.create(area, { + position, + rotation: Quaternion.create(0, 0, 0, 1), + scale: Vector3.create(1, 1, 1) + }) + GltfContainer.create(area, { + src: 'assets/models/Skill_FX/Explosion.glb' + }) + Animator.createOrReplace(area, { + states: [ + { + clip: 'idle', + playing: true, + loop: true + }, + { + clip: 'action', + playing: false, + loop: true + } + ] + }) + Animator.playSingleAnimation(area, 'action') + AudioSource.playSound(area, 'assets/sounds/attack.mp3') + utils.timers.setTimeout(() => { + engine.removeEntity(area) + }, duration) +} + +export const applyEnemyAttackedMageEffectToLocation = ( + position: Vector3, + duration: number +): void => { + const area = engine.addEntity() + Transform.create(area, { + position, + rotation: Quaternion.create(0, 0, 0, 1), + scale: Vector3.create(1, 1, 1) + }) + GltfContainer.create(area, { + src: 'assets/models/Skill_FX/EnemySelect.glb' + }) + Animator.createOrReplace(area, { + states: [ + { + clip: 'idle', + playing: true, + loop: true + }, + { + clip: 'action', + playing: false, + loop: true + } + ] + }) + Animator.playSingleAnimation(area, 'action') + AudioSource.playSound(area, 'assets/sounds/attack.mp3') + utils.timers.setTimeout(() => { + engine.removeEntity(area) + }, duration) +} + +export const applyEnemyHealedEffectToLocation = (position: Vector3): void => { + const area = engine.addEntity() + Transform.create(area, { + position, + rotation: Quaternion.create(0, 0, 0, 1), + scale: Vector3.create(1, 1, 1) + }) + GltfContainer.create(area, { + src: 'assets/models/Skill_FX/heal.glb' + }) + Animator.createOrReplace(area, { + states: [ + { + clip: 'idle', + playing: true, + loop: true + }, + { + clip: 'action', + playing: false, + loop: true + } + ] + }) + Animator.playSingleAnimation(area, 'action') + AudioSource.playSound(area, 'assets/sounds/Heal.mp3') + utils.timers.setTimeout(() => { + engine.removeEntity(area) + }, 10000) +} + +export const applyMageAttackEffectToLocation = (position: Vector3): void => { + const area = engine.addEntity() + Transform.create(area, { + position, + rotation: Quaternion.create(0, 0, 0, 1), + scale: Vector3.create(1, 1, 1) + }) + GltfContainer.create(area, { + src: 'assets/models/Skill_FX/whiteswirl.glb' + }) + Animator.createOrReplace(area, { + states: [ + { + clip: 'idle', + playing: true, + loop: true + }, + { + clip: 'action', + playing: false, + loop: true + } + ] + }) + Animator.playSingleAnimation(area, 'action') + AudioSource.playSound(area, 'assets/sounds/Heal.mp3') + utils.timers.setTimeout(() => { + engine.removeEntity(area) + }, 10000) +} + +export const applyEnemySkillFireBallEffectToLocation = ( + position: Vector3, + duration: number +): void => { + const area = engine.addEntity() + Transform.create(area, { + position, + rotation: Quaternion.create(0, 0, 0, 1), + scale: Vector3.create(1, 1, 1) + }) + GltfContainer.create(area, { + src: 'assets/models/Skill_FX/Fire_VFX.glb' + }) + Animator.createOrReplace(area, { + states: [ + { + clip: 'idle', + playing: true, + loop: true + }, + { + clip: 'action', + playing: false, + loop: true + } + ] + }) + Animator.playSingleAnimation(area, 'action') + AudioSource.playSound(area, 'assets/sounds/Heal.mp3') + utils.timers.setTimeout(() => { + engine.removeEntity(area) + }, duration) +} + +export const applyGeneralSkillEffectToLocation = ( + position: Vector3, + duration: number +): void => { + const area = engine.addEntity() + Transform.create(area, { + position, + rotation: Quaternion.create(0, 0, 0, 1), + scale: Vector3.create(1, 1, 1) + }) + GltfContainer.create(area, { + src: 'assets/models/Skill_FX/Circular.glb' + }) + Animator.createOrReplace(area, { + states: [ + { + clip: 'idle', + playing: true, + loop: true + }, + { + clip: 'action', + playing: false, + loop: true + } + ] + }) + Animator.playSingleAnimation(area, 'action') + AudioSource.playSound(area, 'assets/sounds/attack.mp3') + utils.timers.setTimeout(() => { + engine.removeEntity(area) + }, duration) +} + +export const applyHealToLocation = ( + position: Vector3, + duration: number = 10000 +): void => { + const area = engine.addEntity() + Transform.create(area, { + position, + rotation: Quaternion.create(0, 0, 0, 1), + scale: Vector3.create(1, 1, 1) + }) + GltfContainer.create(area, { + src: 'assets/models/Skill_FX/heal.glb' + }) + Animator.createOrReplace(area, { + states: [ + { + clip: 'idle', + playing: true, + loop: true + }, + { + clip: 'heal', + playing: false, + loop: true + } + ] + }) + Animator.playSingleAnimation(area, 'heal') + AudioSource.playSound(area, 'assets/sounds/Heal.mp3') + utils.timers.setTimeout(() => { + engine.removeEntity(area) + }, duration) +} + +export const applyPlayerSkillBladesEffectToLocation = ( + position: Vector3, + duration: number = 10000 +): void => { + const area = engine.addEntity() + Transform.create(area, { + position, + rotation: Quaternion.create(0, 0, 0, 1), + scale: Vector3.create(1, 1, 1) + }) + GltfContainer.create(area, { + src: 'assets/models/Skill_FX/Sword_VFX.glb' + }) + Animator.createOrReplace(area, { + states: [ + { + clip: 'idle', + playing: true, + loop: true + }, + { + clip: 'VFX', + playing: false, + loop: true + } + ] + }) + Animator.playSingleAnimation(area, 'VFX') + AudioSource.playSound(area, 'assets/sounds/attack.mp3') + utils.timers.setTimeout(() => { + engine.removeEntity(area) + }, duration) +} + +export const applyPlayerSkillFireBallEffectToLocation = ( + position: Vector3, + duration: number +): void => { + const area = engine.addEntity() + Transform.create(area, { + position, + rotation: Quaternion.create(0, 0, 0, 1), + scale: Vector3.create(1, 1, 1) + }) + GltfContainer.create(area, { + src: 'assets/models/Skill_FX/Fire_VFX.glb' + }) + Animator.createOrReplace(area, { + states: [ + { + clip: 'idle', + playing: true, + loop: true + }, + { + clip: 'VFX', + playing: false, + loop: true + } + ] + }) + Animator.playSingleAnimation(area, 'VFX') + AudioSource.playSound(area, 'assets/sounds/attack.mp3') + utils.timers.setTimeout(() => { + engine.removeEntity(area) + }, duration) +} + +export const applyrelicEnergyToLocation = ( + position: Vector3, + duration: number +): void => { + const area = engine.addEntity() + Transform.create(area, { + position, + rotation: Quaternion.create(0, 0, 0, 1), + scale: Vector3.create(1, 1, 1) + }) + GltfContainer.create(area, { + src: 'assets/models/Skill_FX/Summon_a.glb' + }) + Animator.createOrReplace(area, { + states: [ + { + clip: 'idle', + playing: true, + loop: true + }, + { + clip: 'Plane L1 FXAction', + playing: false, + loop: true + } + ] + }) + Animator.playSingleAnimation(area, 'Plane L1 FXAction') + AudioSource.playSound(area, 'assets/sounds/Heal.mp3') + utils.timers.setTimeout(() => { + engine.removeEntity(area) + }, duration) +} + +export const applyAttackedEnemyEffectToLocation = ( + position: Vector3, + duration: number +): void => { + const area = engine.addEntity() + Transform.create(area, { + position, + rotation: Quaternion.create(0, 0, 0, 1), + scale: Vector3.create(1, 1, 1) + }) + GltfContainer.create(area, { + src: 'assets/models/Skill_FX/CharacterSelect.glb' + }) + Animator.createOrReplace(area, { + states: [ + { + clip: 'idle', + playing: true, + loop: true + }, + { + clip: 'action', + playing: false, + loop: true + } + ] + }) + Animator.playSingleAnimation(area, 'action') + AudioSource.playSound(area, 'assets/sounds/attack.mp3') + utils.timers.setTimeout(() => { + engine.removeEntity(area) + }, duration) +} + +export const applyCritToLocation = (position: Vector3): void => { + const area = engine.addEntity() + Transform.create(area, { + position, + rotation: Quaternion.create(0, 0, 0, 1), + scale: Vector3.create(1, 1, 1) + }) + GltfContainer.create(area, { src: 'assets/models/Skill_FX/Summon_b.glb' }) + const clip = 'Plane L1 FX.001Action.001' + Animator.createOrReplace(area, { + states: [ + { + clip, + playing: true, + loop: true + } + ] + }) + Animator.playSingleAnimation(area, clip) + + AudioSource.playSound(area, 'assets/sounds/Heal.mp3') + utils.timers.setTimeout(() => { + engine.removeEntity(area) + }, 2000) +} + +export const applyDefSkillEffectToEnemyLocation = ( + position: Vector3, + duration: number +): void => { + const area = engine.addEntity() + Transform.create(area, { + position, + rotation: Quaternion.create(0, 0, 0, 1), + scale: Vector3.create(1, 1, 1) + }) + GltfContainer.create(area, { src: 'assets/models/Skill_FX/ShieldSkill.glb' }) + Animator.createOrReplace(area, { + states: [ + { + clip: 'idle', + playing: true, + loop: true + }, + { + clip: 'action', + playing: false, + loop: true + } + ] + }) + Animator.playSingleAnimation(area, 'action') + + AudioSource.playSound(area, 'assets/sounds/attack.mp3') + utils.timers.setTimeout(() => { + engine.removeEntity(area) + }, duration) +} diff --git a/scene/src/effects/enemyDeffSkillActivation.ts b/scene/src/effects/enemyDeffSkillActivation.ts index e82ca62..cc6a6a5 100644 --- a/scene/src/effects/enemyDeffSkillActivation.ts +++ b/scene/src/effects/enemyDeffSkillActivation.ts @@ -1,35 +1,42 @@ -import { type Vector3 } from '@dcl/sdk/math' +import { + Animator, + AudioSource, + GltfContainer, + Transform, + engine +} from '@dcl/sdk/ecs' +import { Quaternion, Vector3 } from '@dcl/sdk/math' +import * as utils from '@dcl-sdk/utils' export const applyDefSkillEffectToEnemyLocation = ( position: Vector3, - duration?: number + duration: number ): void => { - // const area = new Entity("area") - // const transform60 = new Transform({ - // position, - // rotation: new Quaternion(0, 0, 0, 1), - // scale: new Vector3(1, 1, 1), - // }) - // area.addComponentOrReplace(transform60) - // const gltfShape20 = new GLTFShape("models/Skill_FX/ShieldSkill.glb") - // gltfShape20.visible = true - // area.addComponentOrReplace(gltfShape20) - // const clip = new AudioClip("sounds/attack.mp3") - // const attackSound = new AudioSource(clip) - // area.addComponent(attackSound) - // attackSound.volume = 0.5 - // let d2animator = new Animator() - // // Add animator component to the entity - // area.addComponent(d2animator) - // // Instance animation clip object - // const idleClip = new AnimationState("idle", { looping: true }) - // const actionClip = new AnimationState("action", { looping: true }) - // // Add animation clip to Animator component - // d2animator.addClip(idleClip) - // d2animator.addClip(actionClip) - // // Add entity to engine - // engine.addEntity(area) - // actionClip.play() - // attackSound.playOnce() - // setTimeout(duration, () => engine.removeEntity(area)) + const area = engine.addEntity() + Transform.create(area, { + position, + rotation: Quaternion.create(0, 0, 0, 1), + scale: Vector3.create(1, 1, 1) + }) + GltfContainer.create(area, { src: 'assets/models/Skill_FX/ShieldSkill.glb' }) + Animator.createOrReplace(area, { + states: [ + { + clip: 'idle', + playing: true, + loop: true + }, + { + clip: 'action', + playing: false, + loop: true + } + ] + }) + Animator.playSingleAnimation(area, 'action') + + AudioSource.playSound(area, 'assets/sounds/attack.mp3') + utils.timers.setTimeout(() => { + engine.removeEntity(area) + }, duration) }