refactor(skill): 重构伤害计算逻辑
- 删除SkillEnt.ts及其meta文件,简化技能实体管理 - 将SDataCom重命名为更清晰的DmgDataCom和SDataCom - 重构伤害计算系统,增加命中检测和伤害类型处理 - 优化技能碰撞检测逻辑,支持范围伤害和数量限制
This commit is contained in:
@@ -3,6 +3,7 @@ import { FacSet } from "../common/config/BoxSet";
|
|||||||
import { Attrs } from "../common/config/HeroAttrs";
|
import { Attrs } from "../common/config/HeroAttrs";
|
||||||
import { FightSet } from "../common/config/Mission";
|
import { FightSet } from "../common/config/Mission";
|
||||||
import { SkillSet } from "../common/config/SkillSet";
|
import { SkillSet } from "../common/config/SkillSet";
|
||||||
|
import { DmgDataCom } from "../skill/SDataCom";
|
||||||
import { HeroAttrsComp } from "./HeroAttrsComp";
|
import { HeroAttrsComp } from "./HeroAttrsComp";
|
||||||
import { HeroViewComp } from "./HeroViewComp";
|
import { HeroViewComp } from "./HeroViewComp";
|
||||||
|
|
||||||
@@ -14,8 +15,12 @@ export class HeroAtkComp extends ecs.Comp {
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
interface FDData{
|
||||||
/** 业务层业务逻辑处理对象 */
|
damage:number,
|
||||||
|
isCrit:boolean,
|
||||||
|
isDodge:boolean,
|
||||||
|
}
|
||||||
|
/** 业务层业务逻辑处理对象 伤害处理系统 */
|
||||||
@ecs.register('HeroAtkSystem')
|
@ecs.register('HeroAtkSystem')
|
||||||
export class HeroAtkSystem extends ecs.ComblockSystem implements ecs.ISystemUpdate, ecs.IEntityEnterSystem {
|
export class HeroAtkSystem extends ecs.ComblockSystem implements ecs.ISystemUpdate, ecs.IEntityEnterSystem {
|
||||||
|
|
||||||
@@ -25,7 +30,7 @@ export class HeroAtkSystem extends ecs.ComblockSystem implements ecs.ISystemUpd
|
|||||||
* 过滤器:只处理拥有 HeroAttrsComp 的实体
|
* 过滤器:只处理拥有 HeroAttrsComp 的实体
|
||||||
*/
|
*/
|
||||||
filter(): ecs.IMatcher {
|
filter(): ecs.IMatcher {
|
||||||
return ecs.allOf(HeroAttrsComp);
|
return ecs.allOf(HeroAttrsComp,DmgDataCom);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -33,9 +38,11 @@ export class HeroAtkSystem extends ecs.ComblockSystem implements ecs.ISystemUpd
|
|||||||
*/
|
*/
|
||||||
entityEnter(e: ecs.Entity): void {
|
entityEnter(e: ecs.Entity): void {
|
||||||
const model = e.get(HeroAttrsComp);
|
const model = e.get(HeroAttrsComp);
|
||||||
if (!model) return;
|
const dmgData=e.get(DmgDataCom)
|
||||||
|
if (!model || !dmgData) return;
|
||||||
console.log(`[HeroBattleSystem] 英雄进入战斗系统: ${model.hero_name} (uuid: ${model.hero_uuid})`);
|
let FDData = this.doAttack(e,dmgData)
|
||||||
|
e.remove(DmgDataCom)
|
||||||
|
console.log(`[HeroAtkSystem] 英雄${model.hero_name} (uuid: ${model.hero_uuid}) 受到伤害 ${FDData.damage},技能ID ${dmgData.s_uuid}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -46,13 +53,19 @@ export class HeroAtkSystem extends ecs.ComblockSystem implements ecs.ISystemUpd
|
|||||||
* @param skillId 技能ID
|
* @param skillId 技能ID
|
||||||
* @returns 实际造成的伤害
|
* @returns 实际造成的伤害
|
||||||
*/
|
*/
|
||||||
public doAttack(target: ecs.Entity, remainingDamage: number, attackerAttrs: any, skillId: number): number {
|
public doAttack(target: ecs.Entity,dmgData:DmgDataCom): FDData {
|
||||||
const targetModel = target.get(HeroAttrsComp);
|
const targetModel = target.get(HeroAttrsComp);
|
||||||
const targetView = target.get(HeroViewComp);
|
const targetView = target.get(HeroViewComp);
|
||||||
if (!targetModel || targetModel.is_dead) return 0;
|
let reDate:FDData={
|
||||||
|
damage:0,
|
||||||
|
isCrit:false,
|
||||||
|
isDodge:false,
|
||||||
|
}
|
||||||
|
if (!targetModel || targetModel.is_dead) return reDate;
|
||||||
|
|
||||||
// 获取技能配置
|
// 获取技能配置
|
||||||
const skillConf = SkillSet[skillId];
|
const skillConf = SkillSet[dmgData.s_uuid];
|
||||||
|
if (!skillConf) return reDate;
|
||||||
|
|
||||||
// 触发被攻击事件
|
// 触发被攻击事件
|
||||||
this.onAttacked(target);
|
this.onAttacked(target);
|
||||||
@@ -60,15 +73,17 @@ export class HeroAtkSystem extends ecs.ComblockSystem implements ecs.ISystemUpd
|
|||||||
// 闪避判定
|
// 闪避判定
|
||||||
if (this.checkDodge(targetModel)) {
|
if (this.checkDodge(targetModel)) {
|
||||||
// TODO: 触发闪避视图表现
|
// TODO: 触发闪避视图表现
|
||||||
return 0;
|
reDate.isDodge=true;
|
||||||
|
return reDate;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 暴击判定
|
// 暴击判定
|
||||||
const isCrit = this.checkCrit(attackerAttrs[Attrs.CRITICAL]);
|
const isCrit = this.checkCrit(targetModel.Attrs[Attrs.CRITICAL]);
|
||||||
let damage = remainingDamage;
|
let damage = this.dmgCount(dmgData.Attrs,dmgData.s_uuid);
|
||||||
|
|
||||||
if (isCrit) {
|
if (isCrit) {
|
||||||
damage = Math.floor(damage * (1 + (FightSet.CRIT_DAMAGE + attackerAttrs[Attrs.CRITICAL_DMG]) / 100));
|
damage = Math.floor(damage * (1 + (FightSet.CRIT_DAMAGE + targetModel.Attrs[Attrs.CRITICAL_DMG]) / 100));
|
||||||
|
reDate.isCrit=true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 伤害计算(考虑易伤等debuff)
|
// 伤害计算(考虑易伤等debuff)
|
||||||
@@ -77,7 +92,7 @@ export class HeroAtkSystem extends ecs.ComblockSystem implements ecs.ISystemUpd
|
|||||||
// 护盾吸收
|
// 护盾吸收
|
||||||
damage = this.absorbShield(targetModel, damage);
|
damage = this.absorbShield(targetModel, damage);
|
||||||
|
|
||||||
if (damage <= 0) return 0;
|
if (damage <= 0) return reDate;
|
||||||
|
|
||||||
// 应用伤害到数据层
|
// 应用伤害到数据层
|
||||||
targetModel.hp -= damage;
|
targetModel.hp -= damage;
|
||||||
@@ -85,7 +100,7 @@ export class HeroAtkSystem extends ecs.ComblockSystem implements ecs.ISystemUpd
|
|||||||
|
|
||||||
// ✅ 触发视图层表现(伤害数字、受击动画、后退)
|
// ✅ 触发视图层表现(伤害数字、受击动画、后退)
|
||||||
if (targetView) {
|
if (targetView) {
|
||||||
targetView.do_atked(damage, isCrit, skillId);
|
targetView.do_atked(damage, isCrit, dmgData.s_uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 检查死亡
|
// 检查死亡
|
||||||
@@ -101,9 +116,16 @@ export class HeroAtkSystem extends ecs.ComblockSystem implements ecs.ISystemUpd
|
|||||||
console.log(`[HeroAtkSystem] ${targetModel.hero_name} 受到 ${damage} 点伤害 (暴击: ${isCrit})`);
|
console.log(`[HeroAtkSystem] ${targetModel.hero_name} 受到 ${damage} 点伤害 (暴击: ${isCrit})`);
|
||||||
}
|
}
|
||||||
|
|
||||||
return damage;
|
reDate.damage=damage;
|
||||||
|
return reDate;
|
||||||
|
}
|
||||||
|
//伤害计算,暂时简单计算
|
||||||
|
private dmgCount(Attrs:any,s_uuid){
|
||||||
|
let sConf = SkillSet[s_uuid];
|
||||||
|
if (!sConf) return 0;
|
||||||
|
let AP = sConf.ap*Attrs[Attrs.AP];
|
||||||
|
return AP;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 处理角色死亡
|
* 处理角色死亡
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ec
|
|||||||
import { Attrs, AttrsType, BType, NeAttrs } from "../common/config/HeroAttrs";
|
import { Attrs, AttrsType, BType, NeAttrs } from "../common/config/HeroAttrs";
|
||||||
import { BuffConf, SkillSet } from "../common/config/SkillSet";
|
import { BuffConf, SkillSet } from "../common/config/SkillSet";
|
||||||
import { HeroInfo, AttrSet, HeroUpSet } from "../common/config/heroSet";
|
import { HeroInfo, AttrSet, HeroUpSet } from "../common/config/heroSet";
|
||||||
|
import { DmgDataCom } from "../skill/SDataCom";
|
||||||
import { EBusComp } from "./EBusComp";
|
import { EBusComp } from "./EBusComp";
|
||||||
|
|
||||||
|
|
||||||
@@ -345,6 +346,8 @@ export class HeroAttrsComp extends ecs.Comp {
|
|||||||
return this.NeAttrs[NeAttrs.IN_FROST]?.time > 0;
|
return this.NeAttrs[NeAttrs.IN_FROST]?.time > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
reset() {
|
reset() {
|
||||||
// 重置为初始状态
|
// 重置为初始状态
|
||||||
this.hero_uuid = 1001;
|
this.hero_uuid = 1001;
|
||||||
|
|||||||
@@ -1,9 +0,0 @@
|
|||||||
{
|
|
||||||
"ver": "4.0.24",
|
|
||||||
"importer": "typescript",
|
|
||||||
"imported": true,
|
|
||||||
"uuid": "a38a89b8-24eb-429f-92d4-7d3f4d87ba88",
|
|
||||||
"files": [],
|
|
||||||
"subMetas": {},
|
|
||||||
"userData": {}
|
|
||||||
}
|
|
||||||
@@ -3,7 +3,6 @@ import { Vec3, v3 } from "cc";
|
|||||||
import { HeroAttrsComp } from "./HeroAttrsComp";
|
import { HeroAttrsComp } from "./HeroAttrsComp";
|
||||||
import { HeroViewComp } from "./HeroViewComp";
|
import { HeroViewComp } from "./HeroViewComp";
|
||||||
import { SkillSet, SType } from "../common/config/SkillSet";
|
import { SkillSet, SType } from "../common/config/SkillSet";
|
||||||
import { SkillEnt } from "../skill/SkillEnt";
|
|
||||||
import { HeroSkillsComp } from "./HeroSkills";
|
import { HeroSkillsComp } from "./HeroSkills";
|
||||||
import { Skill } from "../skill/Skill";
|
import { Skill } from "../skill/Skill";
|
||||||
import { CSRequestComp } from "../skill/STagComps";
|
import { CSRequestComp } from "../skill/STagComps";
|
||||||
|
|||||||
@@ -1,9 +0,0 @@
|
|||||||
{
|
|
||||||
"ver": "4.0.24",
|
|
||||||
"importer": "typescript",
|
|
||||||
"imported": true,
|
|
||||||
"uuid": "5ef9c9a8-c661-44fd-93f4-fc133f734867",
|
|
||||||
"files": [],
|
|
||||||
"subMetas": {},
|
|
||||||
"userData": {}
|
|
||||||
}
|
|
||||||
@@ -3,16 +3,34 @@ import { BoxSet } from "../common/config/BoxSet";
|
|||||||
import { HeroViewComp } from "../hero/HeroViewComp";
|
import { HeroViewComp } from "../hero/HeroViewComp";
|
||||||
|
|
||||||
/** 业务层对象 */
|
/** 业务层对象 */
|
||||||
|
//技能数据
|
||||||
@ecs.register('SDataCom')
|
@ecs.register('SDataCom')
|
||||||
export class SDataCom extends ecs.Comp {
|
export class SDataCom extends ecs.Comp {
|
||||||
/** 业务层组件移除时,重置所有数据为默认值 */
|
/** 业务层组件移除时,重置所有数据为默认值 */
|
||||||
attrs:any=null
|
Attrs:any=null
|
||||||
caster:HeroViewComp=null
|
caster:HeroViewComp=null
|
||||||
group:BoxSet=BoxSet.HERO
|
group:BoxSet=BoxSet.HERO
|
||||||
|
fac: number = 0; // 0:hero 1:monster
|
||||||
|
s_uuid:number=0
|
||||||
|
hit_count:number=0 //击中数量
|
||||||
|
reset() {
|
||||||
|
this.Attrs=null
|
||||||
|
this.group=BoxSet.HERO
|
||||||
|
this.fac=0
|
||||||
|
this.s_uuid=0
|
||||||
|
this.caster=null
|
||||||
|
this.hit_count=0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//伤害数据
|
||||||
|
@ecs.register('DmgDataCom')
|
||||||
|
export class DmgDataCom extends ecs.Comp {
|
||||||
|
/** 业务层组件移除时,重置所有数据为默认值 */
|
||||||
|
Attrs:any=null
|
||||||
|
caster:HeroViewComp=null
|
||||||
s_uuid:number=0
|
s_uuid:number=0
|
||||||
reset() {
|
reset() {
|
||||||
this.attrs=null
|
this.Attrs=null
|
||||||
this.group=0
|
|
||||||
this.s_uuid=0
|
this.s_uuid=0
|
||||||
this.caster=null
|
this.caster=null
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ export class Skill extends ecs.Entity {
|
|||||||
const sDataCom = this.get(SDataCom);
|
const sDataCom = this.get(SDataCom);
|
||||||
sDataCom.group=caster.box_group
|
sDataCom.group=caster.box_group
|
||||||
sDataCom.caster=caster
|
sDataCom.caster=caster
|
||||||
sDataCom.attrs=casterAttrs
|
sDataCom.Attrs=casterAttrs
|
||||||
sDataCom.s_uuid=s_uuid
|
sDataCom.s_uuid=s_uuid
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -92,6 +92,7 @@ export class Skill extends ecs.Entity {
|
|||||||
destroy() {
|
destroy() {
|
||||||
// 注: 自定义释放逻辑,视图层实现 ecs.IComp 接口的 ecs 组件需要手动释放
|
// 注: 自定义释放逻辑,视图层实现 ecs.IComp 接口的 ecs 组件需要手动释放
|
||||||
this.remove(SDataCom);
|
this.remove(SDataCom);
|
||||||
|
this.remove(SMoveDataComp)
|
||||||
this.remove(SkillView)
|
this.remove(SkillView)
|
||||||
super.destroy();
|
super.destroy();
|
||||||
|
|
||||||
|
|||||||
@@ -1,77 +0,0 @@
|
|||||||
import { instantiate, Node, Prefab, v3, Vec3 } from "cc";
|
|
||||||
import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
|
|
||||||
import { 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";
|
|
||||||
import { HeroViewComp } from "../hero/HeroViewComp";
|
|
||||||
|
|
||||||
/** SkillCon 模块 */
|
|
||||||
@ecs.register(`SkillEnt`)
|
|
||||||
export class SkillEnt extends ecs.Entity {
|
|
||||||
|
|
||||||
load(startPos: Vec3, parent: Node, uuid: number, targetPos: any[], caster:HeroViewComp=null,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;
|
|
||||||
}
|
|
||||||
// console.log("load skill startPos",startPos)
|
|
||||||
const node: Node = instantiate(prefab);
|
|
||||||
console.log("load skill node",node)
|
|
||||||
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)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// 添加技能组件
|
|
||||||
const SComp = node.getComponent(SkillViewCom); // 初始化技能参数
|
|
||||||
// 只设置必要的运行时属性,配置信息通过 SkillSet[uuid] 访问
|
|
||||||
// 核心标识
|
|
||||||
SComp.s_uuid= uuid
|
|
||||||
SComp.cName=caster.hero_name
|
|
||||||
SComp.scale= caster.node.scale.x
|
|
||||||
// 位置和施法者信息
|
|
||||||
SComp.startPos= startPos
|
|
||||||
SComp.targetPos= targetPos
|
|
||||||
SComp.group= caster.box_group
|
|
||||||
SComp.fac= caster.fac,
|
|
||||||
// 技能数值(深拷贝避免引用问题)
|
|
||||||
SComp.Attrs = { ...caster.Attrs } // 或使用 Object.assign({}, caster.Attrs)
|
|
||||||
SComp.caster= caster,
|
|
||||||
this.add(SComp);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 实始添加的数据层组件 */
|
|
||||||
protected init() {
|
|
||||||
// this.addComponents<ecs.Comp>();
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 模块资源释放 */
|
|
||||||
destroy() {
|
|
||||||
// 注: 自定义释放逻辑,视图层实现 ecs.IComp 接口的 ecs 组件需要手动释放
|
|
||||||
this.remove(SkillViewCom);
|
|
||||||
super.destroy();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
{
|
|
||||||
"ver": "4.0.24",
|
|
||||||
"importer": "typescript",
|
|
||||||
"imported": true,
|
|
||||||
"uuid": "65a6cf41-5233-445e-b656-1fcf0e37d53d",
|
|
||||||
"files": [],
|
|
||||||
"subMetas": {},
|
|
||||||
"userData": {}
|
|
||||||
}
|
|
||||||
@@ -1,12 +1,15 @@
|
|||||||
import { _decorator, Animation, CCInteger, Collider2D, Contact2DType, v3, Vec3 } from "cc";
|
import { _decorator, Animation, CCInteger, Collider2D, Contact2DType, UITransform, v3, Vec3 } from "cc";
|
||||||
import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
|
import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
|
||||||
import { CCComp } from "../../../../extensions/oops-plugin-framework/assets/module/common/CCComp";
|
import { CCComp } from "../../../../extensions/oops-plugin-framework/assets/module/common/CCComp";
|
||||||
import { HeroViewComp } from "../hero/HeroViewComp";
|
import { HeroViewComp } from "../hero/HeroViewComp";
|
||||||
import { DTType, RType, SkillSet } from "../common/config/SkillSet";
|
import { DTType, EType, RType, SkillSet } from "../common/config/SkillSet";
|
||||||
import { BezierMove } from "../BezierMove/BezierMove";
|
import { BezierMove } from "../BezierMove/BezierMove";
|
||||||
import { BoxSet } from "../common/config/BoxSet";
|
import { BoxSet } from "../common/config/BoxSet";
|
||||||
import { SDataCom } from "./SDataCom";
|
import { DmgDataCom, SDataCom } from "./SDataCom";
|
||||||
import { SMoveDataComp } from "./SMoveComp";
|
import { SMoveDataComp } from "./SMoveComp";
|
||||||
|
import { Attrs } from "../common/config/HeroAttrs";
|
||||||
|
import { MonMoveComp } from "../hero/MonMove";
|
||||||
|
import { HeroAttrsComp } from "../hero/HeroAttrsComp";
|
||||||
|
|
||||||
const { ccclass, property } = _decorator;
|
const { ccclass, property } = _decorator;
|
||||||
|
|
||||||
@@ -108,6 +111,71 @@ export class SkillView extends CCComp {
|
|||||||
}
|
}
|
||||||
onAnimationFinished(){
|
onAnimationFinished(){
|
||||||
|
|
||||||
|
}
|
||||||
|
//动画帧事件 atk 触发
|
||||||
|
public atk(args:any){
|
||||||
|
let dis=this.node.getComponent(UITransform).width/2
|
||||||
|
let sData=this.ent.get(SDataCom)
|
||||||
|
let fac=sData.fac
|
||||||
|
let enemys:any=[]
|
||||||
|
if(fac==BoxSet.HERO){
|
||||||
|
enemys=ecs.query(ecs.allOf(MonMoveComp))
|
||||||
|
}else{
|
||||||
|
enemys=ecs.query(ecs.allOf(HeroViewComp))
|
||||||
|
}
|
||||||
|
let IRTargets: HeroViewComp[] = []
|
||||||
|
// 收集范围内所有敌方目标
|
||||||
|
enemys.some(e => {
|
||||||
|
const view = e.get(HeroViewComp);
|
||||||
|
const distance = Math.abs(this.node.position.x - view.node.position.x);
|
||||||
|
if(distance <= dis) {
|
||||||
|
IRTargets.push(view);
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
// 根据配置的hit_num决定攻击模式
|
||||||
|
const hitNum = SkillSet[this.s_uuid].hit_num || 0;
|
||||||
|
if(hitNum > 0) {
|
||||||
|
// 限制目标数量:按距离排序,选择最近的N个目标
|
||||||
|
if(IRTargets.length > 0) {
|
||||||
|
// 按距离排序(从近到远)
|
||||||
|
IRTargets.sort((a, b) => {
|
||||||
|
const distanceA = Math.abs(this.node.position.x - a.node.position.x);
|
||||||
|
const distanceB = Math.abs(this.node.position.x - b.node.position.x);
|
||||||
|
return distanceA - distanceB;
|
||||||
|
});
|
||||||
|
|
||||||
|
// 限制目标数量
|
||||||
|
const maxTargets = Math.min(hitNum, IRTargets.length);
|
||||||
|
const sTargets = IRTargets.slice(0, maxTargets);
|
||||||
|
|
||||||
|
sTargets.forEach(target => {
|
||||||
|
this.apply_damage(target, false);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// 范围伤害:对所有范围内目标造成伤害
|
||||||
|
if(IRTargets.length > 0) {
|
||||||
|
IRTargets.forEach(target => {
|
||||||
|
this.apply_damage(target, true);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//伤害应用
|
||||||
|
apply_damage(target:HeroViewComp,is_range:boolean=false){
|
||||||
|
if(target == null) return;
|
||||||
|
if (!this.SConf) return;
|
||||||
|
let sData=this.ent.get(SDataCom)
|
||||||
|
//伤害处理
|
||||||
|
let dmgData=target.ent.add(DmgDataCom)
|
||||||
|
dmgData.Attrs=sData.Attrs
|
||||||
|
dmgData.caster=sData.caster
|
||||||
|
dmgData.s_uuid=sData.s_uuid
|
||||||
|
|
||||||
|
sData.hit_count++
|
||||||
|
// console.log("[SkillCom]:碰撞次数:技能次数:穿刺次数",this.hit_count,this.Config.hit,this.puncture)
|
||||||
|
if(sData.hit_count>=(this.SConf.hit+sData.Attrs[Attrs.PUNCTURE])&&(this.SConf.DTType!=DTType.range)&&(this.SConf.EType!=EType.animationEnd)&&(this.SConf.EType!=EType.timeEnd)) this.ent.destroy// 技能命中次数
|
||||||
}
|
}
|
||||||
/** 视图对象通过 ecs.Entity.remove(ModuleViewComp) 删除组件是触发组件处理自定义释放逻辑 */
|
/** 视图对象通过 ecs.Entity.remove(ModuleViewComp) 删除组件是触发组件处理自定义释放逻辑 */
|
||||||
reset() {
|
reset() {
|
||||||
|
|||||||
@@ -1,9 +0,0 @@
|
|||||||
{
|
|
||||||
"ver": "1.2.0",
|
|
||||||
"importer": "directory",
|
|
||||||
"imported": true,
|
|
||||||
"uuid": "e8a3bd61-1102-4fb8-8eca-c795cad7ef52",
|
|
||||||
"files": [],
|
|
||||||
"subMetas": {},
|
|
||||||
"userData": {}
|
|
||||||
}
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
{
|
|
||||||
"ver": "1.2.0",
|
|
||||||
"importer": "directory",
|
|
||||||
"imported": true,
|
|
||||||
"uuid": "d3d7bbfc-9c24-4551-8bb5-7a40d7c271cd",
|
|
||||||
"files": [],
|
|
||||||
"subMetas": {},
|
|
||||||
"userData": {}
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user