Files
pixelheros/assets/script/game/hero/HeroSpine.ts
panFD 8c8810bb7e fix(hero): 修复英雄大招动画播放异常问题
1. 重构大招播放方法,支持传入自定义动画clip名,适配不同职业的大招动画
2. 修复技能匹配逻辑,通过前缀匹配处理max0/max1类型的大招技能
3. 更新技能配置表,将辅助职业的技能act改为max1适配新逻辑
2026-09-14 21:38:52 +08:00

93 lines
1.9 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(name: string = "max0"){
this.anm.max(name)
}
play(name:string){
// 技能表 act 配置的是 clip 名(max0/max1),不能用全等匹配 "max"
if(name.startsWith("max")){
this.max(name)
return
}
switch(name){
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
}
}