diff --git a/assets/script/game/map/MissionMonComp.ts b/assets/script/game/map/MissionMonComp.ts index f0cfa03a..769c24fa 100644 --- a/assets/script/game/map/MissionMonComp.ts +++ b/assets/script/game/map/MissionMonComp.ts @@ -4,7 +4,7 @@ import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ec import { CCComp } from "../../../../extensions/oops-plugin-framework/assets/module/common/CCComp"; import { oops } from "../../../../extensions/oops-plugin-framework/assets/core/Oops"; import { Monster } from "../hero/Mon"; -import { HeroInfo } from "../common/config/heroSet"; +import { HeroInfo, HType } from "../common/config/heroSet"; import { smc } from "../common/SingletonModuleComp"; import { GameEvent } from "../common/config/GameEvent"; import {BoxSet } from "../common/config/GameSet"; @@ -47,7 +47,6 @@ export class MissionMonCompComp extends CCComp { monLv: number, }>> = []; private slotOccupiedEids: Array = []; - private nextAssignSlotIndex: number = 0; /** 全局生成顺序计数器,用于层级管理(预留) */ private globalSpawnOrder: number = 0; /** 插队刷怪处理计时器 */ @@ -149,7 +148,6 @@ export class MissionMonCompComp extends CCComp { this.waveSpawnedCount = 0; this.bossSpawnedInWave = false; this.waveSpawnTimer = this.waveSpawnCd; - this.nextAssignSlotIndex = 0; this.primeWaveInitialBurst(); oops.message.dispatchEvent(GameEvent.NewWave, { wave: this.currentWave, @@ -233,7 +231,6 @@ export class MissionMonCompComp extends CCComp { { length: MissionMonCompComp.MON_SLOT_COUNT }, () => null ); - this.nextAssignSlotIndex = 0; } private hasPendingSlotQueue() { @@ -271,18 +268,26 @@ export class MissionMonCompComp extends CCComp { return occupied + this.slotSpawnQueues[slotIndex].length; } - private pickAssignSlotIndex(): number { + private resolveSlotPriorityIndexes(uuid: number): number[] { + const type = HeroInfo[uuid]?.type; + if (type === HType.Melee) { + return [0, 1, 2, 3, 4, 5]; + } + return [5, 4, 3, 2, 1, 0]; + } + + private pickAssignSlotIndex(uuid: number): number { + const slotPriority = this.resolveSlotPriorityIndexes(uuid); let bestLoad = Number.MAX_SAFE_INTEGER; - let bestIndex = this.nextAssignSlotIndex % MissionMonCompComp.MON_SLOT_COUNT; - for (let step = 0; step < MissionMonCompComp.MON_SLOT_COUNT; step++) { - const index = (this.nextAssignSlotIndex + step) % MissionMonCompComp.MON_SLOT_COUNT; + let bestIndex = slotPriority[0] ?? 0; + for (let i = 0; i < slotPriority.length; i++) { + const index = slotPriority[i]; const load = this.getSlotQueueLoad(index); if (load < bestLoad) { bestLoad = load; bestIndex = index; } } - this.nextAssignSlotIndex = (bestIndex + 1) % MissionMonCompComp.MON_SLOT_COUNT; return bestIndex; } @@ -293,7 +298,7 @@ export class MissionMonCompComp extends CCComp { monLv: number = 1, priority: boolean = false, ) { - const slotIndex = this.pickAssignSlotIndex(); + const slotIndex = this.pickAssignSlotIndex(uuid); const request = { uuid, isBoss, upType, monLv }; if (priority) { this.slotSpawnQueues[slotIndex].unshift(request);