import { _decorator, Component, Node } from 'cc'; import { oops } from 'db://oops-framework/core/Oops'; import { GameEvent } from '../common/config/GameEvent'; const { ccclass, property } = _decorator; @ccclass('LifeComp') export class LifeComp extends Component { loss_life:number=0 protected onLoad(): void { oops.message.on(GameEvent.FightReady,this.onFightReady,this) oops.message.on(GameEvent.LifeChange,this.onLifeChange,this) } start() { } update(deltaTime: number) { } onFightReady(args: any) { console.log("[LifeComp]:onMissionStart",args) let nodes=this.node.children nodes[0].active=true nodes[1].active=true nodes[2].active=true this.loss_life=0 } onLifeChange(args: any) { console.log("[LifeComp]:onLifeChange loss_life:",this.loss_life) if(this.loss_life >= 3) return let nodes=this.node.children nodes[this.loss_life].active=false this.loss_life++ if(this.loss_life >= 3){ oops.message.dispatchEvent(GameEvent.FightEnd) } } }