From 95f216e6e76b6311bcaf6ff210fe8cac9ba065c3 Mon Sep 17 00:00:00 2001 From: walkpan Date: Thu, 1 Jan 2026 23:39:22 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E6=80=AA=E7=89=A9=E7=B3=BB=E7=BB=9F):=20?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=B8=B8=E6=88=8F=E6=97=B6=E9=97=B4=E5=8F=82?= =?UTF-8?q?=E6=95=B0=E5=BD=B1=E5=93=8D=E6=80=AA=E7=89=A9=E5=B1=9E=E6=80=A7?= =?UTF-8?q?=E8=AE=A1=E7=AE=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 在怪物加载和生成逻辑中添加gameTime参数,用于动态成长系统根据游戏时间调整怪物属性 --- assets/script/game/hero/Mon.ts | 4 ++-- assets/script/game/map/MissionMonComp.ts | 14 ++++++++++---- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/assets/script/game/hero/Mon.ts b/assets/script/game/hero/Mon.ts index 17f7882f..961175ee 100644 --- a/assets/script/game/hero/Mon.ts +++ b/assets/script/game/hero/Mon.ts @@ -35,7 +35,7 @@ export class Monster extends ecs.Entity { } /** 加载角色 */ - load(pos: Vec3 = Vec3.ZERO,scale:number = 1,uuid:number=1001,lv:number=1,monType:MonType=MonType.NORMAL, buffs: BuffConf[] = [],is_call=false, lane: number = 0, spawnOrder: number = 0) { + load(pos: Vec3 = Vec3.ZERO,scale:number = 1,uuid:number=1001,lv:number=1,monType:MonType=MonType.NORMAL, buffs: BuffConf[] = [],is_call=false, lane: number = 0, spawnOrder: number = 0, gameTime: number = 0) { scale=-1 let size=1 var scene = smc.map.MapView.scene; @@ -71,7 +71,7 @@ export class Monster extends ecs.Entity { model.is_kalami = true; } // 根据等级和类型获取怪物属性(使用新的动态成长系统) - const {hp, mp, ap, def, speed} = getMonAttr(lv, uuid, monType); + const {hp, mp, ap, def, speed} = getMonAttr(lv, uuid, monType, gameTime); // 初始化属性数组 model.Attrs = getAttrs(); model.hp = model.Attrs[Attrs.HP_MAX] = hp; diff --git a/assets/script/game/map/MissionMonComp.ts b/assets/script/game/map/MissionMonComp.ts index 4ff881e7..1dabf913 100644 --- a/assets/script/game/map/MissionMonComp.ts +++ b/assets/script/game/map/MissionMonComp.ts @@ -32,6 +32,8 @@ export class MissionMonCompComp extends CCComp { private eventProcessed: boolean = false; // 事件是否已处理 /** 全局生成顺序计数器,用于层级管理 */ private globalSpawnOrder: number = 0; + /** 游戏进行时间(秒) */ + private gameTime: number = 0; onLoad(){ @@ -56,6 +58,9 @@ export class MissionMonCompComp extends CCComp { protected update(dt: number): void { if(!smc.mission.play||smc.mission.pause) return + // 累加游戏时间 + this.gameTime += dt; + // 处理随机事件 @@ -167,7 +172,8 @@ export class MissionMonCompComp extends CCComp { monsterData.position, monsterData.type, monsterData.level, - monsterData.buffs + monsterData.buffs, + this.gameTime ); // 增加召唤计数 this.spawnCount++; @@ -180,8 +186,8 @@ export class MissionMonCompComp extends CCComp { i: number = 0, monType: number = 0, lv: number = 1, - buffs: BuffConf[] = [] - + buffs: BuffConf[] = [], + gameTime: number = 0 ) { let mon = ecs.getEntity(Monster); let scale = -1; @@ -199,7 +205,7 @@ export class MissionMonCompComp extends CCComp { this.globalSpawnOrder = (this.globalSpawnOrder + 1) % 999; // 防止无限增长,在999处循环重置 // 生成怪物,传递线路和生成顺序 - mon.load(pos, scale, uuid, lv, monType, buffs, false, lane, this.globalSpawnOrder); + mon.load(pos, scale, uuid, lv, monType, buffs, false, lane, this.globalSpawnOrder, gameTime); }