import { _decorator, v3, Vec3 } from "cc"; import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS"; import { CCComp } from "../../../../extensions/oops-plugin-framework/assets/module/common/CCComp"; import { BoxSet } from "../common/config/BoxSet"; import { HeroList, HeroSet } from "../common/config/heroSet"; import { Hero } from "../hero/Hero"; import { smc } from "../common/SingletonModuleComp"; import { Timer } from "db://oops-framework/core/common/timer/Timer"; import { RandomManager } from "db://oops-framework/core/common/random/RandomManager"; const { ccclass, property } = _decorator; /** 视图层对象 */ @ccclass('MissionHeroCompComp') @ecs.register('MissionHeroComp', false) export class MissionHeroCompComp extends CCComp { timer:Timer=new Timer(2) start() { } protected update(dt: number): void { if(smc.mission.status != 1) return if(this.timer.update(dt)){ this.call_hero() } } call_hero(){ this.timer.reset() let hero_list =HeroList let x=RandomManager.instance.getRandomInt(0,hero_list.length,1) let uuid=hero_list[x] console.log("call_hero",uuid) this.addHero(uuid) } /** 添加玩家 */ private addHero(uuid:number=1001,i:number=0) { let hero = ecs.getEntity(Hero); let scale = 1 let pos:Vec3 = v3(HeroSet.StartPos[1]-i*10,BoxSet.GAME_LINE); hero.load(pos,scale,uuid); } /** 视图对象通过 ecs.Entity.remove(ModuleViewComp) 删除组件是触发组件处理自定义释放逻辑 */ reset() { this.node.destroy(); } }