dd
This commit is contained in:
39
assets/script/game/map/LifeComp.ts
Normal file
39
assets/script/game/map/LifeComp.ts
Normal file
@@ -0,0 +1,39 @@
|
||||
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() {
|
||||
this.node.setSiblingIndex(100)
|
||||
}
|
||||
|
||||
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)
|
||||
let nodes=this.node.children
|
||||
nodes[this.loss_life].active=false
|
||||
this.loss_life++
|
||||
if(this.loss_life >= 3){
|
||||
oops.message.dispatchEvent(GameEvent.MissionLoss)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user