|
|
|
@ -1,4 +1,4 @@ |
|
|
|
import { Node, sp } from 'cc'; |
|
|
|
import { Node, UITransform, Vec3, sp } from 'cc'; |
|
|
|
import { MergeEventType, type MergeEvent } from 'db://assets/mx/module/merge'; |
|
|
|
import { MergeEventType, type MergeEvent } from 'db://assets/mx/module/merge'; |
|
|
|
import type { BattleBagSession } from '../../battle/bag/BattleBagSession'; |
|
|
|
import type { BattleBagSession } from '../../battle/bag/BattleBagSession'; |
|
|
|
import { BattleSpinePlayback } from '../../battle/presentation/BattleSpinePlayback'; |
|
|
|
import { BattleSpinePlayback } from '../../battle/presentation/BattleSpinePlayback'; |
|
|
|
@ -17,6 +17,7 @@ const FINGER_NODE = '引导手指'; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 新玩家首次进战弱引导:点召唤 → 拖字上阵。 |
|
|
|
* 新玩家首次进战弱引导:点召唤 → 拖字上阵。 |
|
|
|
|
|
|
|
* 手指对齐召唤按钮世界坐标,避免预制体旧坐标偏移。 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
export class BattleFirstGuidePresenter { |
|
|
|
export class BattleFirstGuidePresenter { |
|
|
|
/** 引导根 */ |
|
|
|
/** 引导根 */ |
|
|
|
@ -29,17 +30,22 @@ export class BattleFirstGuidePresenter { |
|
|
|
private _finger: Node | null = null; |
|
|
|
private _finger: Node | null = null; |
|
|
|
/** 手指 Spine */ |
|
|
|
/** 手指 Spine */ |
|
|
|
private _fingerSk: sp.Skeleton | null = null; |
|
|
|
private _fingerSk: sp.Skeleton | null = null; |
|
|
|
|
|
|
|
/** 召唤按钮(对齐目标) */ |
|
|
|
|
|
|
|
private _summonBtn: Node | null = null; |
|
|
|
/** 本机背包 */ |
|
|
|
/** 本机背包 */ |
|
|
|
private _bag: BattleBagSession | null = null; |
|
|
|
private _bag: BattleBagSession | null = null; |
|
|
|
/** 当前步:0 未开 / 2 点召唤 / 3 拖字 */ |
|
|
|
/** 当前步:0 未开 / 2 点召唤 / 3 拖字 */ |
|
|
|
private _step = 0; |
|
|
|
private _step = 0; |
|
|
|
|
|
|
|
/** 复用世界坐标,避免每帧 new */ |
|
|
|
|
|
|
|
private readonly _alignWorld = new Vec3(); |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 绑定并按存档决定是否展示第一步。 |
|
|
|
* 绑定并按存档决定是否展示第一步。 |
|
|
|
* @param root ui_guide |
|
|
|
* @param root ui_guide |
|
|
|
* @param bag 本机背包会话 |
|
|
|
* @param bag 本机背包会话 |
|
|
|
|
|
|
|
* @param summonBtn 召唤按钮(btnRefresh) |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
bind(root: Node | null, bag: BattleBagSession | null): void { |
|
|
|
bind(root: Node | null, bag: BattleBagSession | null, summonBtn?: Node | null): void { |
|
|
|
this.unbind(); |
|
|
|
this.unbind(); |
|
|
|
if (!root?.isValid) { |
|
|
|
if (!root?.isValid) { |
|
|
|
console.error('[BattleFirstGuide] ui_guide 缺失'); |
|
|
|
console.error('[BattleFirstGuide] ui_guide 缺失'); |
|
|
|
@ -60,13 +66,23 @@ export class BattleFirstGuidePresenter { |
|
|
|
console.error('[BattleFirstGuide] bagSession 未就绪'); |
|
|
|
console.error('[BattleFirstGuide] bagSession 未就绪'); |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (!summonBtn?.isValid) { |
|
|
|
|
|
|
|
console.warn('[BattleFirstGuide] 召唤按钮缺失,手指可能错位'); |
|
|
|
|
|
|
|
} |
|
|
|
this._root = root; |
|
|
|
this._root = root; |
|
|
|
this._bag = bag; |
|
|
|
this._bag = bag; |
|
|
|
|
|
|
|
this._summonBtn = summonBtn?.isValid ? summonBtn : null; |
|
|
|
this._bag.on(MergeEventType.TilePlaced, this._onPlayerDrag); |
|
|
|
this._bag.on(MergeEventType.TilePlaced, this._onPlayerDrag); |
|
|
|
this._bag.on(MergeEventType.TileMoved, this._onPlayerDrag); |
|
|
|
this._bag.on(MergeEventType.TileMoved, this._onPlayerDrag); |
|
|
|
this._showSummon(); |
|
|
|
this._showSummon(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** Widget 布局后再对齐一次(由界面 scheduleOnce 调用) */ |
|
|
|
|
|
|
|
realignFinger(): void { |
|
|
|
|
|
|
|
if (this._step !== 2) return; |
|
|
|
|
|
|
|
this._alignFingerToSummon(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** 召唤刷新成功:藏手指,切到拖字提示 */ |
|
|
|
/** 召唤刷新成功:藏手指,切到拖字提示 */ |
|
|
|
onSummonOk(): void { |
|
|
|
onSummonOk(): void { |
|
|
|
if (this._step !== 2) return; |
|
|
|
if (this._step !== 2) return; |
|
|
|
@ -89,6 +105,7 @@ export class BattleFirstGuidePresenter { |
|
|
|
this._stepDrag = null; |
|
|
|
this._stepDrag = null; |
|
|
|
this._finger = null; |
|
|
|
this._finger = null; |
|
|
|
this._fingerSk = null; |
|
|
|
this._fingerSk = null; |
|
|
|
|
|
|
|
this._summonBtn = null; |
|
|
|
this._bag = null; |
|
|
|
this._bag = null; |
|
|
|
this._step = 0; |
|
|
|
this._step = 0; |
|
|
|
} |
|
|
|
} |
|
|
|
@ -102,9 +119,28 @@ export class BattleFirstGuidePresenter { |
|
|
|
if (this._stepSummon) this._stepSummon.active = true; |
|
|
|
if (this._stepSummon) this._stepSummon.active = true; |
|
|
|
if (this._stepDrag) this._stepDrag.active = false; |
|
|
|
if (this._stepDrag) this._stepDrag.active = false; |
|
|
|
if (this._finger) this._finger.active = true; |
|
|
|
if (this._finger) this._finger.active = true; |
|
|
|
|
|
|
|
this._alignFingerToSummon(); |
|
|
|
this._playFinger(); |
|
|
|
this._playFinger(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** 将手指对齐到召唤按钮中心(不拦截点击,否则会挡住召唤) */ |
|
|
|
|
|
|
|
private _alignFingerToSummon(): void { |
|
|
|
|
|
|
|
const finger = this._finger; |
|
|
|
|
|
|
|
const btn = this._summonBtn; |
|
|
|
|
|
|
|
if (!finger?.isValid || !btn?.isValid) return; |
|
|
|
|
|
|
|
btn.getWorldPosition(this._alignWorld); |
|
|
|
|
|
|
|
const put = finger.parent?.getComponent(UITransform); |
|
|
|
|
|
|
|
if (!put) { |
|
|
|
|
|
|
|
finger.setWorldPosition(this._alignWorld); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
const local = put.convertToNodeSpaceAR(this._alignWorld); |
|
|
|
|
|
|
|
finger.setPosition(local.x, local.y, 0); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// Spine 仍绘制;命中盒清零,触摸落到下方 btnRefresh
|
|
|
|
|
|
|
|
const fut = finger.getComponent(UITransform); |
|
|
|
|
|
|
|
if (fut) fut.setContentSize(0, 0); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** 第二步:只留拖字文案 */ |
|
|
|
/** 第二步:只留拖字文案 */ |
|
|
|
private _showDrag(): void { |
|
|
|
private _showDrag(): void { |
|
|
|
this._step = 3; |
|
|
|
this._step = 3; |
|
|
|
|