|
@@ -63,6 +63,8 @@ export class Hero extends BattleNodeBase {
|
|
|
|
|
|
battleEventManager: BattleEventManager;
|
|
|
|
|
|
+ private _nextAnimName: string = "idle";
|
|
|
+
|
|
|
|
|
|
set posIndex(posIndx:number){
|
|
|
this._posIndex = posIndx;
|
|
@@ -76,6 +78,7 @@ export class Hero extends BattleNodeBase {
|
|
|
}
|
|
|
|
|
|
protected onLoad(): void {
|
|
|
+ this.modelSpine.setStartListener(this.actionStart.bind(this))
|
|
|
this.modelSpine.setCompleteListener(this.actionComplete.bind(this))
|
|
|
this.modelSpine.setEventListener(this.actionCallback.bind(this))
|
|
|
|
|
@@ -156,41 +159,30 @@ export class Hero extends BattleNodeBase {
|
|
|
this.attackBone2.rotation = 0
|
|
|
this.attackBone3.rotation = 0
|
|
|
this.attackBone4.rotation = 0
|
|
|
- let bChange = false
|
|
|
+ let curAnimName = this.modelSpine.animation
|
|
|
if(rotationAngleDegrees<67.5 || rotationAngleDegrees > 292.5){
|
|
|
let rotationAngle = this.getRotationAngle(this.gunNode1,pos)
|
|
|
this.attackBone1.rotation = (rotationAngle+this.attackAngle1)
|
|
|
- if(this.modelSpine.animation != "atk_right"){
|
|
|
- this.modelSpine.setAnimation(0, 'atk_right', true);
|
|
|
- bChange = true
|
|
|
- }
|
|
|
+ this._nextAnimName = "atk_right"
|
|
|
}
|
|
|
else if(rotationAngleDegrees < 112.5){
|
|
|
let rotationAngle = this.getRotationAngle(this.gunNode3,pos)
|
|
|
this.attackBone3.rotation = rotationAngle+this.attackAngle3-90
|
|
|
- if(this.modelSpine.animation != "atk_up"){
|
|
|
- this.modelSpine.setAnimation(0, 'atk_up', true);
|
|
|
- bChange = true
|
|
|
- }
|
|
|
+ this._nextAnimName = "atk_up"
|
|
|
}
|
|
|
else if(rotationAngleDegrees < 247.5){
|
|
|
let rotationAngle = this.getRotationAngle(this.gunNode1,pos)
|
|
|
this.attackBone4.rotation = 180-rotationAngle+this.attackAngle4
|
|
|
- if(this.modelSpine.animation != "atk_left"){
|
|
|
- this.modelSpine.setAnimation(0, 'atk_left', true);
|
|
|
- bChange = true
|
|
|
- }
|
|
|
+ this._nextAnimName = "atk_left"
|
|
|
}
|
|
|
else if(rotationAngleDegrees < 292.5){
|
|
|
let rotationAngle = this.getRotationAngle(this.gunNode2,pos)
|
|
|
this.attackBone2.rotation = rotationAngle+this.attackAngle2-270
|
|
|
- if(this.modelSpine.animation != "atk_down"){
|
|
|
- this.modelSpine.setAnimation(0, 'atk_down', true);
|
|
|
- bChange = true
|
|
|
- }
|
|
|
+ this._nextAnimName = "atk_down"
|
|
|
}
|
|
|
|
|
|
- if(bChange){
|
|
|
+ if(!curAnimName.includes("atk_") && this._nextAnimName.includes("atk_")){
|
|
|
+ this.modelSpine.setAnimation(0,this._nextAnimName, true);
|
|
|
let conf = UptypeConf.data
|
|
|
let speedScale = conf.HeroSpeedColArr[this.level]
|
|
|
this.modelSpine.timeScale = speedScale;
|
|
@@ -213,12 +205,11 @@ export class Hero extends BattleNodeBase {
|
|
|
attack(attackNode:Node){
|
|
|
if(!this.modelSpine.node.active) return;
|
|
|
|
|
|
+
|
|
|
+ this.attackNode = attackNode;
|
|
|
+
|
|
|
// if(this._bAttackAnimation) return;
|
|
|
this._bAttackAnimation = true;
|
|
|
-
|
|
|
- this.attackNode = attackNode;
|
|
|
-
|
|
|
- Framework.audio.playEffect(AudioID.Tututu);
|
|
|
}
|
|
|
|
|
|
stand() {
|
|
@@ -235,23 +226,29 @@ export class Hero extends BattleNodeBase {
|
|
|
if(animationName.includes("idle")) return;
|
|
|
switch(animationName){
|
|
|
case "atk_right":
|
|
|
+ this._nextAnimName = "atk_right";
|
|
|
this.modelSpine.setAnimation(0, 'idle_right', true);
|
|
|
break;
|
|
|
case "atk_left":
|
|
|
+ this._nextAnimName = "atk_left";
|
|
|
this.modelSpine.setAnimation(0, 'idle_left', true);
|
|
|
break;
|
|
|
case "atk_up":
|
|
|
+ this._nextAnimName = "atk_up";
|
|
|
this.modelSpine.setAnimation(0, 'idle_up', true);
|
|
|
break;
|
|
|
case "atk_down":
|
|
|
+ this._nextAnimName = "atk_down";
|
|
|
this.modelSpine.setAnimation(0, 'idle_down', true);
|
|
|
break;
|
|
|
default:
|
|
|
+ this._nextAnimName = "idk_right";
|
|
|
this.modelSpine.setAnimation(0, 'idle_right', true);
|
|
|
break;
|
|
|
}
|
|
|
this.modelSpine.timeScale = 1;
|
|
|
- // if(this.modelSpine.node.scale.x < 0)
|
|
|
+ // this.modelSpine.setAnimation(0, 'idle_up', true);
|
|
|
+ // if(this.modelSpine.node.scale.x < 0)
|
|
|
// this.modelSpine.node.scale = new Vec3(-this.modelSpine.node.scale.x,this.modelSpine.node.scale.y,this.modelSpine.node.scale.z);
|
|
|
|
|
|
}
|
|
@@ -261,8 +258,8 @@ export class Hero extends BattleNodeBase {
|
|
|
this.levelLabel.string = this.level.toString();
|
|
|
}
|
|
|
|
|
|
- actionCallback(trackEntry){
|
|
|
- // console.log("动作回调:",trackEntry.animation.name)
|
|
|
+ actionCallback(trackEntry: sp.spine.TrackEntry,ev: sp.spine.Event){
|
|
|
+ console.log("动作回调:",trackEntry.animation.name,ev)
|
|
|
if (trackEntry.animation.name && trackEntry.animation.name.includes("atk")) {
|
|
|
|
|
|
// if (this._attackCallback) {
|
|
@@ -279,10 +276,25 @@ export class Hero extends BattleNodeBase {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ actionStart(trackEntry:sp.spine.TrackEntry){
|
|
|
+ // console.log("动作完成:",trackEntry.animation.name,this._posID)
|
|
|
+ if (trackEntry.animation.name && trackEntry.animation.name.includes("atk_")) {
|
|
|
+
|
|
|
+ Framework.audio.playEffect(AudioID.Tututu);
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
actionComplete(trackEntry:sp.spine.TrackEntry){
|
|
|
// console.log("动作完成:",trackEntry.animation.name,this._posID)
|
|
|
- if (trackEntry.animation.name && trackEntry.animation.name.includes("fire")) {
|
|
|
+ if (trackEntry.animation.name && trackEntry.animation.name.includes("atk_")) {
|
|
|
|
|
|
+ if( this._nextAnimName.includes("atk_")){
|
|
|
+ this.modelSpine.setAnimation(0,this._nextAnimName, true);
|
|
|
+ let conf = UptypeConf.data
|
|
|
+ let speedScale = conf.HeroSpeedColArr[this.level]
|
|
|
+ this.modelSpine.timeScale = speedScale;
|
|
|
+ }
|
|
|
// this._bAttackAnimation = false;
|
|
|
// // this.gunNode.angle = 0;
|
|
|
// // this.gunNode.active = false;
|