import { oops } from "../../../../extensions/oops-plugin-framework/assets/core/Oops"; import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS"; import { BoxSet } from "../common/config/BoxSet"; import { SkillSet } from "../common/config/SkillSet"; import { smc } from "../common/SingletonModuleComp"; import { FightConComp } from "../map/FightConComp"; import { SkillCom } from "./SkillCom"; import { instantiate, Node, Prefab, Vec3 ,tween, v3,animation,Label,resources,SpriteFrame,Sprite} from "cc"; /** Skill 模块 */ @ecs.register(`Skill`) export class Skill extends ecs.Entity { FIGHTCON:FightConComp=null! SkillView!: SkillCom; /** 实始添加的数据层组件 */ protected init() { } /** 模块资源释放 */ destroy() { // 注: 自定义释放逻辑,视图层实现 ecs.IComp 接口的 ecs 组件需要手动释放 this.remove(SkillCom); super.destroy(); } load( startPos: Vec3, // 起始位置 parent: Node, // 父节点 uuid: number, // 技能ID targetPos: Vec3, // 目标位置 caster:any=null, // 施法者 angle:number=0, dmg:number=0 ) { let FIGHTCON=parent.getComponent(FightConComp); const config = SkillSet[uuid]; if (!config) return; // 加载预制体 const path = `game/skills/${config.sp_name}`; const prefab = oops.res.get(path, Prefab); const node = instantiate(prefab); // 设置节点属性 node.parent = parent; node.setPosition(startPos); node.angle+=angle // console.log("加载预制体:",startPos,targetPos) // 添加技能组件 const skillComp = node.getComponent(SkillCom); // 初始化技能参数 skillComp.ap = caster.ap+dmg; if(caster.fac==0){ if(caster.is_master){ skillComp.ap=Math.floor(skillComp.ap*(100+FIGHTCON.hero_buff.ATK)/100); }else{ skillComp.ap=Math.floor(skillComp.ap*(100+FIGHTCON.friend_buff.ATK)/100); } }else{ skillComp.ap=Math.floor(skillComp.ap*(100-FIGHTCON.enemy_buff.ATK)/100); } skillComp.s_uuid = uuid; skillComp.animType = config.AnimType; skillComp.endType = config.endType; skillComp.speed = config.speed; skillComp.inTime = config.in; skillComp.atk_count = 0; skillComp.startPos = startPos skillComp.targetPos =targetPos skillComp.caster = caster; skillComp.prefabName = config.sp_name; skillComp.group = caster.box_group; skillComp.fac= caster.box_group==BoxSet.HERO?0:caster.box_group==BoxSet.MONSTER?1:2; // console.log(config.sp_name+"技能配置",skillComp); // 初始化动画名称 skillComp.animName = config.animName; // 从配置获取动画名称 this.add(skillComp); } }