Skip to content

Commit 8dd9eb3

Browse files
committed
feat: update maps for kili
1 parent ec8c588 commit 8dd9eb3

File tree

3 files changed

+17
-6
lines changed

3 files changed

+17
-6
lines changed
-1.54 MB
Loading
-793 KB
Loading

demos/AOTAI_Hike/frontend/src/phaser_view.js

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,8 @@ export function initPhaser() {
8080
// - Add/remove layers by editing this list (order = render order, bottom -> top).
8181
// - For each sceneId, assets should exist at:
8282
// `./assets/scenes/scene_${sceneId}/scene_0_${layer}.png`
83-
const SCENE_IDS = ["base"];
83+
// - base = 鳌太, kilimanjaro = 乞力马扎罗; select by theme in setState
84+
const SCENE_IDS = ["base", "kilimanjaro"];
8485
const SCENE_LAYERS = ["base", "props"];
8586
const sceneKey = (sceneId, layer) => `scene:${sceneId}:${layer}`;
8687
const sceneFile = (sceneId, layer) => `scenes/scene_${sceneId}/scene_0_${layer}.png`;
@@ -139,6 +140,7 @@ export function initPhaser() {
139140
this._ws = null;
140141
this._walkKey = "";
141142
this._sceneKey = "";
143+
this._theme = null; // current theme for scene choice (aotai -> base, kili -> kilimanjaro)
142144

143145
this.mainCam = null;
144146

@@ -297,12 +299,17 @@ export function initPhaser() {
297299
say: (roleId, text) => this._say(roleId, text),
298300
};
299301

300-
// initial paint
302+
// initial paint: pick scene from theme (kili -> kilimanjaro, else base)
303+
const initialTheme = worldState?.theme || "aotai";
304+
const initialSceneId = initialTheme === "kili" ? "kilimanjaro" : "base";
305+
this._theme = initialTheme;
306+
this._swapScene(initialSceneId);
301307
this.setState({
302308
current_node_id: mapStartNodeId || "start",
303309
visited_node_ids: [mapStartNodeId || "start"],
304310
weather: "cloudy",
305311
time_of_day: "morning",
312+
theme: initialTheme,
306313
});
307314
}
308315

@@ -992,20 +999,24 @@ export function initPhaser() {
992999
this._windActive = String(weather) === "windy";
9931000
this._fogActive = String(weather) === "foggy";
9941001

1002+
// theme change: kili -> scene_kilimanjaro, else -> scene_base
1003+
const theme = String(ws?.theme || worldState?.theme || "aotai");
1004+
const themeChanged = theme !== this._theme;
1005+
if (themeChanged) this._theme = theme;
1006+
9951007
// render roles on big map
9961008
try {
9971009
this._syncRolesOnMap(ws);
9981010
} catch {}
9991011

1000-
// 2) update main world: re-render ONLY when location/segment changes (not every km/time tick)
1012+
// 2) update main world: re-render when location/segment or theme changes
10011013
const segFrom = ws?.in_transit_from_node_id || nodeId;
10021014
const segTo = ws?.in_transit_to_node_id || nodeId;
10031015
const sceneKey = `${nodeId}|${segFrom}|${segTo}`;
10041016
const sceneChanged = sceneKey !== this._sceneKey;
10051017
this._sceneKey = sceneKey;
1006-
if (nodeChanged || sceneChanged) {
1007-
// Only swap/re-layout when scene id changes (avoid refresh when scene stays the same).
1008-
const nextSceneId = "base";
1018+
if (nodeChanged || sceneChanged || themeChanged) {
1019+
const nextSceneId = theme === "kili" ? "kilimanjaro" : "base";
10091020
if (nextSceneId !== this._sceneId) this._swapScene(nextSceneId);
10101021
}
10111022

0 commit comments

Comments
 (0)