feat(英雄): 重构复活机制为动态配置
将固定的复活次数属性改为从英雄配置中动态计算。移除 `revive_count` 静态属性,新增 `revive` 数组用于存储复活配置(包含基础次数和等级成长),并添加 `revived_count` 记录已复活次数。在 `Hero` 和 `Monster` 的初始化中同步此属性,并在战斗系统中根据配置和英雄等级计算最大可复活次数。
This commit is contained in:
@@ -188,15 +188,25 @@ export class HeroAtkSystem extends ecs.ComblockSystem implements ecs.ISystemUpd
|
||||
// 检查死亡
|
||||
if (TAttrsComp.hp <= 0) {
|
||||
// 复活机制:如果玩家属性内的复活属性值>=1 则执行复活,原地50%血量复活
|
||||
if (TAttrsComp.revive_count >= 1) {
|
||||
TAttrsComp.revive_count--;
|
||||
let canRevive = false;
|
||||
let maxReviveCount = 0;
|
||||
if (TAttrsComp.revive && TAttrsComp.revive.length > 0) {
|
||||
const reviveConf = TAttrsComp.revive[0];
|
||||
maxReviveCount = reviveConf.r_num + Math.floor((TAttrsComp.lv - 1) * reviveConf.upr);
|
||||
if (TAttrsComp.revived_count < maxReviveCount) {
|
||||
canRevive = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (canRevive) {
|
||||
TAttrsComp.revived_count++;
|
||||
TAttrsComp.is_reviving = true; // 标记为正在复活
|
||||
// 触发死亡动画(假死)
|
||||
if (targetView) {
|
||||
targetView.do_dead();
|
||||
|
||||
}
|
||||
mLogger.log(this.debugMode, 'HeroAtkSystem', ` Hero waiting to revive! Lives left: ${TAttrsComp.revive_count}`);
|
||||
mLogger.log(this.debugMode, 'HeroAtkSystem', ` Hero waiting to revive! Lives revived: ${TAttrsComp.revived_count}/${maxReviveCount}`);
|
||||
return reDate;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user