This commit is contained in:
pan
2024-08-20 18:27:34 +08:00
parent 87a445c225
commit b9edfd7001
17 changed files with 407 additions and 143 deletions

View File

@@ -0,0 +1,62 @@
import { _decorator ,Vec3,v3} 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 { Timer } from "../../../../extensions/oops-plugin-framework/assets/core/common/timer/Timer";
import { Monster } from "../monster/Monster";
import { BoxSet } from "../common/config/BoxSet";
import { smc } from "../common/SingletonModuleComp";
import { oops } from "../../../../extensions/oops-plugin-framework/assets/core/Oops";
import { MapViewScene } from "./view/MapViewScene";
const { ccclass, property } = _decorator;
/** 视图层对象 */
@ccclass('MapMonsterComp')
@ecs.register('MapMonster', false)
export class MapMonsterComp extends CCComp {
scene: MapViewScene = null;
current_map: any;
private monster_refresh_rtimer: Timer = new Timer(1);
async onLoad(){
// 监听全局事件
oops.message.on("do_add_monster", this.on_do_add_monster, this);
}
protected update(dt: number): void {
if (this.monster_refresh_rtimer.update(dt)) {
// 刷新怪物定时器
this.monster_refresh()
}
// if (this.game_timer.update(dt)) {
// smc.vm_data.game.g_time += 1;
// }
// this.shuaxin(dt)
}
monster_refresh(){
if(smc.monsters.length > 0 ){
this.addMonster(smc.monsters[0].uuid)
}
}
private addMonster(uuid:number=1101) {
let monster = ecs.getEntity<Monster>(Monster);
let pos:Vec3 = v3(BoxSet.MONSTER_START,BoxSet.GAME_LINE)
let camp = -1
monster.load(pos,camp,uuid);
smc.monsters.splice(0,1)
}
private on_do_add_monster(event: string, args: any) {
// this.addMonster(args.uuid)
}
/** 视图层逻辑代码分离演示 */
start() {
this.scene = this.getComponent(MapViewScene);
}
/** 视图对象通过 ecs.Entity.remove(ModuleViewComp) 删除组件是触发组件处理自定义释放逻辑 */
reset() {
this.node.destroy();
}
}