英雄动画重构

This commit is contained in:
2025-10-23 10:43:15 +08:00
parent b0751992f4
commit c1544365ba
211 changed files with 83876 additions and 35746 deletions

View File

@@ -1,119 +0,0 @@
import { _decorator, CCClass, Component, sp } from "cc";
import { HeroViewComp } from "./HeroViewComp";
import { FacSet } from "../common/config/BoxSet";
const { ccclass, property } = _decorator;
@ccclass('HeroAnmComp')
export default class HeroAnmComp extends Component{
mixTime:number= 0.2;
private spine?: sp.Skeleton;
private _hasStop = true;
private default_anim:string='Idle'
onLoad () {
var spine = this.spine = this.getComponent('sp.Skeleton') as sp.Skeleton;
this._setMix('Walking', 'Idle');
this._setMix('Walking', 'Attacking');
this._setMix('Walking', 'Taunt');
this._setMix('Walking', 'Hurt');
this._setMix('Idle', 'Attacking');
this._setMix('Idle', 'Taunt');
this._setMix('Idle', 'Walking');
this._setMix('Idle', 'Hurt');
this._setMix('Attacking', 'Idle');
this._setMix('Attacking', 'Walking');
this._setMix('Attacking', 'Hurt');
this._setMix('Attacking', 'Taunt');
this._setMix('Taunt', 'Walking');
this._setMix('Taunt', 'Idle');
this._setMix('Taunt', 'Attacking');
this._setMix('Taunt', 'Hurt');
this._setMix('Hurt', 'Idle');
this._setMix('Hurt', 'Attacking');
this._setMix('Hurt', 'Taunt');
this._setMix('Hurt', 'Walking');
spine.setCompleteListener((trackEntry) => {
var animationName = trackEntry.animation ? trackEntry.animation.name : "";
if (animationName === 'Attacking'||animationName==='Taunt'||animationName==='Hurt') {
this.spine!.clearTrack(1);
this.spine?.setAnimation(0, this.default_anim, true);
}
var loopCount = Math.floor(trackEntry.trackTime / trackEntry.animationEnd);
// console.log("[track %s][animation %s] complete: %s", trackEntry.trackIndex, animationName, loopCount);
});
spine.setEventListener(((trackEntry:any, event:any) => {
var animationName = trackEntry.animation ? trackEntry.animation.name : "";
// console.log("[track %s][animation %s] event: %s, %s, %s, %s", trackEntry.trackIndex, animationName, event.data.name, event.intValue, event.floatValue, event.stringValue);
}) as any);
this._hasStop = false;
}
// OPTIONS
toggleDebugSlots () {
this.spine!.debugSlots = !this.spine?.debugSlots;
}
toggleDebugBones () {
this.spine!.debugBones = !this.spine?.debugBones;
}
toggleDebugMesh () {
this.spine!.debugMesh = !this.spine?.debugMesh;
}
toggleUseTint () {
this.spine!.useTint = !this.spine?.useTint;
}
toggleTimeScale () {
if (this.spine!.timeScale === 1.0) {
this.spine!.timeScale = 0.3;
}
else {
this.spine!.timeScale = 1.0;
}
}
// ANIMATIONS
stop () {
// this.spine?.clearTrack(0);
this._hasStop = true;
}
move () {
if (this._hasStop) {
this.spine?.setToSetupPose();
}
// console.log("do move",this.spine?.animation);
this.spine?.setAnimation(0, 'Walking', true);
this.default_anim='Walking'
this._hasStop = false;
}
atk () {
this.spine?.setAnimation(1, 'Attacking', false);
}
max () {
this.spine?.setAnimation(1, 'Taunt', false);
}
atked () {
if(this.spine.animation==='Hurt') return
this.spine?.setAnimation(1, 'Hurt', false);
}
idle () {
this.spine?.setToSetupPose();
if(this.spine?.animation==='Idle') return
// console.log("do idle",this.spine.animation);
this.spine?.setAnimation(0, 'Idle', true);
this.default_anim='Idle'
}
_setMix (anim1: string, anim2: string) {
this.spine?.setMix(anim1, anim2, this.mixTime);
this.spine?.setMix(anim2, anim1, this.mixTime);
}
}

View File

@@ -1,9 +0,0 @@
{
"ver": "4.0.24",
"importer": "typescript",
"imported": true,
"uuid": "d8a3d973-c3c2-449f-82bd-adb9f6d5149d",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@@ -9,7 +9,7 @@ export default class HeroAnmComp extends Component{
private anmcon:any=null
private _hasStop = true;
private default_anim:string='Idle'
anms:any[]=["idle","move","atk","max","debbuff","atked"]
anms:any[]=["idle","move","atk1","atk2","atk","max","max1","stun","dead","buff"]
onLoad () {
this.anmcon=this.node.getComponent(Animation)
this.anmcon.on(Animation.EventType.FINISHED, this.onAnimationFinished, this);
@@ -38,10 +38,6 @@ export default class HeroAnmComp extends Component{
if(this.anmcon.getState("max").isPlaying) return
this.anmcon.play("max")
}
atked () {
if(this.anmcon.getState("atked").isPlaying) return
this.anmcon.play("atked")
}
idle () {
if(this.anmcon.getState("idle").isPlaying) return
this.anmcon.play("idle")

View File

@@ -75,11 +75,6 @@ export class HeroSpine extends Component {
this.status="move"
this.anm.move()
}
atked() {
// console.log("do atked");
this.anm.atked()
}
onDestroy() {
this.node.destroy();
}

View File

@@ -766,7 +766,6 @@ export class HeroViewComp extends CCComp {
/** 立即显示伤害效果 */
private showDamageImmediate(damage: number, isCrit: boolean,anm:string="atked") {
// this.as.atked()
this.BUFFCOMP.hp_show(this.hp,this.Attrs[Attrs.HP_MAX])
this.BUFFCOMP.in_atked(anm,this.fac==FacSet.HERO?1:-1)
this.atked_count++;