dd
This commit is contained in:
@@ -41,6 +41,8 @@ export class SkillCom extends CCComp {
|
||||
distance_y:number=0;
|
||||
ap:number=0;
|
||||
FIGHTCON:FightConComp=null;
|
||||
hited_time:number=0;
|
||||
hit_count:number=0;
|
||||
private moveDirection: Vec3 | null = null; // 添加一个属性来存储移动方向
|
||||
|
||||
protected onLoad(): void {
|
||||
@@ -88,14 +90,14 @@ export class SkillCom extends CCComp {
|
||||
if(this.node.getComponent(Animation)){
|
||||
let anim = this.node.getComponent(Animation);
|
||||
console.log("has anim",anim)
|
||||
anim.on(Animation.EventType.FINISHED, this.onAnimationFinished, this);
|
||||
anim.on(Animation.EventType.FINISHED, this.onAnimationFinishedToDestroy, this);
|
||||
}
|
||||
if(this.node.getChildByName('anm')){
|
||||
if(this.node.getChildByName('anm').getComponent('sp.Skeleton')){
|
||||
var spine = this.node.getChildByName('anm').getComponent('sp.Skeleton') as sp.Skeleton;
|
||||
console.log("has spine",spine)
|
||||
spine.setCompleteListener((trackEntry) => {
|
||||
this.onAnimationFinished()
|
||||
this.onAnimationFinishedToDestroy()
|
||||
console.log("[track %s][animation %s] complete: %s", trackEntry.trackIndex);
|
||||
});
|
||||
}
|
||||
@@ -103,47 +105,13 @@ export class SkillCom extends CCComp {
|
||||
break;
|
||||
}
|
||||
|
||||
// let dir_x = this.targetPos.x > this.node.position.x ? 1 : -1
|
||||
// this.node.scale = v3(dir_x,1,1)
|
||||
// 根据目标位置设置节点朝向
|
||||
// if ( this.targetPos) {
|
||||
// // 计算朝向
|
||||
// let direction = this.targetPos.x > this.node.position.x ? 1 : -1;
|
||||
// // 设置节点缩放来改变朝向
|
||||
// this.node.scale = v3(direction * Math.abs(this.scale), this.scale, 1);
|
||||
// }
|
||||
// let dir_y = ( this.targetPos.y+BoxSet.ATK_Y) > this.node.position.y ? 1 : -1
|
||||
// if( this.targetPos.y+BoxSet.ATK_Y==this.node.position.y){
|
||||
// dir_y=0
|
||||
// }
|
||||
// // 计算这一帧的移动距离
|
||||
// this.distance_x = SkillSet[this.s_uuid].speed*dir_x;
|
||||
// this.distance_y = this.distance_x*Math.abs(this.targetPos.y-this.node.position.y)/Math.abs(this.targetPos.x-this.node.position.x)*dir_y;
|
||||
// this.startMovement();
|
||||
|
||||
// // 计算目标角度
|
||||
// if (this.targetPos) {
|
||||
// const currentPos = this.node.position;
|
||||
|
||||
// // 计算角度(弧度)
|
||||
// const dx = this.targetPos.x - currentPos.x;
|
||||
// const dy = (this.targetPos.y + BoxSet.ATK_Y) - currentPos.y;
|
||||
// const angle = Math.atan2(dy, dx);
|
||||
|
||||
// // 将弧度转换为角度并设置节点旋转
|
||||
// this.angle = angle * 180 / Math.PI;
|
||||
// this.node.angle = this.angle; // 移除负号,修正角度方向
|
||||
// }
|
||||
|
||||
// // 计算速度分量
|
||||
// const radians = this.angle * Math.PI / 180; // 移除负号,使用正确的角度
|
||||
// this.distance_x = this.speed * Math.cos(radians);
|
||||
// this.distance_y = this.speed * Math.sin(radians);
|
||||
|
||||
// this.startMovement();
|
||||
// console.log("skill start",this.node.parent)
|
||||
|
||||
}
|
||||
onAnimationFinishedToDestroy(){
|
||||
this.is_destroy=true
|
||||
}
|
||||
onAnimationFinished(){
|
||||
this.hit_count++
|
||||
let remainingDamage = this.ap;
|
||||
remainingDamage=remainingDamage*(100-this.FIGHTCON.enemy_buff.DEF+this.FIGHTCON.enemy_debuff.BURN)/100
|
||||
let enemys=ecs.query(ecs.allOf(MonModelComp))
|
||||
@@ -155,8 +123,7 @@ export class SkillCom extends CCComp {
|
||||
view.do_atked(remainingDamage)
|
||||
}
|
||||
});
|
||||
|
||||
this.is_destroy=true
|
||||
|
||||
}
|
||||
onBeginContact (seCol: Collider2D, oCol: Collider2D) {
|
||||
// console.log(this.scale+"碰撞开始 ",seCol,oCol);
|
||||
@@ -194,42 +161,6 @@ export class SkillCom extends CCComp {
|
||||
}
|
||||
}
|
||||
|
||||
private startBezierMove() {
|
||||
|
||||
// let s_pos = v3(this.startPos.x,this.startPos.y)
|
||||
// let c_pos = v3((this.targetPos.x+this.startPos.x)/2,this.startPos.y+150)
|
||||
// let e_pos = v3(this.targetPos.x,this.targetPos.y)
|
||||
// let time =Math.abs(Math.abs(this.targetPos.x-this.startPos.x)/this.speed)
|
||||
|
||||
// // console.log("开始贝塞尔运动=>time:"+time,"s_pos:"+s_pos,"c_pos:"+c_pos,"e_pos:"+e_pos)
|
||||
// SkillCom.bezierTo(this.node,time,s_pos,c_pos,e_pos,{
|
||||
// onComplete: (target?: object) => {
|
||||
// this.is_destroy=true
|
||||
// },
|
||||
// }).start();
|
||||
}
|
||||
|
||||
|
||||
public static bezierTo(target: any, duration: number, c1: Vec3, c2: Vec3, to: Vec3, opts: any) {
|
||||
opts = opts || Object.create(null);
|
||||
/*
|
||||
* @desc 二阶贝塞尔
|
||||
* @param {number} t 当前百分比
|
||||
* @param {} p1 起点坐标
|
||||
* @param {} cp 控制点
|
||||
* @param {} p2 终点坐标
|
||||
* @returns {any}
|
||||
*/
|
||||
let twoBezier = (t:number, p1: Vec3, cp: Vec3, p2: Vec3) => {
|
||||
let x = (1 - t) * (1 - t) * p1.x + 2 * t * (1 - t) * cp.x + t * t * p2.x;
|
||||
let y = (1 - t) * (1 - t) * p1.y + 2 * t * (1 - t) * cp.y + t * t * p2.y;
|
||||
return v3(x, y, 0);
|
||||
};
|
||||
opts.onUpdate = (arg: Vec3, ratio: number) => {
|
||||
target.position = twoBezier(ratio, c1, c2, to);
|
||||
};
|
||||
return tween(target).to(duration, {}, opts);
|
||||
}
|
||||
|
||||
to_console(value:any,value2:any=null,value3:any=null){
|
||||
console.log("["+this.s_name+this.s_uuid+"]:",value,value2,value3)
|
||||
@@ -238,8 +169,12 @@ export class SkillCom extends CCComp {
|
||||
update(deltaTime: number) {
|
||||
if(smc.mission.pause) return;
|
||||
if (!this.node || !this.node.isValid) return;
|
||||
|
||||
if(this.animType == AnimType.linear) this.startLinearMove(deltaTime);
|
||||
this.hited_time+=deltaTime
|
||||
if(this.hited_time>SkillSet[this.s_uuid].hited&&this.animType==AnimType.fixedEnd&&this.hit_count==0){
|
||||
this.hited_time=0
|
||||
this.onAnimationFinished()
|
||||
}
|
||||
// if(this.animType == AnimType.linear) this.startLinearMove(deltaTime);
|
||||
this.toDestroy();
|
||||
}
|
||||
toDestroy() {
|
||||
|
||||
Reference in New Issue
Block a user