From 2e1c6c3aa1755afc2636a4160342b7dc6a040d02 Mon Sep 17 00:00:00 2001 From: walkpan Date: Sat, 1 Nov 2025 21:34:40 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E8=8B=B1=E9=9B=84=E5=B1=9E=E6=80=A7):=20?= =?UTF-8?q?=E8=B0=83=E6=95=B4=E8=8B=B1=E9=9B=84=E9=94=9A=E7=82=B9=E4=BD=8D?= =?UTF-8?q?=E7=BD=AE=E5=B9=B6=E4=BF=AE=E5=A4=8DHP/MP=E5=9B=9E=E5=A4=8D?= =?UTF-8?q?=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 将英雄hk1的锚点y坐标从0调整为0.2以改善显示效果 使用Timer控制HP/MP回复频率,从每帧改为每秒回复固定值 --- assets/resources/game/heros/hk1.prefab | 2 +- assets/script/game/hero/HeroAttrsComp.ts | 12 +++++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/assets/resources/game/heros/hk1.prefab b/assets/resources/game/heros/hk1.prefab index ab58a058..2c05eb7e 100644 --- a/assets/resources/game/heros/hk1.prefab +++ b/assets/resources/game/heros/hk1.prefab @@ -902,7 +902,7 @@ "_anchorPoint": { "__type__": "cc.Vec2", "x": 0.5, - "y": 0 + "y": 0.2 }, "_id": "" }, diff --git a/assets/script/game/hero/HeroAttrsComp.ts b/assets/script/game/hero/HeroAttrsComp.ts index 0eb417a6..27bd63eb 100644 --- a/assets/script/game/hero/HeroAttrsComp.ts +++ b/assets/script/game/hero/HeroAttrsComp.ts @@ -1,3 +1,4 @@ +import { Timer } from "db://oops-framework/core/common/timer/Timer"; import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS"; import { smc } from "../common/SingletonModuleComp"; import { Attrs, AttrsType, BType, NeAttrs } from "../common/config/HeroAttrs"; @@ -406,7 +407,7 @@ export class HeroAttrSystem extends ecs.ComblockSystem private entityCount: number = 0; // 本帧处理的实体数 private frameCount: number = 0; // 总帧数 private debugMode: boolean = false; // 是否启用调试模式 - + private timer:Timer=new Timer(1) /** * 过滤器:只处理拥有 HeroAttrsComp 的实体 */ @@ -455,10 +456,11 @@ export class HeroAttrSystem extends ecs.ComblockSystem // 1. 更新临时 Buff/Debuff(时间递减,过期自动移除) model.updateTemporaryBuffsDebuffs(this.dt); - - // 2. HP/MP 自然回复(业务规则) - model.mp += HeroUpSet.MP * this.dt/60; - model.hp += HeroUpSet.HP * this.dt/60; + if(this.timer.update(this.dt)){ + // 2. HP/MP 自然回复(业务规则) + model.mp += HeroUpSet.MP + model.hp += HeroUpSet.HP + } // 3. 限制属性值在合理范围内 if (model.mp > model.Attrs[Attrs.MP_MAX]) {