调整HeroAnmComp中动画完成时的状态检查,增加dead和stun状态 修改MissionMonComp中怪物生成逻辑,现在只生成第一个怪物 重构HeroViewComp的死亡处理逻辑,添加死亡计时器和复活功能
54 lines
1.7 KiB
TypeScript
54 lines
1.7 KiB
TypeScript
import { _decorator, Animation, AnimationState, CCClass, Component, } from "cc";
|
|
import { HeroViewComp } from "./HeroViewComp";
|
|
import { FacSet } from "../common/config/GameSet";
|
|
const { ccclass, property } = _decorator;
|
|
|
|
@ccclass('HeroAnmComp')
|
|
export default class HeroAnmComp extends Component{
|
|
|
|
private anmcon:any=null
|
|
private _hasStop = true;
|
|
private default_anim:string='Idle'
|
|
anms:any[]=["idle","move","stun","dead","buff","atk0","atk1","atk2","max0","max1"]
|
|
onLoad () {
|
|
this.anmcon=this.node.getComponent(Animation)
|
|
this.anmcon.on(Animation.EventType.FINISHED, this.onAnimationFinished, this);
|
|
}
|
|
|
|
|
|
stop () {
|
|
this._hasStop = true;
|
|
}
|
|
onAnimationFinished(type:Animation.EventType, state:AnimationState){
|
|
// console.log("[HeroAnmComp]: 动画播放完毕",state.name)
|
|
if(state.name!="idle"&&state.name!="move"&&state.name!="dead"&&state.name!="stun"){
|
|
this.anmcon.play(this.default_anim)
|
|
}
|
|
}
|
|
move () {
|
|
if(this.anmcon.getState("move").isPlaying) return
|
|
this.anmcon.play("move")
|
|
this.default_anim='move'
|
|
}
|
|
atk () {
|
|
if(this.anmcon.getState("atk0").isPlaying) return
|
|
this.anmcon.play("atk0")
|
|
}
|
|
max () {
|
|
if(this.anmcon.getState("max0").isPlaying) return
|
|
this.anmcon.play("max0")
|
|
}
|
|
idle () {
|
|
if(this.anmcon.getState("idle").isPlaying) return
|
|
this.anmcon.play("idle")
|
|
this.default_anim='idle'
|
|
}
|
|
buff(){
|
|
if(this.anmcon.getState("buff").isPlaying) return
|
|
this.anmcon.play("buff")
|
|
}
|
|
dead(){
|
|
if(this.anmcon.getState("dead").isPlaying) return
|
|
this.anmcon.play("dead")
|
|
}
|
|
} |