|
|
|
@ -135,6 +135,8 @@ export class CocosBagBoardView { |
|
|
|
private _deploySync: DeploySync | null = null; |
|
|
|
private _deploySync: DeploySync | null = null; |
|
|
|
private _map: MapManager | null = null; |
|
|
|
private _map: MapManager | null = null; |
|
|
|
private _bagList: Node | null = null; |
|
|
|
private _bagList: Node | null = null; |
|
|
|
|
|
|
|
/** 拖字删除落点(BattleGame ui_delete) */ |
|
|
|
|
|
|
|
private _deleteNode: Node | null = null; |
|
|
|
/** ui_textList 开启 / 待解锁 / 未解锁 */ |
|
|
|
/** ui_textList 开启 / 待解锁 / 未解锁 */ |
|
|
|
private readonly _land = new TextListLandHost(); |
|
|
|
private readonly _land = new TextListLandHost(); |
|
|
|
/** 开格展示字块补显重试帧计数(textGrid 预制体异步加载未就绪时留空格) */ |
|
|
|
/** 开格展示字块补显重试帧计数(textGrid 预制体异步加载未就绪时留空格) */ |
|
|
|
@ -1250,6 +1252,14 @@ export class CocosBagBoardView { |
|
|
|
this._otherBagAnchor = node?.isValid ? node : null; |
|
|
|
this._otherBagAnchor = node?.isValid ? node : null; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 绑定拖字删除节点(BattleGame ui_delete)。 |
|
|
|
|
|
|
|
* @param node 删除落点;无效则不能拖字删除 |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
setDeleteNode(node: Node | null | undefined): void { |
|
|
|
|
|
|
|
this._deleteNode = node?.isValid ? node : null; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
bind( |
|
|
|
bind( |
|
|
|
battle: ProjectBattleHandle, |
|
|
|
battle: ProjectBattleHandle, |
|
|
|
map: MapManager, |
|
|
|
map: MapManager, |
|
|
|
@ -1306,7 +1316,7 @@ export class CocosBagBoardView { |
|
|
|
|
|
|
|
|
|
|
|
this._bindMapGridClicks(); |
|
|
|
this._bindMapGridClicks(); |
|
|
|
this._warmTextGridPool(); |
|
|
|
this._warmTextGridPool(); |
|
|
|
// 开局只给 tolockland 放字;normalland 留空;grid17 不出字
|
|
|
|
// 开局只给 tolockland 放字;normalland 留空
|
|
|
|
this._bagSession.autoFillOpenSlots(); |
|
|
|
this._bagSession.autoFillOpenSlots(); |
|
|
|
this._rebuildBagFromSession(true); |
|
|
|
this._rebuildBagFromSession(true); |
|
|
|
this._refreshDragEnabled(); |
|
|
|
this._refreshDragEnabled(); |
|
|
|
@ -1431,6 +1441,7 @@ export class CocosBagBoardView { |
|
|
|
this.disarmBagEntrance(); |
|
|
|
this.disarmBagEntrance(); |
|
|
|
this.setInkstoneWorldPosProvider(null); |
|
|
|
this.setInkstoneWorldPosProvider(null); |
|
|
|
this.setOtherBagAnchor(null); |
|
|
|
this.setOtherBagAnchor(null); |
|
|
|
|
|
|
|
this.setDeleteNode(null); |
|
|
|
this.setBagEntranceHandler(null, null); |
|
|
|
this.setBagEntranceHandler(null, null); |
|
|
|
this.setSkillPeachFlyHandler(null); |
|
|
|
this.setSkillPeachFlyHandler(null); |
|
|
|
this._unbindMapGridClicks(); |
|
|
|
this._unbindMapGridClicks(); |
|
|
|
@ -3308,6 +3319,20 @@ export class CocosBagBoardView { |
|
|
|
const fromSlot = drag?.source.kind === 'bag' ? drag.source.slotIndex : -1; |
|
|
|
const fromSlot = drag?.source.kind === 'bag' ? drag.source.slotIndex : -1; |
|
|
|
const fromMapIndex = this._mapDragFromIndex(drag); |
|
|
|
const fromMapIndex = this._mapDragFromIndex(drag); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (this._isOverDelete(uiPos)) { |
|
|
|
|
|
|
|
this._setDragSelectTarget(null); |
|
|
|
|
|
|
|
const del = this._deleteNode; |
|
|
|
|
|
|
|
if (lineFrom && del?.isValid) { |
|
|
|
|
|
|
|
this._linePresenter.show(lineFrom, del.worldPosition); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
this._linePresenter.hide(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (drag && this._isType3Drag(grid, drag)) { |
|
|
|
|
|
|
|
this._updateType3PathPreview(null, drag); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const bagSlotIndex = this._resolveBagSlotAt(uiPos); |
|
|
|
const bagSlotIndex = this._resolveBagSlotAt(uiPos); |
|
|
|
if (bagSlotIndex != null) { |
|
|
|
if (bagSlotIndex != null) { |
|
|
|
const bagSwap = fromSlot >= 0 && bagSlotIndex !== fromSlot; |
|
|
|
const bagSwap = fromSlot >= 0 && bagSlotIndex !== fromSlot; |
|
|
|
@ -3419,8 +3444,8 @@ export class CocosBagBoardView { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const target = this._resolveDropTarget(event, drag.source); |
|
|
|
const target = this._resolveDropTarget(event, drag.source); |
|
|
|
if (target.kind === 'bag' && this._land.isBlank(target.slotIndex)) { |
|
|
|
if (this._isOverDelete(event.getUILocation())) { |
|
|
|
this._discardGlyphToBlank(grid, drag); |
|
|
|
this._discardGlyphToDelete(grid, drag); |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
if (target.kind === 'bag' && this._interceptLandDrop(target.slotIndex)) { |
|
|
|
if (target.kind === 'bag' && this._interceptLandDrop(target.slotIndex)) { |
|
|
|
@ -3510,8 +3535,8 @@ export class CocosBagBoardView { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const bagSlotIndex = this._resolveBagSlotAt(uiPos); |
|
|
|
const bagSlotIndex = this._resolveBagSlotAt(uiPos); |
|
|
|
if (bagSlotIndex != null && this._land.isBlank(bagSlotIndex)) { |
|
|
|
if (this._isOverDelete(uiPos)) { |
|
|
|
this._discardGlyphToBlank(grid, drag); |
|
|
|
this._discardGlyphToDelete(grid, drag); |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
if (bagSlotIndex != null && this._interceptLandDrop(bagSlotIndex)) { |
|
|
|
if (bagSlotIndex != null && this._interceptLandDrop(bagSlotIndex)) { |
|
|
|
@ -4116,17 +4141,22 @@ export class CocosBagBoardView { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 背包或地图上的字拖到空装饰格:飞到 grid17 后消失,不留在格子上。 |
|
|
|
* 背包或地图上的字拖到 ui_delete:飞到该节点后消失,不留在格子上。 |
|
|
|
* @param grid 被拖的字 |
|
|
|
* @param grid 被拖的字 |
|
|
|
* @param drag 本次拖拽 |
|
|
|
* @param drag 本次拖拽 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
private _discardGlyphToBlank(grid: TextGrid, drag: NonNullable<typeof this._activeDrag>): void { |
|
|
|
private _discardGlyphToDelete(grid: TextGrid, drag: NonNullable<typeof this._activeDrag>): void { |
|
|
|
const session = this._bagSession; |
|
|
|
const session = this._bagSession; |
|
|
|
const blank = this._blankLandNode(); |
|
|
|
const del = this._deleteNode; |
|
|
|
const layer = this._dragLayer; |
|
|
|
const layer = this._dragLayer; |
|
|
|
if (!session || !blank?.isValid || !layer?.isValid || !grid.node?.isValid) { |
|
|
|
if (!del?.isValid || !del.activeInHierarchy) { |
|
|
|
this._discardGlyphData(drag); |
|
|
|
console.log('[CocosBagBoardView] ui_delete 不可用,取消删除'); |
|
|
|
if (grid.node?.isValid) this._forceRecycleTextGrid(grid); |
|
|
|
this._lineDragCancel(grid, drag); |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (!session || !layer?.isValid || !grid.node?.isValid) { |
|
|
|
|
|
|
|
console.log('[CocosBagBoardView] 删除字块缺少拖拽层或会话'); |
|
|
|
|
|
|
|
this._lineDragCancel(grid, drag); |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
const from: GridDetachSource = drag.source.kind === 'bag' |
|
|
|
const from: GridDetachSource = drag.source.kind === 'bag' |
|
|
|
@ -4154,7 +4184,7 @@ export class CocosBagBoardView { |
|
|
|
this._lineDragCancel(grid, drag); |
|
|
|
this._lineDragCancel(grid, drag); |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
const target = blank.worldPosition.clone(); |
|
|
|
const target = del.worldPosition.clone(); |
|
|
|
BagToMapPlaceAnimator.play(grid, target, layer, () => { |
|
|
|
BagToMapPlaceAnimator.play(grid, target, layer, () => { |
|
|
|
this._finishDiscardFlight(grid); |
|
|
|
this._finishDiscardFlight(grid); |
|
|
|
}, { showTrail: DeviceProfile.enableBoardPlaceTrail }); |
|
|
|
}, { showTrail: DeviceProfile.enableBoardPlaceTrail }); |
|
|
|
@ -4176,7 +4206,7 @@ export class CocosBagBoardView { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 飞到空装饰格后回收字块,并补上推迟的盘面刷新。 |
|
|
|
* 飞到 ui_delete 后回收字块,并补上推迟的盘面刷新。 |
|
|
|
* @param grid 飞行中的字 |
|
|
|
* @param grid 飞行中的字 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
private _finishDiscardFlight(grid: TextGrid): void { |
|
|
|
private _finishDiscardFlight(grid: TextGrid): void { |
|
|
|
@ -4188,7 +4218,17 @@ export class CocosBagBoardView { |
|
|
|
this._refreshCanUpgradeHints(); |
|
|
|
this._refreshCanUpgradeHints(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** 空装饰格节点(grid17) */ |
|
|
|
/** |
|
|
|
|
|
|
|
* 手指是否在 ui_delete 上。 |
|
|
|
|
|
|
|
* @param uiPos 屏幕坐标 |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private _isOverDelete(uiPos: { x: number; y: number }): boolean { |
|
|
|
|
|
|
|
const node = this._deleteNode; |
|
|
|
|
|
|
|
if (!node?.isValid || !node.activeInHierarchy) return false; |
|
|
|
|
|
|
|
return this._hitNode(node, uiPos); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** 空装饰格节点。当前没有这种格子 */ |
|
|
|
private _blankLandNode(): Node | null { |
|
|
|
private _blankLandNode(): Node | null { |
|
|
|
const list = this._bagList; |
|
|
|
const list = this._bagList; |
|
|
|
if (!list?.isValid) return null; |
|
|
|
if (!list?.isValid) return null; |
|
|
|
|