// 活動實體 import Entity from "./Entity"; const {ccclass, property} = cc._decorator; @ccclass export default class LiveEntity extends Entity{ @property(cc.ProgressBar) hpBar:cc.ProgressBar=null; actlist=[]; living_state:number=0; hp:number=100; mp:number=0; is_die:boolean=false; livingtype:number=0; playStop(){ if(this.living_state==0){ return; } this.living_state=0; } playAtk(){ this.living_state=1; } playHit(hp:number) { if (this.hpBar != null) { this.hpBar.node.active = true; this.hpBar.progress = hp / this.hp; } //播放被打動畫 } playDie() { this.living_state = 3; //播放死亡動畫 this.is_die = true; this.node.runAction(cc.sequence(cc.fadeOut(1), cc.removeSelf())); } start() { this.schedule(this.objUpdate, 0.1, cc.macro.REPEAT_FOREVER, 0.1); } objUpdate() { this.node.zIndex = Math.round(576 - (this.node.parent.convertToWorldSpaceAR(cc.v2(this.node.x, this.node.y))).y); if (this.actlist.length > 0) { if (this.actlist[0].type == 2 && this.living_state != 2) { let act = this.actlist.shift(); this.objMove(act.info.r, act.info.l); } } else { this.playStop(); } } objMove(row:number, line:number) { this.living_state = 2; } }