继续技能系统重构

This commit is contained in:
2025-10-15 17:28:16 +08:00
parent 2e2c9d82f9
commit 9e2ae6f30f
11 changed files with 116 additions and 76 deletions

View File

@@ -389,7 +389,7 @@
"_lpos": { "_lpos": {
"__type__": "cc.Vec3", "__type__": "cc.Vec3",
"x": 30.788, "x": 30.788,
"y": -114.71, "y": -14.71,
"z": 0 "z": 0
}, },
"_lrot": { "_lrot": {
@@ -3607,8 +3607,6 @@
"__id__": 0 "__id__": 0
}, },
"fileId": "c4IqMKgXNExa5w4EAciRxE", "fileId": "c4IqMKgXNExa5w4EAciRxE",
"instance": null,
"targetOverrides": null,
"nestedPrefabInstanceRoots": null "nestedPrefabInstanceRoots": null
}, },
{ {
@@ -3697,7 +3695,7 @@
"_isTrimmedMode": true, "_isTrimmedMode": true,
"_useGrayscale": false, "_useGrayscale": false,
"_atlas": null, "_atlas": null,
"_id": "e9qkWRtmVPf4oSiCZ+e0yg" "_id": "a9O91cLlJGoY5y1TC9zgB9"
}, },
{ {
"__type__": "cc.CompPrefabInfo", "__type__": "cc.CompPrefabInfo",
@@ -3956,7 +3954,7 @@
"_lpos": { "_lpos": {
"__type__": "cc.Vec3", "__type__": "cc.Vec3",
"x": 0, "x": 0,
"y": -100, "y": 0,
"z": 0 "z": 0
}, },
"_lrot": { "_lrot": {

View File

@@ -313,8 +313,10 @@
}, },
"runType": 0, "runType": 0,
"hasReady": false, "hasReady": false,
"ReadyTime": 0.5, "ReadyTime": 0.1,
"postion_y": 0, "ready_y": 0,
"atk_x": 10,
"atk_y": 40,
"_id": "" "_id": ""
}, },
{ {

View File

@@ -111,8 +111,8 @@
}, },
"_lscale": { "_lscale": {
"__type__": "cc.Vec3", "__type__": "cc.Vec3",
"x": 0.8, "x": 1.3,
"y": 0.8, "y": 1.3,
"z": 1 "z": 1
}, },
"_mobility": 0, "_mobility": 0,

View File

