|
|
|
@ -31,6 +31,8 @@ export default class ChaseScene extends BaseScene { |
|
|
|
private model?: ChaseModelLike; |
|
|
|
private readonly modelFactory?: () => ChaseModelLike; |
|
|
|
private hudText?: Text; |
|
|
|
private winCountText?: Text; |
|
|
|
private seedText?: Text; |
|
|
|
private setupText?: Text; |
|
|
|
private setupLayer = new Container(); |
|
|
|
private graphLayer = new Container(); |
|
|
|
@ -80,6 +82,29 @@ export default class ChaseScene extends BaseScene { |
|
|
|
this.hudText.position.set(24, 24); |
|
|
|
this.stage.addChild(this.hudText); |
|
|
|
|
|
|
|
this.winCountText = new Text({ |
|
|
|
text: "", |
|
|
|
style: new TextStyle({ |
|
|
|
fontSize: 18, |
|
|
|
fill: 0xffffff, |
|
|
|
fontFamily: "'Microsoft YaHei', 'PingFang SC', system-ui, sans-serif", |
|
|
|
}), |
|
|
|
}); |
|
|
|
this.winCountText.position.set(24, 6); |
|
|
|
this.stage.addChild(this.winCountText); |
|
|
|
|
|
|
|
this.seedText = new Text({ |
|
|
|
text: "", |
|
|
|
style: new TextStyle({ |
|
|
|
fontSize: 18, |
|
|
|
fill: 0xffffff, |
|
|
|
fontFamily: "'Microsoft YaHei', 'PingFang SC', system-ui, sans-serif", |
|
|
|
}), |
|
|
|
}); |
|
|
|
this.seedText.anchor.set(1, 0); |
|
|
|
this.seedText.position.set(760, 6); |
|
|
|
this.stage.addChild(this.seedText); |
|
|
|
|
|
|
|
this.setupText = new Text({ |
|
|
|
text: "", |
|
|
|
style: new TextStyle({ |
|
|
|
@ -137,11 +162,13 @@ export default class ChaseScene extends BaseScene { |
|
|
|
} |
|
|
|
|
|
|
|
public refreshView(): void { |
|
|
|
if (!this.model || !this.hudText || !this.setupText) { |
|
|
|
if (!this.model || !this.hudText || !this.setupText || !this.winCountText || !this.seedText) { |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
const state = this.model.getState(); |
|
|
|
this.winCountText.text = `成功次数: ${state.winCount}`; |
|
|
|
this.seedText.text = `Seed: ${state.snapshot.seed}`; |
|
|
|
this.hudText.text = `Turn ${state.turn} | ${state.snapshot.status} | thief=${state.snapshot.thiefNodeId} guard=${state.snapshot.guardNodeId}`; |
|
|
|
this.setupText.text = `difficulty=${this.selectedDifficulty} | seed=${this.seedInput.trim() || "(auto)"} | locked=${this.difficultyLocked ? "yes" : "no"}`; |
|
|
|
this.drawDifficultyButtons(); |
|
|
|
@ -152,6 +179,23 @@ export default class ChaseScene extends BaseScene { |
|
|
|
child.destroy({ children: true }); |
|
|
|
} |
|
|
|
|
|
|
|
const thiefNode = state.snapshot.graph.nodes[state.snapshot.thiefNodeId]; |
|
|
|
const availableMoves = thiefNode |
|
|
|
? thiefNode.neighbors.filter((id) => id !== state.snapshot.guardNodeId) |
|
|
|
: []; |
|
|
|
for (const nodeId of availableMoves) { |
|
|
|
const node = state.snapshot.graph.nodes[nodeId]; |
|
|
|
if (!node) { |
|
|
|
continue; |
|
|
|
} |
|
|
|
const highlight = new Graphics(); |
|
|
|
highlight.label = "move-highlight"; |
|
|
|
highlight.circle(0, 0, NODE_RADIUS + 8); |
|
|
|
highlight.stroke({ width: 3, color: 0xfacc15, alpha: 0.9 }); |
|
|
|
highlight.position.set(node.q * NODE_GAP, node.r * NODE_GAP); |
|
|
|
this.graphLayer.addChild(highlight); |
|
|
|
} |
|
|
|
|
|
|
|
const nodes = Object.values(state.snapshot.graph.nodes); |
|
|
|
for (const node of nodes) { |
|
|
|
const nodeView = new Graphics(); |
|
|
|
|