feat: consolidate unspool gameplay, 30 release levels, and 5 validation samples (026A/B, 038A, 039, 051)

This commit is contained in:
fannyxl committed 2026-11-26 09:45:05 +08:00
1 parent 96c19dca82
commit f02f9b085e
18 files changed
+2922 -39

No files matched your search

+371 -33
View File
@@ -3,6 +3,7 @@ import { AtelierService } from '../core/AtelierService';
import { CHAPTERS, CHAPTER_UNLOCK_STARS, formatLength, formatShort, HOOP_HEIGHT, HOOP_WIDTH, LEVELS, NEST, YARN_COLORS } from '../core/LevelData';
import {
ANT_SPEED,
availableTargets,
checkSegmentBlock,
createEmptyRoute,
dispatchWarning,
@@ -11,11 +12,15 @@ import {
findNextHint,
interpolate,
isButtonEvent,
isClipUnlocked,
isDeliveryEvent,
isDyeEvent,
isGateEvent,
isPickEvent,
isSpoolEvent,
isStrandClipLocked,
isStrandExposed,
isTargetLocked,
passedGateIds,
planStops,
prepareRouteForRun,
@@ -28,8 +33,8 @@ import {
} from '../core/RouteEngine';
import { SoundService } from '../core/SoundService';
import { StorageService } from '../core/StorageService';
import { BlockReason, GameState, LevelDef, Point2D, RouteState, TargetColor } from '../core/Types';
import { EmbroideryRenderer } from '../render/EmbroideryRenderer';
import { BallDef, BlockReason, GameState, LevelDef, Point2D, RouteState, TargetColor } from '../core/Types';
import { EmbroideryRenderer, UNSPOOL_CLOTH_HEIGHT, UNSPOOL_CLOTH_WIDTH } from '../render/EmbroideryRenderer';
import { AtelierTab } from './AtelierModal';
import { applyCoverBackground, applySafeContentTransform, ScreenMetrics } from './ScreenAdapter';
import {
@@ -54,6 +59,8 @@ const { ccclass } = _decorator;
const HOOP_DISPLAY_W = 708;
const HOOP_DISPLAY_H = Math.round((HOOP_DISPLAY_W * HOOP_HEIGHT) / HOOP_WIDTH);
const RELATIVE_GAIN = 1.42;
const UNSPOOL_DISPLAY_WIDTH = 492;
const UNSPOOL_DISPLAY_HEIGHT = Math.round((UNSPOOL_DISPLAY_WIDTH * UNSPOOL_CLOTH_HEIGHT) / UNSPOOL_CLOTH_WIDTH);
const CHIP_STYLES: Record<TargetColor, { icon: string; dot: string; fill: string; stroke: string; text: string }> = {
gold: { icon: '✿', dot: '#d89a2c', fill: '#fbf0d4', stroke: '#d9b574', text: '#6a410b' },
@@ -86,8 +93,19 @@ export class PlayView extends Component {
private onOpenAtelier?: (tab: AtelierTab, chapterIndex: number, focusLevelIndex?: number) => void;
private currentIndex = 0;
private customMode = false;
private level: LevelDef = LEVELS[0];
private activeNestIndex = 0;
private get unspoolMode(): boolean {
return Boolean(this.level.unspool);
}
private unspoolNextBallId = 100;
private unspoolHistory: (
| { kind: 'unspool'; strandId: string; slotIndex: number; ballId: number }
| { kind: 'stitch'; restoredBalls: { slotIndex: number; ball: BallDef }[] }
)[] = [];
private targetCounts: Record<TargetColor, number> = {
gold: 0,
green: 0,
@@ -150,9 +168,14 @@ export class PlayView extends Component {
private topBarNode!: Node;
private missionRowNode!: Node;
private whisperRibbonNode!: Node;
private unspoolPanelNode!: Node;
private unspoolClothNode!: Node;
private unspoolClothTransform!: UITransform;
private unspoolHeaderLabel!: Label;
private resultFrameNode!: Node;
private relativeAnchorNode!: Node;
private relativeThumbNode!: Node;
private lastMetrics: ScreenMetrics | null = null;
private hintBtn!: ArtButton;
private hintHalo!: Node;
@@ -229,6 +252,38 @@ export class PlayView extends Component {
hoopSprite.sizeMode = Sprite.SizeMode.CUSTOM;
hoopSprite.spriteFrame = this.renderer.getSpriteFrame();
// 「拆旧织新」胡桃木铜钉旧布抽线板(仅在带 unspool 配置的关卡显示)
const unspoolFrame = createPanel('UnspoolClothPanel', 698, 132, {
fill: '#3c2514ee',
stroke: '#d8b068',
strokeWidth: 2,
radius: 20,
depth: 4,
depthColor: '#221308',
shadow: 5,
rivets: true,
rivetColor: '#e2ba6d',
}, this.safeRoot);
this.unspoolPanelNode = unspoolFrame.node;
this.unspoolHeaderLabel = createLabel('UnspoolHeader', '旧荷包\n点线头抽线', 166, 92, {
size: 21,
lineHeight: 30,
color: '#fff4d8',
bold: true,
align: Label.HorizontalAlign.LEFT,
overflow: Label.Overflow.SHRINK,
}, unspoolFrame.node);
this.unspoolHeaderLabel.node.setPosition(-242, 0, 0);
this.unspoolClothNode = createUINode('UnspoolClothCanvas', UNSPOOL_DISPLAY_WIDTH, UNSPOOL_DISPLAY_HEIGHT, unspoolFrame.node);
this.unspoolClothNode.setPosition(88, 0, 0);
this.unspoolClothTransform = this.unspoolClothNode.getComponent(UITransform)!;
const unspoolSprite = this.unspoolClothNode.addComponent(Sprite);
unspoolSprite.sizeMode = Sprite.SizeMode.CUSTOM;
unspoolSprite.spriteFrame = this.renderer.getUnspoolClothSpriteFrame();
this.unspoolClothNode.on(Node.EventType.TOUCH_START, this.onUnspoolClothTouch, this);
this.unspoolPanelNode.active = false;
// 隐形相对滑动轻提示环(松手即隐)
const relAnchor = createPanel('RelativeAnchor', 58, 58, {
fill: '#f7e7c426', stroke: '#fff7e082', strokeWidth: 2, radius: 29,
@@ -509,7 +564,7 @@ export class PlayView extends Component {
onClick: () => {
this.sound.unlock();
const gate = this.getNextChapterGate();
if (this.currentIndex + 1 < LEVELS.length && !gate.locked) {
if (!this.customMode && this.currentIndex + 1 < LEVELS.length && !gate.locked) {
this.loadLevel(this.currentIndex + 1);
} else {
this.onBackLobby();
@@ -670,10 +725,16 @@ export class PlayView extends Component {
}
public applyScreenMetrics(m: ScreenMetrics): void {
this.lastMetrics = m;
this.safeContentScale = Math.max(0.5, m.contentScale);
if (this.bgArtNode) applyCoverBackground(this.bgArtNode, m);
if (this.safeRoot) applySafeContentTransform(this.safeRoot, m);
if (!this.topBarNode) return;
this.layoutPlayArea();
}
private layoutPlayArea(): void {
if (!this.topBarNode || !this.lastMetrics) return;
const m = this.lastMetrics;
// 全面屏动态贴顶/贴底锚定并拉宽 HUD 与绣绷上下呼吸感,消除大块死空白
const h = m.safeHalfH;
@@ -681,20 +742,44 @@ export class PlayView extends Component {
const topBarY = h - 56;
const missionY = topBarY - 88 - e * 0.08;
const ribbonY = missionY - 68 - e * 0.08;
const dockY = -h + 84;
const hoopY = ((ribbonY - 20) + (dockY + 76)) / 2 + 8;
const dockY = -h + (this.customMode ? 128 : 84);
this.topBarNode.setPosition(0, topBarY, 0);
this.missionRowNode.setPosition(0, missionY, 0);
this.whisperRibbonNode.setPosition(0, ribbonY, 0);
this.dockTrayNode.setPosition(0, dockY, 0);
this.hoopNode.setPosition(0, hoopY, 0);
this.hoopShadowNode.setPosition(4, hoopY - 22, 0);
this.dragSurfaceNode.setPosition(0, hoopY - 10, 0);
this.resultFrameNode.setPosition(0, -h + 286, 0);
this.tutorialOverlay.setPosition(0, ribbonY - 94, 0);
this.resultFrameNode.setPosition(0, -h + (this.customMode ? 310 : 286), 0);
if (this.unspoolMode) {
const unspoolY = missionY - 96 - e * 0.04;
const ribbonY = dockY + 94;
const availTop = unspoolY - 70;
const availBottom = ribbonY + 24;
const availH = Math.max(480, availTop - availBottom);
const hoopScale = Math.min(0.95, availH / HOOP_DISPLAY_H);
const hoopY = (availTop + availBottom) / 2;
this.unspoolPanelNode.setPosition(0, unspoolY, 0);
this.whisperRibbonNode.setPosition(0, ribbonY, 0);
this.hoopNode.setPosition(0, hoopY, 0);
this.hoopNode.setScale(hoopScale, hoopScale, 1);
this.hoopShadowNode.setPosition(4 * hoopScale, hoopY - 22 * hoopScale, 0);
this.hoopShadowNode.setScale(hoopScale, hoopScale, 1);
this.dragSurfaceNode.setPosition(0, hoopY, 0);
this.dragSurfaceNode.getComponent(UITransform)!.setContentSize(740, availH + 20);
this.tutorialOverlay.setPosition(0, unspoolY, 0);
} else {
const ribbonY = missionY - 68 - e * 0.08;
const hoopY = ((ribbonY - 20) + (dockY + 76)) / 2 + 8;
this.whisperRibbonNode.setPosition(0, ribbonY, 0);
this.hoopNode.setPosition(0, hoopY, 0);
this.hoopNode.setScale(1, 1, 1);
this.hoopShadowNode.setPosition(4, hoopY - 22, 0);
this.hoopShadowNode.setScale(1, 1, 1);
this.dragSurfaceNode.setPosition(0, hoopY - 10, 0);
this.dragSurfaceNode.getComponent(UITransform)!.setContentSize(740, 940);
this.tutorialOverlay.setPosition(0, ribbonY - 94, 0);
}
}
private syncLoupeButton(): void {
@@ -736,7 +821,8 @@ export class PlayView extends Component {
if (this.pointer.relative) {
const uiLoc = event.getUILocation();
this.updateRelativeIndicator(uiLoc, false);
const scaleInv = 1 / this.safeContentScale;
const hoopScale = Math.max(0.5, this.hoopNode.scale.x);
const scaleInv = 1 / (this.safeContentScale * hoopScale);
const dx = (uiLoc.x - this.pointer.startUI.x) * scaleInv * (HOOP_WIDTH / HOOP_DISPLAY_W) * RELATIVE_GAIN;
const dy = -(uiLoc.y - this.pointer.startUI.y) * scaleInv * (HOOP_HEIGHT / HOOP_DISPLAY_H) * RELATIVE_GAIN;
if (this.state.drawing) this.state.drawing.fingerTip = null;
@@ -831,8 +917,27 @@ export class PlayView extends Component {
}
public loadLevel(index: number): void {
this.customMode = false;
this.currentIndex = index;
this.level = LEVELS[index];
const blueprint = LEVELS[index];
if (!blueprint) return;
this.level = blueprint.unspool ? { ...blueprint, balls: [] } : blueprint;
const numStr = index + 1 < 10 ? '0' + (index + 1) : String(index + 1);
this.setupLoadedLevel(`${numStr} ${this.level.name}`);
this.tutorialOverlay.active = !this.unspoolMode && index === 0 && !this.storage.hasSeenTutorial();
}
public loadCustomLevel(blueprint: LevelDef, headerTitle?: string): void {
this.customMode = true;
this.currentIndex = 0;
this.level = blueprint.unspool
? { ...blueprint, balls: [] }
: { ...blueprint, balls: blueprint.balls.map(b => ({ ...b })) };
this.setupLoadedLevel(headerTitle ?? blueprint.name);
this.tutorialOverlay.active = false;
}
private setupLoadedLevel(headerTitle: string): void {
this.targetCounts = {
gold: 0,
green: 0,
@@ -848,19 +953,16 @@ export class PlayView extends Component {
}
this.renderer.selectLevel(this.level);
const numStr = index + 1 < 10 ? '0' + (index + 1) : String(index + 1);
this.titleLabel.string = `${numStr} ${this.level.name}`;
if (this.nextBtn.label) this.nextBtn.label.string = index + 1 < LEVELS.length ? '下一关' : '返回大厅';
this.titleLabel.string = headerTitle;
if (this.nextBtn.label) {
this.nextBtn.label.string = !this.customMode && this.currentIndex + 1 < LEVELS.length ? '下一关' : '返回大厅';
}
this.layoutTopChips();
this.syncSoundButton();
this.syncLanguageChrome();
this.state.demoWatched = false;
this.resetLevel();
if (index === 0 && !this.storage.hasSeenTutorial()) {
this.tutorialOverlay.active = true;
} else {
this.tutorialOverlay.active = false;
}
this.layoutPlayArea();
}
private dismissTutorial(): void {
@@ -919,6 +1021,23 @@ export class PlayView extends Component {
this.pointer = null;
this.activeNestIndex = 0;
this.hideRelativeIndicator();
if (this.unspoolMode && this.level.unspool) {
this.level.balls = [];
this.unspoolHistory = [];
this.unspoolNextBallId = 100;
this.state.unspool = {
removedIds: [],
animating: null,
slotBallIds: this.level.unspool.slots.map(() => null),
deadlocked: false,
pulseTargetId: null,
pulseUntil: 0,
};
this.unspoolHeaderLabel.string = `${this.level.unspool.storyTitle}\n点线头抽线`;
this.renderer.renderUnspoolClothFrame(this.level.unspool, this.state.unspool, this.state.time, this.state.lines);
} else {
this.state.unspool = null;
}
this.setStatus(
this.state.demoWatched
? '已看过本关演示(本局最高 2 ★,换关后可重新挑战三星)。'
@@ -928,6 +1047,160 @@ export class PlayView extends Component {
this.renderer.renderFrame(this.state, this.activeNestIndex);
}
private pointToSegDist(px: number, py: number, ax: number, ay: number, bx: number, by: number): number {
const dx = bx - ax;
const dy = by - ay;
const lenSq = dx * dx + dy * dy;
const t = lenSq > 0 ? Math.max(0, Math.min(1, ((px - ax) * dx + (py - ay) * dy) / lenSq)) : 0;
return Math.hypot(px - (ax + dx * t), py - (ay + dy * t));
}
private onUnspoolClothTouch(event: EventTouch): void {
if (!this.unspoolMode || !this.level.unspool || !this.state.unspool) return;
if (this.state.complete || this.state.drawing || this.state.unspool.animating) return;
this.sound.unlock();
event.propagationStopped = true;
const uiLoc = event.getUILocation();
const local = this.unspoolClothTransform.convertToNodeSpaceAR(new Vec3(uiLoc.x, uiLoc.y, 0));
const { width, height } = this.unspoolClothTransform.contentSize;
const cx = (local.x / width + 0.5) * UNSPOOL_CLOTH_WIDTH;
const cy = (0.5 - local.y / height) * UNSPOOL_CLOTH_HEIGHT;
if (this.level.unspool.clips?.length) {
const hitLockedClip = this.level.unspool.clips.find(
clip => !isClipUnlocked(clip, this.state.lines) &&
cx >= clip.x && cx <= clip.x + clip.w && cy >= clip.y && cy <= clip.y + clip.h,
);
if (hitLockedClip) {
this.sound.block();
this.state.unspool.pulseTargetId = hitLockedClip.unlockSectionId;
this.state.unspool.pulseUntil = this.state.time + 2200;
this.setStatus('这块旧布被木夹夹住了!先绣出绣面上带同纹样木夹标示的针位即可松开。');
return;
}
}
const removed = new Set(this.state.unspool.removedIds);
const strands = this.level.unspool.strands;
const remaining = strands.filter(strand => !removed.has(strand.id));
let pickedStrand: typeof strands[number] | undefined;
let nearestTip = 33;
for (const strand of remaining) {
const [x, y] = strand.points[strand.points.length - 1];
const dist = Math.hypot(cx - x, cy - y);
if (dist < nearestTip) {
nearestTip = dist;
pickedStrand = strand;
}
}
if (!pickedStrand) {
pickedStrand = remaining.reverse().find(strand => strand.points.some(([x, y], index) => {
if (index === 0) return false;
const [px, py] = strand.points[index - 1];
return this.pointToSegDist(cx, cy, px, py, x, y) <= 14;
}));
}
if (!pickedStrand) return;
const lockedClip = isStrandClipLocked(this.level.unspool, pickedStrand, this.state.lines);
if (lockedClip) {
this.sound.block();
this.state.unspool.pulseTargetId = lockedClip.unlockSectionId;
this.state.unspool.pulseUntil = this.state.time + 2200;
this.setStatus('这缕线在被木夹锁住的旧布里,先绣出带同纹样木夹标示的针位即可松开!');
return;
}
const exposed = isStrandExposed(this.level.unspool, pickedStrand, removed, this.state.lines);
if (!exposed) {
const blockers = pickedStrand.coveredBy.filter(cid => !removed.has(cid)).length;
this.sound.block();
this.setStatus(
blockers > 1
? `这缕旧线被 ${blockers} 缕上层线压住,需先抽走压着它的上层发光线头!`
: '这缕旧线还压在底下,先抽走压着它的上层发光线头!',
);
return;
}
const capacity = this.level.unspool.capacity ?? this.level.unspool.slots.length;
const occupiedCount = this.state.unspool.slotBallIds.filter(id => id !== null).length;
if (occupiedCount >= capacity) {
this.sound.block();
this.setStatus(`线碗已装满(${occupiedCount}/${capacity})。先落针腾一格,或点「撤销」。`);
return;
}
const freeSlot = pickedStrand.slotIndex !== undefined && this.state.unspool.slotBallIds[pickedStrand.slotIndex] === null
? pickedStrand.slotIndex
: this.state.unspool.slotBallIds.indexOf(null);
if (freeSlot === -1) {
this.sound.block();
this.setStatus('线碗已经装满。先落针腾一格,或点「撤销」。');
return;
}
this.sound.unspool();
this.state.unspool.animating = { strandId: pickedStrand.id, progress: 0, slotIndex: freeSlot };
this.setStatus('滋溜抽线中,毛线正卷球滚入线碗…');
}
private finishUnspoolAnimation(): void {
if (!this.level.unspool || !this.state.unspool || !this.state.unspool.animating) return;
const { strandId, slotIndex } = this.state.unspool.animating;
const strand = this.level.unspool.strands.find(s => s.id === strandId);
const slotPos = this.level.unspool.slots[slotIndex];
this.state.unspool.animating = null;
if (!strand || !slotPos) return;
this.state.unspool.removedIds.push(strandId);
const ballId = this.unspoolNextBallId++;
const newBall: BallDef = { id: ballId, x: slotPos.x, y: slotPos.y, color: strand.color };
this.level.balls.push(newBall);
this.state.unspool.slotBallIds[slotIndex] = ballId;
this.unspoolHistory.push({ kind: 'unspool', strandId, slotIndex, ballId });
this.sound.pick(this.state.unspool.slotBallIds.filter(id => id !== null).length);
if (!this.checkUnspoolDeadlock()) {
const rem = this.level.unspool.strands.length - this.state.unspool.removedIds.length;
this.setStatus(
rem > 0
? `线球落入线碗 ${slotIndex + 1}!可继续抽线,或直接拖蚂蚁开始绣花。`
: '旧线已全部拆完,拖蚂蚁把线碗里的毛线织成新画吧!',
);
}
this.updateHud();
}
private checkUnspoolDeadlock(): boolean {
if (!this.unspoolMode || !this.level.unspool || !this.state.unspool) return false;
const capacity = this.level.unspool.capacity ?? this.level.unspool.slots.length;
const occupiedCount = this.state.unspool.slotBallIds.filter(id => id !== null).length;
if (occupiedCount < capacity) {
this.state.unspool.deadlocked = false;
return false;
}
const unlockedTargets = availableTargets(this.level, this.state.lines).filter(
t => !isTargetLocked(this.level, t.id, this.state.lines),
);
if (unlockedTargets.length === 0) {
this.state.unspool.deadlocked = false;
return false;
}
const unlockedColors = new Set(unlockedTargets.map(t => t.color));
const bowlColors = this.state.unspool.slotBallIds
.map(id => this.level.balls.find(b => b.id === id)?.color)
.filter((c): c is TargetColor => Boolean(c));
const canDeliver = bowlColors.some(c => unlockedColors.has(c));
this.state.unspool.deadlocked = !canDeliver;
if (!canDeliver) {
this.sound.block();
this.setStatus('线碗装满且对应针位还上着锁!点「撤销」换条拆线顺序试试~');
}
return !canDeliver;
}
private toggleHint(): void {
if (this.state.demo || this.state.complete) return;
const curTier = this.state.hint?.tier ?? 0;
@@ -969,7 +1242,28 @@ export class PlayView extends Component {
}
private undoLastLine(): void {
if (!this.state.lines.length || this.state.complete || this.state.demo) return;
if (this.state.complete || this.state.demo) return;
if (this.unspoolMode && this.state.unspool) {
if (this.state.unspool.animating || !this.unspoolHistory.length) return;
const last = this.unspoolHistory.pop()!;
if (last.kind === 'stitch') {
this.state.lines.pop();
for (const item of last.restoredBalls) {
this.state.unspool.slotBallIds[item.slotIndex] = item.ball.id;
}
this.setStatus('已收回上一笔刺绣,毛线球放回线碗。');
} else {
this.state.unspool.removedIds = this.state.unspool.removedIds.filter(id => id !== last.strandId);
this.state.unspool.slotBallIds[last.slotIndex] = null;
this.level.balls = this.level.balls.filter(b => b.id !== last.ballId);
this.setStatus('已把这缕旧线放回旧绣片,可以改抽其他线头。');
}
this.sound.undo();
this.checkUnspoolDeadlock();
this.updateHud();
return;
}
if (!this.state.lines.length) return;
this.state.lines.pop();
if (!this.state.lines.length) this.state.assisted = false;
this.sound.undo();
@@ -1116,7 +1410,26 @@ export class PlayView extends Component {
prepareRouteForRun(route, this.state.time);
this.state.lines.push(route);
this.state.hint = null;
this.setStatus(dispatchWarning(this.level, this.state.lines) || (route.picks.length > 1 ? '两颗球一起出发。' : '蚂蚁出发了,也可继续画下一笔。'));
if (this.unspoolMode && this.state.unspool) {
const restoredBalls: { slotIndex: number; ball: BallDef }[] = [];
for (const p of route.picks) {
const sIdx = this.state.unspool.slotBallIds.indexOf(p.ball.id);
if (sIdx >= 0) {
restoredBalls.push({ slotIndex: sIdx, ball: p.ball });
this.state.unspool.slotBallIds[sIdx] = null;
}
}
this.unspoolHistory.push({ kind: 'stitch', restoredBalls });
this.state.unspool.deadlocked = false;
}
this.setStatus(
dispatchWarning(this.level, this.state.lines) ||
(this.unspoolMode
? '蚂蚁出发啦!线碗已腾空,可以继续抽旧线~'
: route.picks.length > 1
? '两颗球一起出发。'
: '蚂蚁出发了,也可继续画下一笔。'),
);
this.updateHud();
return true;
}
@@ -1154,6 +1467,7 @@ export class PlayView extends Component {
const elapsed = now - route.startedAt;
let pause = 0;
let delivered = false;
let unlockedAnyClip = false;
for (let i = 0; i < route.events.length; i++) {
const ev = route.events[i];
const ms = ev.ms ?? 0;
@@ -1170,7 +1484,17 @@ export class PlayView extends Component {
route.carry.shift();
ev.arrivedAt = now;
delivered = true;
this.sound.deliver();
const openedClip = this.level.unspool?.clips?.find(c => c.unlockSectionId === ev.target.id);
if (openedClip) {
unlockedAnyClip = true;
this.sound.bonus();
if (this.state.unspool?.pulseTargetId === ev.target.id) {
this.state.unspool.pulseTargetId = null;
}
if (!this.state.drawing) this.setStatus('咔哒!旧布木夹松开了,右侧旧料已解锁可抽!');
} else {
this.sound.deliver();
}
} else if (isSpoolEvent(ev)) {
ev.collectedAt = now;
this.sound.bonus();
@@ -1205,7 +1529,9 @@ export class PlayView extends Component {
route.ant.walk = walking;
if (delivered) {
if (!this.state.drawing) this.setStatus(dispatchWarning(this.level, this.state.lines) || '送达落针!');
if (!this.state.drawing && !unlockedAnyClip) {
this.setStatus(dispatchWarning(this.level, this.state.lines) || '送达落针!');
}
this.updateHud();
}
if (elapsed >= route.duration) {
@@ -1378,9 +1704,10 @@ export class PlayView extends Component {
}
}
this.undoBtn.setEnabled(!this.state.demo && !this.state.complete && this.state.lines.length > 0);
this.demoBtn.setEnabled(!this.state.demo);
this.hintBtn.setEnabled(!this.state.demo && !this.state.complete);
const canUndo = this.unspoolMode ? this.unspoolHistory.length > 0 : this.state.lines.length > 0;
this.undoBtn.setEnabled(!this.state.demo && !this.state.complete && canUndo);
this.demoBtn.setEnabled(!this.state.demo && !this.unspoolMode);
this.hintBtn.setEnabled(!this.state.demo && !this.state.complete && !this.unspoolMode);
this.hintHalo.active = Boolean(this.state.hint);
if (this.hintBtn.label) {
this.hintBtn.label.string = this.state.hint ? `提示 ${this.state.hint.tier}/3` : '提示';
@@ -1391,6 +1718,7 @@ export class PlayView extends Component {
this.syncLoupeButton();
this.dockTrayNode.active = !this.state.complete;
this.unspoolPanelNode.active = this.unspoolMode && !this.state.complete;
this.resultOverlay.active = this.state.complete;
if (this.state.complete) {
const rawStars = scoreForLength(this.level, totalLength(this.state.lines));
@@ -1411,7 +1739,7 @@ export class PlayView extends Component {
this.resultLengthLabel.string = '用线 ' + formatLength(totalLength(this.state.lines)) + suffix;
if (this.nextBtn.label) {
const gate = this.getNextChapterGate();
if (this.currentIndex + 1 >= LEVELS.length) {
if (this.customMode || this.currentIndex + 1 >= LEVELS.length) {
this.nextBtn.label.string = en ? 'Lobby' : '返回大厅';
} else if (gate.locked) {
this.nextBtn.label.string = en ? `Need ${gate.req}★` : `集满${gate.req}★解锁下章`;
@@ -1442,6 +1770,16 @@ export class PlayView extends Component {
const clampedMs = Math.min(50, Math.max(0, dt * 1000));
this.state.time += clampedMs;
if (this.unspoolMode && this.level.unspool && this.state.unspool) {
if (this.state.unspool.animating) {
this.state.unspool.animating.progress += clampedMs / 340;
if (this.state.unspool.animating.progress >= 1) {
this.finishUnspoolAnimation();
}
}
this.renderer.renderUnspoolClothFrame(this.level.unspool, this.state.unspool, this.state.time, this.state.lines);
}
if (this.state.demo) this.runDemo(this.state.time);
for (const line of this.state.lines) {
if (!line.finished) this.animateRoute(line, this.state.time);
@@ -1472,7 +1810,7 @@ export class PlayView extends Component {
this.state.complete = true;
this.state.demo = false;
this.setStatus(this.state.assisted ? '演示完成,点「重绣本关」自己试一试。' : '这一幅绣好啦,可以保存绣画留念!');
if (!this.state.assisted) {
if (!this.state.assisted && !this.customMode) {
const len = totalLength(this.state.lines);
const rawStars = scoreForLength(this.level, len);
const earnedStars = this.state.hintCapped ? Math.min(2, rawStars) : rawStars;