开始重构技能系统
This commit is contained in:
@@ -105,101 +105,101 @@ export const MonSet = {
|
||||
export const HeroInfo = {
|
||||
//主将
|
||||
5001:{uuid:5001,name:"火焰骑士",path:"hk1", fac:FacSet.HERO, quality:QualitySet.GREEN,lv:1,kind:1,
|
||||
type:HType.warrior,hp:100,def:5,ap:15,dis:100,cd:1,speed:150,skills:[6001,6001,6301,6302,6303],
|
||||
type:HType.warrior,hp:100,mp:100,def:5,ap:15,dis:100,cd:1,speed:150,skills:[6005,6005],
|
||||
buff:[],info:""},
|
||||
|
||||
5002:{uuid:5002,name:"刺客",path:"hc1", fac:FacSet.HERO, quality:QualitySet.BLUE,lv:1,kind:1,
|
||||
type:HType.warrior,hp:100,def:5,ap:15,dis:100,cd:1,speed:150,skills:[6001,6001,6301,6302,6303],
|
||||
type:HType.warrior,hp:100,mp:100,def:5,ap:15,dis:100,cd:1,speed:150,skills:[6005,6005],
|
||||
buff:[],info:""},
|
||||
|
||||
|
||||
5005:{uuid:5005,name:"绿箭",path:"ha1", fac:FacSet.HERO, quality:QualitySet.BLUE,lv:1,kind:2,
|
||||
type:HType.remote,hp:100,def:5,ap:15,dis:400,cd:1,speed:100,skills:[6003,6003,6301,6302,6303],
|
||||
type:HType.remote,hp:100,mp:100,def:5,ap:15,dis:400,cd:1,speed:100,skills:[6005,6005],
|
||||
buff:[],info:""},
|
||||
|
||||
|
||||
5007:{uuid:5007,name:"牧师",path:"hmh1", fac:FacSet.HERO, quality:QualitySet.PURPLE,lv:1,kind:2,
|
||||
type:HType.mage,hp:100,def:5,ap:15,dis:400,cd:1,speed:100,skills:[6004,6004,6301,6302,6303],
|
||||
type:HType.mage,hp:100,mp:100,def:5,ap:15,dis:400,cd:1,speed:100,skills:[6005,6005],
|
||||
buff:[],info:""},
|
||||
|
||||
5008:{uuid:5008,name:"火女",path:"hmf1", fac:FacSet.HERO, quality:QualitySet.BLUE,lv:1,kind:2,
|
||||
type:HType.mage,hp:100,def:5,ap:15,dis:400,cd:1.5,speed:100,skills:[6005,6005,6301,6302,6303],
|
||||
type:HType.mage,hp:100,mp:100,def:5,ap:15,dis:400,cd:1.5,speed:100,skills:[6005,6005],
|
||||
buff:[],info:""},
|
||||
|
||||
// 5009:{uuid:5009,name:"风暴精灵",path:"hk1", fac:FacSet.HERO, quality:QualitySet.BLUE,lv:1,kind:2,
|
||||
// type:HType.mage,hp:100,def:5,ap:15,dis:400,cd:1.5,speed:100,skills:[6006,6006,6301,6302,6303],
|
||||
// type:HType.mage,hp:100,mp:100,def:5,ap:15,dis:400,cd:1.5,speed:100,skills:[6006,6006,6301,6302,6303],
|
||||
// buff:[],info:""},
|
||||
|
||||
// 5010:{uuid:5010,name:"战争祭祀",path:"hk1", fac:FacSet.HERO, quality:QualitySet.ORANGE,lv:1,kind:2,
|
||||
// type:HType.mage,hp:100,def:5,ap:15,dis:400,cd:1.5,speed:100,skills:[6007,6007,6301,6302,6303],
|
||||
// type:HType.mage,hp:100,mp:100,def:5,ap:15,dis:400,cd:1.5,speed:100,skills:[6007,6007,6301,6302,6303],
|
||||
// buff:[],info:""},
|
||||
|
||||
// 5011:{uuid:5011,name:"ha2",path:"ha2", fac:FacSet.HERO, quality:QualitySet.BLUE,lv:1,kind:2,
|
||||
// type:HType.remote,hp:100,def:5,ap:15,dis:400,cd:1,speed:100,skills:[6003,6003,6301,6302,6303],
|
||||
// type:HType.remote,hp:100,mp:100,def:5,ap:15,dis:400,cd:1,speed:100,skills:[6003,6003,6301,6302,6303],
|
||||
// buff:[],info:""},
|
||||
|
||||
|
||||
//怪物
|
||||
5201:{uuid:5201,name:"兽人战士",path:"mo1", fac:FacSet.MON, quality:QualitySet.GREEN,lv:1,kind:1,
|
||||
type:HType.warrior,hp:25,def:5,ap:5,dis:90,cd:2,speed:100,skills:[6001],
|
||||
type:HType.warrior,hp:25,mp:100,def:5,ap:5,dis:90,cd:2,speed:100,skills:[6005,6005],
|
||||
buff:[],info:"普通怪物-战士型"},
|
||||
|
||||
5202:{uuid:5202,name:"兽人刺客",path:"mo1", fac:FacSet.MON, quality:QualitySet.GREEN,lv:1,kind:1,
|
||||
type:HType.remote,hp:20,def:5,ap:5,dis:350,cd:1,speed:100,skills:[6007],
|
||||
type:HType.remote,hp:20,mp:100,def:5,ap:5,dis:350,cd:1,speed:100,skills:[6005,6005],
|
||||
buff:[],info:"普通怪物-战士型"},
|
||||
|
||||
5203:{uuid:5203,name:"兽人护卫",path:"mo1", fac:FacSet.MON, quality:QualitySet.GREEN,lv:1,kind:1,
|
||||
type:HType.warrior,hp:25,def:5,ap:5,dis:90,cd:2,speed:100,skills:[6001],
|
||||
type:HType.warrior,hp:25,mp:100,def:5,ap:5,dis:90,cd:2,speed:100,skills:[6005,6005],
|
||||
buff:[],info:"普通怪物-战士型"},
|
||||
|
||||
5204:{uuid:5204,name:"石卫", path:"mo1", fac:FacSet.MON, quality:QualitySet.GREEN,lv:1,kind:1,
|
||||
type:HType.mage,hp:18,def:5,ap:5,dis:90,cd:2.5,speed:100,skills:[6001],
|
||||
type:HType.mage,hp:18,mp:100,def:5,ap:5,dis:90,cd:2.5,speed:100,skills:[6005,6005],
|
||||
buff:[],info:"法师怪物-高伤害脆弱"},
|
||||
|
||||
5205:{uuid:5205,name:"土卫", path:"mo1", fac:FacSet.MON, quality:QualitySet.GREEN,lv:1,kind:1,
|
||||
type:HType.mage,hp:18,def:5,ap:5,dis:90,cd:2.5,speed:100,skills:[6001],
|
||||
type:HType.mage,hp:18,mp:100,def:5,ap:5,dis:90,cd:2.5,speed:100,skills:[6005,6005],
|
||||
buff:[],info:"法师怪物-高伤害脆弱"},
|
||||
|
||||
5206:{uuid:5206,name:"树卫", path:"mo1", fac:FacSet.MON, quality:QualitySet.GREEN,lv:1,kind:1,
|
||||
type:HType.mage,hp:18,def:5,ap:5,dis:90,cd:2.5,speed:100,skills:[6001],
|
||||
type:HType.mage,hp:18,mp:100,def:5,ap:5,dis:90,cd:2.5,speed:100,skills:[6005,6005],
|
||||
buff:[],info:"法师怪物-高伤害脆弱"},
|
||||
|
||||
|
||||
|
||||
5219:{uuid:5219,name:"牛头战士",path:"mo1", fac:FacSet.MON, quality:QualitySet.GREEN,lv:2,kind:1,
|
||||
type:HType.warrior,hp:25,def:5,ap:5,dis:90,cd:2,speed:100,skills:[6001],
|
||||
type:HType.warrior,hp:25,mp:100,def:5,ap:5,dis:90,cd:2,speed:100,skills:[6005,6005],
|
||||
buff:[],info:"普通怪物-战士型"},
|
||||
|
||||
5220:{uuid:5220,name:"牛头战士",path:"mo1", fac:FacSet.MON, quality:QualitySet.GREEN,lv:1,kind:1,
|
||||
type:HType.warrior,hp:25,def:5,ap:5,dis:90,cd:2,speed:100,skills:[6001],
|
||||
type:HType.warrior,hp:25,mp:100,def:5,ap:5,dis:90,cd:2,speed:100,skills:[6005,6005],
|
||||
buff:[],info:"普通怪物-战士型"},
|
||||
|
||||
5221:{uuid:5221,name:"牛头战士",path:"mo1", fac:FacSet.MON, quality:QualitySet.GREEN,lv:1,kind:1,
|
||||
type:HType.remote,hp:20,def:5,ap:5,dis:350,cd:1.5,speed:100,skills:[6007],
|
||||
type:HType.remote,hp:20,mp:100,def:5,ap:5,dis:350,cd:1.5,speed:100,skills:[6005,6005],
|
||||
buff:[],info:"普通怪物-战士型"},
|
||||
|
||||
5222:{uuid:5222,name:"独眼巨人",path:"mo1", fac:FacSet.MON, quality:QualitySet.GREEN,lv:1,kind:1,
|
||||
type:HType.warrior,hp:25,def:5,ap:5,dis:90,cd:2,speed:100,skills:[6001],
|
||||
type:HType.warrior,hp:25,mp:100,def:5,ap:5,dis:90,cd:2,speed:100,skills:[6005,6005],
|
||||
buff:[],info:"普通怪物-战士型"},
|
||||
|
||||
5223:{uuid:5223,name:"独眼巨人",path:"mo1", fac:FacSet.MON, quality:QualitySet.GREEN,lv:1,kind:1,
|
||||
type:HType.warrior,hp:25,def:5,ap:5,dis:90,cd:2,speed:100,skills:[6001],
|
||||
type:HType.warrior,hp:25,mp:100,def:5,ap:5,dis:90,cd:2,speed:100,skills:[6005,6005],
|
||||
buff:[],info:"普通怪物-战士型"},
|
||||
|
||||
5224:{uuid:5224,name:"独眼巨人",path:"mo1", fac:FacSet.MON, quality:QualitySet.GREEN,lv:1,kind:1,
|
||||
type:HType.remote,hp:20,def:5,ap:5,dis:350,cd:1.5,speed:100,skills:[6001],
|
||||
type:HType.remote,hp:20,mp:100,def:5,ap:5,dis:350,cd:1.5,speed:100,skills:[6005,6005],
|
||||
buff:[],info:"普通怪物-战士型"},
|
||||
|
||||
5225:{uuid:5225,name:"精英独眼",path:"mo1", fac:FacSet.MON, quality:QualitySet.BLUE,lv:1,kind:1,
|
||||
type:HType.warrior,hp:45,def:5,ap:12,dis:300,cd:2,speed:100,skills:[6006],
|
||||
type:HType.warrior,hp:45,mp:100,def:5,ap:12,dis:300,cd:2,speed:100,skills:[6006],
|
||||
buff:[],info:"精英怪物-战士型"},
|
||||
|
||||
5226:{uuid:5226,name:"精英牛头",path:"mo1", fac:FacSet.MON, quality:QualitySet.BLUE,lv:1,kind:1,
|
||||
type:HType.warrior,hp:45,def:5,ap:12,dis:300,cd:2,speed:100,skills:[6007],
|
||||
type:HType.warrior,hp:45,mp:100,def:5,ap:12,dis:300,cd:2,speed:100,skills:[6005,6005],
|
||||
buff:[],info:"精英怪物-战士型"},
|
||||
|
||||
5227:{uuid:5227,name:"精英兽人",path:"mo1", fac:FacSet.MON, quality:QualitySet.BLUE,lv:1,kind:1,
|
||||
type:HType.warrior,hp:45,def:5,ap:12,dis:300,cd:2,speed:100,skills:[6005],
|
||||
type:HType.warrior,hp:45,mp:100,def:5,ap:12,dis:300,cd:2,speed:100,skills:[6005,6005],
|
||||
buff:[],info:"精英怪物-战士型"},
|
||||
|
||||
};
|
||||
|
||||
233
assets/script/game/skill/AtkConCom.ts
Normal file
233
assets/script/game/skill/AtkConCom.ts
Normal file
@@ -0,0 +1,233 @@
|
||||
import { _decorator, Animation, Collider2D, Contact2DType, Tween, v3, Vec3 } from "cc";
|
||||
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 { BoxSet, FacSet } from "../common/config/BoxSet";
|
||||
import { HeroViewComp } from "../hero/HeroViewComp";
|
||||
import { GameEvent } from "../common/config/GameEvent";
|
||||
import { smc } from "../common/SingletonModuleComp";
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
/** 视图层对象 */
|
||||
@ccclass('AtkConCom')
|
||||
@ecs.register('AtkCon', false)
|
||||
export class AtkConCom extends CCComp {
|
||||
@property({ type:Boolean })
|
||||
public anmEnd: boolean = false;
|
||||
@property({ type:Boolean })
|
||||
public cbox: boolean = false;
|
||||
// 核心标识和配置
|
||||
s_uuid:number = 0;
|
||||
// 运行时状态(必须缓存的)
|
||||
is_destroy:boolean = false;
|
||||
startPos: Vec3 = v3(); // 起始位置
|
||||
targetPos: Vec3 = v3(); // 目标位置
|
||||
group:number = 0; //阵营
|
||||
fac:number=0; //阵营
|
||||
caster:any=null;
|
||||
|
||||
// 战斗相关运行时数据
|
||||
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;
|
||||
// 组件引用
|
||||
anim:Animation=null;
|
||||
tweenInstance:Tween<any> = null;
|
||||
private moveDirection: Vec3 | null = null; // 添加一个属性来存储移动方向
|
||||
// 缓存的配置对象(避免重复查找)
|
||||
public skillConfig: any = null;
|
||||
private isInitialized: boolean = false;
|
||||
private initializeSkillConfig() {
|
||||
if (this.isInitialized) return;
|
||||
// 缓存技能配置,避免重复查找
|
||||
this.skillConfig = SkillSet[this.s_uuid];
|
||||
if (!this.skillConfig) {
|
||||
// console.error("[SkillCom] 技能配置不存在:", this.s_uuid);
|
||||
return;
|
||||
}
|
||||
this.isInitialized = true;
|
||||
// console.log("[SkillCom] 技能配置初始化完成:", this.s_uuid, this.skillConfig.name);
|
||||
}
|
||||
start() {
|
||||
this.initializeSkillConfig();
|
||||
// var entity = this.ent as ecs.Entity; // ecs.Entity 可转为当前模块的具体实体对象
|
||||
// this.on(ModuleEvent.Cmd, this.onHandler, this);
|
||||
this.node.setPosition(this.startPos.x,this.startPos.y,0)
|
||||
this.anim=this.node.getComponent(Animation)
|
||||
this.on(GameEvent.MissionEnd, this.doDestroy, this);
|
||||
this.node.active = true;
|
||||
let collider = this.getComponent(Collider2D);
|
||||
if(collider) {
|
||||
collider.group = this.group;
|
||||
collider.on(Contact2DType.BEGIN_CONTACT, this.onBeginContact, this);
|
||||
}
|
||||
let bm=this.node.getComponent(BezierMove)
|
||||
// //console.log(this.group +"技能 collider ",collider);
|
||||
switch(this.skillConfig.AType){
|
||||
case AType.parabolic:
|
||||
this.node.angle +=10
|
||||
// bm.speed=700
|
||||
if(this.group==BoxSet.MONSTER) {bm.controlPointSide=-1 }
|
||||
bm.rotationSmoothness=0.6
|
||||
bm.moveTo(this.targetPos)
|
||||
break;
|
||||
case AType.linear:
|
||||
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);
|
||||
break;
|
||||
case AType.StartEnd:
|
||||
// 2段位移:先升高,然后移到目的地
|
||||
this.node.setPosition(this.startPos.x > 360?300:this.startPos.x,0,0)
|
||||
this.do_anim()
|
||||
break;
|
||||
case AType.fixedEnd:
|
||||
this.node.setPosition(this.targetPos.x > 360?300:this.targetPos.x,0,0)
|
||||
this.do_anim()
|
||||
break;
|
||||
case AType.fixedStart: //
|
||||
if(this.s_uuid==6001){
|
||||
console.log("skillcom startPos",this.startPos)
|
||||
}
|
||||
this.node.setPosition(this.startPos.x > 360?300:this.startPos.x,0,0)
|
||||
this.do_anim()
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
do_anim(){
|
||||
if(this.node.getComponent(Animation)){
|
||||
let anim = this.node.getComponent(Animation);
|
||||
//console.log("[SkillCom]:has anim",anim)
|
||||
anim.on(Animation.EventType.FINISHED, this.onAnimationFinished, this);
|
||||
}
|
||||
|
||||
}
|
||||
onAnimationFinished(){
|
||||
// console.log("[SkillCom]:onAnimationFinished",this.s_uuid)
|
||||
if (!this.skillConfig) return;
|
||||
|
||||
if(this.skillConfig.EType==EType.timeEnd) return
|
||||
if(this.skillConfig.SType!=SType.damage){
|
||||
|
||||
}
|
||||
this.is_destroy=true
|
||||
}
|
||||
onBeginContact (seCol: Collider2D, oCol: Collider2D) {
|
||||
// console.log(this.scale+"碰撞开始 ",seCol,oCol);
|
||||
if(seCol.node.position.x-oCol.node.position.x > 100 ) return
|
||||
let target = oCol.getComponent(HeroViewComp)
|
||||
if(oCol.group!=this.group){
|
||||
if(target == null) return;
|
||||
if (!this.skillConfig) 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.ent.destroy()
|
||||
}
|
||||
}
|
||||
//单体伤害
|
||||
single_damage(target:HeroViewComp,is_range:boolean=false){
|
||||
// //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 // 技能命中次数
|
||||
}
|
||||
update(deltaTime: number) {
|
||||
// 确保配置已初始化(处理 update 可能先于 start 执行的情况)
|
||||
if (!this.isInitialized) {
|
||||
this.initializeSkillConfig();
|
||||
if (!this.skillConfig) return;
|
||||
}
|
||||
|
||||
if(smc.mission.pause) {
|
||||
if(this.anim) this.anim.pause()
|
||||
return;
|
||||
}
|
||||
if(this.anim) this.anim.resume()
|
||||
if (!this.node || !this.node.isValid) return;
|
||||
|
||||
if(this.skillConfig.EType==EType.timeEnd){
|
||||
this.run_time+=deltaTime
|
||||
if(this.run_time>this.skillConfig.in){
|
||||
// //console.log("[SkillCom]: timeEnd destroy",this.s_uuid,this.run_time)
|
||||
this.is_destroy=true
|
||||
}
|
||||
}
|
||||
|
||||
//直线移动
|
||||
// if(this.skillConfig.AType == AType.linear) this.startLinearMove(deltaTime);
|
||||
this.toDestroy();
|
||||
}
|
||||
|
||||
toDestroy() {
|
||||
if(this.is_destroy){
|
||||
if (this.ent) {
|
||||
this.ent.destroy();
|
||||
} else {
|
||||
// 如果ent不存在,直接销毁节点
|
||||
if (this.node && this.node.isValid) {
|
||||
this.node.destroy();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
doDestroy(){
|
||||
// //console.log("[SkillCom]:doDestroy")
|
||||
this.is_destroy=true
|
||||
}
|
||||
reset() {
|
||||
this.node.destroy();
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,7 @@
|
||||
"ver": "4.0.24",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "36448c83-0bd9-495b-806d-6e7d640370e3",
|
||||
"uuid": "411a8c58-dab3-45d4-92d9-9fe420a9faa0",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
@@ -1,139 +0,0 @@
|
||||
// import { Node, UI, UITransform, Vec3 } from "cc";
|
||||
// import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
|
||||
// import { HeroViewComp } from "../hero/HeroViewComp";
|
||||
// import { SkillSet, TGroup, TType } from "../common/config/SkillSet";
|
||||
// import { CdType } from "../common/config/SkillSet";
|
||||
// import { oops } from "db://oops-framework/core/Oops";
|
||||
// import { GameEvent } from "../common/config/GameEvent";
|
||||
// import { Skill } from "../skills/Skill";
|
||||
// import { SkillCom } from "../skills/SkillCom";
|
||||
// import { AType } from "../common/config/SkillSet";
|
||||
// import { BoxSet } from "../common/config/BoxSet";
|
||||
|
||||
|
||||
// /** 技能系统 */
|
||||
// @ecs.register('HeroSkillSystem')
|
||||
// export class HeroSkillSystem extends ecs.ComblockSystem {
|
||||
// // export class HeroSkillSystem implements ecs.ISystemUpdate {
|
||||
// // private updateInterval: number = 0.1; // 每0.1秒更新一次
|
||||
// // private accumulator: number = 0;
|
||||
// private _timers: { [key: string]: number } = {};
|
||||
// private _damageQueue: Array<{ timer: number; callback: () => void }> = [];
|
||||
// init(): void {
|
||||
// oops.message.on(GameEvent.FightEnd, this.clear_timer, this);
|
||||
// }
|
||||
// filter(): ecs.IMatcher {
|
||||
// return ecs.allOf(HeroViewComp);
|
||||
// }
|
||||
// update(e: ecs.Entity) {
|
||||
// //return false
|
||||
// // 处理伤害队列
|
||||
// const view = e.get(HeroViewComp);
|
||||
// // 只在攻击状态触发技能
|
||||
// if (view.is_atking &&view.at > view.cd) {
|
||||
// const config = SkillSet[view.atk_skill];
|
||||
// if (!config) return;
|
||||
// this.castSkill(e, view.atk_skill, config);
|
||||
// view.at = 0;
|
||||
// }
|
||||
|
||||
// }
|
||||
|
||||
// /** 施放技能 */
|
||||
// private castSkill(caster: ecs.Entity, skillId: number, config: typeof SkillSet[keyof typeof SkillSet]) {
|
||||
// const view = caster.get(HeroViewComp);
|
||||
// // console.log(view.uuid+"=>"+view.hero_name+"施放技能:"+config.uuid);
|
||||
// if (config.TGroup === TGroup.Enemy) {
|
||||
// caster.get(HeroViewComp).playSkillEffect(config.uuid);
|
||||
// this.doSkill(caster,config);
|
||||
// }
|
||||
|
||||
// if (config.TGroup === TGroup.Ally) {
|
||||
// const targets = this.selectAllyTargets(caster, config);
|
||||
// if (targets.length === 0) return;
|
||||
|
||||
// }
|
||||
// if (config.TGroup === TGroup.Self) {
|
||||
|
||||
// }
|
||||
|
||||
// }
|
||||
// private doSkill(caster: ecs.Entity, config: typeof SkillSet[keyof typeof SkillSet]) {
|
||||
// const view = caster.get(HeroViewComp);
|
||||
// const skillEntity = ecs.getEntity<Skill>(Skill);
|
||||
// const targets = this.selectEnemyTargets(caster, config);
|
||||
// if (targets.length === 0) return;
|
||||
// skillEntity.load(
|
||||
// new Vec3(view.node.position.x, view.node.position.y+BoxSet.ATK_Y, 0), // 起始位置
|
||||
// view.box_group, // 阵营
|
||||
// view.node.parent, // 父节点
|
||||
// config.uuid, // 技能ID
|
||||
// new Vec3(targets[0]?.get(HeroViewComp).node.position.x, targets[0]?.get(HeroViewComp).node.position.y, 0), // 目标位置
|
||||
// view
|
||||
// );
|
||||
// // console.log("技能:"+config.uuid+"=>"+targets[0]?.get(HeroViewComp).hero_name);
|
||||
// }
|
||||
|
||||
// private selectEnemyTargets(caster: ecs.Entity, config: typeof SkillSet[keyof typeof SkillSet]): ecs.Entity[] {
|
||||
// const casterView = caster.get(HeroViewComp);
|
||||
// const team = casterView.fac;
|
||||
// const isEnemyTeam = team === 0 ? 1 : 0;
|
||||
// const candidates= ecs.query(ecs.allOf(HeroViewComp)).filter(e => e.get(HeroViewComp).fac !== team);
|
||||
// return this.filterFrontRow(candidates, isEnemyTeam);
|
||||
// }
|
||||
// private selectAllyTargets(caster: ecs.Entity, config: typeof SkillSet[keyof typeof SkillSet]): ecs.Entity[] {
|
||||
// const casterView = caster.get(HeroViewComp);
|
||||
// const team = casterView.fac;
|
||||
// const candidates= ecs.query(ecs.allOf(HeroViewComp)).filter(e => e.get(HeroViewComp).fac === team);
|
||||
// // 第二阶段:位置/血量等精细筛选
|
||||
// switch(config.TType) {
|
||||
// case TType.Melee:
|
||||
// return candidates.filter(e => e.get(HeroViewComp).type === 0);
|
||||
// case TType.Ranged:
|
||||
// return candidates.filter(e => e.get(HeroViewComp).type === 1);
|
||||
// case TType.SupportClass:
|
||||
// return candidates.filter(e => e.get(HeroViewComp).type === 2);
|
||||
// case TType.Random:
|
||||
// return this.pickRandomTarget(candidates, config.count || 1);
|
||||
// default:
|
||||
// return candidates;
|
||||
// }
|
||||
// }
|
||||
|
||||
// /** 筛选最前排单位 */
|
||||
// private filterFrontRow(entities: ecs.Entity[], isEnemyTeam: number): ecs.Entity[] {
|
||||
// // 敌方最前排是x坐标最大的,我方最前排是x坐标最小的
|
||||
// const keyPos = isEnemyTeam ?
|
||||
// Math.min(...entities.map(e => e.get(HeroViewComp).node.position.x)) :
|
||||
// Math.max(...entities.map(e => e.get(HeroViewComp).node.position.x));
|
||||
|
||||
// return entities.filter(e =>
|
||||
// Math.abs(e.get(HeroViewComp).node.position.x - keyPos) < 10
|
||||
// );
|
||||
// }
|
||||
|
||||
// /** 随机选择目标 */
|
||||
// private pickRandomTarget(entities: ecs.Entity[], count: number): ecs.Entity[] {
|
||||
// const shuffled = [...entities].sort(() => 0.5 - Math.random());
|
||||
// return shuffled.slice(0, count);
|
||||
// }
|
||||
|
||||
|
||||
// public clear_timer() {
|
||||
// // console.log("clear_timer");
|
||||
// Object.values(this._timers).forEach(clearTimeout);
|
||||
// }
|
||||
// onDestroy() {
|
||||
// Object.values(this._timers).forEach(clearTimeout);
|
||||
// }
|
||||
|
||||
|
||||
// /** 应用负面状态 */
|
||||
// private applyDebuff(target: ecs.Entity, config: typeof SkillSet[keyof typeof SkillSet]) {
|
||||
// // 实现debuff逻辑...
|
||||
// }
|
||||
|
||||
// }
|
||||
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ export class Skill extends ecs.Entity {
|
||||
}
|
||||
|
||||
// 加载预制体
|
||||
const path = `game/skills/${config.sp_name}`;
|
||||
const path = `game/skill/atk/${config.sp_name}`;
|
||||
const prefab:Prefab = oops.res.get(path, Prefab);
|
||||
if (!prefab) {
|
||||
console.error("[Skill] 预制体加载失败:", path);
|
||||
|
||||
@@ -22,7 +22,6 @@ const { ccclass, property } = _decorator;
|
||||
export class SkillCom extends CCComp {
|
||||
// 核心标识和配置
|
||||
s_uuid:number = 0;
|
||||
|
||||
// 运行时状态(必须缓存的)
|
||||
is_destroy:boolean = false;
|
||||
startPos: Vec3 = v3(); // 起始位置
|
||||
@@ -81,14 +80,9 @@ export class SkillCom extends CCComp {
|
||||
this.initializeSkillConfig();
|
||||
if (!this.skillConfig) return;
|
||||
this.node.setPosition(this.startPos.x,this.startPos.y,0)
|
||||
|
||||
this.anim=this.node.getComponent(Animation)
|
||||
|
||||
this.on(GameEvent.MissionEnd, this.doDestroy, this);
|
||||
this.node.active = true;
|
||||
//console.log("[SkillCom]:caster",this.caster)
|
||||
|
||||
|
||||
let collider = this.getComponent(Collider2D);
|
||||
if(collider) {
|
||||
collider.group = this.group;
|
||||
|
||||
Reference in New Issue
Block a user