mirror of
https://gitee.com/jisol/jisol-game/
synced 2025-06-26 19:34:47 +00:00
83 lines
2.6 KiB
TypeScript
83 lines
2.6 KiB
TypeScript
import { SpriteFrame } from "cc";
|
|
import { TD, app } from "../../../App";
|
|
import GRoleBase from "../role/GRoleBase";
|
|
import { GAttackBase, GAttackBullet } from "./GAttack";
|
|
import GButtleDefault from "../bullet/GButtleDefault";
|
|
import { v3 } from "cc";
|
|
import { bezier } from "cc";
|
|
import { v2 } from "cc";
|
|
import { Vec2 } from "cc";
|
|
import GEffectUtil from "../common/GEffectUtil";
|
|
import GDetection from "../common/GDetection";
|
|
import { rect } from "cc";
|
|
import GRoleDefault from "../role/GRoleDefault";
|
|
import { TB } from "../../../config/data/schema";
|
|
import GRoleAttack from "../common/GRoleAttack";
|
|
import { sp } from "cc";
|
|
|
|
/**
|
|
* 抛物线 单体普攻
|
|
* 攻击子弹,龙骨-初始位置,子弹大小
|
|
*/
|
|
export default class GAttackParabolicSingleRemote implements GAttackBase{
|
|
|
|
attack(role: GRoleDefault, info: TB.TbGRoleAttack): void {
|
|
|
|
let enemy = role.fsm.enemy;
|
|
if(!enemy) return;
|
|
|
|
let image:SpriteFrame = app.battleRes.getData<SpriteFrame>(info.attackArgs[0]);
|
|
let bone = role.spine.findBone(info.attackArgs[1]);
|
|
let scale:number = parseFloat(info.attackArgs[2]);
|
|
|
|
if(!image || !bone || !scale) {
|
|
console.warn("GAttackParabolicBangRemote ERROR",image,bone,scale);
|
|
return;
|
|
}
|
|
|
|
let bullet = GAttackBullet.create(GButtleDefault,{
|
|
image:image,
|
|
scale:scale,
|
|
});
|
|
role.mode.addGObject(bullet);
|
|
let world2 = role.node.worldPosition.clone().add(v3(role.getMirrorValue(bone.worldX),bone.worldY,0))
|
|
|
|
//设置子弹位置
|
|
bullet.node.setWorldPosition(v3(world2.x,world2.y,world2.z))
|
|
|
|
//子弹移动
|
|
let start = bullet.v2World;
|
|
let end = enemy.v2World;
|
|
let center = v2(((start.x + end.x) / 2),((start.y + end.y) / 2) + (Math.abs((start.x - end.x)) / 2));
|
|
|
|
bullet.JTween({})
|
|
.to({},Vec2.distance(start,end)*3)
|
|
.onUpdate((data,elapsed) => {
|
|
if(enemy.get()){
|
|
end = enemy.v2World;
|
|
center = v2(((start.x + end.x) / 2),((start.y + end.y) / 2) + (Math.abs((start.x - end.x)) / 2));
|
|
}
|
|
|
|
bullet.node.setWorldPosition(v3(
|
|
bezier(start.x,center.x,center.x,end.x,elapsed),
|
|
bezier(start.y,center.y,center.y,end.y,elapsed),
|
|
0
|
|
))
|
|
})
|
|
.onComplete(() => {
|
|
|
|
//销毁
|
|
bullet.node.destroy();
|
|
//普攻
|
|
GRoleAttack.onNormalAttack(role,enemy);
|
|
|
|
})
|
|
.start();
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|