修复 buff 逻辑处理 bug : 预制体不能设置全局监听oops.message.on,会一直执行
This commit is contained in:
@@ -21,6 +21,7 @@ import { SkillCom } from "../skills/SkillCom";
|
||||
import { SkillSet } from "../common/config/SkillSet";
|
||||
import { BoxRangComp } from "./BoxRangComp";
|
||||
import { Tooltip } from "../skills/Tooltip";
|
||||
import { MonsterBuffComp } from "./MonsterBuffComp";
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
/** 角色显示组件 */
|
||||
@@ -34,6 +35,9 @@ export class MonsterViewComp extends CCComp {
|
||||
|
||||
@property(Node)
|
||||
BoxRang:Node =null!
|
||||
|
||||
buff:MonsterBuffComp =null!
|
||||
|
||||
/** 角色动画 */
|
||||
as: MonsterSpine = null!;
|
||||
hero_uuid:number = 1001;
|
||||
@@ -66,6 +70,7 @@ export class MonsterViewComp extends CCComp {
|
||||
stop_cd: number = 0.5; /*停止倒计时*/
|
||||
|
||||
shield:number = 0; //护盾量
|
||||
shield_max:number = 0;
|
||||
shield_time:number = 0; //护盾持续时间
|
||||
|
||||
box_group:number = 2;
|
||||
@@ -77,18 +82,18 @@ export class MonsterViewComp extends CCComp {
|
||||
|
||||
onLoad() {
|
||||
this.as = this.getComponent(MonsterSpine);
|
||||
|
||||
this.buff=this.node.getComponent(MonsterBuffComp);
|
||||
this.BoxRang = this.node.getChildByName("range_box");
|
||||
} /** 视图层逻辑代码分离演示 */
|
||||
start () {
|
||||
this.sprite = this.node.getChildByName("avatar").getChildByName("TNode").getChildByName("bb").getComponent(Sprite);
|
||||
this.orginalFlashMaterial = this.sprite.getRenderMaterial(0);
|
||||
|
||||
|
||||
this.BoxRang = this.node.getChildByName("range_box");
|
||||
this.BoxRang.getComponent(BoxRangComp).box_group = this.box_group;
|
||||
this.BoxRang.getComponent(BoxRangComp).offset_x = this.scale*SkillSet[this.skill_uuid].dis;
|
||||
this.BoxRang.getComponent(BoxRangComp).offset_x = this.scale*smc.skills[this.skill_uuid].dis;
|
||||
// console.log("monseter ",this.BoxRang);
|
||||
|
||||
this.buff.group=this.box_group
|
||||
// 注册单个碰撞体的回调函数
|
||||
let collider = this.getComponent(Collider2D);
|
||||
collider.group = this.box_group;
|
||||
@@ -182,11 +187,11 @@ export class MonsterViewComp extends CCComp {
|
||||
let x=32
|
||||
let pos = v3(35*this.scale,40)
|
||||
let scale = this.scale
|
||||
let speed =SkillSet[skill_uuid].speed;
|
||||
let dis = SkillSet[skill_uuid].dis;
|
||||
let atk = SkillSet[skill_uuid].atk+this.atk;
|
||||
let speed =smc.skills[skill_uuid].speed;
|
||||
let dis = smc.skills[skill_uuid].dis;
|
||||
let atk = smc.skills[skill_uuid].atk+this.atk;
|
||||
skill.load(pos,speed,dis,scale,this.node,skill_uuid,atk);
|
||||
// this.tooltip(3,SkillSet[skill_uuid].name,this.skill_uuid);
|
||||
// this.tooltip(3,smc.skills[skill_uuid].name,this.skill_uuid);
|
||||
}
|
||||
//使用max_skill
|
||||
do_max_skill(){
|
||||
@@ -194,11 +199,11 @@ export class MonsterViewComp extends CCComp {
|
||||
let x=32
|
||||
let pos = v3(35*this.scale,40)
|
||||
let scale = this.scale
|
||||
let speed =SkillSet[this.max_skill_uuid].speed;
|
||||
let dis = SkillSet[this.max_skill_uuid].dis;
|
||||
let atk = SkillSet[this.max_skill_uuid].atk+this.atk;
|
||||
let speed =smc.skills[this.max_skill_uuid].speed;
|
||||
let dis = smc.skills[this.max_skill_uuid].dis;
|
||||
let atk = smc.skills[this.max_skill_uuid].atk+this.atk;
|
||||
skill.load(pos,speed,dis,scale,this.node,this.max_skill_uuid,atk);
|
||||
this.tooltip(3,SkillSet[this.max_skill_uuid].name,this.max_skill_uuid);
|
||||
this.tooltip(3,smc.skills[this.max_skill_uuid].name,this.max_skill_uuid);
|
||||
}
|
||||
in_act(dt: number) {
|
||||
|
||||
@@ -219,7 +224,11 @@ export class MonsterViewComp extends CCComp {
|
||||
if(this.is_dead){
|
||||
return;
|
||||
}
|
||||
this.hp -= hp;
|
||||
let lhp=this.shield_change(hp);
|
||||
if(lhp == 0){
|
||||
return;
|
||||
}
|
||||
this.hp += lhp;
|
||||
this.tooltip(1,hp.toString());
|
||||
if(this.hp > this.hp_max){
|
||||
this.hp = this.hp_max;
|
||||
@@ -234,6 +243,18 @@ export class MonsterViewComp extends CCComp {
|
||||
}, 15);
|
||||
}
|
||||
}
|
||||
shield_change(hp: number){
|
||||
let ls=this.shield - hp;
|
||||
if(ls <= 0){
|
||||
this.shield = 0;
|
||||
return ls;
|
||||
}else{
|
||||
this.shield = ls;
|
||||
return 0;
|
||||
}
|
||||
// let shield_progress= this.shield/this.shield_max;
|
||||
// this.node.getChildByName("shield").getComponent(ProgressBar)!.progress = shield_progress;
|
||||
}
|
||||
tooltip(type:number=1,value:string="",s_uuid:number=1001){
|
||||
// console.log("tooltip",type);
|
||||
let tip =ecs.getEntity<Tooltip>(Tooltip);
|
||||
|
||||
Reference in New Issue
Block a user