|
|
|
|
@ -4,7 +4,7 @@ |
|
|
|
|
// time: Tue Aug 18 2026
|
|
|
|
|
// desc: 战斗界面 — 地图、出怪、背包刷新(召唤)
|
|
|
|
|
//*********************
|
|
|
|
|
import { _decorator, find, game, Label, Node, Sprite, Tween, tween, v3, Vec3, sp } from 'cc'; |
|
|
|
|
import { _decorator, find, game, Label, Node, Tween, tween, v3, Vec3, sp } from 'cc'; |
|
|
|
|
import { Auto_BattleGame } from './Auto_BattleGame'; |
|
|
|
|
import { CocosBattleMapHost } from '../../battle/map/CocosBattleMapHost'; |
|
|
|
|
import { applyMapTopologyToSession } from '../../battle/map/importTopologyFromMapManager'; |
|
|
|
|
@ -64,10 +64,6 @@ import { WeaponComposeConfigProvider } from '../../battle/bag/WeaponComposeConfi |
|
|
|
|
|
|
|
|
|
const { ccclass } = _decorator; |
|
|
|
|
|
|
|
|
|
/** 召唤按钮 bg fillRange 变化 tween 时长(秒) */ |
|
|
|
|
const REFRESH_FILL_TWEEN_SEC = 0.2; |
|
|
|
|
/** btnRefresh/bg2 fillRange 下限(负值,接近凑够时不再小于 -0.1) */ |
|
|
|
|
const REFRESH_FILL_RANGE_MIN = -0.1; |
|
|
|
|
/** 召唤按钮进度满后 Q 弹第一下相对缩放增量 */ |
|
|
|
|
const REFRESH_BOUNCE_AMP = 0.1; |
|
|
|
|
/** 单段弹起/回落时长(秒) */ |
|
|
|
|
@ -95,12 +91,6 @@ export class UIBattleGame extends Auto_BattleGame { |
|
|
|
|
private _bagView: CocosBagBoardView | null = null; |
|
|
|
|
/** 普攻/技能表现:监听 PresentationCue → HeroActor */ |
|
|
|
|
private _skillController: SkillController | null = null; |
|
|
|
|
/** 召唤按钮填充进度(btnRefresh/bg2,水平从右到左) */ |
|
|
|
|
private _refreshFill: Sprite | null = null; |
|
|
|
|
/** 召唤按钮 bg2 目标 fillRange(= -(1 - 桃子进度)) */ |
|
|
|
|
private _refreshFillTarget = 0; |
|
|
|
|
/** 召唤按钮可刷新态(bg3) */ |
|
|
|
|
private _refreshBg3: Node | null = null; |
|
|
|
|
/** 召唤按钮基准缩放 */ |
|
|
|
|
private readonly _refreshBtnScaleHome = new Vec3(1, 1, 1); |
|
|
|
|
/** 本段「桃子足够」是否已播过满进度 Q 弹 */ |
|
|
|
|
@ -276,13 +266,9 @@ export class UIBattleGame extends Auto_BattleGame { |
|
|
|
|
this._ensureOwnedDesc(); |
|
|
|
|
this._ensureOtherOwnedDesc(); |
|
|
|
|
this._linkSkillDescPeers(); |
|
|
|
|
this._refreshFill = this.btnRefresh?.getChildByName('bg2')?.getComponent(Sprite) |
|
|
|
|
?? this.btnRefresh?.getChildByName('bg')?.getComponent(Sprite) |
|
|
|
|
?? null; |
|
|
|
|
this._refreshBg3 = this.btnRefresh?.getChildByName('bg3') ?? null; |
|
|
|
|
this._showRefreshBg1(); |
|
|
|
|
this._disableRefreshBreathe(); |
|
|
|
|
this.btnRefresh?.getScale(this._refreshBtnScaleHome); |
|
|
|
|
this._setupRefreshFillSprite(); |
|
|
|
|
this._lbWaveTip = this.ui_nextWaveTime?.getChildByName('lb1')?.getComponent(Label) ?? null; |
|
|
|
|
this._lbWaveTipTime = this.ui_nextWaveTime?.getChildByName('lb2')?.getComponent(Label) ?? null; |
|
|
|
|
if (!this.ui_nextWaveTime?.isValid) { |
|
|
|
|
@ -711,6 +697,10 @@ export class UIBattleGame extends Auto_BattleGame { |
|
|
|
|
rangeNode, |
|
|
|
|
this.ui_textGrids, |
|
|
|
|
); |
|
|
|
|
if (!this.ui_delete?.isValid) { |
|
|
|
|
console.log('[UIBattleGame] ui_delete 缺失,无法拖字删除'); |
|
|
|
|
} |
|
|
|
|
this._bagView.setDeleteNode(this.ui_delete); |
|
|
|
|
// bind() 开头会 unbind,入场回调必须在 bind 之后再挂
|
|
|
|
|
this._bagView.setOtherBagAnchor(this.ui_otherBag); |
|
|
|
|
this._bagView.setInkstoneWorldPosProvider(this._inkstoneWorldPos); |
|
|
|
|
@ -1074,27 +1064,8 @@ export class UIBattleGame extends Auto_BattleGame { |
|
|
|
|
if (this.lb_RefreshNeed?.isValid) { |
|
|
|
|
this.lb_RefreshNeed.string = `${cost}`; |
|
|
|
|
} |
|
|
|
|
this._showRefreshBg1(); |
|
|
|
|
const enough = cost <= 0 || gold >= cost; |
|
|
|
|
if (this._refreshBg3?.isValid) { |
|
|
|
|
this._refreshBg3.active = enough; |
|
|
|
|
} |
|
|
|
|
if (this._refreshFill?.isValid) { |
|
|
|
|
const fillNode = this._refreshFill.node; |
|
|
|
|
if (enough) { |
|
|
|
|
if (fillNode.active) { |
|
|
|
|
this._tweenRefreshFillRange(0, this._hideRefreshFill.bind(this)); |
|
|
|
|
} else { |
|
|
|
|
this._stopRefreshFillTween(); |
|
|
|
|
this._refreshFillTarget = 0; |
|
|
|
|
this._refreshFill.fillRange = 0; |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
fillNode.active = true; |
|
|
|
|
const progress = cost > 0 ? Math.min(1, Math.max(0, gold / cost)) : 1; |
|
|
|
|
const fillRange = Math.min(REFRESH_FILL_RANGE_MIN, -(1 - progress)); |
|
|
|
|
this._tweenRefreshFillRange(fillRange); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
this._syncRefreshBounce(enough); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -1127,47 +1098,20 @@ export class UIBattleGame extends Auto_BattleGame { |
|
|
|
|
if (node?.isValid && node.active !== active) node.active = active; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** btnRefresh/bg2:水平从右到左;fillRange = min(-0.1, -(1 - 桃子/消耗)),凑够为 0 */ |
|
|
|
|
private _setupRefreshFillSprite(): void { |
|
|
|
|
const sprite = this._refreshFill; |
|
|
|
|
if (!sprite?.isValid) return; |
|
|
|
|
sprite.type = Sprite.Type.FILLED; |
|
|
|
|
sprite.fillType = Sprite.FillType.HORIZONTAL; |
|
|
|
|
sprite.fillStart = 1; |
|
|
|
|
sprite.fillRange = -1; |
|
|
|
|
this._refreshFillTarget = -1; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** btnRefresh/bg2:fillRange 0.2s tween 到目标(不足时为负,凑够为 0) */ |
|
|
|
|
private _tweenRefreshFillRange(target: number, onComplete?: () => void): void { |
|
|
|
|
const sprite = this._refreshFill; |
|
|
|
|
if (!sprite?.isValid) return; |
|
|
|
|
if (Math.abs(target - this._refreshFillTarget) < 1e-4) { |
|
|
|
|
onComplete?.(); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
this._refreshFillTarget = target; |
|
|
|
|
Tween.stopAllByTarget(sprite); |
|
|
|
|
const tw = tween(sprite).to(REFRESH_FILL_TWEEN_SEC, { fillRange: target }); |
|
|
|
|
if (onComplete) { |
|
|
|
|
tw.call(onComplete); |
|
|
|
|
} |
|
|
|
|
tw.start(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** 桃子已够:fillRange 到 0 后隐藏 bg2 */ |
|
|
|
|
private _hideRefreshFill(): void { |
|
|
|
|
const fillNode = this._refreshFill?.node; |
|
|
|
|
if (fillNode?.isValid) { |
|
|
|
|
fillNode.active = false; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** 停止召唤按钮 bg fillRange tween */ |
|
|
|
|
private _stopRefreshFillTween(): void { |
|
|
|
|
if (this._refreshFill?.isValid) { |
|
|
|
|
Tween.stopAllByTarget(this._refreshFill); |
|
|
|
|
/** btnRefresh 只显示 bg1,隐藏进度底 bg2 和可刷新底 bg3 */ |
|
|
|
|
private _showRefreshBg1(): void { |
|
|
|
|
const btn = this.btnRefresh; |
|
|
|
|
if (!btn?.isValid) return; |
|
|
|
|
const bg1 = btn.getChildByName('bg1'); |
|
|
|
|
const bg2 = btn.getChildByName('bg2'); |
|
|
|
|
const bg3 = btn.getChildByName('bg3'); |
|
|
|
|
if (!bg1?.isValid) { |
|
|
|
|
console.log('[UIBattleGame] btnRefresh 缺少 bg1'); |
|
|
|
|
} |
|
|
|
|
this._setNodeActive(bg1, true); |
|
|
|
|
if (bg2?.isValid) Tween.stopAllByTarget(bg2); |
|
|
|
|
this._setNodeActive(bg2, false); |
|
|
|
|
this._setNodeActive(bg3, false); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** 关掉预制体上的 TweenBreathe,避免与 Q 弹抢缩放 */ |
|
|
|
|
@ -1368,10 +1312,6 @@ export class UIBattleGame extends Auto_BattleGame { |
|
|
|
|
this._mapHost = null; |
|
|
|
|
this._battle = null; |
|
|
|
|
this._combatStarted = false; |
|
|
|
|
this._stopRefreshFillTween(); |
|
|
|
|
this._refreshFill = null; |
|
|
|
|
this._refreshBg3 = null; |
|
|
|
|
this._refreshFillTarget = 0; |
|
|
|
|
this._stopRefreshBounce(); |
|
|
|
|
this._refreshBounceHinted = false; |
|
|
|
|
this._illustratedHintShownThisBattle = false; |
|
|
|
|
|