Files
pixelheros/assets/script/game/hero/HeroSpine.ts
panFD d951896799 refactor(hero): 优化英雄动画状态同步逻辑
移除测试用的英雄成长模拟数据,修复动画状态与实际表现不一致的问题

1. 重构HeroSpine的idle/move方法,新增返回值标记动画是否被拦截
2. 重构HeroViewComp的status_change逻辑,仅在动画切换成功时更新状态
3. 重构HeroAnmComp的动画播放逻辑,修复动画结束后默认播放的异常
4. 移除SingletonModuleComp中的测试用英雄成长数据
5. 简化MoveSystem中状态切换的冗余判断逻辑
2026-09-12 14:04:18 +08:00

91 lines
1.8 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { Color, Component, EventTouch, Vec3, _decorator ,} from "cc";
import HeroAnmComp from "./HeroAnmComp";
const { ccclass, property } = _decorator;
@ccclass('HeroSpine')
export class HeroSpine extends Component {
@property(HeroAnmComp)
anm: HeroAnmComp = null;
status:string="";
onLoad() {
// 角色控制组件
}
protected start(): void {
this.idle();
}
/** 初始化动画 */
protected initAnimator() {
}
in_playing(){
}
change_status(value:string){
this.status=value
}
change_default(value:string){
}
default() {
}
/**
* 播放待机动画:动画层成功切换才记录 status,
* 被普攻/buff/大招拦截时返回 false 且不记录,保证记录与实际动画一致。
*/
idle(): boolean {
if(this.status=="idle") return true
if(!this.anm.idle()) return false
this.status="idle"
return true
}
atk() {
this.anm.atk()
}
max(){
this.anm.max()
}
play(name:string){
switch(name){
case "max":
this.max()
break
case "atk":
this.atk()
break
case "idle":
this.idle()
break
case "move":
this.move()
break
}
}
do_atked(){
this.anm.atked()
}
dead(){
}
do_buff(){
this.anm.buff()
}
buff(){
this.anm.buff()
}
/** 播放移动动画(返回值语义与 idle() 一致:拦截时不记录状态) */
move(): boolean {
if(this.status=="move") return true
if(!this.anm.move()) return false
this.status="move"
return true
}
}