feat(skill): 重做普攻弹道逻辑,优化攻击命中表现
1. 新增atk_ci普攻预制体,替换原有的atk_light预制体配置 2. 调整普攻预制体的位置、缩放属性,更新技能配置的sp名 3. 重构施法目标坐标计算,修正Y轴高度偏移以命中目标中心 4. 优化线性弹道移动逻辑,统一处理弹道延长和旋转计算 5. 更新攻击动画的帧时长和精灵贴图资源
This commit is contained in:
@@ -172,7 +172,7 @@ export const SkillUpList = {
|
||||
export const SkillSet: Record<number, SkillConfig> = {
|
||||
// ========== 基础技能 ==========
|
||||
6001: {
|
||||
uuid:6001,name:"普通攻击",sp_name:"atk",icon:"1026",TGroup:TGroup.Enemy,readyAnm:"",endAnm:"",act:"atk",
|
||||
uuid:6001,name:"普通攻击",sp_name:"atk_ci",icon:"1026",TGroup:TGroup.Enemy,readyAnm:"",endAnm:"",act:"atk",
|
||||
DTType:DTType.single,ap:100,hit_count:1,hitcd:0.2,speed:720,with:0,ready:0.2,EAnm:0,DAnm:"",IType:IType.Melee,
|
||||
RType:RType.linear,EType:EType.collision,buffs:[],info:"造成攻击力100%的伤害",
|
||||
},
|
||||
|
||||
@@ -679,9 +679,22 @@ export class SCastSystem extends ecs.ComblockSystem implements ecs.ISystemUpdate
|
||||
|
||||
/** 生成沿目标方向的施法目标坐标 */
|
||||
private buildEnemyCastTargetPos(caster: HeroViewComp, target: HeroViewComp, castRange: number): Vec3 {
|
||||
const casterPos = caster.node.position;
|
||||
const targetPos = target.node.position;
|
||||
const direction = targetPos.x >= casterPos.x ? 1 : -1;
|
||||
return new Vec3(casterPos.x + direction * castRange, casterPos.y, casterPos.z);
|
||||
// 直接返回目标的真实坐标,保留其 Y 轴信息,确保能向目标真实所在位置发射
|
||||
// 考虑到目前角色的 y 坐标都是脚底(碰撞体底部),为了命中身体中心,给目标 y 加上高度的一半
|
||||
let halfHeight = 0;
|
||||
if (target.node) {
|
||||
const transform = target.node.getComponent('cc.UITransform') as any;
|
||||
if (transform) {
|
||||
halfHeight = transform.height / 2;
|
||||
} else {
|
||||
halfHeight = 40; // 如果没有 UITransform,给一个默认高度偏移
|
||||
}
|
||||
}
|
||||
|
||||
const pos = target.node.position.clone();
|
||||
pos.y += halfHeight;
|
||||
|
||||
// 至于最终投射物是否要飞出屏幕(例如线性弹道延长至 +-500),由 SMoveSystem 统一处理
|
||||
return pos;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,31 +64,46 @@ export class SMoveSystem extends ecs.ComblockSystem implements ecs.ISystemUpdate
|
||||
|
||||
switch(moveComp.runType) {
|
||||
case RType.linear:
|
||||
// linear类型:根据atk_x和atk_y调整位置
|
||||
// linear类型:根据atk_x和atk_y调整起始位置
|
||||
const adjustedStartPos = v3(
|
||||
moveComp.startPos.x + moveComp.atk_x,
|
||||
moveComp.startPos.x + moveComp.atk_x * moveComp.scale,
|
||||
moveComp.startPos.y + moveComp.atk_y,
|
||||
moveComp.startPos.z
|
||||
);
|
||||
const adjustedTargetPos = v3(
|
||||
moveComp.targetPos.x + moveComp.atk_x,
|
||||
moveComp.targetPos.y + moveComp.atk_y,
|
||||
|
||||
const originTargetPos = v3(
|
||||
moveComp.targetPos.x,
|
||||
moveComp.targetPos.y,
|
||||
moveComp.targetPos.z
|
||||
);
|
||||
|
||||
// 如果开启水平移动开关,强制目标Y等于起点Y
|
||||
if (moveComp.isHorizontal) {
|
||||
adjustedTargetPos.y = adjustedStartPos.y;
|
||||
const direction = new Vec3();
|
||||
Vec3.subtract(direction, originTargetPos, adjustedStartPos);
|
||||
|
||||
// 延长终止点,统一消亡点的x坐标为 +-500
|
||||
const targetX = moveComp.scale > 0 ? 500 : -500;
|
||||
let targetY = originTargetPos.y;
|
||||
|
||||
if (Math.abs(direction.x) > 0.01) {
|
||||
const slope = direction.y / direction.x;
|
||||
targetY = adjustedStartPos.y + slope * (targetX - adjustedStartPos.x);
|
||||
}
|
||||
|
||||
const adjustedTargetPos = v3(
|
||||
targetX,
|
||||
targetY,
|
||||
originTargetPos.z
|
||||
);
|
||||
|
||||
moveComp.startPos.set(adjustedStartPos);
|
||||
moveComp.targetPos.set(adjustedTargetPos);
|
||||
node.setPosition(adjustedStartPos);
|
||||
|
||||
// 设置旋转角度
|
||||
const direction = new Vec3();
|
||||
Vec3.subtract(direction, moveComp.targetPos, moveComp.startPos);
|
||||
if (direction.length() > 0.01) {
|
||||
const angle = Math.atan2(direction.y, direction.x) * (180 / Math.PI);
|
||||
const dirForAngle = new Vec3();
|
||||
Vec3.subtract(dirForAngle, adjustedTargetPos, adjustedStartPos);
|
||||
if (dirForAngle.length() > 0.01) {
|
||||
const angle = Math.atan2(dirForAngle.y, dirForAngle.x) * (180 / Math.PI);
|
||||
node.angle = angle;
|
||||
}
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user