feat(护盾系统): 完善护盾功能并添加吸收提示
- 在GameSet.ts中添加shield类型提示 - HeroViewComp新增shield_tip方法显示护盾吸收值 - 修改HeroAttrsComp移除护盾值上限限制 - TooltipCom添加shield类型提示处理 - 调整SACastSystem中治疗和护盾技能计算方式 - HeroAtkSystem优化护盾吸收逻辑并添加吸收提示
This commit is contained in:
@@ -147,4 +147,5 @@ export const TooltipTypes = {
|
|||||||
apup:7,
|
apup:7,
|
||||||
hpup:8,
|
hpup:8,
|
||||||
addmp:9,
|
addmp:9,
|
||||||
|
shield:10,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ interface FinalData {
|
|||||||
@ecs.register('HeroAtkSystem')
|
@ecs.register('HeroAtkSystem')
|
||||||
export class HeroAtkSystem extends ecs.ComblockSystem implements ecs.ISystemUpdate {
|
export class HeroAtkSystem extends ecs.ComblockSystem implements ecs.ISystemUpdate {
|
||||||
|
|
||||||
private debugMode: boolean = false; // 是否启用调试模式
|
private debugMode: boolean = true; // 是否启用调试模式
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 过滤器:处理拥有伤害队列的实体
|
* 过滤器:处理拥有伤害队列的实体
|
||||||
@@ -164,8 +164,13 @@ export class HeroAtkSystem extends ecs.ComblockSystem implements ecs.ISystemUpd
|
|||||||
}
|
}
|
||||||
if (this.debugMode) console.log("[HeroAtkSystem] after crit",damage)
|
if (this.debugMode) console.log("[HeroAtkSystem] after crit",damage)
|
||||||
// 护盾吸收
|
// 护盾吸收
|
||||||
damage =Math.floor(this.absorbShield(TAttrsComp, damage))
|
const shieldResult = this.absorbShield(TAttrsComp, damage);
|
||||||
|
damage = shieldResult.remainingDamage;
|
||||||
if (this.debugMode) console.log("[HeroAtkSystem] after shield",damage)
|
if (this.debugMode) console.log("[HeroAtkSystem] after shield",damage)
|
||||||
|
// 显示护盾吸收飘字
|
||||||
|
if (shieldResult.absorbedDamage > 0 && targetView) {
|
||||||
|
targetView.shield_tip(shieldResult.absorbedDamage);
|
||||||
|
}
|
||||||
if (damage <= 0) return reDate;
|
if (damage <= 0) return reDate;
|
||||||
// 应用伤害到数据层
|
// 应用伤害到数据层
|
||||||
TAttrsComp.hp -= damage;
|
TAttrsComp.hp -= damage;
|
||||||
@@ -429,10 +434,14 @@ export class HeroAtkSystem extends ecs.ComblockSystem implements ecs.ISystemUpd
|
|||||||
*
|
*
|
||||||
* @param TAttrsComp 被攻击者的属性组件(包含当前护盾值)
|
* @param TAttrsComp 被攻击者的属性组件(包含当前护盾值)
|
||||||
* @param damage 原始伤害值
|
* @param damage 原始伤害值
|
||||||
* @returns 剩余伤害值(护盾吸收后的结果)
|
* @returns {remainingDamage, absorbedDamage} 剩余伤害值和吸收的护盾值
|
||||||
*/
|
*/
|
||||||
private absorbShield(TAttrsComp: HeroAttrsComp, damage: number): number {
|
private absorbShield(TAttrsComp: HeroAttrsComp, damage: number): {remainingDamage: number, absorbedDamage: number} {
|
||||||
if (TAttrsComp.shield <= 0) return damage;
|
|
||||||
|
if (TAttrsComp.shield <= 0) {
|
||||||
|
console.log("[HeroAtkSystem] 护盾值小于等于0,无法吸收伤害");
|
||||||
|
return {remainingDamage: damage, absorbedDamage: 0};
|
||||||
|
};
|
||||||
|
|
||||||
if (TAttrsComp.shield >= damage) {
|
if (TAttrsComp.shield >= damage) {
|
||||||
TAttrsComp.shield -= damage;
|
TAttrsComp.shield -= damage;
|
||||||
@@ -440,12 +449,15 @@ export class HeroAtkSystem extends ecs.ComblockSystem implements ecs.ISystemUpd
|
|||||||
TAttrsComp.shield = 0;
|
TAttrsComp.shield = 0;
|
||||||
TAttrsComp.Attrs[Attrs.SHIELD_MAX] = 0;
|
TAttrsComp.Attrs[Attrs.SHIELD_MAX] = 0;
|
||||||
}
|
}
|
||||||
return 0;
|
console.log(`[HeroAtkSystem] 护盾值完全吸收伤害 ${damage}`);
|
||||||
|
return {remainingDamage: 0, absorbedDamage: damage};
|
||||||
} else {
|
} else {
|
||||||
|
const absorbedDamage = TAttrsComp.shield;
|
||||||
const remainingDamage = damage - TAttrsComp.shield;
|
const remainingDamage = damage - TAttrsComp.shield;
|
||||||
TAttrsComp.shield = 0;
|
TAttrsComp.shield = 0;
|
||||||
TAttrsComp.Attrs[Attrs.SHIELD_MAX] = 0;
|
TAttrsComp.Attrs[Attrs.SHIELD_MAX] = 0;
|
||||||
return remainingDamage;
|
console.log(`[HeroAtkSystem] 护盾值部分吸收伤害 ${absorbedDamage}`);
|
||||||
|
return {remainingDamage, absorbedDamage};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -159,7 +159,6 @@ export class HeroAttrsComp extends ecs.Comp {
|
|||||||
addValue = value * this.Attrs[Attrs.HP_MAX] / 100;
|
addValue = value * this.Attrs[Attrs.HP_MAX] / 100;
|
||||||
}
|
}
|
||||||
this.shield += addValue;
|
this.shield += addValue;
|
||||||
this.shield = Math.max(0, Math.min(this.shield, this.Attrs[Attrs.HP_MAX]));
|
|
||||||
this.dirty_shield = true; // 标记护盾需要更新
|
this.dirty_shield = true; // 标记护盾需要更新
|
||||||
}
|
}
|
||||||
// ==================== BUFF 管理 ====================
|
// ==================== BUFF 管理 ====================
|
||||||
|
|||||||
@@ -280,6 +280,11 @@ export class HeroViewComp extends CCComp {
|
|||||||
let pos = v3(x, ny, 0);
|
let pos = v3(x, ny, 0);
|
||||||
tip.load(pos, type, value, s_uuid, this.node.parent);
|
tip.load(pos, type, value, s_uuid, this.node.parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 护盾吸收提示 */
|
||||||
|
shield_tip(absorbed: number) {
|
||||||
|
this.hp_tip(TooltipTypes.life, absorbed.toFixed(0));
|
||||||
|
}
|
||||||
|
|
||||||
/** 治疗特效 */
|
/** 治疗特效 */
|
||||||
private heathed() {
|
private heathed() {
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import { smc } from "../common/SingletonModuleComp";
|
|||||||
import { TalComp } from "./TalComp";
|
import { TalComp } from "./TalComp";
|
||||||
import { TalEffet, TriType } from "../common/config/TalSet";
|
import { TalEffet, TriType } from "../common/config/TalSet";
|
||||||
import { BoxSet } from "../common/config/GameSet";
|
import { BoxSet } from "../common/config/GameSet";
|
||||||
|
import { Attrs } from "../common/config/HeroAttrs";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ==================== 自动施法系统 ====================
|
* ==================== 自动施法系统 ====================
|
||||||
@@ -389,14 +390,14 @@ export class SACastSystem extends ecs.ComblockSystem implements ecs.ISystemUpdat
|
|||||||
* 执行治疗技能
|
* 执行治疗技能
|
||||||
*/
|
*/
|
||||||
private executeHealSkill(casterEntity: ecs.Entity, s_uuid: number, heroView: HeroViewComp, hset: HSSet): boolean {
|
private executeHealSkill(casterEntity: ecs.Entity, s_uuid: number, heroView: HeroViewComp, hset: HSSet): boolean {
|
||||||
const heroAttrs = casterEntity.get(HeroAttrsComp);
|
const hAttrsCom = casterEntity.get(HeroAttrsComp);
|
||||||
const config = SkillSet[s_uuid];
|
const config = SkillSet[s_uuid];
|
||||||
if (!config) return false;
|
if (!config) return false;
|
||||||
|
|
||||||
const targets = this.sHealTargets(heroView, heroAttrs, config);
|
const targets = this.sHealTargets(heroView, hAttrsCom, config);
|
||||||
if (targets.length === 0) return false;
|
if (targets.length === 0) return false;
|
||||||
|
|
||||||
const healAmount = config.ap;
|
const healAmount = config.ap * hAttrsCom.Attrs[Attrs.HP_MAX];
|
||||||
const delay = 0.3;
|
const delay = 0.3;
|
||||||
|
|
||||||
heroView.scheduleOnce(() => {
|
heroView.scheduleOnce(() => {
|
||||||
@@ -417,14 +418,14 @@ export class SACastSystem extends ecs.ComblockSystem implements ecs.ISystemUpdat
|
|||||||
* 执行护盾技能
|
* 执行护盾技能
|
||||||
*/
|
*/
|
||||||
private executeShieldSkill(casterEntity: ecs.Entity, s_uuid: number, heroView: HeroViewComp, hset: HSSet): boolean {
|
private executeShieldSkill(casterEntity: ecs.Entity, s_uuid: number, heroView: HeroViewComp, hset: HSSet): boolean {
|
||||||
const heroAttrs = casterEntity.get(HeroAttrsComp);
|
const hAttrsCom = casterEntity.get(HeroAttrsComp);
|
||||||
const config = SkillSet[s_uuid];
|
const config = SkillSet[s_uuid];
|
||||||
if (!config) return false;
|
if (!config) return false;
|
||||||
|
|
||||||
const targets = this.sShieldTargets(heroView, heroAttrs, config);
|
const targets = this.sShieldTargets(heroView, hAttrsCom, config);
|
||||||
if (targets.length === 0) return false;
|
if (targets.length === 0) return false;
|
||||||
|
|
||||||
const shieldAmount = config.ap;
|
const shieldAmount = config.ap * hAttrsCom.Attrs[Attrs.HP_MAX];
|
||||||
const delay = 0.3;
|
const delay = 0.3;
|
||||||
|
|
||||||
heroView.scheduleOnce(() => {
|
heroView.scheduleOnce(() => {
|
||||||
|
|||||||
@@ -102,6 +102,15 @@ export class TooltipCom extends CCComp {
|
|||||||
this.scheduleOnce(()=>{
|
this.scheduleOnce(()=>{
|
||||||
this.ent.destroy()
|
this.ent.destroy()
|
||||||
},0.5)
|
},0.5)
|
||||||
|
break
|
||||||
|
case TooltipTypes.shield:
|
||||||
|
this.node.setSiblingIndex(110);
|
||||||
|
this.node.getChildByName("add_life").getChildByName("hp").getComponent(Label).string = this.value;
|
||||||
|
this.node.getChildByName("add_life").active=true;
|
||||||
|
this.scheduleOnce(()=>{
|
||||||
|
this.ent.destroy()
|
||||||
|
},0.5)
|
||||||
|
break
|
||||||
}
|
}
|
||||||
// console.log("TooltipView start:",this.node.getSiblingIndex());
|
// console.log("TooltipView start:",this.node.getSiblingIndex());
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user