From 070346fbe4a86fb62dc9453b96b3f83048532261 Mon Sep 17 00:00:00 2001 From: panw Date: Tue, 14 Oct 2025 16:58:07 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8A=80=E8=83=BD=E9=87=8D=E6=9E=84=E5=BC=80?= =?UTF-8?q?=E5=A7=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../resources/game/skill/atk/atk_fire.prefab | 110 +++++++++++++----- .../resources/game/skill/prefab/ready1.prefab | 4 +- assets/script/game/common/config/SkillSet.ts | 2 +- assets/script/game/hero/SkillConComp.ts | 3 +- assets/script/game/skill/ReadyCom.ts | 29 +++++ assets/script/game/skill/ReadyCom.ts.meta | 9 ++ assets/script/game/skill/SkillCon.ts | 100 ++++++++++++++++ assets/script/game/skill/SkillCon.ts.meta | 9 ++ assets/script/game/skill/SkillViewCom.ts | 97 +++++++++++++++ assets/script/game/skill/SkillViewCom.ts.meta | 9 ++ 10 files changed, 338 insertions(+), 34 deletions(-) create mode 100644 assets/script/game/skill/ReadyCom.ts create mode 100644 assets/script/game/skill/ReadyCom.ts.meta create mode 100644 assets/script/game/skill/SkillCon.ts create mode 100644 assets/script/game/skill/SkillCon.ts.meta create mode 100644 assets/script/game/skill/SkillViewCom.ts create mode 100644 assets/script/game/skill/SkillViewCom.ts.meta diff --git a/assets/resources/game/skill/atk/atk_fire.prefab b/assets/resources/game/skill/atk/atk_fire.prefab index 23658f6e..48492e39 100644 --- a/assets/resources/game/skill/atk/atk_fire.prefab +++ b/assets/resources/game/skill/atk/atk_fire.prefab @@ -22,20 +22,23 @@ "__id__": 2 }, { - "__id__": 10 + "__id__": 11 }, { - "__id__": 18 + "__id__": 19 } ], "_active": true, "_components": [ { - "__id__": 26 + "__id__": 28 + }, + { + "__id__": 30 } ], "_prefab": { - "__id__": 28 + "__id__": 32 }, "_lpos": { "__type__": "cc.Vec3", @@ -112,6 +115,9 @@ }, { "__id__": 9 + }, + { + "__id__": 10 } ], "removedComponents": [] @@ -178,6 +184,16 @@ "z": 0 } }, + { + "__type__": "CCPropertyOverrideInfo", + "targetInfo": { + "__id__": 6 + }, + "propertyPath": [ + "_active" + ], + "value": false + }, { "__type__": "cc.Node", "_objFlags": 0, @@ -185,14 +201,14 @@ "__id__": 1 }, "_prefab": { - "__id__": 11 + "__id__": 12 }, "__editorExtras__": {} }, { "__type__": "cc.PrefabInfo", "root": { - "__id__": 10 + "__id__": 11 }, "asset": { "__uuid__": "43a67d73-b426-4f20-9a1f-1aaae1c82bd0", @@ -200,7 +216,7 @@ }, "fileId": "cfqCWnxbFLNoQMedQXsav3", "instance": { - "__id__": 12 + "__id__": 13 }, "targetOverrides": null }, @@ -214,16 +230,16 @@ "mountedComponents": [], "propertyOverrides": [ { - "__id__": 13 - }, - { - "__id__": 15 + "__id__": 14 }, { "__id__": 16 }, { "__id__": 17 + }, + { + "__id__": 18 } ], "removedComponents": [] @@ -231,7 +247,7 @@ { "__type__": "CCPropertyOverrideInfo", "targetInfo": { - "__id__": 14 + "__id__": 15 }, "propertyPath": [ "_name" @@ -247,7 +263,7 @@ { "__type__": "CCPropertyOverrideInfo", "targetInfo": { - "__id__": 14 + "__id__": 15 }, "propertyPath": [ "_lpos" @@ -262,7 +278,7 @@ { "__type__": "CCPropertyOverrideInfo", "targetInfo": { - "__id__": 14 + "__id__": 15 }, "propertyPath": [ "_lrot" @@ -278,7 +294,7 @@ { "__type__": "CCPropertyOverrideInfo", "targetInfo": { - "__id__": 14 + "__id__": 15 }, "propertyPath": [ "_euler" @@ -297,14 +313,14 @@ "__id__": 1 }, "_prefab": { - "__id__": 19 + "__id__": 20 }, "__editorExtras__": {} }, { "__type__": "cc.PrefabInfo", "root": { - "__id__": 18 + "__id__": 19 }, "asset": { "__uuid__": "26ff5f8c-e160-4977-bf1b-0b6153052bef", @@ -312,7 +328,7 @@ }, "fileId": "c46/YsCPVOJYA4mWEpNYRx", "instance": { - "__id__": 20 + "__id__": 21 }, "targetOverrides": null }, @@ -326,16 +342,19 @@ "mountedComponents": [], "propertyOverrides": [ { - "__id__": 21 - }, - { - "__id__": 23 + "__id__": 22 }, { "__id__": 24 }, { "__id__": 25 + }, + { + "__id__": 26 + }, + { + "__id__": 27 } ], "removedComponents": [] @@ -343,12 +362,12 @@ { "__type__": "CCPropertyOverrideInfo", "targetInfo": { - "__id__": 22 + "__id__": 23 }, "propertyPath": [ "_name" ], - "value": "atk_fire" + "value": "atk" }, { "__type__": "cc.TargetInfo", @@ -359,7 +378,7 @@ { "__type__": "CCPropertyOverrideInfo", "targetInfo": { - "__id__": 22 + "__id__": 23 }, "propertyPath": [ "_lpos" @@ -374,7 +393,7 @@ { "__type__": "CCPropertyOverrideInfo", "targetInfo": { - "__id__": 22 + "__id__": 23 }, "propertyPath": [ "_lrot" @@ -390,7 +409,7 @@ { "__type__": "CCPropertyOverrideInfo", "targetInfo": { - "__id__": 22 + "__id__": 23 }, "propertyPath": [ "_euler" @@ -402,6 +421,16 @@ "z": 0 } }, + { + "__type__": "CCPropertyOverrideInfo", + "targetInfo": { + "__id__": 23 + }, + "propertyPath": [ + "_active" + ], + "value": false + }, { "__type__": "cc.UITransform", "_name": "", @@ -412,7 +441,7 @@ }, "_enabled": true, "__prefab": { - "__id__": 27 + "__id__": 29 }, "_contentSize": { "__type__": "cc.Size", @@ -430,6 +459,27 @@ "__type__": "cc.CompPrefabInfo", "fileId": "63NP9yq3hEUKD/OZZZ5t7x" }, + { + "__type__": "fa24e/W24dKOpV/zeDMOkBU", + "_name": "", + "_objFlags": 0, + "__editorExtras__": {}, + "node": { + "__id__": 1 + }, + "_enabled": true, + "__prefab": { + "__id__": 31 + }, + "hasReady": true, + "ReadyTime": 0, + "postion_y": 0, + "_id": "" + }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "71M8fD8N5EuYBVRGv+zaXd" + }, { "__type__": "cc.PrefabInfo", "root": { @@ -443,10 +493,10 @@ "targetOverrides": null, "nestedPrefabInstanceRoots": [ { - "__id__": 18 + "__id__": 19 }, { - "__id__": 10 + "__id__": 11 }, { "__id__": 2 diff --git a/assets/resources/game/skill/prefab/ready1.prefab b/assets/resources/game/skill/prefab/ready1.prefab index 5acdb6da..b8404cf7 100644 --- a/assets/resources/game/skill/prefab/ready1.prefab +++ b/assets/resources/game/skill/prefab/ready1.prefab @@ -257,7 +257,7 @@ "fileId": "63z5ZyjTNKYbn+kEVB1s3W" }, { - "__type__": "0f3c4JhFbFO2rEFqBJJ7hFv", + "__type__": "be4ce0BvYZAT7jwDh/8uEKc", "_name": "", "_objFlags": 0, "__editorExtras__": {}, @@ -272,7 +272,7 @@ }, { "__type__": "cc.CompPrefabInfo", - "fileId": "32SLcINL1JHZ+vIyextzaC" + "fileId": "43LhUxREVP5o28vKbBCWcd" }, { "__type__": "cc.PrefabInfo", diff --git a/assets/script/game/common/config/SkillSet.ts b/assets/script/game/common/config/SkillSet.ts index c3a82fe6..e254a0fe 100644 --- a/assets/script/game/common/config/SkillSet.ts +++ b/assets/script/game/common/config/SkillSet.ts @@ -328,7 +328,7 @@ export const SkillSet: Record = { buffs:[],debuffs:[],info:"向最前方敌人释放寒冰弹,造成100%攻击的伤害" }, 6005: { - uuid:6005,name:"火球术",for_hero:true,sp_name:"am_fire",AtkedType:AtkedType.fire,path:"3039",quality:QualitySet.BLUE,TType:TType.Frontline, + uuid:6005,name:"火球术",for_hero:true,sp_name:"atk_fire",AtkedType:AtkedType.fire,path:"3039",quality:QualitySet.BLUE,TType:TType.Frontline, TGroup:TGroup.Enemy,SType:SType.damage,act:"atk",DTType:DTType.single,CdType:CdType.cd,AType:AType.linear,EType:EType.collision, ap:100,cd:5,in:0,hit_num:1,hit:2,hited:0.3,speed:720,cost:10,fname:"max",flash:false,with:90,maxC:1, buffs:[],debuffs:[{debuff:DebuffAttr.STUN,dev:0,deC:1,deR:50}],info:"召唤大火球攻击前方所有敌人,造成300%攻击的伤害,有一定几率施加灼烧" diff --git a/assets/script/game/hero/SkillConComp.ts b/assets/script/game/hero/SkillConComp.ts index 9b38ac31..629ab270 100644 --- a/assets/script/game/hero/SkillConComp.ts +++ b/assets/script/game/hero/SkillConComp.ts @@ -12,6 +12,7 @@ import { MonModelComp } from './MonModelComp'; import { HeroModelComp } from './HeroModelComp'; import { FightSet } from '../common/config/Mission'; import { Timer } from 'db://oops-framework/core/common/timer/Timer'; +import { SkillCon } from '../skill/SkillCon'; const { ccclass, property } = _decorator; @ccclass('SkillCon') @@ -103,7 +104,7 @@ export class SkillConComp extends CCComp { } this.HeroView.playSkillEffect(config.uuid) - const skillEntity = ecs.getEntity(Skill); + const skillEntity = ecs.getEntity(SkillCon); const timerId = setTimeout(() => { diff --git a/assets/script/game/skill/ReadyCom.ts b/assets/script/game/skill/ReadyCom.ts new file mode 100644 index 00000000..f493dcae --- /dev/null +++ b/assets/script/game/skill/ReadyCom.ts @@ -0,0 +1,29 @@ +import { _decorator } from "cc"; +import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS"; +import { CCComp } from "../../../../extensions/oops-plugin-framework/assets/module/common/CCComp"; + +const { ccclass, property } = _decorator; + +/** 视图层对象 */ +@ccclass('ReadyComComp') +@ecs.register('ReadyCom', false) +export class ReadyComComp extends CCComp { + /** 视图层逻辑代码分离演示 */ + start() { + // var entity = this.ent as ecs.Entity; // ecs.Entity 可转为当前模块的具体实体对象 + // this.on(ModuleEvent.Cmd, this.onHandler, this); + } + + /** 全局消息逻辑处理 */ + // private onHandler(event: string, args: any) { + // switch (event) { + // case ModuleEvent.Cmd: + // break; + // } + // } + + /** 视图对象通过 ecs.Entity.remove(ModuleViewComp) 删除组件是触发组件处理自定义释放逻辑 */ + reset() { + this.node.destroy(); + } +} \ No newline at end of file diff --git a/assets/script/game/skill/ReadyCom.ts.meta b/assets/script/game/skill/ReadyCom.ts.meta new file mode 100644 index 00000000..bd434150 --- /dev/null +++ b/assets/script/game/skill/ReadyCom.ts.meta @@ -0,0 +1,9 @@ +{ + "ver": "4.0.24", + "importer": "typescript", + "imported": true, + "uuid": "be4ced01-bd86-404f-b8f0-0e1ffcb8429c", + "files": [], + "subMetas": {}, + "userData": {} +} diff --git a/assets/script/game/skill/SkillCon.ts b/assets/script/game/skill/SkillCon.ts new file mode 100644 index 00000000..b57d5b31 --- /dev/null +++ b/assets/script/game/skill/SkillCon.ts @@ -0,0 +1,100 @@ +import { instantiate, Node, Prefab, v3, Vec3 } from "cc"; +import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS"; +import { BuffAttr, SkillSet } from "../common/config/SkillSet"; +import { oops } from "db://oops-framework/core/Oops"; +import { smc } from "../common/SingletonModuleComp"; +import { FacSet } from "../common/config/BoxSet"; +import { HType } from "../common/config/heroSet"; +import { SkillViewCom } from "./SkillViewCom"; + +/** SkillCon 模块 */ +@ecs.register(`SkillCon`) +export class SkillCon extends ecs.Entity { + +load(startPos: Vec3, parent: Node, uuid: number, targetPos: Vec3, caster:any=null, angle:number=0,dmg:number=0) { + const config = SkillSet[uuid]; + if (!config) { + console.error("[Skill] 技能配置不存在:", uuid); + return; + } + // 检查施法者 + if (!caster) { + console.error("[Skill] 施法者为空"); + return; + } + // 加载预制体 + const path = `game/skill/atk/${config.sp_name}`; + const prefab:Prefab = oops.res.get(path, Prefab); + if (!prefab) { + console.error("[Skill] 预制体加载失败:", path); + return; + } + if(uuid==6001){ + console.log("load skill startPos",startPos) + } + const node: Node = instantiate(prefab); + node.parent = parent; + // 设置节点属性 + node.setPosition(startPos); + if(caster.fac==FacSet.MON){ + node.scale=v3(node.scale.x*-1,1,1) + }else{ + if(caster.type==HType.warrior){ + if(caster.node.scale.x<0){ + node.scale=v3(node.scale.x*-1,node.scale.y,1) + } + } + } + node.angle+=angle + // 添加技能组件 + const SComp = node.getComponent(SkillViewCom); // 初始化技能参数 + + // 只设置必要的运行时属性,配置信息通过 SkillSet[uuid] 访问 + Object.assign(SComp, { + // 核心标识 + s_uuid: uuid, + // 位置和施法者信息 + startPos: startPos, + targetPos: targetPos, + group: caster.box_group, + fac: caster.fac, + // 技能数值 + ap: caster.Attrs[BuffAttr.AP], + caster_crit: caster.Attrs[BuffAttr.CRITICAL], + caster_crit_d: caster.Attrs[BuffAttr.CRITICAL_DMG], + puncture: caster.Attrs[BuffAttr.PUNCTURE], + puncture_damage: caster.Attrs[BuffAttr.PUNCTURE_DMG], + burn_count: caster.Attrs[BuffAttr.BURN_COUNT], + burn_value: caster.Attrs[BuffAttr.BURN_VALUE], + stun_time: caster.Attrs[BuffAttr.STUN_TIME], + stun_ratio: caster.Attrs[BuffAttr.STUN_RATIO], + frost_time: caster.Attrs[BuffAttr.FROST_TIME], + frost_ratio: caster.Attrs[BuffAttr.FROST_RATIO], + debuff_up: caster.Attrs[BuffAttr.DEBUFF_UP], + debuff_value: caster.Attrs[BuffAttr.DEBUFF_VALUE], + debuff_count: caster.Attrs[BuffAttr.DEBUFF_COUNT], + }); + this.add(SComp); + } + + /** 实始添加的数据层组件 */ + protected init() { + // this.addComponents(); + } + + /** 模块资源释放 */ + destroy() { + // 注: 自定义释放逻辑,视图层实现 ecs.IComp 接口的 ecs 组件需要手动释放 + this.remove(SkillViewCom); + super.destroy(); + } +} + +/** SkillCon 模块业务逻辑系统组件,如无业务逻辑处理可删除此对象 */ +export class EcsSkillConSystem extends ecs.System { + constructor() { + super(); + + // this.add(new ecs.ComblockSystem()); + } +} diff --git a/assets/script/game/skill/SkillCon.ts.meta b/assets/script/game/skill/SkillCon.ts.meta new file mode 100644 index 00000000..ad374b65 --- /dev/null +++ b/assets/script/game/skill/SkillCon.ts.meta @@ -0,0 +1,9 @@ +{ + "ver": "4.0.24", + "importer": "typescript", + "imported": true, + "uuid": "65a6cf41-5233-445e-b656-1fcf0e37d53d", + "files": [], + "subMetas": {}, + "userData": {} +} diff --git a/assets/script/game/skill/SkillViewCom.ts b/assets/script/game/skill/SkillViewCom.ts new file mode 100644 index 00000000..0233df53 --- /dev/null +++ b/assets/script/game/skill/SkillViewCom.ts @@ -0,0 +1,97 @@ +import { _decorator } 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 { HeroViewComp } from "../hero/HeroViewComp"; + +const { ccclass, property } = _decorator; + +/** 视图层对象 */ +@ccclass('SkillViewCom') +@ecs.register('SkillView', false) +export class SkillViewCom extends CCComp { + /** 视图层逻辑代码分离演示 */ + @property({ type: Boolean }) + hasReady: boolean = false; + @property({ type: Number }) + ReadyTime: number = 0; + @property({ type: Number }) + postion_y: number = 0; + + s_uuid:number=0; + s_count:number=1; + s_interval:number=0.2; + s_cd:number=0; + caster:HeroViewComp=null; + target:HeroViewComp=null; + parent:Node=null; + target_postions: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; + + start() { + // var entity = this.ent as ecs.Entity; // ecs.Entity 可转为当前模块的具体实体对象 + // this.on(ModuleEvent.Cmd, this.onHandler, this); + } + protected update(dt: number): void { + if(this.hasReady) { + this.doTimer(dt) + if(this.ReadyTime <= 0) { + this.doAtk(dt) + } + }{ + this.doAtk(dt) + } + this.move(dt) + } + + doTimer(dt: number){ + if(this.ReadyTime <= 0) return + this.ReadyTime -= dt + } + doAtk(dt:number): void { + if(this.s_cd <= 0&&this.s_count > 0) { + this.doSkill() + this.s_count-- + this.s_cd = this.s_interval + } + this.s_cd -= dt + } + doSkill(){ + console.log("doSkill") + } + move(dt: number): void { + if(this.caster == null) return + if(this.caster.is_dead) return + if(this.caster.node.isValid) return + this.node.setPosition(this.caster.node.position.x,this.caster.node.position.y+this.postion_y) + console.log("[skillview]move",this.caster.node.position,this.node.position) + } + /** 全局消息逻辑处理 */ + // private onHandler(event: string, args: any) { + // switch (event) { + // case ModuleEvent.Cmd: + // break; + // } + // } + + /** 视图对象通过 ecs.Entity.remove(ModuleViewComp) 删除组件是触发组件处理自定义释放逻辑 */ + reset() { + this.node.destroy(); + } +} \ No newline at end of file diff --git a/assets/script/game/skill/SkillViewCom.ts.meta b/assets/script/game/skill/SkillViewCom.ts.meta new file mode 100644 index 00000000..01a12cda --- /dev/null +++ b/assets/script/game/skill/SkillViewCom.ts.meta @@ -0,0 +1,9 @@ +{ + "ver": "4.0.24", + "importer": "typescript", + "imported": true, + "uuid": "fa24efd6-db87-4a3a-957f-cde0cc3a4054", + "files": [], + "subMetas": {}, + "userData": {} +}