|
|
|
|
@ -940,9 +940,10 @@ export class CocosBagBoardView { |
|
|
|
|
if (this._bagSession?.merge.map.hasTile(mapGrid)) { |
|
|
|
|
const tile = this._bagSession.merge.map.getTile(mapGrid); |
|
|
|
|
const level = tile?.level ?? 1; |
|
|
|
|
const w1 = Number(tile?.weapon1Id) || 0; |
|
|
|
|
const grid = this._mapGrids.get(mapGrid); |
|
|
|
|
if (grid?.isValid) { |
|
|
|
|
grid.applyMapLevel(level); |
|
|
|
|
grid.applyMapLevel(level, w1); |
|
|
|
|
grid.enableDrag(this._canDrag()); |
|
|
|
|
this._bindDrag(grid); |
|
|
|
|
} |
|
|
|
|
@ -964,7 +965,7 @@ export class CocosBagBoardView { |
|
|
|
|
const record = this._bagSession.getBagSlots()[bagSlot]; |
|
|
|
|
if (grid?.isValid && record) { |
|
|
|
|
this._grids.setBagGrid(bagSlot, grid); |
|
|
|
|
grid.applyMapLevel(record.level ?? 1); |
|
|
|
|
grid.applyMapLevel(record.level ?? 1, Number(record.weapon1Id) || 0); |
|
|
|
|
} |
|
|
|
|
this._sanitizeBagSlotAfterMerge(bagSlot); |
|
|
|
|
this._playBagUpgradeEffect(bagSlot); |
|
|
|
|
@ -4593,7 +4594,7 @@ export class CocosBagBoardView { |
|
|
|
|
this._deferredBagUpgradeSlot = event.slotIndex; |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
if (this._applyBagUpgradeInPlace(event.slotIndex, event.level)) { |
|
|
|
|
if (this._applyBagUpgradeInPlace(event.slotIndex, event.level, event.weapon1Id)) { |
|
|
|
|
this._sanitizeBagSlotAfterMerge(event.slotIndex); |
|
|
|
|
if (!this._suppressDefaultUpgradeFx) { |
|
|
|
|
this._playBagUpgradeEffect(event.slotIndex); |
|
|
|
|
@ -4614,7 +4615,7 @@ export class CocosBagBoardView { |
|
|
|
|
} |
|
|
|
|
const prevMapLv = Math.floor(Number(this._grids.getMapGrid(event.gridIndex)?.level) || 0); |
|
|
|
|
const mapLevelDown = event.level < prevMapLv; |
|
|
|
|
if (this._applyMapUpgradeInPlace(event.gridIndex, event.level)) { |
|
|
|
|
if (this._applyMapUpgradeInPlace(event.gridIndex, event.level, event.weapon1Id)) { |
|
|
|
|
this._refreshHeroLevelAtGrid(event.gridIndex, event.level); |
|
|
|
|
if (this._deploySync && this._map.gridsInitialized) { |
|
|
|
|
this._deploySync.reconcileFromMerge('mapUpgraded'); |
|
|
|
|
@ -5471,9 +5472,12 @@ const w2Type = WeaponComposeConfigProvider.instance.getWeapon2Type(weapon2Id) as |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 地图字块仅等级变化:原地刷新 TextGrid,避免全量 rebuild 叠字。 |
|
|
|
|
* @param gridIndex 地图格 |
|
|
|
|
* @param newLevel 新等级 |
|
|
|
|
* @param weapon1Id 新 Hero.id(0 表示仅改等级) |
|
|
|
|
* @returns 是否已在原节点上更新成功 |
|
|
|
|
*/ |
|
|
|
|
private _applyMapUpgradeInPlace(gridIndex: number, newLevel: number): boolean { |
|
|
|
|
private _applyMapUpgradeInPlace(gridIndex: number, newLevel: number, weapon1Id = 0): boolean { |
|
|
|
|
if (!this._bagSession || !this._map) return false; |
|
|
|
|
if (!this._bagSession.merge.map.hasTile(gridIndex)) return false; |
|
|
|
|
|
|
|
|
|
@ -5483,13 +5487,14 @@ const w2Type = WeaponComposeConfigProvider.instance.getWeapon2Type(weapon2Id) as |
|
|
|
|
const indices = composition?.gridIndices.length |
|
|
|
|
? composition.gridIndices.slice() |
|
|
|
|
: [gridIndex]; |
|
|
|
|
const w1 = Math.floor(Number(weapon1Id) || 0) || (composition?.weapon1Id ?? 0); |
|
|
|
|
|
|
|
|
|
let applied = 0; |
|
|
|
|
for (let i = 0; i < indices.length; i++) { |
|
|
|
|
const idx = indices[i]; |
|
|
|
|
const grid = this._resolveMapTextGridForUpgrade(idx); |
|
|
|
|
if (!grid?.isValid) continue; |
|
|
|
|
grid.applyMapLevel(newLevel); |
|
|
|
|
grid.applyMapLevel(newLevel, w1); |
|
|
|
|
this._grids.setMapGrid(idx, grid); |
|
|
|
|
applied++; |
|
|
|
|
} |
|
|
|
|
@ -5497,8 +5502,13 @@ const w2Type = WeaponComposeConfigProvider.instance.getWeapon2Type(weapon2Id) as |
|
|
|
|
return applied > 0; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** 背包字块仅等级变化:原地刷新 TextGrid */ |
|
|
|
|
private _applyBagUpgradeInPlace(slotIndex: number, newLevel: number): boolean { |
|
|
|
|
/** |
|
|
|
|
* 背包字块仅等级变化:原地刷新 TextGrid。 |
|
|
|
|
* @param slotIndex 槽 |
|
|
|
|
* @param newLevel 新等级 |
|
|
|
|
* @param weapon1Id 新 Hero.id |
|
|
|
|
*/ |
|
|
|
|
private _applyBagUpgradeInPlace(slotIndex: number, newLevel: number, weapon1Id = 0): boolean { |
|
|
|
|
if (!this._bagSession || !this._bagList) return false; |
|
|
|
|
if (!this._bagSession.getBagSlots()[slotIndex]) return false; |
|
|
|
|
const slotNode = this._bagSlotNodeAt(slotIndex); |
|
|
|
|
@ -5506,7 +5516,9 @@ const w2Type = WeaponComposeConfigProvider.instance.getWeapon2Type(weapon2Id) as |
|
|
|
|
|
|
|
|
|
const grid = this._resolveBagTextGridForUpgrade(slotIndex, slotNode); |
|
|
|
|
if (!grid?.isValid) return false; |
|
|
|
|
grid.applyMapLevel(newLevel); |
|
|
|
|
const slot = this._bagSession.getBagSlots()[slotIndex]; |
|
|
|
|
const w1 = Math.floor(Number(weapon1Id) || 0) || (Number(slot?.weapon1Id) || 0); |
|
|
|
|
grid.applyMapLevel(newLevel, w1); |
|
|
|
|
this._grids.setBagGrid(slotIndex, grid); |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
@ -6912,12 +6924,13 @@ const w2Type = WeaponComposeConfigProvider.instance.getWeapon2Type(weapon2Id) as |
|
|
|
|
return loc?.kind === 'map' && this._isEnemyPlaceCampCell(loc.gridIndex); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** 字块完整快照(敌方格补 ECS runtime) */ |
|
|
|
|
private _resolveTextGridData(grid: TextGrid): TextGridData { |
|
|
|
|
/** 字块完整快照(敌方格补 ECS runtime);无实体时 null */ |
|
|
|
|
private _resolveTextGridData(grid: TextGrid): TextGridData | null { |
|
|
|
|
const deploySync = this._isEnemyTextGrid(grid) |
|
|
|
|
? AiBattleBridge.inst.aiDeploySync |
|
|
|
|
: this._deploySync; |
|
|
|
|
const data = grid.getData(deploySync); |
|
|
|
|
if (!data) return null; |
|
|
|
|
if (!this._isEnemyTextGrid(grid)) return data; |
|
|
|
|
const loc = grid.location; |
|
|
|
|
if (loc?.kind !== 'map') return data; |
|
|
|
|
@ -6981,7 +6994,7 @@ const w2Type = WeaponComposeConfigProvider.instance.getWeapon2Type(weapon2Id) as |
|
|
|
|
|
|
|
|
|
/** 字块占格合成体(含敌方) */ |
|
|
|
|
private _resolveGridComposition(grid: TextGrid, gridIndex: number): ComposedUnit | null { |
|
|
|
|
const fromEntity = this._resolveTextGridData(grid).composition; |
|
|
|
|
const fromEntity = this._resolveTextGridData(grid)?.composition; |
|
|
|
|
if (fromEntity) return fromEntity; |
|
|
|
|
if (this._isEnemyPlaceCampCell(gridIndex)) { |
|
|
|
|
const enemyPlayer = this._battle?.getPlayer(this._resolveEnemyPlayerId()); |
|
|
|
|
@ -7004,6 +7017,11 @@ const w2Type = WeaponComposeConfigProvider.instance.getWeapon2Type(weapon2Id) as |
|
|
|
|
this._textInteractDedupKey = dedupKey; |
|
|
|
|
|
|
|
|
|
const data = this._resolveTextGridData(grid); |
|
|
|
|
if (!data) { |
|
|
|
|
console.warn('[BagBoard] 字块交互无快照', target.kind, target.index, grid.weapon2Id); |
|
|
|
|
this._clearTextSelect(); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
const isPeachTree = grid.isPeachTreeTile(); |
|
|
|
|
const isBagItem = this._isBagItemEntity(data); |
|
|
|
|
// 五行数字与旧 Single=1 编号重叠,数字格子一律 Hero,勿再开 Desc1
|
|
|
|
|
@ -7136,6 +7154,7 @@ const w2Type = WeaponComposeConfigProvider.instance.getWeapon2Type(weapon2Id) as |
|
|
|
|
): Pick<BattleWeaponDescHeroPanelData, 'entity' | 'runtime' | 'weaponId'> | null { |
|
|
|
|
if (!grid?.node?.isValid) return null; |
|
|
|
|
let data = this._resolveTextGridData(grid); |
|
|
|
|
if (!data) return null; |
|
|
|
|
if (target.kind === 'map') { |
|
|
|
|
const comp = this._resolveGridComposition(grid, target.index); |
|
|
|
|
if (comp) { |
|
|
|
|
@ -7215,6 +7234,7 @@ const w2Type = WeaponComposeConfigProvider.instance.getWeapon2Type(weapon2Id) as |
|
|
|
|
|
|
|
|
|
private _gridCanShowWeaponDesc(grid: TextGrid): boolean { |
|
|
|
|
const data = this._resolveTextGridData(grid); |
|
|
|
|
if (!data) return false; |
|
|
|
|
if (grid.isPeachTreeTile()) return !!data.tile; |
|
|
|
|
if (this._isBagItemEntity(data)) return !!data.tile; |
|
|
|
|
return !!(data.tower && data.weapon1Id > 0); |
|
|
|
|
@ -7249,6 +7269,7 @@ const w2Type = WeaponComposeConfigProvider.instance.getWeapon2Type(weapon2Id) as |
|
|
|
|
/** 字块攻击范围(像素):已部署优先读 runtime */ |
|
|
|
|
private _resolveGridRangePx(grid: TextGrid): number { |
|
|
|
|
const data = this._resolveTextGridData(grid); |
|
|
|
|
if (!data) return 0; |
|
|
|
|
const px = data.runtime?.stats.range ?? data.tower?.stats.range ?? 0; |
|
|
|
|
return px > 0 ? px : 0; |
|
|
|
|
} |
|
|
|
|
@ -7437,6 +7458,7 @@ const w2Type = WeaponComposeConfigProvider.instance.getWeapon2Type(weapon2Id) as |
|
|
|
|
private _canShowType1Range(grid: TextGrid | null): boolean { |
|
|
|
|
if (!grid?.node?.isValid) return false; |
|
|
|
|
const data = this._resolveTextGridData(grid); |
|
|
|
|
if (!data) return false; |
|
|
|
|
if (this._isCampGridText(data)) return false; |
|
|
|
|
if (!data.tower && !data.runtime) return false; |
|
|
|
|
const rangePx = this._resolveGridRangePx(grid); |
|
|
|
|
|