From e8e3867cae7dcc1fd5460e3eb7d573b86f600e39 Mon Sep 17 00:00:00 2001 From: Giorgio <65674128+Gaffomdz@users.noreply.github.com> Date: Tue, 30 Jul 2024 12:57:32 +0200 Subject: [PATCH 01/13] feat: autoBattle, DesertDungeon and MinersCave added --- .DS_Store | Bin 6148 -> 6148 bytes scene/src/controllers/realm.controller.ts | 2 +- scene/src/controllers/ui.controller.tsx | 5 + scene/src/counters.ts | 1 + scene/src/enemies/Executioner.ts | 4 +- scene/src/enemies/ExecutionerCaveDungeon.ts | 177 ++++++++++ scene/src/enemies/ExecutionerDesertDungeon.ts | 177 ++++++++++ scene/src/enemies/MonsterMob.ts | 8 +- .../desertBosses/EasyDesertDungeonBoss.ts | 10 +- scene/src/enemies/monster.ts | 2 +- scene/src/enemies/monsterAttack.ts | 7 +- scene/src/enemies/monsterGeneric.ts | 2 +- scene/src/enemies/monsterMeat.ts | 6 +- scene/src/enemies/monsterMobAuto.ts | 9 +- scene/src/enemies/pig.ts | 2 + scene/src/mineables.ts | 38 ++- scene/src/realms/antrom.ts | 7 +- scene/src/realms/dungeon.ts | 302 +++++------------- scene/src/realms/minerscave.ts | 71 +++- scene/src/realms/types.ts | 2 + scene/src/scenes/main.tsx | 2 +- scene/src/ui/dungeon/playDungeon.tsx | 5 + 22 files changed, 562 insertions(+), 277 deletions(-) create mode 100644 scene/src/enemies/ExecutionerCaveDungeon.ts create mode 100644 scene/src/enemies/ExecutionerDesertDungeon.ts diff --git a/.DS_Store b/.DS_Store index d64fb0cc69f46e1d1473748d37d2898bab1d32ee..afbfefcd7b3f00e19c1d408352468c3b10128958 100644 GIT binary patch delta 20 bcmZoMXffEJ!pv@DW}u^BY_eIK`KAZ}Il2X4 delta 20 bcmZoMXffEJ!pv@LX{4iIWV~6M`KAZ}Iqn5y diff --git a/scene/src/controllers/realm.controller.ts b/scene/src/controllers/realm.controller.ts index f6b5b43..e455996 100644 --- a/scene/src/controllers/realm.controller.ts +++ b/scene/src/controllers/realm.controller.ts @@ -15,7 +15,7 @@ export class RealmController { this.gameController = gameController } - switchRealm(realm: RealmType): void { + switchRealm(realm: RealmType, difficulty: string): void { this.cleanUpScene() // TODO: utils and npc library should be cleaned as well diff --git a/scene/src/controllers/ui.controller.tsx b/scene/src/controllers/ui.controller.tsx index 03efe8b..75465e0 100644 --- a/scene/src/controllers/ui.controller.tsx +++ b/scene/src/controllers/ui.controller.tsx @@ -17,6 +17,7 @@ import { LoadingUI } from '../ui/loading/loading' import { CreationPlayerController } from './creation-player.controller' import { type GameController } from './game.controller' import { MainHudController } from './main-hud' +import { type RealmType } from '../realms/types' export class UIController { loadingUI: LoadingUI @@ -53,6 +54,10 @@ export class UIController { this.mainHud = new MainHudController() } + loadRealm(realm: RealmType, difficulty: string): void { + this.gameController.realmController.switchRealm(realm, difficulty) + } + displayAnnouncement( announcement: string, color: Color4 = Color4.Yellow(), diff --git a/scene/src/counters.ts b/scene/src/counters.ts index 73a99ae..26f455a 100644 --- a/scene/src/counters.ts +++ b/scene/src/counters.ts @@ -7,5 +7,6 @@ export const jailGuards = new UICounter() export const jailOpenOnce = new UICounter() export const demonKill = new UICounter() export const DungeonStage = new UICounter() +export const desertDungeonMonsterCount = new UICounter() demonKill.set(1) diff --git a/scene/src/enemies/Executioner.ts b/scene/src/enemies/Executioner.ts index 46682ab..5fad625 100644 --- a/scene/src/enemies/Executioner.ts +++ b/scene/src/enemies/Executioner.ts @@ -1,11 +1,11 @@ import { Transform } from '@dcl/sdk/ecs' import { Color4, Quaternion, Vector3 } from '@dcl/sdk/math' -import MonsterMob from './MonsterMob' import { LEVEL_TYPES } from '../player/LevelManager' import { Player } from '../player/player' import { BannerType } from '../ui/banner/bannerConstants' import { ITEM_TYPES } from '../inventory/playerInventoryMap' import { entityController } from '../realms/entityController' +import MonsterMobAuto from './monsterMobAuto' function getRandomIntRange(min: number, max: number): number { min = Math.ceil(min) @@ -13,7 +13,7 @@ function getRandomIntRange(min: number, max: number): number { return Math.floor(Math.random() * (max - min + 1)) + min } -export default class Executioner extends MonsterMob { +export default class Executioner extends MonsterMobAuto { shapeFile = 'assets/models/ExecutionerAxe.glb' hoverText: string diff --git a/scene/src/enemies/ExecutionerCaveDungeon.ts b/scene/src/enemies/ExecutionerCaveDungeon.ts new file mode 100644 index 0000000..91a88ca --- /dev/null +++ b/scene/src/enemies/ExecutionerCaveDungeon.ts @@ -0,0 +1,177 @@ +import { Color4, Quaternion, Vector3 } from '@dcl/sdk/math' +import { LEVEL_TYPES } from '../player/LevelManager' +import MonsterMob from './MonsterMob' +import { Player } from '../player/player' +import { type GameController } from '../controllers/game.controller' +import { DungeonStage, desertDungeonMonsterCount } from '../counters' +import { Transform } from '@dcl/sdk/ecs' +import { getRandomInt, getRandomIntRange } from '../utils/getRandomInt' +import { ITEM_TYPES } from '../inventory/playerInventoryMap' + +export default class ExecutionerCaveDungeon extends MonsterMob { + shapeFile = 'assets/models/RockMonster.glb' + hoverText = `Attack Metapsammite Disciple!` + + gameController: GameController + constructor(gameController: GameController, initialPos: Vector3) { + const player = Player.getInstanceOrNull() + const level = player?.levels.getLevel(LEVEL_TYPES.PLAYER) ?? 1 + const stage = DungeonStage.read() + super(5 + stage * 7, level + 100, level + 1, 10) + this.gameController = gameController + this.minLuck = 20 + + Transform.createOrReplace(this.entity, { + position: Vector3.create(0, 0, 0) + }) + this.initMonster() + super.setupEngageTriggerBox() + this.loadTransformation(initialPos) + this.setTopOffset(2.25) + this.dropRate = -2 + } + + onDropXp(): void { + const xp = getRandomIntRange(this.xp, this.xp + 10) + console.log(xp) + desertDungeonMonsterCount.increase(1) + + // let damage = player.levels.getLevel(LEVEL_TYPES.PLAYER) * 5 + // if (player.levels.getLevel(LEVEL_TYPES.PLAYER) >= 60) { + // damage = player.levels.getLevel(LEVEL_TYPES.PLAYER) * 10 + // } + + // const doorOpeningSource = globalThis.doorOpeningSource + + // ui.displayAnnouncement(`${easyDungeonMonsterCount1.read()}`) + + if (desertDungeonMonsterCount.read() === 1) { + this.gameController.uiController.displayAnnouncement( + 'Cube Removed!', + Color4.Yellow(), + 2000 + ) + if ( + this.gameController.realmController.currentRealm?.removeSingleEntity !== + undefined + ) { + this.gameController.realmController.currentRealm?.removeSingleEntity( + 'wall6' + ) + } + // TODO lerp animation + } + + if (desertDungeonMonsterCount.read() === 2) { + this.gameController.uiController.displayAnnouncement( + 'Cube Removed!', + Color4.Yellow(), + 2000 + ) + if ( + this.gameController.realmController.currentRealm?.removeSingleEntity !== + undefined + ) { + this.gameController.realmController.currentRealm?.removeSingleEntity( + 'wall5' + ) + } + } + + if (desertDungeonMonsterCount.read() === 3) { + this.gameController.uiController.displayAnnouncement( + 'Cube Removed!', + Color4.Yellow(), + 2000 + ) + if ( + this.gameController.realmController.currentRealm?.removeSingleEntity !== + undefined + ) { + this.gameController.realmController.currentRealm?.removeSingleEntity( + 'wall4' + ) + } + } + + if (desertDungeonMonsterCount.read() === 4) { + this.gameController.uiController.displayAnnouncement( + 'Cube Removed!', + Color4.Yellow(), + 2000 + ) + if ( + this.gameController.realmController.currentRealm?.removeSingleEntity !== + undefined + ) { + this.gameController.realmController.currentRealm?.removeSingleEntity( + 'wall3' + ) + } + } + + if (desertDungeonMonsterCount.read() === 5) { + this.gameController.uiController.displayAnnouncement( + 'Cube Removed!', + Color4.Yellow(), + 2000 + ) + if ( + this.gameController.realmController.currentRealm?.removeSingleEntity !== + undefined + ) { + this.gameController.realmController.currentRealm?.removeSingleEntity( + 'wall1' + ) + } + desertDungeonMonsterCount.decrease(47) + } + + const exp = [ + { + type: LEVEL_TYPES.ENEMY, + value: 1 + }, + { + type: LEVEL_TYPES.PLAYER, + value: xp + } + ] + const loot = [ + { + type: ITEM_TYPES.BONE, + value: 1 + } + ] + console.log(exp, loot) + // UI ? addRewards(exp, loot) + // DailyQuestHUD.getInstance().listenAndUpdateForAnyActiveQuest( + // LEVEL_TYPES.ENEMY + // ) + } + + onDropLoot(): void {} + + setupAttackTriggerBox(): void { + super.setupAttackTriggerBox() + } + + create(): void {} + + loadTransformation(initialPos: Vector3): void { + const initialPosition = Vector3.create( + initialPos.x, + initialPos.y, + initialPos.z + ) + const initialRotation = Quaternion.fromEulerDegrees( + 0, + getRandomInt(10) / 10 + getRandomInt(4), + 0 + ) + Transform.createOrReplace(this.entity, { + position: initialPosition, + rotation: initialRotation + }) + } +} diff --git a/scene/src/enemies/ExecutionerDesertDungeon.ts b/scene/src/enemies/ExecutionerDesertDungeon.ts new file mode 100644 index 0000000..47ba982 --- /dev/null +++ b/scene/src/enemies/ExecutionerDesertDungeon.ts @@ -0,0 +1,177 @@ +import { Color4, Quaternion, Vector3 } from '@dcl/sdk/math' +import { LEVEL_TYPES } from '../player/LevelManager' +import MonsterMob from './MonsterMob' +import { Player } from '../player/player' +import { type GameController } from '../controllers/game.controller' +import { DungeonStage, desertDungeonMonsterCount } from '../counters' +import { Transform } from '@dcl/sdk/ecs' +import { getRandomInt, getRandomIntRange } from '../utils/getRandomInt' +import { ITEM_TYPES } from '../inventory/playerInventoryMap' + +export default class ExecutionerDesertDungeon extends MonsterMob { + shapeFile = 'assets/models/desertnpcM.glb' + hoverText = `Attack Apex Ahau Disciple!` + + gameController: GameController + constructor(gameController: GameController, initialPos: Vector3) { + const player = Player.getInstanceOrNull() + const level = player?.levels.getLevel(LEVEL_TYPES.PLAYER) ?? 1 + const stage = DungeonStage.read() + super(5 + stage * 7, level + 100, level + 1, 10) + this.gameController = gameController + this.minLuck = 20 + + Transform.createOrReplace(this.entity, { + position: Vector3.create(0, 0, 0) + }) + this.initMonster() + super.setupEngageTriggerBox() + this.loadTransformation(initialPos) + this.setTopOffset(2.25) + this.dropRate = -2 + } + + onDropXp(): void { + const xp = getRandomIntRange(this.xp, this.xp + 10) + console.log(xp) + desertDungeonMonsterCount.increase(1) + + // let damage = player.levels.getLevel(LEVEL_TYPES.PLAYER) * 5 + // if (player.levels.getLevel(LEVEL_TYPES.PLAYER) >= 60) { + // damage = player.levels.getLevel(LEVEL_TYPES.PLAYER) * 10 + // } + + // const doorOpeningSource = globalThis.doorOpeningSource + + // ui.displayAnnouncement(`${easyDungeonMonsterCount1.read()}`) + + if (desertDungeonMonsterCount.read() === 1) { + this.gameController.uiController.displayAnnouncement( + 'room 1 opens', + Color4.Yellow(), + 2000 + ) + if ( + this.gameController.realmController.currentRealm?.removeSingleEntity !== + undefined + ) { + this.gameController.realmController.currentRealm?.removeSingleEntity( + 'wall6' + ) + } + // TODO lerp animation + } + + if (desertDungeonMonsterCount.read() === 2) { + this.gameController.uiController.displayAnnouncement( + 'room 2 opens', + Color4.Yellow(), + 2000 + ) + if ( + this.gameController.realmController.currentRealm?.removeSingleEntity !== + undefined + ) { + this.gameController.realmController.currentRealm?.removeSingleEntity( + 'wall5' + ) + } + } + + if (desertDungeonMonsterCount.read() === 3) { + this.gameController.uiController.displayAnnouncement( + 'room 3 opens', + Color4.Yellow(), + 2000 + ) + if ( + this.gameController.realmController.currentRealm?.removeSingleEntity !== + undefined + ) { + this.gameController.realmController.currentRealm?.removeSingleEntity( + 'wall4' + ) + } + } + + if (desertDungeonMonsterCount.read() === 4) { + this.gameController.uiController.displayAnnouncement( + 'room 4 opens', + Color4.Yellow(), + 2000 + ) + if ( + this.gameController.realmController.currentRealm?.removeSingleEntity !== + undefined + ) { + this.gameController.realmController.currentRealm?.removeSingleEntity( + 'wall3' + ) + } + } + + if (desertDungeonMonsterCount.read() === 5) { + this.gameController.uiController.displayAnnouncement( + 'room 6 opens', + Color4.Yellow(), + 2000 + ) + if ( + this.gameController.realmController.currentRealm?.removeSingleEntity !== + undefined + ) { + this.gameController.realmController.currentRealm?.removeSingleEntity( + 'wall1' + ) + } + desertDungeonMonsterCount.decrease(47) + } + + const exp = [ + { + type: LEVEL_TYPES.ENEMY, + value: 1 + }, + { + type: LEVEL_TYPES.PLAYER, + value: xp + } + ] + const loot = [ + { + type: ITEM_TYPES.BONE, + value: 1 + } + ] + console.log(exp, loot) + // UI ? addRewards(exp, loot) + // DailyQuestHUD.getInstance().listenAndUpdateForAnyActiveQuest( + // LEVEL_TYPES.ENEMY + // ) + } + + onDropLoot(): void {} + + setupAttackTriggerBox(): void { + super.setupAttackTriggerBox() + } + + create(): void {} + + loadTransformation(initialPos: Vector3): void { + const initialPosition = Vector3.create( + initialPos.x, + initialPos.y, + initialPos.z + ) + const initialRotation = Quaternion.fromEulerDegrees( + 0, + getRandomInt(10) / 10 + getRandomInt(4), + 0 + ) + Transform.createOrReplace(this.entity, { + position: initialPosition, + rotation: initialRotation + }) + } +} diff --git a/scene/src/enemies/MonsterMob.ts b/scene/src/enemies/MonsterMob.ts index eac9a61..cd9b7bf 100644 --- a/scene/src/enemies/MonsterMob.ts +++ b/scene/src/enemies/MonsterMob.ts @@ -107,9 +107,9 @@ export class MonsterMob extends GenericMonster { ] }) - this.setupRangedAttackTriggerBox() + // this.setupRangedAttackTriggerBox() // this.setupEngageTriggerBox() - this.setupAttackTriggerBox() + // this.setupAttackTriggerBox() this.attackSystem = new MonsterAttack(this, { moveSpeed: 2, @@ -149,7 +149,7 @@ export class MonsterMob extends GenericMonster { throw new Error('onDropXp is required to be implemented for this monster') } - loadTransformation(): void { + loadTransformation(pos: Vector3): void { // function needs to be implemented per individual monster throw new Error( 'loadTransformation is required to be implemented for this monster' @@ -195,6 +195,7 @@ export class MonsterMob extends GenericMonster { [{ type: 'box', scale: Vector3.create(16, 2, 15) }], () => { engine.addSystem(this.attackSystem.attackSystem) + Animator.playSingleAnimation(this.entity, this.attackClip, false) }, () => { console.log('im out') @@ -303,7 +304,6 @@ export class MonsterMob extends GenericMonster { this.updateHealthBar() if (isCriticalAttack) { - // UI from ui.ts // showCriticalIcon() } diff --git a/scene/src/enemies/desertBosses/EasyDesertDungeonBoss.ts b/scene/src/enemies/desertBosses/EasyDesertDungeonBoss.ts index ac228e4..b377df8 100644 --- a/scene/src/enemies/desertBosses/EasyDesertDungeonBoss.ts +++ b/scene/src/enemies/desertBosses/EasyDesertDungeonBoss.ts @@ -1,11 +1,11 @@ import { Transform } from '@dcl/sdk/ecs' -import MonsterOligar from '../monster' import { Quaternion, Vector3 } from '@dcl/sdk/math' import { Player } from '../../player/player' import { quest } from '../../utils/refresherTimer' import { LEVEL_TYPES } from '../../player/LevelManager' import { ITEM_TYPES } from '../../inventory/playerInventoryMap' import { backToAntrom } from './NightmareDesertDungeonBoss' +import MonsterMob from '../MonsterMob' // const DEFAULT_ATTACK = 35 const DEFAULT_XP = 60 @@ -13,18 +13,16 @@ const DEFAULT_XP = 60 // const DEFAULT_HP = 200 // const DEFAULT_DEF = 0.1 -export default class EasyDesertDungeonBoss extends MonsterOligar { +export default class EasyDesertDungeonBoss extends MonsterMob { shapeFile = 'assets/models/SandBoss.glb' hoverText = `Attack Wasteland Apex Ahau!` constructor(difficulty: number) { super(20, DEFAULT_XP, Player.getInstance().getLevel() * difficulty, 1000) this.minLuck = 10 - this.initMonster() - - // super.setupEngageTriggerBox(new utils.TriggerSphereShape(0)) - + this.loadTransformation() + super.setupEngageTriggerBox() this.setTopOffset(4) // # in % this.dropRate = -1 diff --git a/scene/src/enemies/monster.ts b/scene/src/enemies/monster.ts index 8199c79..4dd375d 100644 --- a/scene/src/enemies/monster.ts +++ b/scene/src/enemies/monster.ts @@ -165,7 +165,7 @@ export class MonsterOligar extends GenericMonster { throw new Error('onDropXp is required to be implemented for this monster') } - loadTransformation(): void { + loadTransformation(pos: Vector3): void { // function needs to be implemented per individual monster throw new Error( 'loadTransformation is required to be implemented for this monster' diff --git a/scene/src/enemies/monsterAttack.ts b/scene/src/enemies/monsterAttack.ts index 1403342..b3743e1 100644 --- a/scene/src/enemies/monsterAttack.ts +++ b/scene/src/enemies/monsterAttack.ts @@ -1,6 +1,6 @@ import { Quaternion, Vector3 } from '@dcl/sdk/math' import type MonsterOligar from './monster' -import { type Entity, Transform, engine, Animator } from '@dcl/sdk/ecs' +import { type Entity, Transform, engine } from '@dcl/sdk/ecs' // Configuration const MOVE_SPEED = 1 @@ -67,11 +67,6 @@ export class MonsterAttack { const distance = Vector3.distanceSquared(monsterPos, playerPos) if (distance >= this.engageDistance) { - Animator.playSingleAnimation( - this.monster.entity, - this.monster.walkClip, - false - ) this.isIdle = false const dirVector = Vector3.Forward() diff --git a/scene/src/enemies/monsterGeneric.ts b/scene/src/enemies/monsterGeneric.ts index b55b440..e928ec6 100644 --- a/scene/src/enemies/monsterGeneric.ts +++ b/scene/src/enemies/monsterGeneric.ts @@ -29,7 +29,7 @@ export class GenericMonster extends Character { this.setTopOffset(topOffSet) } - setupAttackTriggerBox(scale: Vector3 = Vector3.create(4, 2, 4)): void { + setupAttackTriggerBox(scale: Vector3 = Vector3.create(8, 2, 8)): void { this.cleanup() this.attackTrigger = entityController.addEntity() diff --git a/scene/src/enemies/monsterMeat.ts b/scene/src/enemies/monsterMeat.ts index 4069bb8..ae163fe 100644 --- a/scene/src/enemies/monsterMeat.ts +++ b/scene/src/enemies/monsterMeat.ts @@ -122,9 +122,9 @@ export class MonsterMeat extends GenericMonster { ] }) - this.setupRangedAttackTriggerBox() - this.setupEngageTriggerBox() - this.setupAttackTriggerBox() + // this.setupRangedAttackTriggerBox() + // this.setupEngageTriggerBox() + // this.setupAttackTriggerBox() this.attackSystem = new MonsterAttack(this, { moveSpeed: 2, diff --git a/scene/src/enemies/monsterMobAuto.ts b/scene/src/enemies/monsterMobAuto.ts index 7ca2f3a..b69b15e 100644 --- a/scene/src/enemies/monsterMobAuto.ts +++ b/scene/src/enemies/monsterMobAuto.ts @@ -123,7 +123,7 @@ export class MonsterMobAuto extends GenericMonster { ] }) - this.setupRangedAttackTriggerBox() + // this.setupRangedAttackTriggerBox() this.setupEngageTriggerBox() this.setupAttackTriggerBox() @@ -256,7 +256,10 @@ export class MonsterMobAuto extends GenericMonster { // ) utils.timers.setTimeout(() => { // TODO entity removing triggers error - // entityController.removeEntity(this.entity) + entityController.removeEntity(this.entity) + entityController.removeEntity(this.rangeAttackTrigger) + entityController.removeEntity(this.engageAttackTrigger) + super.cleanup() this.isDead = true }, 5 * 1000) } @@ -331,7 +334,7 @@ export class MonsterMobAuto extends GenericMonster { const reduceHealthBy = player.getPlayerAttack(isCriticalAttack) // remove monsters defence roll (bugged, monster has very high def) * (1 - defPercent) let playerAttack = Math.round(reduceHealthBy) switch (true) { - case random < 200: { + case random < 1100: { // 30% chance // TODO UI // bossDefense() diff --git a/scene/src/enemies/pig.ts b/scene/src/enemies/pig.ts index 7b6e98d..25757ac 100644 --- a/scene/src/enemies/pig.ts +++ b/scene/src/enemies/pig.ts @@ -92,6 +92,8 @@ export default class Pig extends MonsterMeat { }) } + create(): void {} + removeEntity(): void { super.cleanup() entityController.removeEntity(this.rangeAttackTrigger) diff --git a/scene/src/mineables.ts b/scene/src/mineables.ts index d336d34..a97f22e 100644 --- a/scene/src/mineables.ts +++ b/scene/src/mineables.ts @@ -7,7 +7,9 @@ import { PointerEvents, PointerEventType, InputAction, - inputSystem + inputSystem, + pointerEventsSystem, + type Entity } from '@dcl/sdk/ecs' import { Vector3, Quaternion } from '@dcl/sdk/math' import { getRandomInt, getRandomIntRange } from './utils/getRandomInt' @@ -267,7 +269,7 @@ export class BerryTree { } export class Pot { - public pot = entityController.addEntity() + public pot: Entity = entityController.addEntity() gameController: GameController constructor( gameController: GameController, @@ -299,29 +301,31 @@ export class Pot { playing: true }, { - clip: 'mine', - playing: false, + clip: 'action', + playing: true, loop: false } ] }) + pointerEventsSystem.onPointerDown( + { + entity: this.pot, + opts: { + button: InputAction.IA_POINTER, + hoverText: 'Mine pot!', + maxDistance: 7 + } + }, + () => { + Animator.playSingleAnimation(this.pot, 'action', false) + console.log('mined') + } + ) + this.battle() } battle(): void { - PointerEvents.createOrReplace(this.pot, { - pointerEvents: [ - { - eventType: PointerEventType.PET_DOWN, - eventInfo: { - button: InputAction.IA_POINTER, - showFeedback: true, - hoverText: 'Mine pot!', - maxDistance: 7 - } - } - ] - }) engine.addSystem(() => { if ( inputSystem.isTriggered( diff --git a/scene/src/realms/antrom.ts b/scene/src/realms/antrom.ts index 6263985..a26b1e3 100644 --- a/scene/src/realms/antrom.ts +++ b/scene/src/realms/antrom.ts @@ -762,7 +762,7 @@ export class Antrom implements Realm { ) { if (trewsKill.read() === 1) { if (garrisonCreatedOnce.read() === 0) { - this.gameController.realmController.switchRealm('demonKingDungeon') + // this.gameController.realmController.switchRealm('demonKingDungeon') // spawnBoss3() garrisonCreatedOnce.increase(1) } else { @@ -1556,13 +1556,11 @@ export class Antrom implements Realm { } spawnSingleEntity(entityName: string): void { - console.log('singleentit', entityName, this.butcher) switch (entityName) { case 'butcher': this.butcher = new BetaBoss1(this.gameController) break case 'jailGuards': - console.log('Guards spawned') this.jailGuard1 = new Minion( this.gameController, Vector3.create(-51.27, 4.15, -53.72) @@ -1627,7 +1625,8 @@ export class Antrom implements Realm { entityController.removeEntity(this.npc_RandomVillager9) entityController.removeEntity(this.npc_RandomVillager10) entityController.removeEntity(this.npc_RandomVillager11) - this.butcher.removeEntity() + // entityController.removeEntity(this.butcher.entity) + // this.butcher.removeEntity() this.executioners.forEach((executioner) => { executioner.removeEntity() }) diff --git a/scene/src/realms/dungeon.ts b/scene/src/realms/dungeon.ts index 22543f7..254f6a8 100644 --- a/scene/src/realms/dungeon.ts +++ b/scene/src/realms/dungeon.ts @@ -25,17 +25,22 @@ import { LeaderBoard } from '../leaderboard/leaderboard' import { setPlayerPosition } from '../utils/engine' import { type RealmType, type Realm } from './types' import { entityController } from './entityController' +import ExecutionerDesertDungeon from '../enemies/ExecutionerDesertDungeon' +import EasyDesertDungeonBoss from '../enemies/desertBosses/EasyDesertDungeonBoss' +import NightmareDesertDungeonBoss from '../enemies/desertBosses/NightmareDesertDungeonBoss' +import HardDesertDungeonBoss from '../enemies/desertBosses/HardDesertDungeonBoss' +import MedDesertDungeonBoss from '../enemies/desertBosses/MedDesertDungeonBoss' -type Difficulty = { - EASY: 'easy' - MEDIUM: 'medium' - HARD: 'hard' - NIGHTMARE: 'nightmare' -} -type Location = { - CAVE: 'cave' - DESERT: 'desert' -} +// type Difficulty = { +// EASY: 'easy' +// MEDIUM: 'medium' +// HARD: 'hard' +// NIGHTMARE: 'nightmare' +// } +// type Location = { +// CAVE: 'cave' +// DESERT: 'desert' +// } const desertSoldierPositions = [ // room1 Vector3.create(-16.52, 2.39, 60.76), @@ -99,50 +104,6 @@ const desertSoldierPositions = [ Vector3.create(49.51, 2.39, 17.07) ] -const caveSoldierPositions = [ - // room1 - Vector3.create(61.89, 17.79, 25.92), - Vector3.create(62.85, 17.81, 24.6), - Vector3.create(61.47, 19.74, -2.11), - Vector3.create(55.26, 20.42, -6.11), - Vector3.create(13.07, 3.15, 10.38), - Vector3.create(19.44, 3.75, 12.24), - // room2 - // 1 - Vector3.create(40.97, 3.16, 51.58), - Vector3.create(41.58, 3.16, 44.85), - Vector3.create(44.0, 3.16, 50.73), - - // 2 - Vector3.create(20.48, 3.16, 45.13), - Vector3.create(21.21, 3.16, 47.47), - Vector3.create(23.48, 3.16, 43.49), - - // 3 - Vector3.create(26.41, 3.16, 80.57), - Vector3.create(23.69, 3.16, 77.26), - Vector3.create(29.63, 3.16, 82.97), - - // 4 - Vector3.create(24.5, 12.34, 62.51), - Vector3.create(24.02, 12.12, 68.02), - Vector3.create(19.48, 11.56, 59.89), - - // 5 - Vector3.create(-2.71, 3.16, 64.76), - Vector3.create(-3.89, 3.16, 68.67), - Vector3.create(1.29, 3.16, 66.02), - - // room 3 - Vector3.create(-31.96, 12.11, 57.14), - Vector3.create(-34.98, 9.43, 66.18), - Vector3.create(-36.55, 9.25, 61.02), - - Vector3.create(-46.08, 13.57, 51.86), - Vector3.create(-46.28, 13.35, 53.8), - Vector3.create(-43.62, 14.47, 57.88) -] - // const magePositions = [ // Vector3.create(43.61, 3.29, 54.45), // Vector3.create(61.91, 3.29, 56.97) @@ -163,9 +124,13 @@ export class Dungeon implements Realm { private readonly sandDungeonSecret = entityController.addEntity() private readonly villager1 = entityController.addEntity() private readonly doorOpening = entityController.addEntity() + private readonly boss: EasyDesertDungeonBoss gameController: GameController constructor(gameController: GameController) { this.gameController = gameController + this.buildDungeon('DesertDungeon') + this.createDesertDungeonEnemies(this.gameController) + this.boss = new EasyDesertDungeonBoss(8) GltfContainer.create(this.wall1, { src: 'assets/models/sandDungeonDoor.glb' }) @@ -405,7 +370,7 @@ export class Dungeon implements Realm { utils.timers.setTimeout(() => { // quest.turnOnKingQuestTimer() setPlayerPosition(23.01, 1.72, 91.7) - }, 5000) + }, 1000) } if (scene === 'LegacyDungeon') { // buildLegacyDungeonScene() @@ -483,47 +448,6 @@ export class Dungeon implements Realm { } resetCaveDungeonScene(): void {} - createNightmareDungeonLegacy(): void { - // const evilGodric = Array.from({ length: 1 }, () => new EvilGodricNightmare()) - // evilGodric.forEach((evilGodric) => entityController.addEntity(evilGodric)) - // const trews = Array.from({ length: 1 }, () => new TrewsNightmare()) - // trews.forEach((trews) => entityController.addEntity(trews)) - // const berserker = Array.from({ length: 1 }, () => new BerserkerNightmare()) - // berserker.forEach((berserker) => entityController.addEntity(berserker)) - // const undeadKing = Array.from({ length: 1 }, () => new UndeadKingNightmare()) - // undeadKing.forEach((undeadKing) => entityController.addEntity(undeadKing)) - // const dragonMothere = Array.from({ length: 1 }, () => new DragonMotherNightmare()) - // dragonMothere.forEach((dragonMothere) => entityController.addEntity(dragonMothere)) - // console.log('create easy enemies') - } - - createHardDungeonLegacy(): void { - // const evilGodric = Array.from({ length: 1 }, () => new EvilGodric()) - // evilGodric.forEach((evilGodric) => entityController.addEntity(evilGodric)) - // const trews = Array.from({ length: 1 }, () => new Trews()) - // trews.forEach((trews) => entityController.addEntity(trews)) - // const berserker = Array.from({ length: 1 }, () => new Berserker()) - // berserker.forEach((berserker) => entityController.addEntity(berserker)) - // const undeadKing = Array.from({ length: 1 }, () => new UndeadKing()) - // undeadKing.forEach((undeadKing) => entityController.addEntity(undeadKing)) - // const dragonMothere = Array.from({ length: 1 }, () => new DragonMother()) - // dragonMothere.forEach((dragonMothere) => entityController.addEntity(dragonMothere)) - // console.log("create easy enemies") - } - - createEasyDungeonLegacy(): void { - // const evilGodric = Array.from({ length: 1 }, () => new EvilGodricE()) - // evilGodric.forEach((evilGodric) => entityController.addEntity(evilGodric)) - // const trews = Array.from({ length: 1 }, () => new TrewsE()) - // trews.forEach((trews) => entityController.addEntity(trews)) - // const berserker = Array.from({ length: 1 }, () => new BerserkerE()) - // berserker.forEach((berserker) => entityController.addEntity(berserker)) - // const undeadKing = Array.from({ length: 1 }, () => new UndeadKingE()) - // undeadKing.forEach((undeadKing) => entityController.addEntity(undeadKing)) - // const dragonMothere = Array.from({ length: 1 }, () => new DragonMotherE()) - // dragonMothere.forEach((dragonMothere) => entityController.addEntity(dragonMothere)) - // console.log("create easy enemies") - } moveWalls(wall: number): void { // Move the wall after kill the enemies @@ -581,145 +505,40 @@ export class Dungeon implements Realm { } } - createSoldier( - position: Vector3, - type: any, - attack: number, - hp: number - ): void { + createSoldier(position: Vector3, gameController: GameController): void { try { // eslint-disable-next-line @typescript-eslint/no-unused-vars, new-cap - const soldier = new type(position, attack, hp) + const soldier = new ExecutionerDesertDungeon(gameController, position) } catch (error) { console.log('Failed to create soldier:', error) } } - createDungeon(difficulty: Difficulty, location: Location): void { - // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions - if (location.CAVE) { - // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions - if (difficulty.EASY) { - // eslint-disable-next-line @typescript-eslint/no-unused-vars - const easyEnemyAttack = 20 - // eslint-disable-next-line @typescript-eslint/no-unused-vars - const easyEnemyHP = 400 - // createCaveDungeonEnemies(easyEnemyAttack, easyEnemyHP) - // const wastelandApex = Array.from( - // { length: 1 }, - // () => new EasyCaveDungeonBoss(easyEnemyAttack) - // ) - // wastelandApex.forEach((wastelandApex) => entityController.addEntity(wastelandApex)) - // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions - } else if (difficulty.MEDIUM) { - // eslint-disable-next-line @typescript-eslint/no-unused-vars - const mediumEnemyAttack = 180 - // eslint-disable-next-line @typescript-eslint/no-unused-vars - const mediumEnemyHP = 3600 - // createCaveDungeonEnemies(mediumEnemyAttack, mediumEnemyHP) - // const wastelandApex = Array.from( - // { length: 1 }, - // () => new MedCaveDungeonBoss(mediumEnemyAttack) - // ) - // wastelandApex.forEach((wastelandApex) => entityController.addEntity(wastelandApex)) - // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions - } else if (difficulty.HARD) { - // eslint-disable-next-line @typescript-eslint/no-unused-vars - const hardEnemyAttack = 900 - // eslint-disable-next-line @typescript-eslint/no-unused-vars - const hardEnemyHP = 9000 - // createCaveDungeonEnemies(hardEnemyAttack, hardEnemyHP) - // const wastelandApex = Array.from( - // { length: 1 }, - // () => new HardCaveDungeonBoss(hardEnemyAttack) - // ) - // wastelandApex.forEach((wastelandApex) => entityController.addEntity(wastelandApex)) - // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions - } else if (difficulty.NIGHTMARE) { - // eslint-disable-next-line @typescript-eslint/no-unused-vars - const nightmareEnemyAttack = 2000 - // eslint-disable-next-line @typescript-eslint/no-unused-vars - const nightmareEnemyHP = 222500 - // createCaveDungeonEnemies(nightmareEnemyAttack, nightmareEnemyHP) - // const wastelandApex = Array.from( - // { length: 1 }, - // () => new NightmareCaveDungeonBoss(nightmareEnemyAttack) - // ) - // wastelandApex.forEach((wastelandApex) => entityController.addEntity(wastelandApex)) - } else { - // eslint-disable-next-line @typescript-eslint/restrict-template-expressions, @typescript-eslint/no-base-to-string - console.log(`Invalid difficulty level: ${difficulty}`) - } - // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions - } else if (location.DESERT) { - // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions - if (difficulty.EASY) { - // eslint-disable-next-line @typescript-eslint/no-unused-vars - const easyEnemyAttack = 8 - // eslint-disable-next-line @typescript-eslint/no-unused-vars - const easyEnemyHP = 200 - // createDesertDungeonEnemies(easyEnemyAttack, easyEnemyHP) - // const wastelandApex = Array.from( - // { length: 1 }, - // () => new EasyDesertDungeonBoss(easyEnemyAttack) - // ) - // wastelandApex.forEach((wastelandApex) => entityController.addEntity(wastelandApex)) - // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions - } else if (difficulty.MEDIUM) { - // eslint-disable-next-line @typescript-eslint/no-unused-vars - const mediumEnemyAttack = 80 - // eslint-disable-next-line @typescript-eslint/no-unused-vars - const mediumEnemyHP = 1200 - // createDesertDungeonEnemies(mediumEnemyAttack, mediumEnemyHP) - // const wastelandApex = Array.from( - // { length: 1 }, - // () => new MedDesertDungeonBoss(mediumEnemyAttack) - // ) - // wastelandApex.forEach((wastelandApex) => entityController.addEntity(wastelandApex)) - // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions - } else if (difficulty.HARD) { - // eslint-disable-next-line @typescript-eslint/no-unused-vars - const hardEnemyAttack = 900 - // eslint-disable-next-line @typescript-eslint/no-unused-vars - const hardEnemyHP = 9000 - // createCaveDungeonEnemies(hardEnemyAttack, hardEnemyHP) - // const wastelandApex = Array.from( - // { length: 1 }, - // () => new HardCaveDungeonBoss(hardEnemyAttack) - // ) - // wastelandApex.forEach((wastelandApex) => entityController.addEntity(wastelandApex)) - // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions - } else if (difficulty.NIGHTMARE) { - // eslint-disable-next-line @typescript-eslint/no-unused-vars - const nightmareEnemyAttack = 2000 - // eslint-disable-next-line @typescript-eslint/no-unused-vars - const nightmareEnemyHP = 222500 - // createCaveDungeonEnemies(nightmareEnemyAttack, nightmareEnemyHP) - // const wastelandApex = Array.from( - // { length: 1 }, - // () => new NightmareCaveDungeonBoss(nightmareEnemyAttack) - // ) - // wastelandApex.forEach((wastelandApex) => entityController.addEntity(wastelandApex)) - } else { - // eslint-disable-next-line @typescript-eslint/restrict-template-expressions, @typescript-eslint/no-base-to-string - console.log(`Invalid difficulty level: ${difficulty}`) - } - } else { - // eslint-disable-next-line @typescript-eslint/restrict-template-expressions - console.log(`Invalid location: ${location}`) - } - } - - createDesertDungeonEnemies(attack: number, hp: number): void { + createDesertDungeonEnemies(gameController: GameController): void { desertSoldierPositions.forEach((position) => { - // this.createSoldier(position, attack, hp) + this.createSoldier(position, gameController) }) } - createCaveDungeonEnemies(attack: number, hp: number): void { - caveSoldierPositions.forEach((position) => { - // this.createSoldier(position, attack, hp) - }) + createDesertDungeonBoss(difficulty: string): void { + switch (difficulty) { + case 'easy': + // eslint-disable-next-line no-case-declarations, @typescript-eslint/no-unused-vars + const bossEasy = new EasyDesertDungeonBoss(8) + break + case 'medium': + // eslint-disable-next-line no-case-declarations, @typescript-eslint/no-unused-vars + const bossMed = new MedDesertDungeonBoss(80) + break + case 'hard': + // eslint-disable-next-line no-case-declarations, @typescript-eslint/no-unused-vars + const bossHard = new HardDesertDungeonBoss(300) + break + case 'nightmare': + // eslint-disable-next-line no-case-declarations, @typescript-eslint/no-unused-vars + const bossNightmare = new NightmareDesertDungeonBoss(800) + console.log('') + } } spawnSingleEntity(entityName: string): void { @@ -728,6 +547,41 @@ export class Dungeon implements Realm { } } + removeSingleEntity(entityName: string): void { + switch (entityName) { + case 'wall6': + if (this.wall6 != null) { + entityController.removeEntity(this.wall6) + console.log('wall6 removed') + } + break + case 'wall5': + if (this.wall5 != null) { + entityController.removeEntity(this.wall5) + console.log('wall5 removed') + } + break + case 'wall4': + if (this.wall4 != null) { + entityController.removeEntity(this.wall4) + console.log('wall4 removed') + } + break + case 'wall3': + if (this.wall3 != null) { + entityController.removeEntity(this.wall3) + console.log('wall3 removed') + } + break + case 'wall1': + if (this.wall1 != null) { + entityController.removeEntity(this.wall1) + console.log('wall1 removed') + } + break + } + } + removeAllEntities(): void { entityController.removeEntity(this.boardParent) this.leaderBoard.destroy() diff --git a/scene/src/realms/minerscave.ts b/scene/src/realms/minerscave.ts index 8ec4433..0423474 100644 --- a/scene/src/realms/minerscave.ts +++ b/scene/src/realms/minerscave.ts @@ -16,6 +16,51 @@ import { setPlayerPosition } from '../utils/engine' import { getRandomInt } from '../utils/getRandomInt' import { type Realm, type RealmType } from './types' import { entityController } from './entityController' +import ExecutionerCaveDungeon from '../enemies/ExecutionerCaveDungeon' + +const caveSoldierPositions = [ + // room1 + Vector3.create(61.89, 17.79, 25.92), + Vector3.create(62.85, 17.81, 24.6), + Vector3.create(61.47, 19.74, -2.11), + Vector3.create(55.26, 20.42, -6.11), + Vector3.create(13.07, 3.15, 10.38), + Vector3.create(19.44, 3.75, 12.24), + // room2 + // 1 + Vector3.create(40.97, 3.16, 51.58), + Vector3.create(41.58, 3.16, 44.85), + Vector3.create(44.0, 3.16, 50.73), + + // 2 + Vector3.create(20.48, 3.16, 45.13), + Vector3.create(21.21, 3.16, 47.47), + Vector3.create(23.48, 3.16, 43.49), + + // 3 + Vector3.create(26.41, 3.16, 80.57), + Vector3.create(23.69, 3.16, 77.26), + Vector3.create(29.63, 3.16, 82.97), + + // 4 + Vector3.create(24.5, 12.34, 62.51), + Vector3.create(24.02, 12.12, 68.02), + Vector3.create(19.48, 11.56, 59.89), + + // 5 + Vector3.create(-2.71, 3.16, 64.76), + Vector3.create(-3.89, 3.16, 68.67), + Vector3.create(1.29, 3.16, 66.02), + + // room 3 + Vector3.create(-31.96, 12.11, 57.14), + Vector3.create(-34.98, 9.43, 66.18), + Vector3.create(-36.55, 9.25, 61.02), + + Vector3.create(-46.08, 13.57, 51.86), + Vector3.create(-46.28, 13.35, 53.8), + Vector3.create(-43.62, 14.47, 57.88) +] export class MinersCave implements Realm { private readonly cave = entityController.addEntity() @@ -26,8 +71,10 @@ export class MinersCave implements Realm { gameController: GameController constructor(gameController: GameController) { this.gameController = gameController - GltfContainer.create(this.cave, { src: 'models/cave.glb' }) - GltfContainer.create(this.ladder, { src: 'models/CaveLadder.glb' }) + this.createCaveDungeonEnemies(this.gameController) + this.buildCave() + GltfContainer.create(this.cave, { src: 'assets/models/cave.glb' }) + GltfContainer.create(this.ladder, { src: 'assets/models/CaveLadder.glb' }) Transform.createOrReplace(this.cave, { position: Vector3.create(16, 0, 16), rotation: Quaternion.create(0, 0, 0, 1), @@ -122,6 +169,22 @@ export class MinersCave implements Realm { ] } + createSoldier(position: Vector3, gameController: GameController): void { + console.log('rock soldier created') + try { + // eslint-disable-next-line @typescript-eslint/no-unused-vars, new-cap + const soldier = new ExecutionerCaveDungeon(gameController, position) + } catch (error) { + console.log('Failed to create soldier:', error) + } + } + + createCaveDungeonEnemies(gameController: GameController): void { + caveSoldierPositions.forEach((position) => { + this.createSoldier(position, gameController) + }) + } + buildCave(): void { utils.timers.setTimeout(() => { // buildCaveBuilderScene() @@ -129,8 +192,8 @@ export class MinersCave implements Realm { utils.timers.setTimeout(() => { // createQuestTimerText() // quest.turnOnKingQuestTimer() - setPlayerPosition(69.38, 17.73, -24.05) - }, 15000) + setPlayerPosition(69.34, 17.38, -26.64) + }, 1000) }, 50) } diff --git a/scene/src/realms/types.ts b/scene/src/realms/types.ts index fcae397..9fb9bc3 100644 --- a/scene/src/realms/types.ts +++ b/scene/src/realms/types.ts @@ -1,5 +1,7 @@ import { type Vector3 } from '@dcl/sdk/math' +// export type DifficultyType = 'easy' | 'medium' | 'hard' | 'nightmare' + export type RealmType = | 'antrom' | 'demonKingDungeon' diff --git a/scene/src/scenes/main.tsx b/scene/src/scenes/main.tsx index 64e41c8..74f6576 100644 --- a/scene/src/scenes/main.tsx +++ b/scene/src/scenes/main.tsx @@ -31,7 +31,7 @@ async function init(retry: boolean): Promise { gameInstance = new GameController() gameInstance.uiController.loadingUI.startLoading() - gameInstance.realmController.switchRealm('antrom') + gameInstance.realmController.switchRealm('antrom', 'easy') await waitNextTick() diff --git a/scene/src/ui/dungeon/playDungeon.tsx b/scene/src/ui/dungeon/playDungeon.tsx index 77c3fed..593494b 100644 --- a/scene/src/ui/dungeon/playDungeon.tsx +++ b/scene/src/ui/dungeon/playDungeon.tsx @@ -101,6 +101,11 @@ export class PlayDungeonUI { this.timer = 2 engine.addSystem(this.loadingDungeonSystem.bind(this)) this.isLoading = true + if (this.dungeon === 'dungeon2') { + this.uiController.loadRealm('minersCave', this.difficulty) + } else { + this.uiController.loadRealm('dungeon', this.difficulty) + } } loadingDungeonSystem(dt: number): void { From 3a768a35f13e314f3e8ac5fdec3c4d7595b11e15 Mon Sep 17 00:00:00 2001 From: Giorgio <65674128+Gaffomdz@users.noreply.github.com> Date: Tue, 30 Jul 2024 14:45:42 +0200 Subject: [PATCH 02/13] fix: pigs and chicken attack fix --- scene/package.json | 2 +- scene/src/enemies/ExecutionerDesertDungeon.ts | 3 ++- scene/src/enemies/chicken.ts | 2 +- scene/src/enemies/pig.ts | 2 +- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/scene/package.json b/scene/package.json index 22ec49b..902f807 100644 --- a/scene/package.json +++ b/scene/package.json @@ -37,4 +37,4 @@ "fp-future": "^1.0.1", "typescript": "^5.3.2" } -} +} \ No newline at end of file diff --git a/scene/src/enemies/ExecutionerDesertDungeon.ts b/scene/src/enemies/ExecutionerDesertDungeon.ts index 47ba982..0784c88 100644 --- a/scene/src/enemies/ExecutionerDesertDungeon.ts +++ b/scene/src/enemies/ExecutionerDesertDungeon.ts @@ -17,7 +17,7 @@ export default class ExecutionerDesertDungeon extends MonsterMob { const player = Player.getInstanceOrNull() const level = player?.levels.getLevel(LEVEL_TYPES.PLAYER) ?? 1 const stage = DungeonStage.read() - super(5 + stage * 7, level + 100, level + 1, 10) + super(5 + stage * 7, level + 100, level + 1, 50) this.gameController = gameController this.minLuck = 20 @@ -25,6 +25,7 @@ export default class ExecutionerDesertDungeon extends MonsterMob { position: Vector3.create(0, 0, 0) }) this.initMonster() + super.setupAttackTriggerBox() super.setupEngageTriggerBox() this.loadTransformation(initialPos) this.setTopOffset(2.25) diff --git a/scene/src/enemies/chicken.ts b/scene/src/enemies/chicken.ts index 72328c1..29f19d5 100644 --- a/scene/src/enemies/chicken.ts +++ b/scene/src/enemies/chicken.ts @@ -75,7 +75,7 @@ export default class Chicken extends MonsterMeat { async onDropLoot(): Promise {} setupAttackTriggerBox(): void { - super.setupAttackTriggerBox() + super.setupEngageTriggerBox() } loadTransformation(): void { diff --git a/scene/src/enemies/pig.ts b/scene/src/enemies/pig.ts index 25757ac..68cfeeb 100644 --- a/scene/src/enemies/pig.ts +++ b/scene/src/enemies/pig.ts @@ -76,7 +76,7 @@ export default class Pig extends MonsterMeat { async onDropLoot(): Promise {} setupAttackTriggerBox(): void { - super.setupAttackTriggerBox() + super.setupEngageTriggerBox() } loadTransformation(): void { From 2cb95f7924539b4904075b5dee7d64efd7a54a92 Mon Sep 17 00:00:00 2001 From: Giorgio <65674128+Gaffomdz@users.noreply.github.com> Date: Tue, 30 Jul 2024 14:46:33 +0200 Subject: [PATCH 03/13] prettier --- scene/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scene/package.json b/scene/package.json index 902f807..22ec49b 100644 --- a/scene/package.json +++ b/scene/package.json @@ -37,4 +37,4 @@ "fp-future": "^1.0.1", "typescript": "^5.3.2" } -} \ No newline at end of file +} From d9a1fc4044d6e5af88ef5b30d992222211d6ab0c Mon Sep 17 00:00:00 2001 From: Giorgio <65674128+Gaffomdz@users.noreply.github.com> Date: Tue, 30 Jul 2024 16:14:49 +0200 Subject: [PATCH 04/13] fix: butcher removeEntity update --- scene/src/realms/antrom.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/scene/src/realms/antrom.ts b/scene/src/realms/antrom.ts index a26b1e3..42be588 100644 --- a/scene/src/realms/antrom.ts +++ b/scene/src/realms/antrom.ts @@ -1625,8 +1625,10 @@ export class Antrom implements Realm { entityController.removeEntity(this.npc_RandomVillager9) entityController.removeEntity(this.npc_RandomVillager10) entityController.removeEntity(this.npc_RandomVillager11) - // entityController.removeEntity(this.butcher.entity) - // this.butcher.removeEntity() + + if (this.butcher != null) { + this.butcher.removeEntity() + } this.executioners.forEach((executioner) => { executioner.removeEntity() }) From 6bd87a43b2ce9f84c8dadcb33fed695985a5dcbb Mon Sep 17 00:00:00 2001 From: Giorgio <65674128+Gaffomdz@users.noreply.github.com> Date: Tue, 30 Jul 2024 16:17:33 +0200 Subject: [PATCH 05/13] prettier --- scene/src/enemies/MonsterMob.ts | 4 ---- 1 file changed, 4 deletions(-) diff --git a/scene/src/enemies/MonsterMob.ts b/scene/src/enemies/MonsterMob.ts index cd9b7bf..6d33f31 100644 --- a/scene/src/enemies/MonsterMob.ts +++ b/scene/src/enemies/MonsterMob.ts @@ -107,10 +107,6 @@ export class MonsterMob extends GenericMonster { ] }) - // this.setupRangedAttackTriggerBox() - // this.setupEngageTriggerBox() - // this.setupAttackTriggerBox() - this.attackSystem = new MonsterAttack(this, { moveSpeed: 2, engageDistance: this.engageDistance From 18ee4c4183b87017fb1f73628c927b303e45e3da Mon Sep 17 00:00:00 2001 From: Giorgio <65674128+Gaffomdz@users.noreply.github.com> Date: Thu, 1 Aug 2024 13:07:41 +0200 Subject: [PATCH 06/13] feat: added correct values for dungeons --- scene/src/counters.ts | 1 + scene/src/enemies/ExecutionerCaveDungeon.ts | 145 ++++++------------ scene/src/enemies/ExecutionerDesertDungeon.ts | 17 +- 3 files changed, 56 insertions(+), 107 deletions(-) diff --git a/scene/src/counters.ts b/scene/src/counters.ts index 26f455a..0ab35b9 100644 --- a/scene/src/counters.ts +++ b/scene/src/counters.ts @@ -8,5 +8,6 @@ export const jailOpenOnce = new UICounter() export const demonKill = new UICounter() export const DungeonStage = new UICounter() export const desertDungeonMonsterCount = new UICounter() +export const caveDungeonMonsterCount = new UICounter() demonKill.set(1) diff --git a/scene/src/enemies/ExecutionerCaveDungeon.ts b/scene/src/enemies/ExecutionerCaveDungeon.ts index 91a88ca..913df15 100644 --- a/scene/src/enemies/ExecutionerCaveDungeon.ts +++ b/scene/src/enemies/ExecutionerCaveDungeon.ts @@ -3,7 +3,7 @@ import { LEVEL_TYPES } from '../player/LevelManager' import MonsterMob from './MonsterMob' import { Player } from '../player/player' import { type GameController } from '../controllers/game.controller' -import { DungeonStage, desertDungeonMonsterCount } from '../counters' +import { DungeonStage, caveDungeonMonsterCount } from '../counters' import { Transform } from '@dcl/sdk/ecs' import { getRandomInt, getRandomIntRange } from '../utils/getRandomInt' import { ITEM_TYPES } from '../inventory/playerInventoryMap' @@ -34,18 +34,13 @@ export default class ExecutionerCaveDungeon extends MonsterMob { onDropXp(): void { const xp = getRandomIntRange(this.xp, this.xp + 10) console.log(xp) - desertDungeonMonsterCount.increase(1) - - // let damage = player.levels.getLevel(LEVEL_TYPES.PLAYER) * 5 - // if (player.levels.getLevel(LEVEL_TYPES.PLAYER) >= 60) { - // damage = player.levels.getLevel(LEVEL_TYPES.PLAYER) * 10 - // } - - // const doorOpeningSource = globalThis.doorOpeningSource - + caveDungeonMonsterCount.increase(1) + this.gameController.uiController.displayAnnouncement( + `${caveDungeonMonsterCount.read()}` + ) // ui.displayAnnouncement(`${easyDungeonMonsterCount1.read()}`) - if (desertDungeonMonsterCount.read() === 1) { + if (caveDungeonMonsterCount.read() === 6) { this.gameController.uiController.displayAnnouncement( 'Cube Removed!', Color4.Yellow(), @@ -55,99 +50,59 @@ export default class ExecutionerCaveDungeon extends MonsterMob { this.gameController.realmController.currentRealm?.removeSingleEntity !== undefined ) { - this.gameController.realmController.currentRealm?.removeSingleEntity( - 'wall6' - ) + // remove cube 1 and 2 } - // TODO lerp animation - } - if (desertDungeonMonsterCount.read() === 2) { - this.gameController.uiController.displayAnnouncement( - 'Cube Removed!', - Color4.Yellow(), - 2000 - ) - if ( - this.gameController.realmController.currentRealm?.removeSingleEntity !== - undefined - ) { - this.gameController.realmController.currentRealm?.removeSingleEntity( - 'wall5' + if (caveDungeonMonsterCount.read() === 21) { + this.gameController.uiController.displayAnnouncement( + 'Cube Removed!', + Color4.Yellow(), + 2000 ) + if ( + this.gameController.realmController.currentRealm + ?.removeSingleEntity !== undefined + ) { + // Remove cube 3 + } } - } - if (desertDungeonMonsterCount.read() === 3) { - this.gameController.uiController.displayAnnouncement( - 'Cube Removed!', - Color4.Yellow(), - 2000 - ) - if ( - this.gameController.realmController.currentRealm?.removeSingleEntity !== - undefined - ) { - this.gameController.realmController.currentRealm?.removeSingleEntity( - 'wall4' + if (caveDungeonMonsterCount.read() === 27) { + this.gameController.uiController.displayAnnouncement( + 'Cube Removed!', + Color4.Yellow(), + 2000 ) + if ( + this.gameController.realmController.currentRealm + ?.removeSingleEntity !== undefined + ) { + // Remove cube 4 + } } - } - if (desertDungeonMonsterCount.read() === 4) { - this.gameController.uiController.displayAnnouncement( - 'Cube Removed!', - Color4.Yellow(), - 2000 - ) - if ( - this.gameController.realmController.currentRealm?.removeSingleEntity !== - undefined - ) { - this.gameController.realmController.currentRealm?.removeSingleEntity( - 'wall3' - ) - } - } - - if (desertDungeonMonsterCount.read() === 5) { - this.gameController.uiController.displayAnnouncement( - 'Cube Removed!', - Color4.Yellow(), - 2000 - ) - if ( - this.gameController.realmController.currentRealm?.removeSingleEntity !== - undefined - ) { - this.gameController.realmController.currentRealm?.removeSingleEntity( - 'wall1' - ) - } - desertDungeonMonsterCount.decrease(47) + const exp = [ + { + type: LEVEL_TYPES.ENEMY, + value: 1 + }, + { + type: LEVEL_TYPES.PLAYER, + value: xp + } + ] + const loot = [ + { + type: ITEM_TYPES.BONE, + value: 1 + } + ] + console.log(exp, loot) + // UI ? addRewards(exp, loot) + // DailyQuestHUD.getInstance().listenAndUpdateForAnyActiveQuest( + // LEVEL_TYPES.ENEMY + // ) } - - const exp = [ - { - type: LEVEL_TYPES.ENEMY, - value: 1 - }, - { - type: LEVEL_TYPES.PLAYER, - value: xp - } - ] - const loot = [ - { - type: ITEM_TYPES.BONE, - value: 1 - } - ] - console.log(exp, loot) - // UI ? addRewards(exp, loot) - // DailyQuestHUD.getInstance().listenAndUpdateForAnyActiveQuest( - // LEVEL_TYPES.ENEMY - // ) } onDropLoot(): void {} diff --git a/scene/src/enemies/ExecutionerDesertDungeon.ts b/scene/src/enemies/ExecutionerDesertDungeon.ts index 0784c88..e3da0a0 100644 --- a/scene/src/enemies/ExecutionerDesertDungeon.ts +++ b/scene/src/enemies/ExecutionerDesertDungeon.ts @@ -37,16 +37,9 @@ export default class ExecutionerDesertDungeon extends MonsterMob { console.log(xp) desertDungeonMonsterCount.increase(1) - // let damage = player.levels.getLevel(LEVEL_TYPES.PLAYER) * 5 - // if (player.levels.getLevel(LEVEL_TYPES.PLAYER) >= 60) { - // damage = player.levels.getLevel(LEVEL_TYPES.PLAYER) * 10 - // } - - // const doorOpeningSource = globalThis.doorOpeningSource - // ui.displayAnnouncement(`${easyDungeonMonsterCount1.read()}`) - if (desertDungeonMonsterCount.read() === 1) { + if (desertDungeonMonsterCount.read() === 10) { this.gameController.uiController.displayAnnouncement( 'room 1 opens', Color4.Yellow(), @@ -63,7 +56,7 @@ export default class ExecutionerDesertDungeon extends MonsterMob { // TODO lerp animation } - if (desertDungeonMonsterCount.read() === 2) { + if (desertDungeonMonsterCount.read() === 19) { this.gameController.uiController.displayAnnouncement( 'room 2 opens', Color4.Yellow(), @@ -79,7 +72,7 @@ export default class ExecutionerDesertDungeon extends MonsterMob { } } - if (desertDungeonMonsterCount.read() === 3) { + if (desertDungeonMonsterCount.read() === 32) { this.gameController.uiController.displayAnnouncement( 'room 3 opens', Color4.Yellow(), @@ -95,7 +88,7 @@ export default class ExecutionerDesertDungeon extends MonsterMob { } } - if (desertDungeonMonsterCount.read() === 4) { + if (desertDungeonMonsterCount.read() === 42) { this.gameController.uiController.displayAnnouncement( 'room 4 opens', Color4.Yellow(), @@ -111,7 +104,7 @@ export default class ExecutionerDesertDungeon extends MonsterMob { } } - if (desertDungeonMonsterCount.read() === 5) { + if (desertDungeonMonsterCount.read() === 47) { this.gameController.uiController.displayAnnouncement( 'room 6 opens', Color4.Yellow(), From 413aa734aece7783360ed429d24bfd94a323901c Mon Sep 17 00:00:00 2001 From: Giorgio <65674128+Gaffomdz@users.noreply.github.com> Date: Fri, 2 Aug 2024 12:30:34 +0200 Subject: [PATCH 07/13] Added pet functionality --- scene/src/enemies/Executioner.ts | 2 +- scene/src/pets/animatedEntity.ts | 88 ++++++++++++++++++++++++++++++++ scene/src/pets/createPet.ts | 23 +++++++++ scene/src/pets/dragon.ts | 29 +++++++++++ scene/src/pets/owl.ts | 27 ++++++++++ scene/src/pets/pet.ts | 60 ++++++++++++++++++++++ scene/src/pets/phoenix.ts | 24 +++++++++ 7 files changed, 252 insertions(+), 1 deletion(-) create mode 100644 scene/src/pets/animatedEntity.ts create mode 100644 scene/src/pets/createPet.ts create mode 100644 scene/src/pets/dragon.ts create mode 100644 scene/src/pets/owl.ts create mode 100644 scene/src/pets/pet.ts create mode 100644 scene/src/pets/phoenix.ts diff --git a/scene/src/enemies/Executioner.ts b/scene/src/enemies/Executioner.ts index 5fad625..3ca9ae6 100644 --- a/scene/src/enemies/Executioner.ts +++ b/scene/src/enemies/Executioner.ts @@ -19,7 +19,7 @@ export default class Executioner extends MonsterMobAuto { constructor() { const player = Player.getInstanceOrNull() - const level = player?.levels.getLevel(LEVEL_TYPES.PLAYER) ?? 1 + const level = player?.levels.getLevel(LEVEL_TYPES.PLAYER) ?? 2 super(level + 20, level + 60, level - 10, level * 100) this.minLuck = 10 this.hoverText = `Attack LVL ${level} Executioner!` diff --git a/scene/src/pets/animatedEntity.ts b/scene/src/pets/animatedEntity.ts new file mode 100644 index 0000000..c6ce528 --- /dev/null +++ b/scene/src/pets/animatedEntity.ts @@ -0,0 +1,88 @@ +import { + GltfContainer, + Transform, + type TransformType, + type Entity, + Animator +} from '@dcl/sdk/ecs' +import { entityController } from '../realms/entityController' + +export class AnimatedEntity { + removed: boolean = false + entity: Entity + onRemove?: () => void + constructor(model: string, transform: TransformType) { + this.entity = entityController.addEntity() + GltfContainer.create(this.entity, { src: model }) + Transform.create(this.entity, { + position: transform.position, + rotation: transform.rotation, + scale: transform.scale + }) + Animator.createOrReplace(this.entity, { + states: [ + { + clip: 'attack', + playing: true, + loop: true + }, + { + clip: 'walk', + playing: false, + loop: true + }, + { + clip: 'idle', + playing: false, + loop: true + }, + { + clip: 'fly', + playing: false, + loop: false + }, + { + clip: 'run', + playing: false, + loop: false + } + ] + }) + } + + attack(): void { + Animator.playSingleAnimation(this.entity, 'attack') + } + + fly(): void { + Animator.playSingleAnimation(this.entity, 'fly') + } + + idle(): void { + Animator.playSingleAnimation(this.entity, 'idle') + } + + // Play walking animation + walk(): void { + Animator.playSingleAnimation(this.entity, 'walk') + } + + run(): void { + Animator.playSingleAnimation(this.entity, 'run') + } + + // Bug workaround: otherwise the next animation clip won't play + stopAnimations(): void { + Animator.stopAllAnimations(this.entity) + } + + remove(): void { + if (!this.removed) { + entityController.removeEntity(this.entity) + this.removed = true + if (this.onRemove != null) { + this.onRemove() + } + } + } +} diff --git a/scene/src/pets/createPet.ts b/scene/src/pets/createPet.ts new file mode 100644 index 0000000..7b2e2e8 --- /dev/null +++ b/scene/src/pets/createPet.ts @@ -0,0 +1,23 @@ +import { Quaternion, Vector3 } from '@dcl/sdk/math' +import { Pet } from './pet' +// import { Transform, engine } from '@dcl/sdk/ecs' +import { getRandomInt } from '../utils/getRandomInt' + +export function createPet( + model: string, + moveSpeed: number = 1, + rotationSpeed: number = 1, + addBuff?: () => void, + removeBuff?: () => void, + proximityEffect?: () => void +): Pet { + addBuff?.() + // Pet + const pet = new Pet(model, { + position: Vector3.create(getRandomInt(5) + 22, 1.8, getRandomInt(14) + 5), + rotation: Quaternion.create(1, 1, 1, 1), + scale: Vector3.create(1, 1, 1) + }) + + return pet +} diff --git a/scene/src/pets/dragon.ts b/scene/src/pets/dragon.ts new file mode 100644 index 0000000..fefdd06 --- /dev/null +++ b/scene/src/pets/dragon.ts @@ -0,0 +1,29 @@ +import { LEVEL_TYPES } from '../player/LevelManager' +import { PetTypes } from '../player/petManager' +import { Player } from '../player/player' +import { createPet } from './createPet' +import { type Pet } from './pet' + +export function createDragon(): Pet { + const player = Player.getInstance() + // Configuration + const MOVE_SPEED = 5 + const ROT_SPEED = 1 + const ATTACK_BUFF = player.levels.getLevel(LEVEL_TYPES.PLAYER) * 7 + + const pet = createPet( + 'assets/models/Dragon.glb', + MOVE_SPEED, + ROT_SPEED, + () => { + Player.getInstance().updateAtkBuff(ATTACK_BUFF) + }, + () => { + Player.getInstance().updateAtkBuff(-ATTACK_BUFF) + } + ) + + Player.getInstance().petManager.addPetInstance(PetTypes.DRAGON, pet) + + return pet +} diff --git a/scene/src/pets/owl.ts b/scene/src/pets/owl.ts new file mode 100644 index 0000000..7d235c0 --- /dev/null +++ b/scene/src/pets/owl.ts @@ -0,0 +1,27 @@ +import { PetTypes } from '../player/petManager' +import { Player } from '../player/player' +import { createPet } from './createPet' +import { type Pet } from './pet' + +export function createOwl(): Pet { + // Configuration + const MOVE_SPEED = 4 + const ROT_SPEED = 1 + const LUCK_BUFF = 7 + + const owl = createPet( + 'assets/models/owl.glb', + MOVE_SPEED, + ROT_SPEED, + () => { + Player.getInstance().updateLuckBuff(LUCK_BUFF) + }, + () => { + Player.getInstance().updateLuckBuff(-LUCK_BUFF) + } + ) + + Player.getInstance().petManager.addPetInstance(PetTypes.OWL, owl) + + return owl +} diff --git a/scene/src/pets/pet.ts b/scene/src/pets/pet.ts new file mode 100644 index 0000000..28bb662 --- /dev/null +++ b/scene/src/pets/pet.ts @@ -0,0 +1,60 @@ +import { Transform, engine, type TransformType } from '@dcl/sdk/ecs' +import { AnimatedEntity } from './animatedEntity' +import { Quaternion, Vector3 } from '@dcl/sdk/math' +import * as utils from '@dcl-sdk/utils' +import { Player } from '../player/player' + +export class Pet extends AnimatedEntity { + dt: any + moveSpeed: number = 1 + constructor(model: string, transform: TransformType) { + super(model, transform) + console.log('Pet Created') + engine.addSystem(this.followPlayerSystem) + this.onRemove = this.handleOnRemove + } + + followPlayerSystem = (dt: number): void => { + const playerPosition = Transform.get(engine.PlayerEntity).position + const transform = Transform.getMutable(this.entity) + // Face player + const lookAtTarget = Vector3.create( + playerPosition.x, + playerPosition.y + 1, + playerPosition.z + ) + const direction = Vector3.subtract(lookAtTarget, transform.position) + const newRotation = Quaternion.slerp( + transform.rotation, + Quaternion.lookRotation(direction), + dt + ) + Transform.getMutable(this.entity).rotation = newRotation + + // Move towards player + const distance = Vector3.distanceSquared(transform.position, playerPosition) + if (distance >= 8) { + // Note: Distance is squared so a value of 4 is when the zombie is standing 2m away + this.idle() + const forwardVector = Vector3.rotate( + Vector3.Forward(), + transform.rotation + ) + const increment = Vector3.scale(forwardVector, dt * 0.5) + const newPosition = Vector3.add(playerPosition, increment) + Transform.getMutable(this.entity).position = newPosition + } else { + // console.log(distance, ' is the distance to the player') + utils.timers.setTimeout(() => { + if (Player.getInstance().health <= 0) { + this.remove() + } + }, 3000) + } + } + + handleOnRemove = (): void => { + console.log('Pet Removed') + engine.removeSystem(this.followPlayerSystem) + } +} diff --git a/scene/src/pets/phoenix.ts b/scene/src/pets/phoenix.ts new file mode 100644 index 0000000..24b43e5 --- /dev/null +++ b/scene/src/pets/phoenix.ts @@ -0,0 +1,24 @@ +import { PetTypes } from '../player/petManager' +import { Player } from '../player/player' +import { createPet } from './createPet' +import { type Pet } from './pet' + +export function createPhoenix(): Pet { + // Configuration + const MOVE_SPEED = 3 + const ROT_SPEED = 1 + + const phoenix = createPet( + 'assets/models/Phoenix.glb', + MOVE_SPEED, + ROT_SPEED, + () => { + Player.getInstance().refillHealthBar(0.1, true) + }, + () => {} + ) + + Player.getInstance().petManager.addPetInstance(PetTypes.PHOENIX, phoenix) + + return phoenix +} From 599380c9bc80d942ae4fcd896a9e40aed6200761 Mon Sep 17 00:00:00 2001 From: Giorgio <65674128+Gaffomdz@users.noreply.github.com> Date: Fri, 2 Aug 2024 12:39:19 +0200 Subject: [PATCH 08/13] Update package.json --- scene/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scene/package.json b/scene/package.json index 22ec49b..902f807 100644 --- a/scene/package.json +++ b/scene/package.json @@ -37,4 +37,4 @@ "fp-future": "^1.0.1", "typescript": "^5.3.2" } -} +} \ No newline at end of file From 23f079a77040a43d5a1448bbc0bdd2ebeab19f9e Mon Sep 17 00:00:00 2001 From: Giorgio <65674128+Gaffomdz@users.noreply.github.com> Date: Fri, 2 Aug 2024 13:17:37 +0200 Subject: [PATCH 09/13] feat: plug companion creation to ui --- scene/package.json | 2 +- .../main-hud/inventory.controller.tsx | 3 ++- scene/src/inventory/equipCompanion.ts | 22 +++++++++++++++++++ 3 files changed, 25 insertions(+), 2 deletions(-) create mode 100644 scene/src/inventory/equipCompanion.ts diff --git a/scene/package.json b/scene/package.json index 902f807..22ec49b 100644 --- a/scene/package.json +++ b/scene/package.json @@ -37,4 +37,4 @@ "fp-future": "^1.0.1", "typescript": "^5.3.2" } -} \ No newline at end of file +} diff --git a/scene/src/controllers/main-hud/inventory.controller.tsx b/scene/src/controllers/main-hud/inventory.controller.tsx index 6d22c75..66238c0 100644 --- a/scene/src/controllers/main-hud/inventory.controller.tsx +++ b/scene/src/controllers/main-hud/inventory.controller.tsx @@ -37,6 +37,7 @@ import { type CompanionType } from '../../ui/inventory/companionsData' import { type ProfessionType } from '../../ui/inventory/professionsData' +import { equipCompanion } from '../../inventory/equipCompanion' // import { WearablesConfig } from '../../player/wearables-config' // import {type GetPlayerDataRes, getPlayer } from '@dcl/sdk/src/players' @@ -481,7 +482,7 @@ export class InventoryController { this.componionButtonSprite = companionPageSprite.equip_button_when_clicked // execute function equip companion - console.log('equip') + equipCompanion(this.selectedCompanion.name) this.equipedCompanion = this.selectedCompanion } else { this.componionButtonSprite = companionPageSprite.Purchase_while_clicked diff --git a/scene/src/inventory/equipCompanion.ts b/scene/src/inventory/equipCompanion.ts new file mode 100644 index 0000000..2241c76 --- /dev/null +++ b/scene/src/inventory/equipCompanion.ts @@ -0,0 +1,22 @@ +import { createDragon } from '../pets/dragon' +import { createOwl } from '../pets/owl' +import { createPhoenix } from '../pets/phoenix' + +export function equipCompanion(companionName: string): void { + if ( + companionName !== null && + companionName !== undefined && + companionName.trim() !== '' + ) { + switch (companionName) { + case 'Owl': + createOwl() + break + case 'Phoenix': + createPhoenix() + break + case 'Dragon': + createDragon() + } + } +} From 29ca4d956b5d3ad529793dff0e88af961c965de1 Mon Sep 17 00:00:00 2001 From: Giorgio <65674128+Gaffomdz@users.noreply.github.com> Date: Fri, 2 Aug 2024 13:20:36 +0200 Subject: [PATCH 10/13] prettier --- scene/package.json | 2 +- scene/src/pets/pet.ts | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/scene/package.json b/scene/package.json index 22ec49b..902f807 100644 --- a/scene/package.json +++ b/scene/package.json @@ -37,4 +37,4 @@ "fp-future": "^1.0.1", "typescript": "^5.3.2" } -} +} \ No newline at end of file diff --git a/scene/src/pets/pet.ts b/scene/src/pets/pet.ts index 28bb662..9d3e29d 100644 --- a/scene/src/pets/pet.ts +++ b/scene/src/pets/pet.ts @@ -5,7 +5,6 @@ import * as utils from '@dcl-sdk/utils' import { Player } from '../player/player' export class Pet extends AnimatedEntity { - dt: any moveSpeed: number = 1 constructor(model: string, transform: TransformType) { super(model, transform) @@ -40,7 +39,7 @@ export class Pet extends AnimatedEntity { Vector3.Forward(), transform.rotation ) - const increment = Vector3.scale(forwardVector, dt * 0.5) + const increment = Vector3.scale(forwardVector, dt * 0.25) const newPosition = Vector3.add(playerPosition, increment) Transform.getMutable(this.entity).position = newPosition } else { From 1a5d0063584a7d8807ba6d6f85a2b10fd15894ac Mon Sep 17 00:00:00 2001 From: Giorgio <65674128+Gaffomdz@users.noreply.github.com> Date: Mon, 5 Aug 2024 14:19:31 +0200 Subject: [PATCH 11/13] fix: duplicated pets fixed --- scene/src/inventory/equipCompanion.ts | 33 +++++++++++++---------- scene/src/pets/createPet.ts | 1 - scene/src/player/petManager.ts | 38 ++++++++++++++------------- 3 files changed, 39 insertions(+), 33 deletions(-) diff --git a/scene/src/inventory/equipCompanion.ts b/scene/src/inventory/equipCompanion.ts index 2241c76..c09d8db 100644 --- a/scene/src/inventory/equipCompanion.ts +++ b/scene/src/inventory/equipCompanion.ts @@ -1,22 +1,27 @@ import { createDragon } from '../pets/dragon' import { createOwl } from '../pets/owl' import { createPhoenix } from '../pets/phoenix' +import { Player } from '../player/player' export function equipCompanion(companionName: string): void { - if ( - companionName !== null && - companionName !== undefined && - companionName.trim() !== '' - ) { - switch (companionName) { - case 'Owl': - createOwl() - break - case 'Phoenix': - createPhoenix() - break - case 'Dragon': - createDragon() + if (Player.getInstance().petManager.getPetInstance(companionName) != null) { + console.log('Pet already equipped!') + } else { + if ( + companionName !== null && + companionName !== undefined && + companionName.trim() !== '' + ) { + switch (companionName) { + case 'Owl': + createOwl() + break + case 'Phoenix': + createPhoenix() + break + case 'Dragon': + createDragon() + } } } } diff --git a/scene/src/pets/createPet.ts b/scene/src/pets/createPet.ts index 7b2e2e8..6339dbe 100644 --- a/scene/src/pets/createPet.ts +++ b/scene/src/pets/createPet.ts @@ -1,6 +1,5 @@ import { Quaternion, Vector3 } from '@dcl/sdk/math' import { Pet } from './pet' -// import { Transform, engine } from '@dcl/sdk/ecs' import { getRandomInt } from '../utils/getRandomInt' export function createPet( diff --git a/scene/src/player/petManager.ts b/scene/src/player/petManager.ts index 71d112a..8f85891 100644 --- a/scene/src/player/petManager.ts +++ b/scene/src/player/petManager.ts @@ -1,35 +1,36 @@ +import { AddPetToPlayer } from '../api/api' +import { type Pet } from '../pets/pet' + export enum PetTypes { PLACEHOLDER = 'placeholder', - OWL = 'owl', - PHOENIX = 'phoenix', - DRAGON = 'dragon', - SOLIDER = 'soldier' + OWL = 'Owl', + PHOENIX = 'Phoenix', + DRAGON = 'Dragon', + SOLIDER = 'Soldier' } -// TODO AnimatedEntity and Pet classes export class PetManager { pets: string[] - // petInstances: { [key: string]: Pet } + petInstances: Record constructor(pets: string[] = []) { this.pets = pets - // this.petInstances = {}; + this.petInstances = {} } - addPet(name: PetTypes): void { + async addPet(name: PetTypes): Promise { if (!this.hasPet(name)) { this.pets.push(name) - // TODO api - // executeTask(() => AddPetToPlayer(name)) + await AddPetToPlayer(name) } } addPetInstance(name: string, pet: any): void { - // this.petInstances[name] = pet; + this.petInstances[name] = pet } - getPetInstance(name: string): void { - // return this.petInstances?.[name]; + getPetInstance(name: string): Pet { + return this.petInstances?.[name] } setPets(pets: string[] = []): void { @@ -37,11 +38,12 @@ export class PetManager { } removeInstance(name: string): void { - // const instance = this.getPetInstance(name); - // if (instance) { - // instance.remove() - // delete this.petInstances[name]; - // } + const instance = this.getPetInstance(name) + if (instance != null) { + instance.remove() + // eslint-disable-next-line @typescript-eslint/no-dynamic-delete + delete this.petInstances[name] + } } removePet(name: string): void { From ed944101a9462f711d57d38a7703d15da7f32e6b Mon Sep 17 00:00:00 2001 From: Giorgio <65674128+Gaffomdz@users.noreply.github.com> Date: Mon, 5 Aug 2024 14:19:52 +0200 Subject: [PATCH 12/13] prettier --- scene/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scene/package.json b/scene/package.json index 902f807..22ec49b 100644 --- a/scene/package.json +++ b/scene/package.json @@ -37,4 +37,4 @@ "fp-future": "^1.0.1", "typescript": "^5.3.2" } -} \ No newline at end of file +} From 14cbebd92bedab8802ef56ee3fcdce2f5ee99841 Mon Sep 17 00:00:00 2001 From: Giorgio <65674128+Gaffomdz@users.noreply.github.com> Date: Tue, 6 Aug 2024 11:55:15 +0200 Subject: [PATCH 13/13] fix: remove dead code and typing issues --- scene/src/controllers/realm.controller.ts | 4 +-- scene/src/enemies/monsterMeat.ts | 17 --------- scene/src/enemies/monsterMobAuto.ts | 1 - scene/src/player/petManager.ts | 11 +++--- scene/src/realms/antrom.ts | 19 ---------- scene/src/realms/dungeon.ts | 44 +++++++++-------------- scene/src/realms/minerscave.ts | 4 ++- 7 files changed, 26 insertions(+), 74 deletions(-) diff --git a/scene/src/controllers/realm.controller.ts b/scene/src/controllers/realm.controller.ts index e455996..89e26ee 100644 --- a/scene/src/controllers/realm.controller.ts +++ b/scene/src/controllers/realm.controller.ts @@ -29,13 +29,13 @@ export class RealmController { this.currentRealm = new DemonKingDungeon(this.gameController) break case 'dungeon': - this.currentRealm = new Dungeon(this.gameController) + this.currentRealm = new Dungeon(this.gameController, difficulty) break case 'dungeonBase': this.currentRealm = new DungeonBase(this.gameController) break case 'minersCave': - this.currentRealm = new MinersCave(this.gameController) + this.currentRealm = new MinersCave(this.gameController, difficulty) break } } diff --git a/scene/src/enemies/monsterMeat.ts b/scene/src/enemies/monsterMeat.ts index ae163fe..ec49155 100644 --- a/scene/src/enemies/monsterMeat.ts +++ b/scene/src/enemies/monsterMeat.ts @@ -64,19 +64,6 @@ export class MonsterMeat extends GenericMonster { this.isDead = false this.isDeadAnimation = false this.engageDistance = engageDistance - // monster sounds - // this.dyingSound = enemyDyingAudioSource - // this.addComponentOrReplace(this.dyingSound) - // - - // this.attackSound = enemyAttackAudioSource - // this.addComponentOrReplace(this.attackSound) - // - // let monDef = enemyDefAudioSource - // this.addComponentOrReplace(monDef) - // - // let monHey = enemyHeyAudioSource - // this.addComponentOrReplace(monHey) MonsterMeat.setGlobalHasSkill(true) } @@ -122,10 +109,6 @@ export class MonsterMeat extends GenericMonster { ] }) - // this.setupRangedAttackTriggerBox() - // this.setupEngageTriggerBox() - // this.setupAttackTriggerBox() - this.attackSystem = new MonsterAttack(this, { moveSpeed: 2, engageDistance: this.engageDistance diff --git a/scene/src/enemies/monsterMobAuto.ts b/scene/src/enemies/monsterMobAuto.ts index b69b15e..382cfe8 100644 --- a/scene/src/enemies/monsterMobAuto.ts +++ b/scene/src/enemies/monsterMobAuto.ts @@ -123,7 +123,6 @@ export class MonsterMobAuto extends GenericMonster { ] }) - // this.setupRangedAttackTriggerBox() this.setupEngageTriggerBox() this.setupAttackTriggerBox() diff --git a/scene/src/player/petManager.ts b/scene/src/player/petManager.ts index 8f85891..bb715ea 100644 --- a/scene/src/player/petManager.ts +++ b/scene/src/player/petManager.ts @@ -11,7 +11,7 @@ export enum PetTypes { export class PetManager { pets: string[] - petInstances: Record + petInstances: Record constructor(pets: string[] = []) { this.pets = pets @@ -25,12 +25,12 @@ export class PetManager { } } - addPetInstance(name: string, pet: any): void { + addPetInstance(name: string, pet: Pet): void { this.petInstances[name] = pet } - getPetInstance(name: string): Pet { - return this.petInstances?.[name] + getPetInstance(name: string): Pet | null { + return this.petInstances?.[name] ?? null } setPets(pets: string[] = []): void { @@ -41,8 +41,7 @@ export class PetManager { const instance = this.getPetInstance(name) if (instance != null) { instance.remove() - // eslint-disable-next-line @typescript-eslint/no-dynamic-delete - delete this.petInstances[name] + this.petInstances[name] = null } } diff --git a/scene/src/realms/antrom.ts b/scene/src/realms/antrom.ts index 42be588..df69975 100644 --- a/scene/src/realms/antrom.ts +++ b/scene/src/realms/antrom.ts @@ -762,8 +762,6 @@ export class Antrom implements Realm { ) { if (trewsKill.read() === 1) { if (garrisonCreatedOnce.read() === 0) { - // this.gameController.realmController.switchRealm('demonKingDungeon') - // spawnBoss3() garrisonCreatedOnce.increase(1) } else { setPlayerPosition(-9.83, 48.19, -45.24) @@ -1495,23 +1493,6 @@ export class Antrom implements Realm { this.campFire ) ) { - // if (refreshtimer <= 0) { - // setRefreshTimer(5) - // let prompt = new ui.OptionPrompt( - // "Cozy Camp Fire", - // "The cool evening air and flickering flames of the campfire make for the perfect setting to cook up some hearty fare. \nTo recover your full health, simply cook five pieces of meat at this campfire!", - // () => { - // if ( - // player.inventory.getItemCount( - // ITEM_TYPES.CHICKEN - // ) >= 5 - // ) { - // player.inventory.reduceItem( - // ITEM_TYPES.CHICKEN, - // 5 - // ) - // setRefreshTimer(6) - // player.writeDataToServer() this.gameController.uiController.displayAnnouncement( 'Cooking...', Color4.Yellow(), diff --git a/scene/src/realms/dungeon.ts b/scene/src/realms/dungeon.ts index 254f6a8..a8e294b 100644 --- a/scene/src/realms/dungeon.ts +++ b/scene/src/realms/dungeon.ts @@ -31,16 +31,6 @@ import NightmareDesertDungeonBoss from '../enemies/desertBosses/NightmareDesertD import HardDesertDungeonBoss from '../enemies/desertBosses/HardDesertDungeonBoss' import MedDesertDungeonBoss from '../enemies/desertBosses/MedDesertDungeonBoss' -// type Difficulty = { -// EASY: 'easy' -// MEDIUM: 'medium' -// HARD: 'hard' -// NIGHTMARE: 'nightmare' -// } -// type Location = { -// CAVE: 'cave' -// DESERT: 'desert' -// } const desertSoldierPositions = [ // room1 Vector3.create(-16.52, 2.39, 60.76), @@ -103,12 +93,6 @@ const desertSoldierPositions = [ Vector3.create(49.56, 2.39, 10.25), Vector3.create(49.51, 2.39, 17.07) ] - -// const magePositions = [ -// Vector3.create(43.61, 3.29, 54.45), -// Vector3.create(61.91, 3.29, 56.97) -// ] - export class Dungeon implements Realm { private readonly boardParent = entityController.addEntity() private readonly leaderBoard: LeaderBoard @@ -124,13 +108,21 @@ export class Dungeon implements Realm { private readonly sandDungeonSecret = entityController.addEntity() private readonly villager1 = entityController.addEntity() private readonly doorOpening = entityController.addEntity() - private readonly boss: EasyDesertDungeonBoss + private readonly difficulty: string + private boss: + | EasyDesertDungeonBoss + | MedDesertDungeonBoss + | HardDesertDungeonBoss + | NightmareDesertDungeonBoss + | null + gameController: GameController - constructor(gameController: GameController) { + constructor(gameController: GameController, difficulty: string) { this.gameController = gameController this.buildDungeon('DesertDungeon') this.createDesertDungeonEnemies(this.gameController) - this.boss = new EasyDesertDungeonBoss(8) + this.boss = null + this.difficulty = difficulty GltfContainer.create(this.wall1, { src: 'assets/models/sandDungeonDoor.glb' }) @@ -519,25 +511,21 @@ export class Dungeon implements Realm { this.createSoldier(position, gameController) }) } + // createDeserDungeonBoss needs to be implemented from the Quest createDesertDungeonBoss(difficulty: string): void { switch (difficulty) { case 'easy': - // eslint-disable-next-line no-case-declarations, @typescript-eslint/no-unused-vars - const bossEasy = new EasyDesertDungeonBoss(8) + this.boss = new EasyDesertDungeonBoss(8) break case 'medium': - // eslint-disable-next-line no-case-declarations, @typescript-eslint/no-unused-vars - const bossMed = new MedDesertDungeonBoss(80) + this.boss = new MedDesertDungeonBoss(80) break case 'hard': - // eslint-disable-next-line no-case-declarations, @typescript-eslint/no-unused-vars - const bossHard = new HardDesertDungeonBoss(300) + this.boss = new HardDesertDungeonBoss(300) break case 'nightmare': - // eslint-disable-next-line no-case-declarations, @typescript-eslint/no-unused-vars - const bossNightmare = new NightmareDesertDungeonBoss(800) - console.log('') + this.boss = new NightmareDesertDungeonBoss(800) } } diff --git a/scene/src/realms/minerscave.ts b/scene/src/realms/minerscave.ts index 0423474..93abe4c 100644 --- a/scene/src/realms/minerscave.ts +++ b/scene/src/realms/minerscave.ts @@ -68,9 +68,11 @@ export class MinersCave implements Realm { private readonly pot_positions: Vector3[] private readonly pots_entities: Pot[] private readonly gems_entities: Gem[] + private readonly difficulty: string gameController: GameController - constructor(gameController: GameController) { + constructor(gameController: GameController, difficulty: string) { this.gameController = gameController + this.difficulty = difficulty this.createCaveDungeonEnemies(this.gameController) this.buildCave() GltfContainer.create(this.cave, { src: 'assets/models/cave.glb' })