@@ -5607,7 +5607,7 @@
"_lpos": { "_lpos": {
"__type__": "cc.Vec3", "__type__": "cc.Vec3",
"x": 0, "x": 0,
"y": 600, "y": 700,
"z": 0 "z": 0
}, },
"_lrot": { "_lrot": {
@@ -6388,7 +6388,7 @@
"_top": 460.8, "_top": 460.8,
"_bottom": 450, "_bottom": 450,
"_horizontalCenter": 0, "_horizontalCenter": 0,
"_verticalCenter": -40, "_verticalCenter": 60,
"_isAbsLeft": true, "_isAbsLeft": true,
"_isAbsRight": true, "_isAbsRight": true,
"_isAbsTop": true, "_isAbsTop": true,

View File

@@ -1,6 +1,7 @@
import { _decorator, Component, Node, view, UITransform, Vec3, math, EventHandler, Graphics, Color, TweenEasing, Enum } from 'cc'; import { _decorator, Component, Node, view, UITransform, Vec3, math, EventHandler, Graphics, Color, TweenEasing, Enum } from 'cc';
import { SkillCom } from '../skills/SkillCom'; import { SkillCom } from '../skills/SkillCom';
import { smc } from '../common/SingletonModuleComp'; import { smc } from '../common/SingletonModuleComp';
import { AtkConCom } from '../skill/AtkConCom';
const { ccclass, property } = _decorator; const { ccclass, property } = _decorator;
// 定义缓动类型枚举 // 定义缓动类型枚举
@@ -154,7 +155,9 @@ export class BezierMove extends Component {
this._isMoving = false; this._isMoving = false;
// 触发移动完成事件 // 触发移动完成事件
// console.log("onMoveComplete") // console.log("onMoveComplete")
let skill=this.node.getComponent(SkillCom) let scom=this.node.getComponent(SkillCom)
let acom=this.node.getComponent(AtkConCom)
let skill=scom?scom:acom
if(skill){ if(skill){
skill.doDestroy() skill.doDestroy()
} }

View File

@@ -28,7 +28,7 @@ export enum BoxSet {
MONSTER_START = 360, MONSTER_START = 360,
END_POINT = 360, END_POINT = 360,
//游戏地平线 //游戏地平线
GAME_LINE = 130, GAME_LINE = 0,
CSKILL_X = 320, CSKILL_X = 320,
CSKILL_Y = 400, CSKILL_Y = 400,
//攻击距离 //攻击距离

View File

@@ -82,19 +82,19 @@ export const getMonList = (quality:number=0)=>{
} }
export const HeroPos={ export const HeroPos={
0:{pos:v3(-290,-100,0)}, 0:{pos:v3(0,0,0)},
1:{pos:v3(0,-100,0)}, 1:{pos:v3(0,0,0)},
2:{pos:v3(-100,-100,0)}, 2:{pos:v3(0,0,0)},
} }
export const MonSet = { export const MonSet = {
0:{pos:v3(240,-100,0)}, 0:{pos:v3(240,0,0)},
1:{pos:v3(320,-100,0)}, 1:{pos:v3(320,0,0)},
2:{pos:v3(360,-100,0)}, 2:{pos:v3(360,0,0)},
3:{pos:v3(400,-100,0)}, 3:{pos:v3(400,0,0)},
4:{pos:v3(440,-100,0)}, 4:{pos:v3(440,0,0)},
5:{pos:v3(480,-100,0)}, 5:{pos:v3(480,0,0)},
6:{pos:v3(520,-100,0)}, 6:{pos:v3(520,0,0)},
7:{pos:v3(560,-100,0)}, 7:{pos:v3(560,0,0)},
} }

View File

@@ -112,15 +112,11 @@ export class SkillConComp extends CCComp {
if (!this.node || !this.node.isValid || !this.HeroView || !this.HeroView.node || !this.HeroView.node.isValid) { if (!this.node || !this.node.isValid || !this.HeroView || !this.HeroView.node || !this.HeroView.node.isValid) {
return; return;
} }
if(config.uuid==6021){
console.log("[SkillConComp] 技能起始坐标:",this.HeroView.node.position.x + BoxSet.ATK_X * this.HeroView.scale,this.HeroView.node.position.y + BoxSet.ATK_Y,0)
}
sEnt.load( sEnt.load(
new Vec3(this.HeroView.node.position.x + BoxSet.ATK_X * this.HeroView.scale, new Vec3(this.HeroView.node.position.x,this.HeroView.node.position.y,0),
this.HeroView.node.position.y + BoxSet.ATK_Y, 0),
this.node.parent, this.node.parent,
config.uuid, config.uuid,
[new Vec3(target.x, target.y+BoxSet.ATK_Y, 0)], [new Vec3(target.x, target.y, 0)],
this.HeroView, this.HeroView,
dmg dmg
); );

View File

@@ -25,8 +25,6 @@ export class AtkConCom extends CCComp {
targetPos: Vec3 = v3(); // 目标位置 targetPos: Vec3 = v3(); // 目标位置
group:number = 0; //阵营 group:number = 0; //阵营
fac:number=0; //阵营 fac:number=0; //阵营
caster:any=null;
// 战斗相关运行时数据 // 战斗相关运行时数据
ap:number=0; ap:number=0;
burn_count:number=0; burn_count:number=0;
@@ -85,6 +83,34 @@ export class AtkConCom extends CCComp {
} }
} }
do_parabolic(){
let bm=this.node.getComponent(BezierMove)
this.node.angle +=10
// bm.speed=700
if(this.group==BoxSet.MONSTER) {bm.controlPointSide=-1 }
bm.rotationSmoothness=0.6
bm.moveTo(this.targetPos)
}
do_line(){
let bm=this.node.getComponent(BezierMove)
let s_x=this.startPos.x
let s_y=this.startPos.y
let t_x=this.targetPos.x
let t_y=this.targetPos.y
// 设定目标x
this.targetPos.x = 400;
if(this.group == BoxSet.MONSTER) {
bm.controlPointSide = -1;
this.targetPos.x = -400;
}
// 计算斜率
const k = (t_y - s_y) / (t_x - s_x);
// 按直线公式计算新的y
this.targetPos.y = k * (this.targetPos.x - s_x) + s_y;
bm.controlPointOffset=0
bm.rotationSmoothness=0.6
bm.moveTo(this.targetPos);
}
onAnimationFinished(){ onAnimationFinished(){
// console.log("[SkillCom]:onAnimationFinished",this.s_uuid) // console.log("[SkillCom]:onAnimationFinished",this.s_uuid)
if (!this.skillConfig) return; if (!this.skillConfig) return;

View File

@@ -30,9 +30,7 @@ load(startPos: Vec3, parent: Node, uuid: number, targetPos: any[], caster:Hero
console.error("[Skill] 预制体加载失败:", path); console.error("[Skill] 预制体加载失败:", path);
return; return;
} }
if(uuid==6001){ console.log("load skill startPos",startPos)
console.log("load skill startPos",startPos)
}
const node: Node = instantiate(prefab); const node: Node = instantiate(prefab);
node.parent = parent; node.parent = parent;
// 设置节点属性 // 设置节点属性
@@ -52,6 +50,8 @@ load(startPos: Vec3, parent: Node, uuid: number, targetPos: any[], caster:Hero
Object.assign(SComp, { Object.assign(SComp, {
// 核心标识 // 核心标识
s_uuid: uuid, s_uuid: uuid,
cName:caster.hero_name,
scale: caster.node.scale.x,
// 位置和施法者信息 // 位置和施法者信息
startPos: startPos, startPos: startPos,
targetPos: targetPos, targetPos: targetPos,

View File

@@ -1,9 +1,10 @@
import { _decorator, instantiate, Node, Prefab } from "cc"; import { _decorator, instantiate, Node, Prefab, v3, Vec3 } from "cc";
import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS"; import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
import { CCComp } from "../../../../extensions/oops-plugin-framework/assets/module/common/CCComp"; import { CCComp } from "../../../../extensions/oops-plugin-framework/assets/module/common/CCComp";
import { HeroViewComp } from "../hero/HeroViewComp"; import { HeroViewComp } from "../hero/HeroViewComp";
import { BuffAttr, RType, SkillSet } from "../common/config/SkillSet"; import { BuffAttr, RType, SkillSet } from "../common/config/SkillSet";
import { AtkConCom } from "./AtkConCom"; import { AtkConCom } from "./AtkConCom";
import { BoxSet } from "../common/config/BoxSet";
const { ccclass, property } = _decorator; const { ccclass, property } = _decorator;
@@ -21,17 +22,26 @@ export class SkillViewCom extends CCComp {
@property({ type: Number }) @property({ type: Number })
ReadyTime: number = 0; ReadyTime: number = 0;
@property({ type: Number }) @property({ type: Number })
postion_y: number = 0; ready_y: number = 0;
@property({ type: Number })
atk_x: number = 0;
@property({ type: Number })
atk_y: number = 0;
endTime: number = 0; endTime: number = 0;
readyFinish: boolean = false;
caster:HeroViewComp=null!;
s_uuid:number=0; s_uuid:number=0;
s_count:number=1; s_count:number=1;
s_interval:number=0.2; s_interval:number=0.2;
s_cd:number=0; s_cd:number=0;
caster:HeroViewComp=null; scale: number = 0;
cName:string=""; cName:string="";
target:HeroViewComp=null; target:HeroViewComp=null;
parent:Node=null; parent:Node=null;
target_postions:any[]=null target_postions:any[]=null
group:0
fac: 0
// 战斗相关运行时数据 // 战斗相关运行时数据
ap:number=0; ap:number=0;
burn_count:number=0; burn_count:number=0;
@@ -53,20 +63,13 @@ export class SkillViewCom extends CCComp {
targetPos:any[]=null targetPos:any[]=null
start() { start() {
// var entity = this.ent as ecs.Entity; // ecs.Entity 可转为当前模块的具体实体对象 // var entity = this.ent as ecs.Entity; // ecs.Entity 可转为当前模块的具体实体对象
this.cName = this.caster.hero_name
this.node.getChildByName("ready").active = this.hasReady this.node.getChildByName("ready").active = this.hasReady
} }
protected update(dt: number): void { protected update(dt: number): void {
this.doTimer(dt) this.doTimer(dt)
this.move(dt) this.move(dt)
this.doEnd(dt) this.doEnd(dt)
if(this.hasReady) { if(this.readyFinish) this.doAtk(dt)
if(this.ReadyTime <= 0) {
this.doAtk(dt)
}
}{
this.doAtk(dt)
}
} }
doEnd(dt: number) { doEnd(dt: number) {
this.endTime += dt this.endTime += dt
@@ -76,7 +79,8 @@ export class SkillViewCom extends CCComp {
} }
doTimer(dt: number){ doTimer(dt: number){
if(this.ReadyTime > 0&&this.hasReady) this.ReadyTime -= dt if(this.ReadyTime > 0) this.ReadyTime -= dt
if(this.ReadyTime <=0) this.readyFinish=true
} }
doAtk(dt:number): void { doAtk(dt:number): void {
// console.log(`${this.cName}_[SkillViewCom] doAtkC`) // console.log(`${this.cName}_[SkillViewCom] doAtkC`)
@@ -88,37 +92,46 @@ export class SkillViewCom extends CCComp {
if(this.s_cd > 0) this.s_cd -= dt if(this.s_cd > 0) this.s_cd -= dt
} }
doSkill(){ doSkill(){
console.log(`${this.cName}_[SkillViewCom] doSkill`,this.atkPrefab) // console.log(`${this.cName}_[SkillViewCom] doSkill`,this.atkPrefab)
if(this.atkPrefab!=null){ if(this.atkPrefab!=null){
let atkNode:Node = instantiate(this.atkPrefab) let atkNode:Node = instantiate(this.atkPrefab)
atkNode.parent = this.node.parent atkNode.parent = this.node.parent
atkNode.setPosition(this.node.position) atkNode.setPosition(v3(this.node.position.x + this.atk_x*this.scale, this.node.position.y + this.atk_y))
// console.log(`${this.cName}_[SkillViewCom] doSkill atkNode`,this.node.position,atkNode.position)
let atkCom=atkNode.getComponent(AtkConCom) let atkCom=atkNode.getComponent(AtkConCom)
// 计算延长后的目标点坐标
const originalStart = v3(this.node.position.x + this.atk_x, this.node.position.y + this.atk_y);
const originalTarget = v3(this.targetPos[0].x, this.targetPos[0].y + BoxSet.ATK_Y);
const direction = new Vec3();
Vec3.subtract(direction, originalTarget, originalStart);
const distance = direction.length();
direction.normalize();
const extendedTarget = new Vec3();
Vec3.scaleAndAdd(extendedTarget, originalTarget, direction, 720);
Object.assign(atkCom, { Object.assign(atkCom, {
// 核心标识 // 核心标识
s_uuid: this.s_uuid, s_uuid: this.s_uuid,
// 位置和施法者信息 // 位置和施法者信息
startPos: this.node.position, startPos: originalStart,
targetPos: this.targetPos[0], targetPos: extendedTarget,
group: this.caster.box_group, group: this.group,
fac: this.caster.fac, fac: this.fac,
// 技能数值 // 技能数值
ap: this.caster.Attrs[BuffAttr.AP], ap: this.ap,
caster: this.caster, caster_crit: this.caster_crit,
caster_crit: this.caster.Attrs[BuffAttr.CRITICAL], caster_crit_d: this.caster_crit_d,
caster_crit_d: this.caster.Attrs[BuffAttr.CRITICAL_DMG], puncture: this.puncture,
puncture: this.caster.Attrs[BuffAttr.PUNCTURE], puncture_damage: this.puncture_damage,
puncture_damage: this.caster.Attrs[BuffAttr.PUNCTURE_DMG], burn_count: this.burn_count,
burn_count: this.caster.Attrs[BuffAttr.BURN_COUNT], burn_value: this.burn_value,
burn_value: this.caster.Attrs[BuffAttr.BURN_VALUE], stun_time: this.stun_time,
stun_time: this.caster.Attrs[BuffAttr.STUN_TIME], stun_ratio: this.stun_ratio,
stun_ratio: this.caster.Attrs[BuffAttr.STUN_RATIO], frost_time: this.frost_time,
frost_time: this.caster.Attrs[BuffAttr.FROST_TIME], frost_ratio: this.frost_ratio,
frost_ratio: this.caster.Attrs[BuffAttr.FROST_RATIO], debuff_up: this.debuff_up,
debuff_up: this.caster.Attrs[BuffAttr.DEBUFF_UP], debuff_value: this.debuff_value,
debuff_value: this.caster.Attrs[BuffAttr.DEBUFF_VALUE], debuff_count: this.debuff_count,
debuff_count: this.caster.Attrs[BuffAttr.DEBUFF_COUNT], });
});
switch(this.runType){ switch(this.runType){
case RType.linear: case RType.linear:
this.do_linear(atkNode) this.do_linear(atkNode)
@@ -133,10 +146,12 @@ export class SkillViewCom extends CCComp {
} }
} }
do_linear(atkNode:any): void { do_linear(atkNode:any): void {
console.log(`${this.cName}_[SkillViewCom] skille run type: linear`) console.log(`${this.cName}_[SkillViewCom] skille run type: linear`,this.node.position,atkNode.position)
atkNode.getComponent(AtkConCom).do_line()
} }
do_bezier(atkNode:any): void { do_bezier(atkNode:any): void {
console.log(`${this.cName}_[SkillViewCom] skille run type: bezier`) console.log(`${this.cName}_[SkillViewCom] skille run type: bezier`)
atkNode.getComponent(AtkConCom).do_parabolic()
} }
do_fixed(atkNode:any): void { do_fixed(atkNode:any): void {
console.log(`${this.cName}_[SkillViewCom] skille run type: fixed`) console.log(`${this.cName}_[SkillViewCom] skille run type: fixed`)
@@ -145,8 +160,8 @@ export class SkillViewCom extends CCComp {
move(dt: number): void { move(dt: number): void {
// console.log(`${this.cName}_[SkillViewCom] move`) // console.log(`${this.cName}_[SkillViewCom] move`)
if(this.caster != null&&this.caster.node!=null) this.node.setPosition(this.caster.node.position.x,this.caster.node.position.y+this.postion_y) if(this.caster != null&&this.caster.node!=null) this.node.setPosition(this.caster.node.position.x,this.caster.node.position.y+this.ready_y)
// console.log(`${this.cName}_[skillview]move`,this.caster.node.position,this.node.position) // console.log(`${this.cName}_[skillview]move`,this.caster.node.position,this.node.position)
} }
reset() { reset() {
this.node.destroy(); this.node.destroy();