技能重构开始
This commit is contained in:
@@ -328,7 +328,7 @@ export const SkillSet: Record<number, SkillConfig> = {
|
||||
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%攻击的伤害,有一定几率施加灼烧"
|
||||
|
||||
@@ -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>(Skill);
|
||||
const skillEntity = ecs.getEntity<SkillCon>(SkillCon);
|
||||
|
||||
|
||||
const timerId = setTimeout(() => {
|
||||
|
||||
29
assets/script/game/skill/ReadyCom.ts
Normal file
29
assets/script/game/skill/ReadyCom.ts
Normal file
@@ -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();
|
||||
}
|
||||
}
|
||||
9
assets/script/game/skill/ReadyCom.ts.meta
Normal file
9
assets/script/game/skill/ReadyCom.ts.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.24",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "be4ced01-bd86-404f-b8f0-0e1ffcb8429c",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
100
assets/script/game/skill/SkillCon.ts
Normal file
100
assets/script/game/skill/SkillCon.ts
Normal file
@@ -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<ecs.Comp>();
|
||||
}
|
||||
|
||||
/** 模块资源释放 */
|
||||
destroy() {
|
||||
// 注: 自定义释放逻辑,视图层实现 ecs.IComp 接口的 ecs 组件需要手动释放
|
||||
this.remove(SkillViewCom);
|
||||
super.destroy();
|
||||
}
|
||||
}
|
||||
|
||||
/** SkillCon 模块业务逻辑系统组件,如无业务逻辑处理可删除此对象 */
|
||||
export class EcsSkillConSystem extends ecs.System {
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
// this.add(new ecs.ComblockSystem());
|
||||
}
|
||||
}
|
||||
9
assets/script/game/skill/SkillCon.ts.meta
Normal file
9
assets/script/game/skill/SkillCon.ts.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.24",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "65a6cf41-5233-445e-b656-1fcf0e37d53d",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
97
assets/script/game/skill/SkillViewCom.ts
Normal file
97
assets/script/game/skill/SkillViewCom.ts
Normal file
@@ -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();
|
||||
}
|
||||
}
|
||||
9
assets/script/game/skill/SkillViewCom.ts.meta
Normal file
9
assets/script/game/skill/SkillViewCom.ts.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.24",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "fa24efd6-db87-4a3a-957f-cde0cc3a4054",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
Reference in New Issue
Block a user