- 新增英雄 ha2、ha3、hk2、hk3、hk4、hm3、hm4、hm5、mo5、mo6 的目录元数据 - 为新增英雄添加完整的动画剪辑(atk0、dead、idle、max0、max1、move) - 移除旧版英雄的冗余动画文件(atk1、atk2、buff、stun) - 更新现有英雄的动画配置,统一使用 atk0 作为攻击动画 - 优化 hm1 英雄的动画时长和采样率,提升流畅度 - 在 HeroViewComp 中增加英雄等级显示逻辑 - 重构 HeroAnmComp,简化动画状态管理
71 lines
2.3 KiB
TypeScript
71 lines
2.3 KiB
TypeScript
import { _decorator, Animation, AnimationState, CCClass, Component, } from "cc";
|
|
import { HeroViewComp } from "./HeroViewComp";
|
|
import { FacSet } from "../common/config/GameSet";
|
|
import { FlashSprite } from "./hit-flash-white/scripts/FlashSprite";
|
|
const { ccclass, property } = _decorator;
|
|
|
|
@ccclass('HeroAnmComp')
|
|
export default class HeroAnmComp extends Component{
|
|
fsSprite:FlashSprite = null!;
|
|
private anmcon:any=null
|
|
private _hasStop = true;
|
|
private _atkIndex = 0;
|
|
private default_anim:string='idle'
|
|
anms:any[]=["idle","move","dead","atk0","max0","max1"]
|
|
onLoad () {
|
|
this.anmcon=this.node.getComponent(Animation)
|
|
this.fsSprite = this.node.getComponent(FlashSprite);
|
|
this.anmcon.on(Animation.EventType.FINISHED, this.onAnimationFinished, this);
|
|
}
|
|
|
|
onDestroy() {
|
|
if (this.anmcon) {
|
|
this.anmcon.off(Animation.EventType.FINISHED, this.onAnimationFinished, this);
|
|
}
|
|
}
|
|
|
|
stop () {
|
|
this._hasStop = true;
|
|
}
|
|
onAnimationFinished(type:Animation.EventType, state:AnimationState){
|
|
if(state.name!="idle"&&state.name!="move"&&state.name!="dead"&&state.name!="stun"){
|
|
this.anmcon.play(this.default_anim)
|
|
}
|
|
}
|
|
atked(){
|
|
this.fsSprite.clickFlash();
|
|
}
|
|
move () {
|
|
if(this.anmcon.getState("move").isPlaying) return
|
|
this.anmcon.play("move")
|
|
this.default_anim='move'
|
|
}
|
|
atk () {
|
|
if(this.anmcon.getState("max0").isPlaying||this.anmcon.getState("max1").isPlaying) return
|
|
this.anmcon.play(`atk0`)
|
|
}
|
|
max () {
|
|
if(this.anmcon.getState("max0").isPlaying||this.anmcon.getState("max1").isPlaying) return
|
|
this.anmcon.play("max0")
|
|
}
|
|
play(anm:string=""){
|
|
if(anm==="") return
|
|
if(this.anmcon.getState("max0").isPlaying||this.anmcon.getState("max1").isPlaying) return
|
|
this.anmcon.play(anm)
|
|
}
|
|
|
|
idle () {
|
|
if(this.anmcon.getState("idle").isPlaying) return
|
|
this.anmcon.play("idle")
|
|
this.default_anim='idle'
|
|
}
|
|
buff(){
|
|
if(this.anmcon.getState("max0").isPlaying||this.anmcon.getState("max1").isPlaying) return
|
|
this.anmcon.play("buff")
|
|
}
|
|
dead(){
|
|
if(this.anmcon.getState("dead").isPlaying) return
|
|
this.anmcon.play("dead")
|
|
}
|
|
}
|