From 76a37049c70a73054f66ae60868d60f20f6b85c1 Mon Sep 17 00:00:00 2001 From: panw Date: Thu, 28 May 2026 09:07:16 +0800 Subject: [PATCH] =?UTF-8?q?feat(HInfoComp):=20=E6=96=B0=E5=A2=9E=E5=8D=A1?= =?UTF-8?q?=E7=89=8C=E8=83=8C=E6=99=AF=E8=8A=82=E7=82=B9=E9=80=82=E9=85=8D?= =?UTF-8?q?=E5=8D=A1=E6=B1=A0=E7=AD=89=E7=BA=A7=E5=92=8C=E7=B1=BB=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. 在hnode.prefab中新增BG_node节点引用 2. 实现根据英雄类型和卡池等级切换背景节点显示逻辑 3. 优化卡池等级标识的显示代码结构 --- assets/resources/gui/element/hnode.prefab | 3 ++ assets/script/game/map/HInfoComp.ts | 54 +++++++++++++++++++---- 2 files changed, 49 insertions(+), 8 deletions(-) diff --git a/assets/resources/gui/element/hnode.prefab b/assets/resources/gui/element/hnode.prefab index 6786f84d..b1b0aed2 100644 --- a/assets/resources/gui/element/hnode.prefab +++ b/assets/resources/gui/element/hnode.prefab @@ -10421,6 +10421,9 @@ "sell_node": { "__id__": 330 }, + "BG_node": { + "__id__": 32 + }, "close_node": { "__id__": 346 }, diff --git a/assets/script/game/map/HInfoComp.ts b/assets/script/game/map/HInfoComp.ts index b8871c3c..6e019f0e 100644 --- a/assets/script/game/map/HInfoComp.ts +++ b/assets/script/game/map/HInfoComp.ts @@ -36,6 +36,7 @@ import { mLogger } from "../common/Logger"; import { MissionHeroComp } from "./MissionHeroComp"; import { MoveComp } from "../hero/MoveComp"; import { FacSet, getLvColor } from "../common/config/GameSet"; +import { CKind } from "../common/config/CardSet"; import { MissionEconomy } from "./MissionEconomy"; const {property, ccclass } = _decorator; @@ -56,6 +57,10 @@ export class HInfoComp extends CCComp { @property(Node) sell_node=null! + /** 卡牌背景底框节点(按卡池等级切换子节点显示) */ + @property(Node) + BG_node=null! + /** 关闭窗口按钮节点 */ @property(Node) close_node=null! @@ -162,6 +167,25 @@ export class HInfoComp extends CCComp { }); } + const poolColorNames = ["green", "blue", "purple", "yellow", "red"]; + const poolColorIdx = Math.min(this.previewPoolLv, 5) - 1; + const activeColor = poolColorNames[poolColorIdx]; + const kindName = CKind[CKind.Hero]; + if (this.BG_node) { + this.BG_node.children.forEach(child => { + child.active = (child.name === kindName); + if (child.active) { + child.children.forEach(colorChild => { + colorChild.active = (colorChild.name === activeColor); + }); + } else { + child.children.forEach(colorChild => { + colorChild.active = false; + }); + } + }); + } + if (heroUuid !== this.iconHeroUuid) { this.iconHeroUuid = heroUuid; this.iconVisualToken += 1; @@ -264,16 +288,30 @@ export class HInfoComp extends CCComp { } // ---- 卡池等级标识 ---- + const poolLv = this.model.pool_lv ?? 1; if (this.pool_lvnode) { - const poolLvStr = `lv${this.model.pool_lv ?? 1}`; + const poolLvStr = `lv${poolLv}`; this.pool_lvnode.children.forEach(child => { - // if (child.name === "light") { - // child.active = false; - // } else if (child.name === "bg") { - // child.active = true; - // } else { - child.active = (child.name === poolLvStr); - // } + child.active = (child.name === poolLvStr); + }); + } + + const poolColorNames = ["green", "blue", "purple", "yellow", "red"]; + const poolColorIdx = Math.min(poolLv, 5) - 1; + const activeColor = poolColorNames[poolColorIdx]; + const kindName = CKind[CKind.Hero]; + if (this.BG_node) { + this.BG_node.children.forEach(child => { + child.active = (child.name === kindName); + if (child.active) { + child.children.forEach(colorChild => { + colorChild.active = (colorChild.name === activeColor); + }); + } else { + child.children.forEach(colorChild => { + colorChild.active = false; + }); + } }); }