英雄动画重构

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

View File

@@ -46,7 +46,7 @@ export const getMonList = ()=>{
}
export const HeroPos={
0:{pos:v3(0,100,0)},
0:{pos:v3(-240,100,0)},
1:{pos:v3(0,100,0)},
2:{pos:v3(0,100,0)},
}
@@ -80,25 +80,25 @@ export interface heroInfo{
export const HeroInfo: Record<number, heroInfo> = {
//主将
5001:{uuid:5001,name:"火焰骑士",path:"hk1", fac:FacSet.HERO, kind:1,
5001:{uuid:5001,name:"骑士",path:"hk1", fac:FacSet.HERO, kind:1,
type:HType.warrior,lv:1,hp:100,mp:100,map:100,def:5,ap:15,dis:100,cd:1,speed:150,skills:[6001,6005],
buff:[],debuff:[],info:""},
5002:{uuid:5002,name:"刺客",path:"hc1", fac:FacSet.HERO, kind:1,
5002:{uuid:5002,name:"刺客",path:"hk1", fac:FacSet.HERO, kind:1,
type:HType.warrior,lv:1,hp:100,mp:100,map:100,def:5,ap:15,dis:100,cd:1,speed:150,skills:[6001,6005],
buff:[],debuff:[],info:""},
5005:{uuid:5005,name:"绿箭",path:"ha1", fac:FacSet.HERO, kind:2,
5005:{uuid:5005,name:"绿箭",path:"hk1", fac:FacSet.HERO, kind:2,
type:HType.remote,lv:1,hp:100,mp:100,map:100,def:5,ap:15,dis:400,cd:1,speed:100,skills:[6001,6005],
buff:[],debuff:[],info:""},
5007:{uuid:5007,name:"牧师",path:"hmh1", fac:FacSet.HERO, kind:2,
5007:{uuid:5007,name:"牧师",path:"hk1", fac:FacSet.HERO, kind:2,
type:HType.mage,lv:1,hp:100,mp:100,map:100,def:5,ap:15,dis:400,cd:1,speed:100,skills:[6001,6005],
buff:[],debuff:[],info:""},
5008:{uuid:5008,name:"火女",path:"hmf1", fac:FacSet.HERO, kind:2,
5008:{uuid:5008,name:"火女",path:"hk1", fac:FacSet.HERO, kind:2,
type:HType.mage,lv:1,hp:100,mp:100,map:100,def:5,ap:15,dis:400,cd:1.5,speed:100,skills:[6001,6005],
buff:[],debuff:[],info:""},
@@ -116,15 +116,15 @@ export const HeroInfo: Record<number, heroInfo> = {
//怪物
5201:{uuid:5201,name:"兽人战士",path:"mo1", fac:FacSet.MON, kind:1,
5201:{uuid:5201,name:"兽人战士",path:"hk1", fac:FacSet.MON, kind:1,
type:HType.warrior,lv:1,hp:25,mp:100,map:100,def:5,ap:5,dis:90,cd:2,speed:100,skills:[6005],
buff:[],debuff:[],info:"普通怪物-战士型"},
5202:{uuid:5202,name:"兽人刺客",path:"mo1", fac:FacSet.MON, kind:1,
5202:{uuid:5202,name:"兽人刺客",path:"hk1", fac:FacSet.MON, kind:1,
type:HType.remote,lv:1,hp:20,mp:100,map:100,def:5,ap:5,dis:350,cd:1,speed:100,skills:[6005],
buff:[],debuff:[],info:"普通怪物-战士型"},
5203:{uuid:5203,name:"兽人护卫",path:"mo3", fac:FacSet.MON, kind:1,
5203:{uuid:5203,name:"兽人护卫",path:"hk1", fac:FacSet.MON, kind:1,
type:HType.warrior,lv:1,hp:25,mp:100,map:100,def:5,ap:5,dis:90,cd:2,speed:100,skills:[6005],
buff:[],debuff:[],info:"普通怪物-战士型"},

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++;

View File

@@ -16,8 +16,8 @@ export class move extends Component {
@property({ type: CCInteger })
sc: number = 1; // 1: 从左到右, -1: 从右到左
@property({ type: CCInteger })
isMove:number=0
@property
isMove:boolean=false
protected onLoad(): void {
oops.message.on(GameEvent.MAP_MOVE_END_LEFT, this.onMapMoveEndLeft, this);
oops.message.on(GameEvent.MAP_MOVE_END_RIGHT, this.onMapMoveEndRight, this);
@@ -27,13 +27,13 @@ export class move extends Component {
}
onMapMoveEndLeft() {
if(this.sc==-1){
this.isMove=1
this.isMove=true
this.setInitialPosition()
}
}
onMapMoveEndRight() {
if(this.sc==1){
this.isMove=1
this.isMove=true
this.setInitialPosition()
}
}
@@ -52,7 +52,7 @@ export class move extends Component {
update(dt: number) {
// 更新位置
if(this.isMove==1){
if(this.isMove){
const newX = this.node.position.x + dt * this.speed * this.sc;
this.node.setPosition(newX, this.node.position.y);
// 检查边界并重置位置
@@ -68,14 +68,14 @@ export class move extends Component {
// 从左到右移动,到达右边界后回到左边界
if (this.node.position.x >= this.maxX) {
this.node.setPosition(this.minX, this.node.position.y);
this.isMove=0
this.isMove=false
oops.message.dispatchEvent(GameEvent.MAP_MOVE_END_LEFT)
}
} else if (this.sc < 0) {
// 从右到左移动,到达左边界后回到右边界
if (this.node.position.x <= this.minX) {
this.node.setPosition(this.maxX, this.node.position.y);
this.isMove=0
this.isMove=false
oops.message.dispatchEvent(GameEvent.MAP_MOVE_END_RIGHT)
}
}

View File

@@ -22,7 +22,6 @@ export class debuff extends Component {
if(this.deff_cd >=1){
// this.node.setPosition(v3(-1000,0,0))
if(this.hero){
// this.hero.in_atked()
// this.hero.hp_less(Math.ceil(this.base.ap/this.base.time))
// console.log("debuff 总扣血:"+this.base.ap+" 每秒: "+Math.ceil(this.base.ap/this.base.time))
}