From c6953865dace1d3b49eddd9543a625ca170d9b89 Mon Sep 17 00:00:00 2001 From: humingxing <930621236@qq.com> Date: Sat, 17 Oct 2026 16:18:19 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bundles/battleGame/prefab/宝箱.prefab | 153 +----------------- .../script/battle/config/BattleHeroTable.ts | 2 +- assets/script/battle/map/MapDigChestHost.ts | 56 ++++--- assets/script/battle/view/TextGrid.ts | 4 +- assets/script/interface/AutoTable.ts | 2 +- .../BattleGame/BattleDigChestFxPresenter.ts | 5 - .../UIBattleWeaponDescHero.ts | 4 +- 7 files changed, 48 insertions(+), 178 deletions(-) diff --git a/assets/bundles/battleGame/prefab/宝箱.prefab b/assets/bundles/battleGame/prefab/宝箱.prefab index 4db60e7..f22e172 100644 --- a/assets/bundles/battleGame/prefab/宝箱.prefab +++ b/assets/bundles/battleGame/prefab/宝箱.prefab @@ -20,19 +20,16 @@ "_children": [ { "__id__": 2 - }, - { - "__id__": 8 } ], "_active": true, "_components": [ { - "__id__": 14 + "__id__": 8 } ], "_prefab": { - "__id__": 16 + "__id__": 10 }, "_lpos": { "__type__": "cc.Vec3", @@ -65,7 +62,7 @@ }, { "__type__": "cc.Node", - "_name": "bg", + "_name": "box", "_objFlags": 0, "__editorExtras__": {}, "_parent": { @@ -87,7 +84,7 @@ "_lpos": { "__type__": "cc.Vec3", "x": 0, - "y": 0, + "y": -2.64, "z": 0 }, "_lrot": { @@ -125,142 +122,6 @@ "__prefab": { "__id__": 4 }, - "_contentSize": { - "__type__": "cc.Size", - "width": 96, - "height": 68 - }, - "_anchorPoint": { - "__type__": "cc.Vec2", - "x": 0.5, - "y": 0.5 - }, - "_id": "" - }, - { - "__type__": "cc.CompPrefabInfo", - "fileId": "eeGzSh9ttB14faENR7nkL1" - }, - { - "__type__": "cc.Sprite", - "_name": "", - "_objFlags": 0, - "__editorExtras__": {}, - "node": { - "__id__": 2 - }, - "_enabled": true, - "__prefab": { - "__id__": 6 - }, - "_customMaterial": null, - "_srcBlendFactor": 2, - "_dstBlendFactor": 4, - "_color": { - "__type__": "cc.Color", - "r": 255, - "g": 255, - "b": 255, - "a": 255 - }, - "_spriteFrame": { - "__uuid__": "0b9461e4-38ea-4e13-b133-f28d07bc5178@f9941", - "__expectedType__": "cc.SpriteFrame" - }, - "_type": 0, - "_fillType": 0, - "_sizeMode": 1, - "_fillCenter": { - "__type__": "cc.Vec2", - "x": 0, - "y": 0 - }, - "_fillStart": 0, - "_fillRange": 0, - "_isTrimmedMode": true, - "_useGrayscale": false, - "_atlas": null, - "_id": "" - }, - { - "__type__": "cc.CompPrefabInfo", - "fileId": "85jSymFOxH47oesupv6Cs1" - }, - { - "__type__": "cc.PrefabInfo", - "root": { - "__id__": 1 - }, - "asset": { - "__id__": 0 - }, - "fileId": "9fCGAPLiROlKwMBu5E73hC", - "instance": null, - "targetOverrides": null, - "nestedPrefabInstanceRoots": null - }, - { - "__type__": "cc.Node", - "_name": "box", - "_objFlags": 0, - "__editorExtras__": {}, - "_parent": { - "__id__": 1 - }, - "_children": [], - "_active": true, - "_components": [ - { - "__id__": 9 - }, - { - "__id__": 11 - } - ], - "_prefab": { - "__id__": 13 - }, - "_lpos": { - "__type__": "cc.Vec3", - "x": 0, - "y": -2.64, - "z": 0 - }, - "_lrot": { - "__type__": "cc.Quat", - "x": 0, - "y": 0, - "z": 0, - "w": 1 - }, - "_lscale": { - "__type__": "cc.Vec3", - "x": 1, - "y": 1, - "z": 1 - }, - "_mobility": 0, - "_layer": 33554432, - "_euler": { - "__type__": "cc.Vec3", - "x": 0, - "y": 0, - "z": 0 - }, - "_id": "" - }, - { - "__type__": "cc.UITransform", - "_name": "", - "_objFlags": 0, - "__editorExtras__": {}, - "node": { - "__id__": 8 - }, - "_enabled": true, - "__prefab": { - "__id__": 10 - }, "_contentSize": { "__type__": "cc.Size", "width": 48, @@ -283,11 +144,11 @@ "_objFlags": 0, "__editorExtras__": {}, "node": { - "__id__": 8 + "__id__": 2 }, "_enabled": true, "__prefab": { - "__id__": 12 + "__id__": 6 }, "_customMaterial": null, "_srcBlendFactor": 2, @@ -345,7 +206,7 @@ }, "_enabled": true, "__prefab": { - "__id__": 15 + "__id__": 9 }, "_contentSize": { "__type__": "cc.Size", diff --git a/assets/script/battle/config/BattleHeroTable.ts b/assets/script/battle/config/BattleHeroTable.ts index 26d6059..906efb4 100644 --- a/assets/script/battle/config/BattleHeroTable.ts +++ b/assets/script/battle/config/BattleHeroTable.ts @@ -224,7 +224,7 @@ export function textDisplayName(text: ITableText): string { if (hero) { const name = (hero.name ?? '').trim(); if (name) return name; - const num = Math.floor(Number(hero.number)); + const num = Math.floor(Number(hero.num)); if (num > 0) return String(num); } return textIconName(text); diff --git a/assets/script/battle/map/MapDigChestHost.ts b/assets/script/battle/map/MapDigChestHost.ts index 290cf3a..672cde8 100644 --- a/assets/script/battle/map/MapDigChestHost.ts +++ b/assets/script/battle/map/MapDigChestHost.ts @@ -200,7 +200,7 @@ export class MapDigChestHost { } /** - * 挂宝箱到地图根(与格子锁同层),对齐格子世界坐标,避免被字块层挡住。 + * 挂宝箱到 MapManager 根(勿挂「格子」:该节点有 Layout,多一个子节点会整图重排偏移)。 * @param slot 宝箱槽 * @param grid 格子 */ @@ -210,13 +210,13 @@ export class MapDigChestHost { console.warn('[MapDigChestHost] 格子节点无效,无法挂宝箱', grid.Index); return; } - const mapRoot = this._map?.mapGridParent; - if (!mapRoot?.isValid) { - console.warn('[MapDigChestHost] mapGridParent 无效,无法挂宝箱', grid.Index); + const tipLayer = this._tipLayer(); + if (!tipLayer?.isValid) { + console.warn('[MapDigChestHost] 宝箱挂点无效', grid.Index); return; } if (slot.tip?.isValid) { - this._placeTipOnMap(slot.tip, cell, mapRoot); + this._placeTipOnMap(slot.tip, cell, tipLayer); this._resetTipVisual(slot.tip); slot.tip.active = true; return; @@ -230,38 +230,52 @@ export class MapDigChestHost { console.warn('[MapDigChestHost] 缺少宝箱预制体', CHEST_TIP_NAME); return; } - this._placeTipOnMap(tip, cell, mapRoot); + this._placeTipOnMap(tip, cell, tipLayer); this._resetTipVisual(tip); tip.active = true; slot.tip = tip; } + /** + * 宝箱 tip 层:MapManager 根下独立节点,压在「格子」之上、不受 Layout 影响。 + */ + private _tipLayer(): Node | null { + const map = this._map; + if (!map?.node?.isValid) return null; + let layer = map.node.getChildByName('宝箱提示层'); + if (layer?.isValid) return layer; + layer = new Node('宝箱提示层'); + layer.layer = map.node.layer; + layer.parent = map.node; + const grids = map.mapGridParent; + if (grids?.isValid) { + layer.setSiblingIndex(grids.getSiblingIndex() + 1); + } else { + layer.setSiblingIndex(map.node.children.length - 1); + } + return layer; + } + /** * @param tip 宝箱节点 * @param cell 格子节点 - * @param mapRoot 地图格子父节点 + * @param tipLayer 宝箱提示层 */ - private _placeTipOnMap(tip: Node, cell: Node, mapRoot: Node): void { - tip.parent = mapRoot; - tip.setSiblingIndex(mapRoot.children.length - 1); + private _placeTipOnMap(tip: Node, cell: Node, tipLayer: Node): void { + tip.parent = tipLayer; + tip.setSiblingIndex(tipLayer.children.length - 1); cell.getWorldPosition(_tipWorld); - const ut = mapRoot.getComponent(UITransform); - if (ut) { - ut.convertToNodeSpaceAR(_tipWorld, _tipLocal); - tip.setPosition(_tipLocal); - } else { - tip.setWorldPosition(_tipWorld); - } + const ut = tipLayer.getComponent(UITransform) ?? tipLayer.addComponent(UITransform); + ut.convertToNodeSpaceAR(_tipWorld, _tipLocal); + tip.setPosition(_tipLocal); } - /** 对象池取出后复位显隐(飞入曾关 bg / 改 opacity) */ + /** 对象池取出后复位显隐(飞入曾改 scale / opacity) */ private _resetTipVisual(tip: Node): void { tip.setScale(1, 1, 1); - const bg = tip.getChildByName('bg'); - if (bg?.isValid) bg.active = true; const box = tip.getChildByName('box'); if (box?.isValid) box.active = true; - let op = tip.getComponent(UIOpacity); + const op = tip.getComponent(UIOpacity); if (op) op.opacity = 255; } diff --git a/assets/script/battle/view/TextGrid.ts b/assets/script/battle/view/TextGrid.ts index e41b343..367cd89 100644 --- a/assets/script/battle/view/TextGrid.ts +++ b/assets/script/battle/view/TextGrid.ts @@ -2205,9 +2205,9 @@ export class TextGrid extends Component { this._hideNumberNodes(); return; } - const num = Math.floor(Number(hero.number)); + const num = Math.floor(Number(hero.num)); if (!(num > 0)) { - console.log('[TextGrid] Hero.number 无效', hero.id, hero.number); + console.log('[TextGrid] Hero.number 无效', hero.id, hero.num); this._hideNumberNodes(); return; } diff --git a/assets/script/interface/AutoTable.ts b/assets/script/interface/AutoTable.ts index 4101e4e..a2d7981 100644 --- a/assets/script/interface/AutoTable.ts +++ b/assets/script/interface/AutoTable.ts @@ -164,7 +164,7 @@ declare global { /** 资源 */ readonly res: string; /** 数字 */ - readonly number: number; + readonly num: number; /** 等级 */ readonly level: number; /** 攻击力 diff --git a/assets/script/ui/BattleGame/BattleDigChestFxPresenter.ts b/assets/script/ui/BattleGame/BattleDigChestFxPresenter.ts index 90770ce..f03e2ee 100644 --- a/assets/script/ui/BattleGame/BattleDigChestFxPresenter.ts +++ b/assets/script/ui/BattleGame/BattleDigChestFxPresenter.ts @@ -68,9 +68,6 @@ export class BattleDigChestFxPresenter { fly.setSiblingIndex(layer.children.length - 1); fly.active = true; fly.setScale(1, 1, 1); - // 飞入只放大箱体,不带 bg - const bg = fly.getChildByName('bg'); - if (bg?.isValid) bg.active = false; let opacity = fly.getComponent(UIOpacity); if (!opacity) opacity = fly.addComponent(UIOpacity); opacity.opacity = 255; @@ -107,8 +104,6 @@ export class BattleDigChestFxPresenter { Tween.stopAllByTarget(fly); const op = fly.getComponent(UIOpacity); if (op) Tween.stopAllByTarget(op); - const bg = fly.getChildByName('bg'); - if (bg?.isValid) bg.active = true; fly.setScale(1, 1, 1); if (op) op.opacity = 255; if (fly['resKey'] && typeof gg !== 'undefined' && gg.res?.putNode) { diff --git a/assets/script/ui/BattleWeaponDescHero/UIBattleWeaponDescHero.ts b/assets/script/ui/BattleWeaponDescHero/UIBattleWeaponDescHero.ts index ea7bb33..ecf77b6 100644 --- a/assets/script/ui/BattleWeaponDescHero/UIBattleWeaponDescHero.ts +++ b/assets/script/ui/BattleWeaponDescHero/UIBattleWeaponDescHero.ts @@ -341,9 +341,9 @@ export class UIBattleWeaponDescHero extends Auto_BattleWeaponDescHero { if (!this.ui_node?.isValid) return; this._clearNumNode(); - const num = Math.floor(Number(w1.number) || 0); + const num = Math.floor(Number(w1.num) || 0); if (!(num > 0)) { - console.warn(LOG, 'Hero.number 无效', w1.id, w1.number); + console.warn(LOG, 'Hero.number 无效', w1.id, w1.num); this.ui_node.active = false; return; }