role 也转为使用hero 预制体

This commit is contained in:
2024-09-02 17:15:30 +08:00
parent 83bd06334f
commit 8b9c04eae3
15 changed files with 299 additions and 223 deletions

View File

@@ -16,21 +16,15 @@ const { ccclass, property } = _decorator;
@ecs.register('MapView', false)
export class MapViewComp extends CCComp {
scene: MapViewScene = null!;
current_map: any;
private game_timer: Timer = new Timer(1);
private mapLoaded() {
}
async onLoad(){
// 监听全局事件
oops.message.on("do_add_hero", this.on_do_add_hero, this);
}
/**监听do_add_hero 添加hero,通过uuid */
private on_do_add_hero(event: string, args: any) {
// console.log("do_add_hero",args.uuid)
this.addHero(args.uuid)
}
reset(): void {
//撤销监听
// oops.message.off("do_add_hero", this.on_do_add_hero, this);
@@ -41,12 +35,7 @@ export class MapViewComp extends CCComp {
this.load_data()
// this.load_role()
}
load_role(){
let role = ecs.getEntity<Role>(Role);
let pos = v3(BoxSet.HERO_START-50,BoxSet.GAME_LINE)
role.load(pos,108)
smc.Role=role
}
load_data(){
// let heros = oops.res.get("config/game/heros")
// console.log("heros",heros)
@@ -79,14 +68,7 @@ export class MapViewComp extends CCComp {
smc.vm_data.shuaxin.min = 0;
}
}
/** 添加玩家 */
private addHero(uuid:number=1001) {
this.scene.node.active = true
let hero = ecs.getEntity<Hero>(Hero);
let pos = v3(BoxSet.HERO_START,BoxSet.GAME_LINE)
let scale = 1
hero.load(pos,scale,uuid);
}
}