feat(技能): 新增驻场技能系统并集成到游戏机制中

- 在英雄配置中增加驻场技能字段,支持八种全局加成类型
- 实现驻场技能数值计算,影响召唤/死亡/战斗开始结束技能触发次数
- 集成驻场技能到金币收益系统,提升每回合和卖出英雄的金币获取
- 为战斗结束治疗添加驻场技能加成,增强队伍恢复效果
This commit is contained in:
walkpan
2026-04-22 23:14:07 +08:00
parent 8df4d5169a
commit 100a520df1
8 changed files with 138 additions and 28 deletions

View File

@@ -25,6 +25,8 @@ import { CCComp } from "../../../../extensions/oops-plugin-framework/assets/modu
import { HeroInfo } from "../common/config/heroSet";
import { HeroAttrsComp } from "../hero/HeroAttrsComp";
import { Hero } from "../hero/Hero";
import { FieldSkillType } from "../common/config/SkillSet";
import { GameEvent } from "../common/config/GameEvent";
import { oops } from "db://oops-framework/core/Oops";
import { UIID } from "../common/config/GameUIConfig";
import { mLogger } from "../common/Logger";
@@ -251,6 +253,13 @@ export class HInfoComp extends CCComp {
removed
});
if (!removed) return;
// 卖出英雄金币收益
const baseSellGold = 1; // 基础卖出金币
const goldBoost = HeroAttrsComp.getFieldSkillTotalValue(FieldSkillType.SellGold);
const totalSellGold = baseSellGold + goldBoost;
oops.message.dispatchEvent(GameEvent.CoinAdd, { delta: totalSellGold });
oops.gui.remove(UIID.IBox);
}

View File

@@ -45,6 +45,7 @@ import { Skill } from "../skill/Skill";
import { Tooltip } from "../skill/Tooltip";
import { CardInitCoins } from "../common/config/CardSet";
import { Timer } from "db://oops-framework/core/common/timer/Timer";
import { FieldSkillType } from "../common/config/SkillSet";
const { ccclass, property } = _decorator;
/** 任务(关卡)生命周期阶段 */
@@ -466,20 +467,30 @@ export class MissionComp extends CCComp {
* @param isStart 是否为战斗开始
*/
private triggerHeroBattleSkills(isStart: boolean) {
let triggerCount = 1;
if (isStart) {
triggerCount += HeroAttrsComp.getFieldSkillTotalValue(FieldSkillType.StartCount);
} else {
triggerCount += HeroAttrsComp.getFieldSkillTotalValue(FieldSkillType.EndCount);
}
triggerCount = Math.max(1, Math.floor(triggerCount));
ecs.query(this.heroAttrsMatcher).forEach(entity => {
const attrs = entity.get(HeroAttrsComp);
const view = entity.get(HeroViewComp);
if (!attrs || !view || attrs.is_dead || attrs.fac !== FacSet.HERO) return;
const skillUuids = isStart ? attrs.fstart : attrs.fend;
if (skillUuids && skillUuids.length > 0) {
skillUuids.forEach(uuid => {
oops.message.dispatchEvent(GameEvent.TriggerSkill, {
s_uuid: uuid,
heroAttrs: attrs,
heroView: view,
triggerType: isStart ? 'fstart' : 'fend'
for (let i = 0; i < triggerCount; i++) {
skillUuids.forEach(uuid => {
oops.message.dispatchEvent(GameEvent.TriggerSkill, {
s_uuid: uuid,
heroAttrs: attrs,
heroView: view,
triggerType: isStart ? 'fstart' : 'fend'
});
});
});
}
}
});
}
@@ -488,13 +499,16 @@ export class MissionComp extends CCComp {
* 战斗结束阶段治疗所有英雄包括墓地英雄恢复70%最大生命值
*/
private healAllHeroes() {
const healRateBoost = HeroAttrsComp.getFieldSkillTotalValue(FieldSkillType.WaveHeal);
const finalHealRate = Math.min(1, FightSet.WAVE_HEAL_RATE + healRateBoost);
ecs.query(this.heroAttrsMatcher).forEach(entity => {
const attrs = entity.get(HeroAttrsComp);
const view = entity.get(HeroViewComp);
if (!attrs || !view || attrs.fac !== FacSet.HERO) return;
// 计算恢复量:基于配置的百分比(如 70%)的最大生命值
const healAmount = Math.floor(attrs.hp_max * FightSet.WAVE_HEAL_RATE);
const healAmount = Math.floor(attrs.hp_max * finalHealRate);
// 应用恢复量,不超过最大生命值
attrs.hp = Math.min(attrs.hp_max, attrs.hp + healAmount);
@@ -649,7 +663,12 @@ export class MissionComp extends CCComp {
const base = Math.max(0, Math.floor(this.prepareBaseCoinReward));
const grow = Math.max(0, Math.floor(this.prepareCoinWaveGrow));
const cap = Math.max(0, Math.floor(this.prepareCoinRewardCap));
const reward = Math.min(cap, base + (wave - 1) * grow);
let reward = Math.min(cap, base + (wave - 1) * grow);
// 增加驻场技能金币收益
const goldBoost = HeroAttrsComp.getFieldSkillTotalValue(FieldSkillType.WaveGold);
reward += goldBoost;
if (reward <= 0) {
this.lastPrepareCoinWave = wave;
return;
@@ -657,7 +676,8 @@ export class MissionComp extends CCComp {
smc.vmdata.mission_data.coin = Math.max(0, Math.floor((smc.vmdata.mission_data.coin ?? 0) + reward));
this.lastPrepareCoinWave = wave;
oops.message.dispatchEvent(GameEvent.CoinAdd, { delta: reward, syncOnly: true });
mLogger.log(this.debugMode, 'MissionComp', "prepare coin reward", { wave, reward, coin: smc.vmdata.mission_data.coin });
mLogger.log(this.debugMode, "MissionComp", "grantPrepareCoinByWave", { wave, reward, boost: goldBoost, coin: smc.vmdata.mission_data.coin });
}
// ======================== 怪物数量管理 ========================

View File

@@ -38,6 +38,7 @@ import { HeroAttrsComp } from "../hero/HeroAttrsComp";
import { FacSet, FightSet, BoxSet } from "../common/config/GameSet";
import { oneCom } from "../skill/oncend";
import { HeroViewComp } from "../hero/HeroViewComp";
import { FieldSkillSet, FieldSkillType } from "../common/config/SkillSet";
const { ccclass } = _decorator;
/**
@@ -252,6 +253,26 @@ export class MissionHeroCompComp extends CCComp {
return heroes;
}
/** 获取指定驻场技能类型的总加成值(只计算存活的英雄) */
public getFieldSkillTotalValue(type: FieldSkillType): number {
let total = 0;
const heroes = this.getAllHeroes();
for (const hero of heroes) {
const model = hero.get(HeroAttrsComp);
if (!model || model.is_dead) continue;
const heroConfig = HeroInfo[model.hero_uuid];
if (heroConfig && heroConfig.field) {
for (const skillUuid of heroConfig.field) {
const skillConfig = FieldSkillSet[skillUuid];
if (skillConfig && skillConfig.type === type) {
total += skillConfig.value;
}
}
}
}
return total;
}
/**
* 从存活英雄中挑选可参与本次合成的英雄组。
*