refactor: udpate to new design
This commit is contained in:
parent
c9acb7f228
commit
65684e6cf5
|
|
@ -1,25 +1,27 @@
|
|||
import Phaser from 'phaser';
|
||||
import { ReactiveScene } from 'boardgame-phaser';
|
||||
import { generatePointCrawlMap, type PointCrawlMap, MapNodeType } from 'boardgame-core/samples/slay-the-spire-like';
|
||||
import { generatePointCrawlMap, type PointCrawlMap, type MapNode, MapNodeType } from 'boardgame-core/samples/slay-the-spire-like';
|
||||
|
||||
const NODE_COLORS: Record<MapNodeType, number> = {
|
||||
[MapNodeType.Start]: 0x44aa44,
|
||||
[MapNodeType.Combat]: 0xcc4444,
|
||||
[MapNodeType.Event]: 0xaaaa44,
|
||||
[MapNodeType.End]: 0xcc8844,
|
||||
[MapNodeType.Minion]: 0xcc4444,
|
||||
[MapNodeType.Elite]: 0xcc44cc,
|
||||
[MapNodeType.Shelter]: 0x44cccc,
|
||||
[MapNodeType.NPC]: 0x4488cc,
|
||||
[MapNodeType.Boss]: 0xcc8844,
|
||||
[MapNodeType.Event]: 0xaaaa44,
|
||||
[MapNodeType.Camp]: 0x44cccc,
|
||||
[MapNodeType.Shop]: 0x4488cc,
|
||||
[MapNodeType.Curio]: 0x8844cc,
|
||||
};
|
||||
|
||||
const NODE_LABELS: Record<MapNodeType, string> = {
|
||||
[MapNodeType.Start]: '起点',
|
||||
[MapNodeType.Combat]: '战斗',
|
||||
[MapNodeType.Event]: '事件',
|
||||
[MapNodeType.End]: '终点',
|
||||
[MapNodeType.Minion]: '战斗',
|
||||
[MapNodeType.Elite]: '精英',
|
||||
[MapNodeType.Shelter]: '篝火',
|
||||
[MapNodeType.NPC]: 'NPC',
|
||||
[MapNodeType.Boss]: 'Boss',
|
||||
[MapNodeType.Event]: '事件',
|
||||
[MapNodeType.Camp]: '篝火',
|
||||
[MapNodeType.Shop]: '商店',
|
||||
[MapNodeType.Curio]: '奇遇',
|
||||
};
|
||||
|
||||
export class MapViewerScene extends ReactiveScene {
|
||||
|
|
@ -149,8 +151,8 @@ export class MapViewerScene extends ReactiveScene {
|
|||
this.titleText.setText(`Map Viewer (Seed: ${this.seed})`);
|
||||
|
||||
// Calculate map bounds
|
||||
const maxLayer = 12; // TOTAL_LAYERS - 1
|
||||
const maxNodesInLayer = 6; // widest layer
|
||||
const maxLayer = 9; // TOTAL_LAYERS - 1 (10 layers: 0-9)
|
||||
const maxNodesInLayer = 5; // widest layer (settlement has 4 nodes)
|
||||
const mapWidth = (maxNodesInLayer - 1) * this.NODE_SPACING + 200;
|
||||
const mapHeight = maxLayer * this.LAYER_HEIGHT + 200;
|
||||
|
||||
|
|
@ -203,9 +205,9 @@ export class MapViewerScene extends ReactiveScene {
|
|||
);
|
||||
|
||||
// Encounter name (if available)
|
||||
if ('encounter' in node && (node as any).encounter) {
|
||||
if (node.encounter) {
|
||||
this.mapContainer.add(
|
||||
this.add.text(posX, posY + this.NODE_RADIUS + 12, (node as any).encounter.name ?? '', {
|
||||
this.add.text(posX, posY + this.NODE_RADIUS + 12, node.encounter.name, {
|
||||
fontSize: '10px',
|
||||
color: '#cccccc',
|
||||
}).setOrigin(0.5)
|
||||
|
|
@ -237,7 +239,7 @@ export class MapViewerScene extends ReactiveScene {
|
|||
});
|
||||
}
|
||||
|
||||
private getNodeX(node: any): number {
|
||||
private getNodeX(node: MapNode): number {
|
||||
const layer = this.map!.layers[node.layerIndex];
|
||||
const nodeIndex = layer.nodeIds.indexOf(node.id);
|
||||
const totalNodes = layer.nodeIds.length;
|
||||
|
|
@ -245,7 +247,7 @@ export class MapViewerScene extends ReactiveScene {
|
|||
return -layerWidth / 2 + nodeIndex * this.NODE_SPACING;
|
||||
}
|
||||
|
||||
private getNodeY(node: any): number {
|
||||
private getNodeY(node: MapNode): number {
|
||||
return -600 + node.layerIndex * this.LAYER_HEIGHT;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue