feat: 实现药水卡限时强化功能,支持自定义数值覆写
1. 新增Buff数值覆写机制,支持药水卡自定义buff效果数值 2. 重构属性计算逻辑,支持读取药水卡传递的覆写值 3. 新增多组限时强化Buff与药水卡配置 4. 优化UI数值显示,实时展示最终属性值 5. 新增多维度调试日志方便排查问题
This commit is contained in:
@@ -355,8 +355,9 @@ export class HInfoComp extends CCComp {
|
||||
}
|
||||
|
||||
// ---- 数值标签 ----
|
||||
// 攻击力显示最终值(含计时 buff 修饰),实时反映药水等限时强化
|
||||
if (this.apLabel) {
|
||||
const currentAp = Math.max(0, Math.floor(this.model.ap ?? 0));
|
||||
const currentAp = Math.max(0, Math.floor(this.model.getFinalAp()));
|
||||
const baseAp = Math.max(0, Math.floor(this.model.base_ap ?? 0));
|
||||
this.apLabel.string = `${currentAp}`;
|
||||
if (this.apPlusLabel) {
|
||||
@@ -370,7 +371,7 @@ export class HInfoComp extends CCComp {
|
||||
}
|
||||
}
|
||||
if (this.hpLabel) {
|
||||
const currentHp = Math.max(0, Math.floor(this.model.hp_max ?? 0));
|
||||
const currentHp = Math.max(0, Math.floor(this.model.getFinalHpMax()));
|
||||
const baseHp = Math.max(0, Math.floor(this.model.base_hp ?? 0));
|
||||
this.hpLabel.string = `${currentHp}`;
|
||||
if (this.hpPlusLabel) {
|
||||
|
||||
@@ -28,6 +28,7 @@ import { SBox } from "./SBox";
|
||||
import { oops } from "db://oops-framework/core/Oops";
|
||||
import { GameEvent } from "../common/config/GameEvent";
|
||||
import { BoxSet } from "../common/config/GameSet";
|
||||
import { SkillOverrides } from "../common/config/SkillSet";
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
/** 技能槽位数据结构 */
|
||||
@@ -73,6 +74,7 @@ export class MissSkillsComp extends CCComp {
|
||||
/** 注册事件监听 */
|
||||
onLoad() {
|
||||
oops.message.on(GameEvent.UseSkillCard, this.onUseSkillCard, this);
|
||||
oops.message.on(GameEvent.UseItemCard, this.onUseSkillCard, this);
|
||||
oops.message.on(GameEvent.RemoveSkillBox, this.onRemoveSkillBox, this);
|
||||
}
|
||||
|
||||
@@ -80,6 +82,7 @@ export class MissSkillsComp extends CCComp {
|
||||
onDestroy() {
|
||||
super.onDestroy();
|
||||
oops.message.off(GameEvent.UseSkillCard, this.onUseSkillCard, this);
|
||||
oops.message.off(GameEvent.UseItemCard, this.onUseSkillCard, this);
|
||||
oops.message.off(GameEvent.RemoveSkillBox, this.onRemoveSkillBox, this);
|
||||
}
|
||||
|
||||
@@ -138,10 +141,12 @@ export class MissSkillsComp extends CCComp {
|
||||
*/
|
||||
private onUseSkillCard(event: string, args: any) {
|
||||
const payload = args ?? event;
|
||||
const uuid = Number(payload?.uuid ?? 0);
|
||||
// 卡 uuid 仅用于查配置;真正施法用技能 id(payload.skill),缺省时退回 uuid(兼容技能卡直接用技能 id 的场景)
|
||||
const skillUuid = Number(payload?.skill ?? payload?.uuid ?? 0);
|
||||
const card_lv = Math.max(1, Math.floor(Number(payload?.card_lv ?? 1)));
|
||||
if (!uuid) return;
|
||||
this.addSkill(uuid, card_lv);
|
||||
if (!skillUuid) return;
|
||||
// 药水/技能卡的 overrides(含 buff_value)需透传到技能实体
|
||||
this.addSkill(skillUuid, card_lv, payload?.overrides);
|
||||
}
|
||||
|
||||
start() {
|
||||
@@ -157,7 +162,7 @@ export class MissSkillsComp extends CCComp {
|
||||
* @param uuid 技能 UUID
|
||||
* @param card_lv 技能卡等级
|
||||
*/
|
||||
addSkill(uuid: number, card_lv: number) {
|
||||
addSkill(uuid: number, card_lv: number, overrides?: SkillOverrides) {
|
||||
if (!this.skill_box) {
|
||||
mLogger.error(this.debugMode, "MissSkillsComp", "skill_box prefab not set");
|
||||
return;
|
||||
@@ -174,7 +179,7 @@ export class MissSkillsComp extends CCComp {
|
||||
// 使用 ECS 实体创建技能节点
|
||||
let sbox = ecs.getEntity<SBox>(SBox);
|
||||
let pos = new Vec3(this.slots[emptyIndex].x, this.slots[emptyIndex].y, 0);
|
||||
let node = sbox.load(uuid, card_lv, pos, this.skill_box);
|
||||
let node = sbox.load(uuid, card_lv, pos, this.skill_box, overrides);
|
||||
|
||||
this.slots[emptyIndex].used = true;
|
||||
this.slots[emptyIndex].node = node;
|
||||
|
||||
@@ -2,6 +2,7 @@ import { instantiate, Prefab, Vec3, Node } from "cc";
|
||||
import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
|
||||
import { smc } from "../common/SingletonModuleComp";
|
||||
import { SkillBoxComp } from "./SkillBoxComp";
|
||||
import { SkillOverrides } from "../common/config/SkillSet";
|
||||
|
||||
/** SBox 实体:负责技能卡效果节点创建、初始化与销毁流程 */
|
||||
@ecs.register(`SBox`)
|
||||
@@ -29,10 +30,10 @@ export class SBox extends ecs.Entity {
|
||||
* 1) 创建节点并挂到 SKILL 层
|
||||
* 2) 初始化表现与属性数据
|
||||
*/
|
||||
load(uuid: number, card_lv: number, pos: Vec3, prefab: Prefab): Node {
|
||||
load(uuid: number, card_lv: number, pos: Vec3, prefab: Prefab, overrides?: SkillOverrides): Node {
|
||||
let node = instantiate(prefab);
|
||||
let scene = smc.map.MapView.scene;
|
||||
|
||||
|
||||
// 统一挂到实体显示层 SKILL 节点下
|
||||
let parent = scene.entityLayer!.node!.getChildByName("SKILL");
|
||||
if (parent) {
|
||||
@@ -43,9 +44,9 @@ export class SBox extends ecs.Entity {
|
||||
// 获取并注册组件
|
||||
let sboxComp = node.getComponent(SkillBoxComp) || node.addComponent(SkillBoxComp);
|
||||
this.add(sboxComp);
|
||||
|
||||
// 初始化业务逻辑
|
||||
sboxComp.init(uuid, card_lv);
|
||||
|
||||
// 初始化业务逻辑(透传药水卡 overrides,含 buff_value)
|
||||
sboxComp.init(uuid, card_lv, overrides);
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
@@ -166,10 +166,10 @@ export class SkillBoxComp extends CCComp {
|
||||
* @param uuid 卡牌 UUID
|
||||
* @param card_lv 技能卡等级
|
||||
*/
|
||||
init(uuid: number, card_lv: number) {
|
||||
init(uuid: number, card_lv: number, overrides?: SkillOverrides) {
|
||||
this.card_lv = card_lv;
|
||||
|
||||
// 查询触发配置
|
||||
// 查询触发配置(药水卡不在 SkillCardList,会走 else 分支)
|
||||
const config = SkillCardList.find(c => c.uuid === uuid);
|
||||
if (config) {
|
||||
this.s_uuid = config.skill ?? uuid; // 获取实际的技能 UUID
|
||||
@@ -177,14 +177,18 @@ export class SkillBoxComp extends CCComp {
|
||||
this.trigger_times = config.t_times ?? 1;
|
||||
this.trigger_interval = config.t_inv ?? 0;
|
||||
this.keep_waves = config.keep_waves ?? 0;
|
||||
this.overrides = config.overrides;
|
||||
this.overrides = overrides ?? config.overrides; // 外部透传(药水卡)优先
|
||||
this.field = config.field || [];
|
||||
this.card_icon = config.icon; // 保存卡牌自定义图标(优先级最高)
|
||||
// 读取触发类型与上限(兜底默认值,避免 undefined)
|
||||
this.trigger_type = config.trigger_type ?? CardTriggerType.Instant;
|
||||
this.trigger_limit = config.trigger_limit ?? Infinity;
|
||||
} else {
|
||||
// 药水卡等:uuid 即技能 id,触发类型默认 Instant(即时生效一次)
|
||||
this.s_uuid = uuid;
|
||||
this.overrides = overrides;
|
||||
this.trigger_type = CardTriggerType.Instant;
|
||||
this.trigger_times = 1;
|
||||
}
|
||||
|
||||
this.current_trigger_times = 0;
|
||||
|
||||
Reference in New Issue
Block a user