This commit is contained in:
2025-10-16 23:40:12 +08:00
parent d486d87676
commit 559ddfb653
8 changed files with 267 additions and 562 deletions

View File

@@ -2,7 +2,7 @@ import { _decorator, Animation, CCBoolean, Collider2D, Contact2DType, Tween, v3,
import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
import { CCComp } from "../../../../extensions/oops-plugin-framework/assets/module/common/CCComp";
import { BezierMove } from "../BezierMove/BezierMove";
import { AType, BuffAttr, DTType, EType, SkillSet, SType, TGroup } from "../common/config/SkillSet";
import { DTType, EType, SkillSet, SType } from "../common/config/SkillSet";
import { BoxSet, FacSet } from "../common/config/BoxSet";
import { HeroViewComp } from "../hero/HeroViewComp";
import { GameEvent } from "../common/config/GameEvent";
@@ -25,44 +25,29 @@ export class AtkConCom extends CCComp {
targetPos: Vec3 = v3(); // 目标位置
group:number = 0; //阵营
fac:number=0; //阵营
run_time:number = 0;
// 战斗相关运行时数据
ap:number=0;
burn_count:number=0;
burn_value:number=0;
stun_time:number=0;
stun_ratio:number=0;
frost_ratio:number=0;
frost_time:number=0;
run_time:number=0;
hited_time:number=0;
hit_count:number=0;
caster_crit:number=0;
caster_crit_d:number=0;
puncture:number=0;
puncture_damage:number=0;
debuff_up:number=0;
debuff_value:number=0;
debuff_count:number=0;
Attrs:any=null
// 组件引用
anim:Animation=null;
tweenInstance:Tween<any> = null;
private moveDirection: Vec3 | null = null; // 添加一个属性来存储移动方向
// 缓存的配置对象(避免重复查找)
public skillConfig: any = null;
public Config: any = null;
private isInitialized: boolean = false;
private initializeSkillConfig() {
private initializeConfig() {
if (this.isInitialized) return;
// 缓存技能配置,避免重复查找
this.skillConfig = SkillSet[this.s_uuid];
if (!this.skillConfig) {
this.Config = SkillSet[this.s_uuid];
if (!this.Config) {
// console.error("[SkillCom] 技能配置不存在:", this.s_uuid);
return;
}
this.isInitialized = true;
// console.log("[SkillCom] 技能配置初始化完成:", this.s_uuid, this.skillConfig.name);
// console.log("[SkillCom] 技能配置初始化完成:", this.s_uuid, this.Config.name);
}
start() {
this.initializeSkillConfig();
this.initializeConfig();
// var entity = this.ent as ecs.Entity; // ecs.Entity 可转为当前模块的具体实体对象
// this.on(ModuleEvent.Cmd, this.onHandler, this);
@@ -122,10 +107,10 @@ export class AtkConCom extends CCComp {
onAnimationFinished(){
// console.log("[SkillCom]:onAnimationFinished",this.s_uuid)
if (!this.skillConfig) return;
if (!this.Config) return;
if(this.skillConfig.EType==EType.timeEnd) return
if(this.skillConfig.SType!=SType.damage){
if(this.Config.EType==EType.timeEnd) return
if(this.Config.SType!=SType.damage){
}
this.is_destroy=true
@@ -136,9 +121,9 @@ export class AtkConCom extends CCComp {
let target = oCol.getComponent(HeroViewComp)
if(oCol.group!=this.group){
if(target == null) return;
if (!this.skillConfig) return;
if (!this.Config) return;
// console.log("[SkillCom]:onBeginContact oCol||seCol",oCol.node.position,seCol.node.position)
this.single_damage(target,this.skillConfig.DTType==DTType.range?true:false)
this.single_damage(target,this.Config.DTType==DTType.range?true:false)
// this.ent.destroy()
}
}
@@ -147,36 +132,36 @@ export class AtkConCom extends CCComp {
// //console.log("[SkillCom]:onBeginContact hit_count:",this.hit_count,SkillSet[this.s_uuid].hit)
// if(this.hit_count > 0&&!is_range) this.ap=this.ap*(50+this.puncture_damage)/100 // 穿刺后 伤害减半,过滤范围伤害
if(target == null) return;
if (!this.skillConfig) return;
let ap=this.ap
if(this.hit_count > 0 &&!is_range ){
ap=ap*(50+this.puncture_damage)/100
}
target.do_atked(ap,this.caster_crit,this.caster_crit_d,
this.burn_count,this.burn_value,
this.stun_time,this.stun_ratio,
this.frost_time,this.frost_ratio,
this.skillConfig.AtkedType
) // ap 及暴击 属性已经在skill.ts 处理
// console.log("[SkillCom]:single_damage t:tp:rtp",this.node.position,this.targetPos,target.node.position)
if(this.skillConfig.debuff>0){
let debuff=this.skillConfig
let dev=debuff.deV*(100+this.debuff_value)/100
let deR=debuff.deR+this.debuff_up
dev=Math.round(dev*100)/100
let deC=debuff.deC+this.debuff_count //dec只作为次数叠加
// //console.log("[SkillCom]:debuff",this.skillConfig.name,debuff.debuff,deUP.deV,deUP.deC)
target.add_debuff(debuff.debuff,dev,deC,deR)
}
this.hit_count++
// console.log("[SkillCom]:碰撞次数:技能次数:穿刺次数",this.hit_count,this.skillConfig.hit,this.puncture)
if(this.hit_count>=(this.skillConfig.hit+this.puncture)&&(this.skillConfig.DTType!=DTType.range)&&(this.skillConfig.EType!=EType.animationEnd)&&(this.skillConfig.EType!=EType.timeEnd)) this.is_destroy=true // 技能命中次数
if (!this.Config) return;
// let ap=this.ap
// if(this.hit_count > 0 &&!is_range ){
// ap=ap*(50+this.puncture_damage)/100
// }
// target.do_atked(ap,this.caster_crit,this.caster_crit_d,
// this.burn_count,this.burn_value,
// this.stun_time,this.stun_ratio,
// this.frost_time,this.frost_ratio,
// this.Config.AtkedType
// ) // ap 及暴击 属性已经在skill.ts 处理
// // console.log("[SkillCom]:single_damage t:tp:rtp",this.node.position,this.targetPos,target.node.position)
// if(this.Config.debuff>0){
// let debuff=this.Config
// let dev=debuff.deV*(100+this.debuff_value)/100
// let deR=debuff.deR+this.debuff_up
// dev=Math.round(dev*100)/100
// let deC=debuff.deC+this.debuff_count //dec只作为次数叠加
// // //console.log("[SkillCom]:debuff",this.Config.name,debuff.debuff,deUP.deV,deUP.deC)
// target.add_debuff(debuff.debuff,dev,deC,deR)
// }
// this.hit_count++
// // console.log("[SkillCom]:碰撞次数:技能次数:穿刺次数",this.hit_count,this.Config.hit,this.puncture)
// if(this.hit_count>=(this.Config.hit+this.puncture)&&(this.Config.DTType!=DTType.range)&&(this.Config.EType!=EType.animationEnd)&&(this.Config.EType!=EType.timeEnd)) this.is_destroy=true // 技能命中次数
}
update(deltaTime: number) {
// 确保配置已初始化(处理 update 可能先于 start 执行的情况)
if (!this.isInitialized) {
this.initializeSkillConfig();
if (!this.skillConfig) return;
this.initializeConfig();
if (!this.Config) return;
}
if(smc.mission.pause) {
@@ -186,9 +171,9 @@ export class AtkConCom extends CCComp {
if(this.anim) this.anim.resume()
if (!this.node || !this.node.isValid) return;
if(this.skillConfig.EType==EType.timeEnd){
if(this.Config.EType==EType.timeEnd){
this.run_time+=deltaTime
if(this.run_time>this.skillConfig.in){
if(this.run_time>this.Config.in){
// //console.log("[SkillCom]: timeEnd destroy",this.s_uuid,this.run_time)
this.is_destroy=true
}