修复 buff 逻辑处理 bug : 预制体不能设置全局监听oops.message.on,会一直执行

This commit is contained in:
2024-08-28 00:09:55 +08:00
parent 5b1991c90f
commit 4096a17330
15 changed files with 195 additions and 143 deletions

View File

@@ -9,6 +9,8 @@ import { MonsterModelComp } from "./MonsterModelComp";
import { MonsterViewComp } from "./MonsterViewComp";
import { BoxSet } from "../common/config/BoxSet";
import { smc } from "../common/SingletonModuleComp";
import { oops } from "../../../../extensions/oops-plugin-framework/assets/core/Oops";
import { HeroModelComp } from "./HeroModelComp";
const { ccclass, property } = _decorator;
/** 视图层对象 */
@@ -29,9 +31,9 @@ export class CSkillComp extends CCComp {
/** 视图层逻辑代码分离演示 */
start() {
// var entity = this.ent as ecs.Entity; // ecs.Entity 可转为当前模块的具体实体对象
this.sd =new Timer(SkillSet[this.skill_uuid].sd)
this.cd = new Timer(SkillSet[this.skill_uuid].cd)
this.time =SkillSet[this.skill_uuid].sd
this.sd =new Timer(smc.skills[this.skill_uuid].sd)
this.cd = new Timer(smc.skills[this.skill_uuid].cd)
this.time =smc.skills[this.skill_uuid].sd
this.node.getChildByName("time").getComponent(Label).string = this.time.toString()
}
@@ -45,7 +47,13 @@ export class CSkillComp extends CCComp {
if (this.cd.update(dt)) {
this.time -=1
this.node.getChildByName("time").getComponent(Label).string = this.time.toString()
this.shoot()
if(smc.skills[this.skill_uuid].type == 1){
this.shoot()
}
if(smc.skills[this.skill_uuid].type == 9){
this.add_buff()
}
}
}
shoot() {
@@ -72,11 +80,24 @@ export class CSkillComp extends CCComp {
angle = randian * (180 / Math.PI);
// console.log("angle",angle);
let scale = this.scale
let dis = SkillSet[this.skill_uuid].dis+this.dis;
let atk = SkillSet[this.skill_uuid].atk+this.atk;
let speed = SkillSet[this.skill_uuid].speed+this.speed;
let dis = smc.skills[this.skill_uuid].dis+this.dis;
let atk = smc.skills[this.skill_uuid].atk+this.atk;
let speed = smc.skills[this.skill_uuid].speed+this.speed;
skill.load(pos,speed,dis,scale,this.node,this.skill_uuid,atk,angle,t_pos);
}
add_buff(){
let uuid= this.skill_uuid;
let eid = 0
let group = BoxSet.HERO;
let heros:any = ecs.query(ecs.allOf(HeroModelComp));
if (heros.length > 0) {
for (let i = 0; i < heros.length; i++) {
let hero = heros[i];
hero.MonsterBuff.add_buff(uuid,eid,group);
}
}
// oops.message.dispatchEvent("add_buff",{uuid:this.skill_uuid,eid:0,group:BoxSet.HERO})
}
/** 全局消息逻辑处理 */
// private onHandler(event: string, args: any) {
// switch (event) {
@@ -106,7 +127,6 @@ export class CSkillComp extends CCComp {
reset() {
this.sd.reset()
this.cd.reset()
this.node.destroy();
}
}