mirror of
https://github.com/ad044/lainTSX.git
synced 2024-10-22 23:19:06 +00:00
fully ported to the new event handler
This commit is contained in:
parent
cddbc7ce62
commit
e0cc665c63
19 changed files with 311 additions and 544 deletions
|
@ -1,6 +1,5 @@
|
||||||
import { useCallback, useEffect } from "react";
|
import { useCallback, useEffect } from "react";
|
||||||
import { useHudStore } from "../../store";
|
import { useHudStore } from "../../store";
|
||||||
import game_action_mappings from "../../resources/game_action_mappings.json";
|
|
||||||
import { StateManagerProps } from "./EventManager";
|
import { StateManagerProps } from "./EventManager";
|
||||||
|
|
||||||
const BlueOrbHUDManager = (props: StateManagerProps) => {
|
const BlueOrbHUDManager = (props: StateManagerProps) => {
|
||||||
|
@ -46,19 +45,10 @@ const BlueOrbHUDManager = (props: StateManagerProps) => {
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (props.eventState) {
|
if (props.eventState) {
|
||||||
const eventObject: any =
|
const eventAction = props.eventState.event;
|
||||||
game_action_mappings[
|
const newActiveHudId = props.eventState.newActiveHudId;
|
||||||
props.eventState as keyof typeof game_action_mappings
|
|
||||||
];
|
|
||||||
|
|
||||||
if (eventObject) {
|
const dispatchedObject = dispatchObject(eventAction, newActiveHudId);
|
||||||
const eventAction = eventObject.action;
|
|
||||||
const targetBlueOrbHudId = eventObject.target_hud_id;
|
|
||||||
|
|
||||||
const dispatchedObject = dispatchObject(
|
|
||||||
eventAction,
|
|
||||||
targetBlueOrbHudId
|
|
||||||
);
|
|
||||||
|
|
||||||
if (dispatchedObject) {
|
if (dispatchedObject) {
|
||||||
toggleHud();
|
toggleHud();
|
||||||
|
@ -69,7 +59,6 @@ const BlueOrbHUDManager = (props: StateManagerProps) => {
|
||||||
}, dispatchedObject.actionDelay);
|
}, dispatchedObject.actionDelay);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}, [props.eventState, setActiveBlueOrbHudId, toggleHud, dispatchObject]);
|
}, [props.eventState, setActiveBlueOrbHudId, toggleHud, dispatchObject]);
|
||||||
return null;
|
return null;
|
||||||
};
|
};
|
||||||
|
|
|
@ -22,7 +22,7 @@ type BlueOrbDispatcher = {
|
||||||
move_left: BlueOrbDispatchData;
|
move_left: BlueOrbDispatchData;
|
||||||
move_right: BlueOrbDispatchData;
|
move_right: BlueOrbDispatchData;
|
||||||
change_blue_orb: BlueOrbDispatchData;
|
change_blue_orb: BlueOrbDispatchData;
|
||||||
select_blue_orb: BlueOrbDispatchData;
|
throw_blue_orb: BlueOrbDispatchData;
|
||||||
};
|
};
|
||||||
|
|
||||||
const BlueOrbManager = (props: StateManagerProps) => {
|
const BlueOrbManager = (props: StateManagerProps) => {
|
||||||
|
@ -120,9 +120,9 @@ const BlueOrbManager = (props: StateManagerProps) => {
|
||||||
value: [newActiveBlueOrbId, newBlueOrbColIdx, newBlueOrbRowIdx],
|
value: [newActiveBlueOrbId, newBlueOrbColIdx, newBlueOrbRowIdx],
|
||||||
actionDelay: 0,
|
actionDelay: 0,
|
||||||
},
|
},
|
||||||
select_blue_orb: {
|
throw_blue_orb: {
|
||||||
action: animateActiveBlueOrbThrow,
|
action: animateActiveBlueOrbThrow,
|
||||||
value: true,
|
value: [true],
|
||||||
actionDelay: 0,
|
actionDelay: 0,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
|
@ -52,17 +52,24 @@ export type GameContext = {
|
||||||
blueOrbColIdx: number;
|
blueOrbColIdx: number;
|
||||||
currentLevel: string;
|
currentLevel: string;
|
||||||
siteRotIdx: string;
|
siteRotIdx: string;
|
||||||
|
activeMediaComponent: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
const EventManager = () => {
|
const EventManager = () => {
|
||||||
|
const currentScene = useSceneStore((state) => state.currentScene);
|
||||||
|
|
||||||
|
// main scene
|
||||||
const blueOrbRowIdx = useBlueOrbStore((state) => state.blueOrbRowIdx);
|
const blueOrbRowIdx = useBlueOrbStore((state) => state.blueOrbRowIdx);
|
||||||
const blueOrbColIdx = useBlueOrbStore((state) => state.blueOrbColIdx);
|
const blueOrbColIdx = useBlueOrbStore((state) => state.blueOrbColIdx);
|
||||||
|
|
||||||
const siteRotIdx = useSiteStore((state) => state.siteRotIdx);
|
const siteRotIdx = useSiteStore((state) => state.siteRotIdx);
|
||||||
const currentLevel = useLevelStore((state) => state.currentLevel);
|
const currentLevel = useLevelStore((state) => state.currentLevel);
|
||||||
|
|
||||||
|
// media scene
|
||||||
|
const activeMediaComponent = useMediaStore(
|
||||||
|
(state) => state.activeMediaComponent
|
||||||
|
);
|
||||||
|
|
||||||
const [eventState, setEventState] = useState<any>();
|
const [eventState, setEventState] = useState<any>();
|
||||||
const currentScene = useSceneStore((state) => state.currentScene);
|
|
||||||
|
|
||||||
const [inputCooldown, setInputCooldown] = useState(false);
|
const [inputCooldown, setInputCooldown] = useState(false);
|
||||||
|
|
||||||
|
@ -73,8 +80,16 @@ const EventManager = () => {
|
||||||
blueOrbRowIdx: blueOrbRowIdx,
|
blueOrbRowIdx: blueOrbRowIdx,
|
||||||
blueOrbColIdx: blueOrbColIdx,
|
blueOrbColIdx: blueOrbColIdx,
|
||||||
currentLevel: currentLevel,
|
currentLevel: currentLevel,
|
||||||
|
activeMediaComponent: activeMediaComponent,
|
||||||
}),
|
}),
|
||||||
[blueOrbColIdx, blueOrbRowIdx, currentLevel, currentScene, siteRotIdx]
|
[
|
||||||
|
activeMediaComponent,
|
||||||
|
blueOrbColIdx,
|
||||||
|
blueOrbRowIdx,
|
||||||
|
currentLevel,
|
||||||
|
currentScene,
|
||||||
|
siteRotIdx,
|
||||||
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
const handleKeyPress = useCallback(
|
const handleKeyPress = useCallback(
|
||||||
|
@ -86,7 +101,7 @@ const EventManager = () => {
|
||||||
if (keyPress && !inputCooldown) {
|
if (keyPress && !inputCooldown) {
|
||||||
gameContext.keyPress = keyPress;
|
gameContext.keyPress = keyPress;
|
||||||
const event = computeAction(gameContext);
|
const event = computeAction(gameContext);
|
||||||
console.log(event)
|
console.log(event);
|
||||||
setEventState(event);
|
setEventState(event);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -109,12 +124,12 @@ const EventManager = () => {
|
||||||
<SiteManager eventState={eventState!} />
|
<SiteManager eventState={eventState!} />
|
||||||
<LainManager eventState={eventState!} />
|
<LainManager eventState={eventState!} />
|
||||||
<MiddleRingManager eventState={eventState!} />
|
<MiddleRingManager eventState={eventState!} />
|
||||||
{/*<MediaComponentManager eventState={eventState!} />*/}
|
<MediaComponentManager eventState={eventState!} />
|
||||||
{/*<MediaWordManager eventState={eventState!} />*/}
|
<MediaWordManager eventState={eventState!} />
|
||||||
{/*<MediaElementManager eventState={eventState!} />*/}
|
<MediaElementManager eventState={eventState!} />
|
||||||
<SceneManager eventState={eventState!} />
|
<SceneManager eventState={eventState!} />
|
||||||
<YellowTextManager eventState={eventState!} />
|
<YellowTextManager eventState={eventState!} />
|
||||||
{/*<MediaImageManager eventState={eventState!} />*/}
|
<MediaImageManager eventState={eventState!} />
|
||||||
<LevelManager eventState={eventState!} />
|
<LevelManager eventState={eventState!} />
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
import { useCallback, useEffect } from "react";
|
import { useCallback, useEffect } from "react";
|
||||||
import { useTextRendererStore } from "../../store";
|
import { useTextRendererStore } from "../../store";
|
||||||
import game_action_mappings from "../../resources/game_action_mappings.json";
|
|
||||||
import site_a from "../../resources/site_a.json";
|
import site_a from "../../resources/site_a.json";
|
||||||
import { StateManagerProps } from "./EventManager";
|
import { StateManagerProps } from "./EventManager";
|
||||||
import blue_orb_huds from "../../resources/blue_orb_huds.json";
|
import blue_orb_huds from "../../resources/blue_orb_huds.json";
|
||||||
|
@ -18,13 +17,12 @@ const GreenTextManager = (props: StateManagerProps) => {
|
||||||
);
|
);
|
||||||
|
|
||||||
const toggleAndSetGreenText = useCallback(
|
const toggleAndSetGreenText = useCallback(
|
||||||
(targetBlueOrbId: string, targetBlueOrbHudId: string, delay: number) => {
|
(newActiveBlueOrbId: string, newActiveHudId: string, delay: number) => {
|
||||||
const targetGreenText =
|
const targetGreenText =
|
||||||
site_a[targetBlueOrbId as keyof typeof site_a].title;
|
site_a[newActiveBlueOrbId as keyof typeof site_a].title;
|
||||||
|
|
||||||
const targetGreenTextPosData =
|
const targetGreenTextPosData =
|
||||||
blue_orb_huds[targetBlueOrbHudId as keyof typeof blue_orb_huds]
|
blue_orb_huds[newActiveHudId as keyof typeof blue_orb_huds].medium_text;
|
||||||
.medium_text;
|
|
||||||
|
|
||||||
toggleGreenText();
|
toggleGreenText();
|
||||||
|
|
||||||
|
@ -42,27 +40,27 @@ const GreenTextManager = (props: StateManagerProps) => {
|
||||||
);
|
);
|
||||||
|
|
||||||
const dispatchObject = useCallback(
|
const dispatchObject = useCallback(
|
||||||
(event: string, targetBlueOrbId: string, targetBlueOrbHudId: string) => {
|
(event: string, newActiveBlueOrbId: string, newActiveHudId: string) => {
|
||||||
const dispatcherObjects = {
|
const dispatcherObjects = {
|
||||||
move_up: {
|
move_up: {
|
||||||
action: toggleAndSetGreenText,
|
action: toggleAndSetGreenText,
|
||||||
value: [targetBlueOrbId, targetBlueOrbHudId, 3903.704],
|
value: [newActiveBlueOrbId, newActiveHudId, 3903.704],
|
||||||
},
|
},
|
||||||
move_down: {
|
move_down: {
|
||||||
action: toggleAndSetGreenText,
|
action: toggleAndSetGreenText,
|
||||||
value: [targetBlueOrbId, targetBlueOrbHudId, 3903.704],
|
value: [newActiveBlueOrbId, newActiveHudId, 3903.704],
|
||||||
},
|
},
|
||||||
move_left: {
|
move_left: {
|
||||||
action: toggleAndSetGreenText,
|
action: toggleAndSetGreenText,
|
||||||
value: [targetBlueOrbId, targetBlueOrbHudId, 3903.704],
|
value: [newActiveBlueOrbId, newActiveHudId, 3903.704],
|
||||||
},
|
},
|
||||||
move_right: {
|
move_right: {
|
||||||
action: toggleAndSetGreenText,
|
action: toggleAndSetGreenText,
|
||||||
value: [targetBlueOrbId, targetBlueOrbHudId, 3903.704],
|
value: [newActiveBlueOrbId, newActiveHudId, 3903.704],
|
||||||
},
|
},
|
||||||
change_blue_orb: {
|
change_blue_orb: {
|
||||||
action: toggleAndSetGreenText,
|
action: toggleAndSetGreenText,
|
||||||
value: [targetBlueOrbId, targetBlueOrbHudId, 500],
|
value: [newActiveBlueOrbId, newActiveHudId, 500],
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -73,27 +71,20 @@ const GreenTextManager = (props: StateManagerProps) => {
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (props.eventState) {
|
if (props.eventState) {
|
||||||
const eventObject: any =
|
const eventAction = props.eventState.event;
|
||||||
game_action_mappings[
|
const newActiveBlueOrbId = props.eventState.newActiveBlueOrbId;
|
||||||
props.eventState as keyof typeof game_action_mappings
|
const newActiveHudId = props.eventState.newActiveHudId;
|
||||||
];
|
|
||||||
|
|
||||||
if (eventObject) {
|
|
||||||
const eventAction = eventObject.action;
|
|
||||||
const targetBlueOrbId = eventObject.target_blue_orb_id;
|
|
||||||
const targetBlueOrbHudId = eventObject.target_hud_id;
|
|
||||||
|
|
||||||
const dispatchedObject = dispatchObject(
|
const dispatchedObject = dispatchObject(
|
||||||
eventAction,
|
eventAction,
|
||||||
targetBlueOrbId,
|
newActiveBlueOrbId,
|
||||||
targetBlueOrbHudId
|
newActiveHudId
|
||||||
);
|
);
|
||||||
|
|
||||||
if (dispatchedObject) {
|
if (dispatchedObject) {
|
||||||
dispatchedObject.action.apply(null, dispatchedObject.value as any);
|
dispatchedObject.action.apply(null, dispatchedObject.value as any);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}, [props.eventState, dispatchObject]);
|
}, [props.eventState, dispatchObject]);
|
||||||
return null;
|
return null;
|
||||||
};
|
};
|
||||||
|
|
|
@ -28,7 +28,7 @@ const LainManager = (props: StateManagerProps) => {
|
||||||
value: "move_right",
|
value: "move_right",
|
||||||
duration: 3904.704,
|
duration: 3904.704,
|
||||||
},
|
},
|
||||||
select_blue_orb: {
|
throw_blue_orb: {
|
||||||
action: setLainMoveState,
|
action: setLainMoveState,
|
||||||
value: "throwBlueOrb",
|
value: "throwBlueOrb",
|
||||||
duration: 3904.704,
|
duration: 3904.704,
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
import { useCallback, useEffect } from "react";
|
import { useCallback, useEffect } from "react";
|
||||||
import { StateManagerProps } from "./EventManager";
|
import { StateManagerProps } from "./EventManager";
|
||||||
import { useMediaStore } from "../../store";
|
import { useMediaStore } from "../../store";
|
||||||
import game_action_mappings from "../../resources/game_action_mappings.json";
|
|
||||||
import blue_orb_directions from "../../resources/blue_orb_directions.json";
|
|
||||||
|
|
||||||
const MediaComponentManager = (props: StateManagerProps) => {
|
const MediaComponentManager = (props: StateManagerProps) => {
|
||||||
const setActiveMediaComponent = useMediaStore(
|
const setActiveMediaComponent = useMediaStore(
|
||||||
|
@ -49,39 +47,39 @@ const MediaComponentManager = (props: StateManagerProps) => {
|
||||||
);
|
);
|
||||||
|
|
||||||
const dispatchObject = useCallback(
|
const dispatchObject = useCallback(
|
||||||
(event: string, targetMediaComponent: string) => {
|
(event: string) => {
|
||||||
const dispatcherObjects = {
|
const dispatcherObjects = {
|
||||||
fstWord_up: {
|
fstWord_up: {
|
||||||
action: setActiveMediaComponent,
|
action: setActiveMediaComponent,
|
||||||
value: targetMediaComponent,
|
value: "thirdWord",
|
||||||
},
|
},
|
||||||
fstWord_down: {
|
fstWord_down: {
|
||||||
action: setActiveMediaComponent,
|
action: setActiveMediaComponent,
|
||||||
value: targetMediaComponent,
|
value: "sndWord",
|
||||||
},
|
},
|
||||||
sndWord_up: {
|
sndWord_up: {
|
||||||
action: setActiveMediaComponent,
|
action: setActiveMediaComponent,
|
||||||
value: targetMediaComponent,
|
value: "fstWord",
|
||||||
},
|
},
|
||||||
sndWord_down: {
|
sndWord_down: {
|
||||||
action: setActiveMediaComponent,
|
action: setActiveMediaComponent,
|
||||||
value: targetMediaComponent,
|
value: "thirdWord",
|
||||||
},
|
},
|
||||||
thirdWord_down: {
|
thirdWord_down: {
|
||||||
action: setActiveMediaComponent,
|
action: setActiveMediaComponent,
|
||||||
value: targetMediaComponent,
|
value: "fstWord",
|
||||||
},
|
},
|
||||||
thirdWord_up: {
|
thirdWord_up: {
|
||||||
action: setActiveMediaComponent,
|
action: setActiveMediaComponent,
|
||||||
value: targetMediaComponent,
|
value: "sndWord",
|
||||||
},
|
},
|
||||||
play_down: {
|
play_down: {
|
||||||
action: setActiveMediaComponent,
|
action: setActiveMediaComponent,
|
||||||
value: targetMediaComponent,
|
value: "exit",
|
||||||
},
|
},
|
||||||
exit_up: {
|
exit_up: {
|
||||||
action: setActiveMediaComponent,
|
action: setActiveMediaComponent,
|
||||||
value: targetMediaComponent,
|
value: "play",
|
||||||
},
|
},
|
||||||
switch_to_right_side_from_play: {
|
switch_to_right_side_from_play: {
|
||||||
action: switchToRightSide,
|
action: switchToRightSide,
|
||||||
|
@ -103,7 +101,7 @@ const MediaComponentManager = (props: StateManagerProps) => {
|
||||||
action: switchToLeftSide,
|
action: switchToLeftSide,
|
||||||
value: "thirdWord",
|
value: "thirdWord",
|
||||||
},
|
},
|
||||||
select_blue_orb: {
|
throw_blue_orb: {
|
||||||
action: setActiveMediaComponent,
|
action: setActiveMediaComponent,
|
||||||
value: "play",
|
value: "play",
|
||||||
},
|
},
|
||||||
|
@ -116,25 +114,14 @@ const MediaComponentManager = (props: StateManagerProps) => {
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (props.eventState) {
|
if (props.eventState) {
|
||||||
const eventObject: any =
|
const eventAction = props.eventState.event;
|
||||||
game_action_mappings[
|
|
||||||
props.eventState as keyof typeof blue_orb_directions
|
|
||||||
];
|
|
||||||
|
|
||||||
if (eventObject) {
|
const dispatchedObject = dispatchObject(eventAction);
|
||||||
const eventAction = eventObject.action;
|
|
||||||
const targetMediaComponent = eventObject.target_media_component;
|
|
||||||
|
|
||||||
const dispatchedObject = dispatchObject(
|
|
||||||
eventAction,
|
|
||||||
targetMediaComponent
|
|
||||||
);
|
|
||||||
|
|
||||||
if (dispatchedObject) {
|
if (dispatchedObject) {
|
||||||
dispatchedObject.action(dispatchedObject.value);
|
dispatchedObject.action(dispatchedObject.value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}, [props.eventState, dispatchObject]);
|
}, [props.eventState, dispatchObject]);
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
import { useCallback, useEffect } from "react";
|
import { useCallback, useEffect } from "react";
|
||||||
|
|
||||||
import { StateManagerProps } from "./EventManager";
|
import { StateManagerProps } from "./EventManager";
|
||||||
import game_action_mappings from "../../resources/game_action_mappings.json";
|
|
||||||
import blue_orb_directions from "../../resources/blue_orb_directions.json";
|
|
||||||
|
|
||||||
const MediaComponentManager = (props: StateManagerProps) => {
|
const MediaComponentManager = (props: StateManagerProps) => {
|
||||||
const playMedia = useCallback(() => {
|
const playMedia = useCallback(() => {
|
||||||
|
@ -13,7 +11,7 @@ const MediaComponentManager = (props: StateManagerProps) => {
|
||||||
const dispatchObject = useCallback(
|
const dispatchObject = useCallback(
|
||||||
(event: string) => {
|
(event: string) => {
|
||||||
const dispatcherObjects = {
|
const dispatcherObjects = {
|
||||||
play_media_element: { action: playMedia },
|
play_select: { action: playMedia },
|
||||||
};
|
};
|
||||||
|
|
||||||
return dispatcherObjects[event as keyof typeof dispatcherObjects];
|
return dispatcherObjects[event as keyof typeof dispatcherObjects];
|
||||||
|
@ -23,13 +21,7 @@ const MediaComponentManager = (props: StateManagerProps) => {
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (props.eventState) {
|
if (props.eventState) {
|
||||||
const eventObject: any =
|
const eventAction = props.eventState.event;
|
||||||
game_action_mappings[
|
|
||||||
props.eventState as keyof typeof blue_orb_directions
|
|
||||||
];
|
|
||||||
|
|
||||||
if (eventObject) {
|
|
||||||
const eventAction = eventObject.action;
|
|
||||||
|
|
||||||
const dispatchedObject = dispatchObject(eventAction);
|
const dispatchedObject = dispatchObject(eventAction);
|
||||||
|
|
||||||
|
@ -37,7 +29,6 @@ const MediaComponentManager = (props: StateManagerProps) => {
|
||||||
dispatchedObject.action();
|
dispatchedObject.action();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}, [props.eventState, dispatchObject]);
|
}, [props.eventState, dispatchObject]);
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
import { useCallback, useEffect } from "react";
|
import { useCallback, useEffect } from "react";
|
||||||
|
|
||||||
import { StateManagerProps } from "./EventManager";
|
import { StateManagerProps } from "./EventManager";
|
||||||
import game_action_mappings from "../../resources/game_action_mappings.json";
|
|
||||||
import site_a from "../../resources/site_a.json";
|
import site_a from "../../resources/site_a.json";
|
||||||
import image_table from "../../resources/image_table.json";
|
import image_table from "../../resources/image_table.json";
|
||||||
import { ImageSrc, useImageStore } from "../../store";
|
import { ImageSrc, useImageStore } from "../../store";
|
||||||
|
@ -9,8 +8,10 @@ import { ImageSrc, useImageStore } from "../../store";
|
||||||
const MediaImageManager = (props: StateManagerProps) => {
|
const MediaImageManager = (props: StateManagerProps) => {
|
||||||
const setImages = useImageStore((state) => state.setImages);
|
const setImages = useImageStore((state) => state.setImages);
|
||||||
|
|
||||||
const updateSceneImages = useCallback((targetBlueOrbId: string) => {
|
const updateSceneImages = useCallback(
|
||||||
const node_name = site_a[targetBlueOrbId as keyof typeof site_a].node_name;
|
(newActiveBlueOrbId: string) => {
|
||||||
|
const node_name =
|
||||||
|
site_a[newActiveBlueOrbId as keyof typeof site_a].node_name;
|
||||||
const images = image_table[node_name as keyof typeof image_table];
|
const images = image_table[node_name as keyof typeof image_table];
|
||||||
|
|
||||||
Object.values(images).forEach((img) => {
|
Object.values(images).forEach((img) => {
|
||||||
|
@ -40,12 +41,17 @@ const MediaImageManager = (props: StateManagerProps) => {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}, []);
|
},
|
||||||
|
[setImages]
|
||||||
|
);
|
||||||
|
|
||||||
const dispatchObject = useCallback(
|
const dispatchObject = useCallback(
|
||||||
(event: string, targetBlueOrbId: string) => {
|
(event: string, newActiveBlueOrbId: string) => {
|
||||||
const dispatcherObjects = {
|
const dispatcherObjects = {
|
||||||
select_blue_orb: { action: updateSceneImages, value: targetBlueOrbId },
|
throw_blue_orb: {
|
||||||
|
action: updateSceneImages,
|
||||||
|
value: newActiveBlueOrbId,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
return dispatcherObjects[event as keyof typeof dispatcherObjects];
|
return dispatcherObjects[event as keyof typeof dispatcherObjects];
|
||||||
|
@ -55,22 +61,15 @@ const MediaImageManager = (props: StateManagerProps) => {
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (props.eventState) {
|
if (props.eventState) {
|
||||||
const eventObject: any =
|
const eventAction = props.eventState.action;
|
||||||
game_action_mappings[
|
const newActiveBlueOrbId = props.eventState.newActiveBlueOrbId;
|
||||||
props.eventState as keyof typeof game_action_mappings
|
|
||||||
];
|
|
||||||
|
|
||||||
if (eventObject) {
|
const dispatchedObject = dispatchObject(eventAction, newActiveBlueOrbId);
|
||||||
const eventAction = eventObject.action;
|
|
||||||
const targetBlueOrbId = eventObject.target_blue_orb_id;
|
|
||||||
|
|
||||||
const dispatchedObject = dispatchObject(eventAction, targetBlueOrbId);
|
|
||||||
|
|
||||||
if (dispatchedObject) {
|
if (dispatchedObject) {
|
||||||
dispatchedObject.action(dispatchedObject.value);
|
dispatchedObject.action(dispatchedObject.value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}, [props.eventState, dispatchObject]);
|
}, [props.eventState, dispatchObject]);
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
import { useCallback, useEffect } from "react";
|
import { useCallback, useEffect } from "react";
|
||||||
import { StateManagerProps } from "./EventManager";
|
import { StateManagerProps } from "./EventManager";
|
||||||
import { useMediaWordStore } from "../../store";
|
import { useMediaWordStore } from "../../store";
|
||||||
import game_action_mappings from "../../resources/game_action_mappings.json";
|
|
||||||
import blue_orb_directions from "../../resources/blue_orb_directions.json";
|
|
||||||
|
|
||||||
type MediaWordDispatcher = {
|
type MediaWordDispatcher = {
|
||||||
action: any;
|
action: any;
|
||||||
|
@ -16,7 +14,7 @@ type MediaWordDispatchData = {
|
||||||
sndWord_up: MediaWordDispatcher;
|
sndWord_up: MediaWordDispatcher;
|
||||||
thirdWord_down: MediaWordDispatcher;
|
thirdWord_down: MediaWordDispatcher;
|
||||||
thirdWord_up: MediaWordDispatcher;
|
thirdWord_up: MediaWordDispatcher;
|
||||||
select_blue_orb: MediaWordDispatcher;
|
throw_blue_orb: MediaWordDispatcher;
|
||||||
};
|
};
|
||||||
|
|
||||||
const MediaWordManager = (props: StateManagerProps) => {
|
const MediaWordManager = (props: StateManagerProps) => {
|
||||||
|
@ -54,7 +52,7 @@ const MediaWordManager = (props: StateManagerProps) => {
|
||||||
action: addToWordPositionDataStructIdx,
|
action: addToWordPositionDataStructIdx,
|
||||||
value: -1,
|
value: -1,
|
||||||
},
|
},
|
||||||
select_blue_orb: {
|
throw_blue_orb: {
|
||||||
action: resetWordPositionDataStructIdx,
|
action: resetWordPositionDataStructIdx,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
@ -66,13 +64,7 @@ const MediaWordManager = (props: StateManagerProps) => {
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (props.eventState) {
|
if (props.eventState) {
|
||||||
const eventObject: any =
|
const eventAction = props.eventState.event;
|
||||||
game_action_mappings[
|
|
||||||
props.eventState as keyof typeof blue_orb_directions
|
|
||||||
];
|
|
||||||
|
|
||||||
if (eventObject) {
|
|
||||||
const eventAction = eventObject.action;
|
|
||||||
|
|
||||||
const dispatchedObject = dispatchObject(eventAction);
|
const dispatchedObject = dispatchObject(eventAction);
|
||||||
|
|
||||||
|
@ -80,7 +72,6 @@ const MediaWordManager = (props: StateManagerProps) => {
|
||||||
dispatchedObject.action(dispatchedObject.value);
|
dispatchedObject.action(dispatchedObject.value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}, [props.eventState, dispatchObject]);
|
}, [props.eventState, dispatchObject]);
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
import { useCallback, useEffect, useMemo } from "react";
|
import { useCallback, useEffect, useMemo } from "react";
|
||||||
import { useMiddleRingStore } from "../../store";
|
import { useMiddleRingStore } from "../../store";
|
||||||
import game_action_mappings from "../../resources/game_action_mappings.json";
|
|
||||||
|
|
||||||
const MiddleRingManager = (props: any) => {
|
const MiddleRingManager = (props: any) => {
|
||||||
const setMiddleRingWobbleStrength = useMiddleRingStore(
|
const setMiddleRingWobbleStrength = useMiddleRingStore(
|
||||||
|
|
|
@ -1,22 +1,21 @@
|
||||||
import { useCallback, useEffect } from "react";
|
import { useCallback, useEffect } from "react";
|
||||||
import { StateManagerProps } from "./EventManager";
|
import { StateManagerProps } from "./EventManager";
|
||||||
import blue_orb_directions from "../../resources/blue_orb_directions.json";
|
|
||||||
import { useSceneStore } from "../../store";
|
import { useSceneStore } from "../../store";
|
||||||
|
|
||||||
const SceneManager = (props: StateManagerProps) => {
|
const SceneManager = (props: StateManagerProps) => {
|
||||||
const setScene = useSceneStore((state) => state.setScene);
|
const setScene = useSceneStore((state) => state.setScene);
|
||||||
|
|
||||||
const dispatchObject = useCallback(
|
const dispatchObject = useCallback(
|
||||||
(event: string) => {
|
(event: string, newScene: string) => {
|
||||||
const dispatcherObjects = {
|
const dispatcherObjects = {
|
||||||
select_blue_orb: {
|
throw_blue_orb: {
|
||||||
action: setScene,
|
action: setScene,
|
||||||
value: "media",
|
value: newScene,
|
||||||
delay: 3904.704,
|
delay: 3904.704,
|
||||||
},
|
},
|
||||||
exit_select: {
|
exit_select: {
|
||||||
action: setScene,
|
action: setScene,
|
||||||
value: "main",
|
value: newScene,
|
||||||
delay: 0,
|
delay: 0,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
@ -27,24 +26,10 @@ const SceneManager = (props: StateManagerProps) => {
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (props.eventState) {
|
if (props.eventState) {
|
||||||
const eventObject =
|
const eventAction = props.eventState.event;
|
||||||
blue_orb_directions[
|
const newScene = props.eventState.newScene;
|
||||||
props.eventState as keyof typeof blue_orb_directions
|
|
||||||
];
|
|
||||||
|
|
||||||
let dispatchedObject: {
|
const dispatchedObject = dispatchObject(eventAction, newScene);
|
||||||
action: (to: string) => void;
|
|
||||||
value: string;
|
|
||||||
delay: number;
|
|
||||||
};
|
|
||||||
|
|
||||||
if (eventObject) {
|
|
||||||
const eventAction = eventObject.action;
|
|
||||||
dispatchedObject = dispatchObject(eventAction);
|
|
||||||
} else {
|
|
||||||
const eventAction = props.eventState;
|
|
||||||
dispatchedObject = dispatchObject(eventAction);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (dispatchedObject) {
|
if (dispatchedObject) {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
|
|
|
@ -1,18 +1,21 @@
|
||||||
import { MutableRefObject, useCallback, useEffect, useRef } from "react";
|
import { MutableRefObject, useCallback, useEffect, useRef } from "react";
|
||||||
import blue_orb_huds from "../../resources/blue_orb_huds.json";
|
import blue_orb_huds from "../../resources/blue_orb_huds.json";
|
||||||
import site_a from "../../resources/site_a.json";
|
import site_a from "../../resources/site_a.json";
|
||||||
import {useBlueOrbStore, useHudStore, useTextRendererStore} from "../../store";
|
import {
|
||||||
import game_action_mappings from "../../resources/game_action_mappings.json";
|
useBlueOrbStore,
|
||||||
|
useHudStore,
|
||||||
|
useTextRendererStore,
|
||||||
|
} from "../../store";
|
||||||
|
|
||||||
type AnimateYellowTextWithMove = (
|
type AnimateYellowTextWithMove = (
|
||||||
yellowLetterPosYOffset: number,
|
yellowLetterPosYOffset: number,
|
||||||
targetBlueOrbHudId: string,
|
newActiveHudId: string,
|
||||||
targetBlueOrbId: string
|
newActiveBlueOrbId: string
|
||||||
) => void;
|
) => void;
|
||||||
|
|
||||||
type AnimateYellowTextWithoutMove = (
|
type AnimateYellowTextWithoutMove = (
|
||||||
targetBlueOrbHudId: string,
|
newActiveHudId: string,
|
||||||
targetBlueOrbId: string
|
newActiveBlueOrbId: string
|
||||||
) => void;
|
) => void;
|
||||||
|
|
||||||
type AnimateMediaYellowText = (
|
type AnimateMediaYellowText = (
|
||||||
|
@ -36,7 +39,7 @@ type YellowTextDispatcher = {
|
||||||
change_blue_orb: YellowTextDispatchData;
|
change_blue_orb: YellowTextDispatchData;
|
||||||
play_down: YellowTextDispatchData;
|
play_down: YellowTextDispatchData;
|
||||||
exit_up: YellowTextDispatchData;
|
exit_up: YellowTextDispatchData;
|
||||||
select_blue_orb: YellowTextDispatchData;
|
throw_blue_orb: YellowTextDispatchData;
|
||||||
exit_media_scene: YellowTextDispatchData;
|
exit_media_scene: YellowTextDispatchData;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -72,8 +75,8 @@ const YellowTextManager = (props: any) => {
|
||||||
const animateYellowTextWithMove: AnimateYellowTextWithMove = useCallback(
|
const animateYellowTextWithMove: AnimateYellowTextWithMove = useCallback(
|
||||||
(
|
(
|
||||||
yellowLetterPosYOffset: number,
|
yellowLetterPosYOffset: number,
|
||||||
targetBlueOrbHudId: string,
|
newActiveHudId: string,
|
||||||
targetBlueOrbId: string
|
newActiveBlueOrbId: string
|
||||||
) => {
|
) => {
|
||||||
// animate the letters to match that of site's
|
// animate the letters to match that of site's
|
||||||
// to create an illusion of not moving
|
// to create an illusion of not moving
|
||||||
|
@ -89,15 +92,17 @@ const YellowTextManager = (props: any) => {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
// animate it to new pos x/y
|
// animate it to new pos x/y
|
||||||
setYellowTextPosX(
|
setYellowTextPosX(
|
||||||
blue_orb_huds[targetBlueOrbHudId as keyof typeof blue_orb_huds]
|
blue_orb_huds[newActiveHudId as keyof typeof blue_orb_huds]
|
||||||
.big_text[0]
|
.big_text[0]
|
||||||
);
|
);
|
||||||
setYellowTextPosY(
|
setYellowTextPosY(
|
||||||
blue_orb_huds[targetBlueOrbHudId as keyof typeof blue_orb_huds]
|
blue_orb_huds[newActiveHudId as keyof typeof blue_orb_huds]
|
||||||
.big_text[1]
|
.big_text[1]
|
||||||
);
|
);
|
||||||
// set new text according to the node name
|
// set new text according to the node name
|
||||||
setYellowText(site_a[targetBlueOrbId as keyof typeof site_a].node_name);
|
setYellowText(
|
||||||
|
site_a[newActiveBlueOrbId as keyof typeof site_a].node_name
|
||||||
|
);
|
||||||
}, 3000);
|
}, 3000);
|
||||||
|
|
||||||
// unshrink text
|
// unshrink text
|
||||||
|
@ -115,17 +120,17 @@ const YellowTextManager = (props: any) => {
|
||||||
);
|
);
|
||||||
|
|
||||||
const animateYellowTextWithoutMove: AnimateYellowTextWithoutMove = useCallback(
|
const animateYellowTextWithoutMove: AnimateYellowTextWithoutMove = useCallback(
|
||||||
(targetBlueOrbHudId: string, targetBlueOrbId: string) => {
|
(newActiveHudId: string, newActiveBlueOrbId: string) => {
|
||||||
// make current hud big text shrink
|
// make current hud big text shrink
|
||||||
setYellowTextOffsetXCoeff(-1);
|
setYellowTextOffsetXCoeff(-1);
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
setYellowTextPosX(
|
setYellowTextPosX(
|
||||||
blue_orb_huds[targetBlueOrbHudId as keyof typeof blue_orb_huds]
|
blue_orb_huds[newActiveHudId as keyof typeof blue_orb_huds]
|
||||||
.big_text[0]
|
.big_text[0]
|
||||||
);
|
);
|
||||||
setYellowTextPosY(
|
setYellowTextPosY(
|
||||||
blue_orb_huds[targetBlueOrbHudId as keyof typeof blue_orb_huds]
|
blue_orb_huds[newActiveHudId as keyof typeof blue_orb_huds]
|
||||||
.big_text[1]
|
.big_text[1]
|
||||||
);
|
);
|
||||||
}, 400);
|
}, 400);
|
||||||
|
@ -133,7 +138,9 @@ const YellowTextManager = (props: any) => {
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
// set new text according to the node name
|
// set new text according to the node name
|
||||||
setYellowText(site_a[targetBlueOrbId as keyof typeof site_a].node_name);
|
setYellowText(
|
||||||
|
site_a[newActiveBlueOrbId as keyof typeof site_a].node_name
|
||||||
|
);
|
||||||
}, 1000);
|
}, 1000);
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
|
@ -209,29 +216,29 @@ const YellowTextManager = (props: any) => {
|
||||||
const dispatchObject = useCallback(
|
const dispatchObject = useCallback(
|
||||||
(
|
(
|
||||||
event: string,
|
event: string,
|
||||||
targetBlueOrbHudId: string | undefined,
|
newActiveHudId: string | undefined,
|
||||||
targetBlueOrbId: string | undefined
|
newActiveBlueOrbId: string | undefined
|
||||||
) => {
|
) => {
|
||||||
const dispatcherObjects: YellowTextDispatcher = {
|
const dispatcherObjects: YellowTextDispatcher = {
|
||||||
move_up: {
|
move_up: {
|
||||||
action: animateYellowTextWithMove,
|
action: animateYellowTextWithMove,
|
||||||
value: [-1.5, targetBlueOrbHudId, targetBlueOrbId],
|
value: [-1.5, newActiveHudId, newActiveBlueOrbId],
|
||||||
},
|
},
|
||||||
move_down: {
|
move_down: {
|
||||||
action: animateYellowTextWithMove,
|
action: animateYellowTextWithMove,
|
||||||
value: [1.5, targetBlueOrbHudId, targetBlueOrbId],
|
value: [1.5, newActiveHudId, newActiveBlueOrbId],
|
||||||
},
|
},
|
||||||
move_left: {
|
move_left: {
|
||||||
action: animateYellowTextWithMove,
|
action: animateYellowTextWithMove,
|
||||||
value: [targetBlueOrbHudId, targetBlueOrbId],
|
value: [newActiveHudId, newActiveBlueOrbId],
|
||||||
},
|
},
|
||||||
move_right: {
|
move_right: {
|
||||||
action: animateYellowTextWithMove,
|
action: animateYellowTextWithMove,
|
||||||
value: [targetBlueOrbHudId, targetBlueOrbId],
|
value: [newActiveHudId, newActiveBlueOrbId],
|
||||||
},
|
},
|
||||||
change_blue_orb: {
|
change_blue_orb: {
|
||||||
action: animateYellowTextWithoutMove,
|
action: animateYellowTextWithoutMove,
|
||||||
value: [targetBlueOrbHudId, targetBlueOrbId],
|
value: [newActiveHudId, newActiveBlueOrbId],
|
||||||
},
|
},
|
||||||
exit_up: {
|
exit_up: {
|
||||||
action: animateMediaYellowText,
|
action: animateMediaYellowText,
|
||||||
|
@ -241,7 +248,7 @@ const YellowTextManager = (props: any) => {
|
||||||
action: animateMediaYellowText,
|
action: animateMediaYellowText,
|
||||||
value: ["Exit", [-0.8, -0.08, 0.6]],
|
value: ["Exit", [-0.8, -0.08, 0.6]],
|
||||||
},
|
},
|
||||||
select_blue_orb: {
|
throw_blue_orb: {
|
||||||
action: initializeYellowTextForMediaScene,
|
action: initializeYellowTextForMediaScene,
|
||||||
},
|
},
|
||||||
exit_media_scene: {
|
exit_media_scene: {
|
||||||
|
@ -262,34 +269,27 @@ const YellowTextManager = (props: any) => {
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (props.eventState) {
|
if (props.eventState) {
|
||||||
const eventObject: any =
|
const eventAction = props.eventState.event;
|
||||||
game_action_mappings[
|
|
||||||
props.eventState as keyof typeof game_action_mappings
|
|
||||||
];
|
|
||||||
|
|
||||||
if (eventObject) {
|
const newActiveBlueOrbId = props.eventState.newActiveBlueOrbId;
|
||||||
const eventAction = eventObject.action;
|
const newActiveHudId = props.eventState.newActiveHudId;
|
||||||
|
|
||||||
const targetBlueOrbId = eventObject.target_blue_orb_id;
|
|
||||||
const targetBlueOrbHudId = eventObject.target_hud_id;
|
|
||||||
|
|
||||||
const dispatchedObject = dispatchObject(
|
const dispatchedObject = dispatchObject(
|
||||||
eventAction,
|
eventAction,
|
||||||
targetBlueOrbHudId,
|
newActiveHudId,
|
||||||
targetBlueOrbId
|
newActiveBlueOrbId
|
||||||
);
|
);
|
||||||
|
|
||||||
if (dispatchedObject) {
|
if (dispatchedObject) {
|
||||||
(dispatchedObject.action as any).apply(null, dispatchedObject.value);
|
(dispatchedObject.action as any).apply(null, dispatchedObject.value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}, [
|
}, [
|
||||||
animateYellowTextWithMove,
|
animateYellowTextWithMove,
|
||||||
animateYellowTextWithoutMove,
|
animateYellowTextWithoutMove,
|
||||||
props.eventState,
|
props.eventState,
|
||||||
props.targetBlueOrbHudId,
|
props.newActiveHudId,
|
||||||
props.targetBlueOrbId,
|
props.newActiveBlueOrbId,
|
||||||
dispatchObject,
|
dispatchObject,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
|
|
@ -1,102 +1,14 @@
|
||||||
import { GameContext } from "../components/StateManagers/EventManager";
|
import { GameContext } from "../components/StateManagers/EventManager";
|
||||||
import available_blue_orbs_on_projection from "../resources/available_blue_orbs_on_projection.json";
|
import handleMainSceneEvent from "./mainSceneEventHandler";
|
||||||
|
import handleMediaSceneEvent from "./mediaSceneEventHandler";
|
||||||
|
|
||||||
const computeAction = (gameContext: GameContext) => {
|
const computeAction = (gameContext: GameContext) => {
|
||||||
let event;
|
switch (gameContext.scene) {
|
||||||
let newBlueOrbColIdx;
|
case "main":
|
||||||
let newBlueOrbRowIdx;
|
return handleMainSceneEvent(gameContext);
|
||||||
let newLevel;
|
case "media":
|
||||||
let newSiteRotIdx;
|
return handleMediaSceneEvent(gameContext);
|
||||||
let newActiveBlueOrbId;
|
|
||||||
|
|
||||||
switch (gameContext.keyPress) {
|
|
||||||
case "left":
|
|
||||||
newBlueOrbColIdx = gameContext.blueOrbColIdx - 1;
|
|
||||||
if (newBlueOrbColIdx < 0) {
|
|
||||||
event = "move_left";
|
|
||||||
newSiteRotIdx = parseInt(gameContext.siteRotIdx) + 1;
|
|
||||||
if (newSiteRotIdx > 8) newSiteRotIdx = "1";
|
|
||||||
console.log(newSiteRotIdx)
|
|
||||||
newBlueOrbColIdx = 0;
|
|
||||||
newBlueOrbRowIdx = gameContext.blueOrbRowIdx;
|
|
||||||
newLevel = gameContext.currentLevel;
|
|
||||||
} else {
|
|
||||||
event = "change_blue_orb";
|
|
||||||
newBlueOrbRowIdx = gameContext.blueOrbRowIdx;
|
|
||||||
newLevel = gameContext.currentLevel;
|
|
||||||
newSiteRotIdx = gameContext.siteRotIdx;
|
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
case "down":
|
|
||||||
newBlueOrbRowIdx = gameContext.blueOrbRowIdx + 1;
|
|
||||||
if (newBlueOrbRowIdx > 2) {
|
|
||||||
event = "move_down";
|
|
||||||
|
|
||||||
newLevel = (parseInt(gameContext.currentLevel) - 1)
|
|
||||||
.toString()
|
|
||||||
.padStart(2, "0");
|
|
||||||
|
|
||||||
newBlueOrbColIdx = gameContext.blueOrbColIdx;
|
|
||||||
newBlueOrbRowIdx = 0;
|
|
||||||
|
|
||||||
newSiteRotIdx = gameContext.siteRotIdx;
|
|
||||||
} else {
|
|
||||||
event = "change_blue_orb";
|
|
||||||
newBlueOrbColIdx = gameContext.blueOrbColIdx;
|
|
||||||
newLevel = gameContext.currentLevel;
|
|
||||||
newSiteRotIdx = gameContext.siteRotIdx;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case "up":
|
|
||||||
newBlueOrbRowIdx = gameContext.blueOrbRowIdx - 1;
|
|
||||||
if (newBlueOrbRowIdx < 0) {
|
|
||||||
event = "move_up";
|
|
||||||
|
|
||||||
newLevel = (parseInt(gameContext.currentLevel) + 1)
|
|
||||||
.toString()
|
|
||||||
.padStart(2, "0");
|
|
||||||
|
|
||||||
newBlueOrbColIdx = gameContext.blueOrbColIdx;
|
|
||||||
newBlueOrbRowIdx = 2;
|
|
||||||
|
|
||||||
newSiteRotIdx = gameContext.siteRotIdx;
|
|
||||||
} else {
|
|
||||||
event = "change_blue_orb";
|
|
||||||
newBlueOrbColIdx = gameContext.blueOrbColIdx;
|
|
||||||
newLevel = gameContext.currentLevel;
|
|
||||||
newSiteRotIdx = gameContext.siteRotIdx;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case "right":
|
|
||||||
newBlueOrbColIdx = gameContext.blueOrbColIdx + 1;
|
|
||||||
if (newBlueOrbColIdx > 3) {
|
|
||||||
event = "move_right";
|
|
||||||
newSiteRotIdx = (parseInt(gameContext.siteRotIdx) - 1).toString();
|
|
||||||
newBlueOrbColIdx = 0;
|
|
||||||
newBlueOrbRowIdx = gameContext.blueOrbRowIdx;
|
|
||||||
newLevel = gameContext.currentLevel;
|
|
||||||
} else {
|
|
||||||
event = "change_blue_orb";
|
|
||||||
newBlueOrbRowIdx = gameContext.blueOrbRowIdx;
|
|
||||||
newLevel = gameContext.currentLevel;
|
|
||||||
newSiteRotIdx = gameContext.siteRotIdx;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
newActiveBlueOrbId =
|
|
||||||
newLevel +
|
|
||||||
available_blue_orbs_on_projection[
|
|
||||||
newSiteRotIdx as keyof typeof available_blue_orbs_on_projection
|
|
||||||
][newBlueOrbRowIdx as number][newBlueOrbColIdx as number];
|
|
||||||
|
|
||||||
return {
|
|
||||||
event: event,
|
|
||||||
newBlueOrbColIdx: newBlueOrbColIdx,
|
|
||||||
newBlueOrbRowIdx: newBlueOrbRowIdx,
|
|
||||||
newSiteRotIdx: newSiteRotIdx,
|
|
||||||
newLevel: newLevel,
|
|
||||||
newActiveBlueOrbId: newActiveBlueOrbId,
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export default computeAction;
|
export default computeAction;
|
||||||
|
|
106
src/core/mainSceneEventHandler.ts
Normal file
106
src/core/mainSceneEventHandler.ts
Normal file
|
@ -0,0 +1,106 @@
|
||||||
|
import { GameContext } from "../components/StateManagers/EventManager";
|
||||||
|
import available_blue_orbs_on_projection from "../resources/available_blue_orbs_on_projection.json";
|
||||||
|
|
||||||
|
const hudAssocs = {
|
||||||
|
"00": "fg_hud_1",
|
||||||
|
"10": "fg_hud_2",
|
||||||
|
"20": "fg_hud_3",
|
||||||
|
"01": "bg_hud_1",
|
||||||
|
"11": "bg_hud_2",
|
||||||
|
"21": "bg_hud_3",
|
||||||
|
"02": "bg_hud_4",
|
||||||
|
"12": "bg_hud_5",
|
||||||
|
"22": "bg_hud_6",
|
||||||
|
"03": "fg_hud_4",
|
||||||
|
"13": "fg_hud_5",
|
||||||
|
"23": "fg_hud_6",
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleMainSceneEvent = (gameContext: GameContext) => {
|
||||||
|
let event;
|
||||||
|
|
||||||
|
const keyPress = gameContext.keyPress;
|
||||||
|
|
||||||
|
let newBlueOrbColIdx = gameContext.blueOrbColIdx;
|
||||||
|
let newBlueOrbRowIdx = gameContext.blueOrbRowIdx;
|
||||||
|
let newLevel = gameContext.currentLevel;
|
||||||
|
let newSiteRotIdx: string | number = gameContext.siteRotIdx;
|
||||||
|
let newScene = gameContext.scene;
|
||||||
|
|
||||||
|
switch (keyPress) {
|
||||||
|
case "left":
|
||||||
|
newBlueOrbColIdx = gameContext.blueOrbColIdx - 1;
|
||||||
|
if (newBlueOrbColIdx < 0) {
|
||||||
|
event = "move_left";
|
||||||
|
newSiteRotIdx = parseInt(gameContext.siteRotIdx) + 1;
|
||||||
|
if (newSiteRotIdx > 8) newSiteRotIdx = "1";
|
||||||
|
newBlueOrbColIdx = 0;
|
||||||
|
} else {
|
||||||
|
event = "change_blue_orb";
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case "down":
|
||||||
|
newBlueOrbRowIdx = gameContext.blueOrbRowIdx + 1;
|
||||||
|
if (newBlueOrbRowIdx > 2) {
|
||||||
|
event = "move_down";
|
||||||
|
|
||||||
|
newLevel = (parseInt(gameContext.currentLevel) - 1)
|
||||||
|
.toString()
|
||||||
|
.padStart(2, "0");
|
||||||
|
newBlueOrbRowIdx = 0;
|
||||||
|
} else {
|
||||||
|
event = "change_blue_orb";
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case "up":
|
||||||
|
newBlueOrbRowIdx = gameContext.blueOrbRowIdx - 1;
|
||||||
|
if (newBlueOrbRowIdx < 0) {
|
||||||
|
event = "move_up";
|
||||||
|
|
||||||
|
newLevel = (parseInt(gameContext.currentLevel) + 1)
|
||||||
|
.toString()
|
||||||
|
.padStart(2, "0");
|
||||||
|
|
||||||
|
newBlueOrbRowIdx = 2;
|
||||||
|
} else {
|
||||||
|
event = "change_blue_orb";
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case "right":
|
||||||
|
newBlueOrbColIdx = gameContext.blueOrbColIdx + 1;
|
||||||
|
if (newBlueOrbColIdx > 3) {
|
||||||
|
event = "move_right";
|
||||||
|
newSiteRotIdx = (parseInt(gameContext.siteRotIdx) - 1).toString();
|
||||||
|
newBlueOrbColIdx = 0;
|
||||||
|
} else {
|
||||||
|
event = "change_blue_orb";
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case "select":
|
||||||
|
event = "throw_blue_orb";
|
||||||
|
newScene = "media";
|
||||||
|
}
|
||||||
|
|
||||||
|
const newActiveBlueOrbId =
|
||||||
|
newLevel +
|
||||||
|
available_blue_orbs_on_projection[
|
||||||
|
newSiteRotIdx as keyof typeof available_blue_orbs_on_projection
|
||||||
|
][newBlueOrbRowIdx as number][newBlueOrbColIdx as number];
|
||||||
|
|
||||||
|
const newActiveHudId =
|
||||||
|
hudAssocs[
|
||||||
|
`${newBlueOrbRowIdx}${newBlueOrbColIdx}` as keyof typeof hudAssocs
|
||||||
|
];
|
||||||
|
return {
|
||||||
|
event: event,
|
||||||
|
newBlueOrbColIdx: newBlueOrbColIdx,
|
||||||
|
newBlueOrbRowIdx: newBlueOrbRowIdx,
|
||||||
|
newSiteRotIdx: newSiteRotIdx,
|
||||||
|
newLevel: newLevel,
|
||||||
|
newScene: newScene,
|
||||||
|
newActiveBlueOrbId: newActiveBlueOrbId,
|
||||||
|
newActiveHudId: newActiveHudId,
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
export default handleMainSceneEvent;
|
17
src/core/mediaSceneEventHandler.ts
Normal file
17
src/core/mediaSceneEventHandler.ts
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
import { GameContext } from "../components/StateManagers/EventManager";
|
||||||
|
|
||||||
|
const handleMediaSceneEvent = (gameContext: GameContext) => {
|
||||||
|
const keyPress = gameContext.keyPress;
|
||||||
|
|
||||||
|
const activeMediaComponent = gameContext.activeMediaComponent;
|
||||||
|
switch (keyPress) {
|
||||||
|
case "right":
|
||||||
|
return { event: `switch_to_right_side_from_${activeMediaComponent}` };
|
||||||
|
case "left":
|
||||||
|
return { event: `switch_to_left_side_from_${activeMediaComponent}` };
|
||||||
|
default:
|
||||||
|
return { event: `${activeMediaComponent}_${keyPress}`, newScene: "main" };
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export default handleMediaSceneEvent;
|
|
@ -1,77 +0,0 @@
|
||||||
{
|
|
||||||
"0422_down": {
|
|
||||||
"action": "change_blue_orb",
|
|
||||||
"target_blue_orb_id": "0414",
|
|
||||||
"target_hud_id": "fg_hud_2"
|
|
||||||
},
|
|
||||||
"0422_right": {
|
|
||||||
"action": "change_blue_orb",
|
|
||||||
"target_blue_orb_id": "0417",
|
|
||||||
"target_hud_id": "bg_hud_1"
|
|
||||||
},
|
|
||||||
"0422_up": {
|
|
||||||
"action": "move_up",
|
|
||||||
"target_blue_orb_id": "0506",
|
|
||||||
"target_hud_id": "fg_hud_3"
|
|
||||||
},
|
|
||||||
"0422_select": {
|
|
||||||
"action": "select_blue_orb",
|
|
||||||
"target_blue_orb_id": "0422",
|
|
||||||
"target_hud_id": "fg_hud_1"
|
|
||||||
},
|
|
||||||
|
|
||||||
"0414_up": {
|
|
||||||
"action": "change_blue_orb",
|
|
||||||
"target_blue_orb_id": "0422",
|
|
||||||
"target_hud_id": "fg_hud_1"
|
|
||||||
},
|
|
||||||
"0414_right": {
|
|
||||||
"action": "change_blue_orb",
|
|
||||||
"target_blue_orb_id": "0417",
|
|
||||||
"target_hud_id": "bg_hud_1"
|
|
||||||
},
|
|
||||||
|
|
||||||
"0413_down": {
|
|
||||||
"action": "change_blue_orb",
|
|
||||||
"target_blue_orb_id": "0405",
|
|
||||||
"target_hud_id": "fg_hud_6"
|
|
||||||
},
|
|
||||||
"0413_left": {
|
|
||||||
"action": "change_blue_orb",
|
|
||||||
"target_blue_orb_id": "0417",
|
|
||||||
"target_hud_id": "bg_hud_1"
|
|
||||||
},
|
|
||||||
|
|
||||||
"0405_left": {
|
|
||||||
"action": "change_blue_orb",
|
|
||||||
"target_blue_orb_id": "0417",
|
|
||||||
"target_hud_id": "bg_hud_1"
|
|
||||||
},
|
|
||||||
"0405_up": {
|
|
||||||
"action": "change_blue_orb",
|
|
||||||
"target_blue_orb_id": "0413",
|
|
||||||
"target_hud_id": "fg_hud_5"
|
|
||||||
},
|
|
||||||
|
|
||||||
"0417_left": {
|
|
||||||
"action": "change_blue_orb",
|
|
||||||
"target_blue_orb_id": "0422",
|
|
||||||
"target_hud_id": "fg_hud_1"
|
|
||||||
},
|
|
||||||
"0417_down": {
|
|
||||||
"action": "change_blue_orb",
|
|
||||||
"target_blue_orb_id": "0414",
|
|
||||||
"target_hud_id": "fg_hud_2"
|
|
||||||
},
|
|
||||||
"0417_right": {
|
|
||||||
"action": "change_blue_orb",
|
|
||||||
"target_blue_orb_id": "0413",
|
|
||||||
"target_hud_id": "fg_hud_5"
|
|
||||||
},
|
|
||||||
|
|
||||||
"0506_down": {
|
|
||||||
"action": "move_down",
|
|
||||||
"target_blue_orb_id": "0422",
|
|
||||||
"target_hud_id": "fg_hud_1"
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -147,7 +147,7 @@
|
||||||
"type": "normal",
|
"type": "normal",
|
||||||
"initial_position": [1.3, 0, -8.6]
|
"initial_position": [1.3, 0, -8.6]
|
||||||
},
|
},
|
||||||
"big_text": [-0.15, 0.08, -8.7],
|
"big_text": [-0.15, 0.06, -8.7],
|
||||||
"medium_text": {
|
"medium_text": {
|
||||||
"position": [0.1, 0, -8.7],
|
"position": [0.1, 0, -8.7],
|
||||||
"initial_position": [1.1, 0, -8.7]
|
"initial_position": [1.1, 0, -8.7]
|
||||||
|
@ -169,7 +169,7 @@
|
||||||
"type": "normal",
|
"type": "normal",
|
||||||
"initial_position": [1.35, -0.12, -8.6]
|
"initial_position": [1.35, -0.12, -8.6]
|
||||||
},
|
},
|
||||||
"big_text": [-0.23, -0.05, -8.7],
|
"big_text": [-0.15, -0.05, -8.7],
|
||||||
"medium_text": {
|
"medium_text": {
|
||||||
"position": [0.18, -0.13, -8.7],
|
"position": [0.18, -0.13, -8.7],
|
||||||
"initial_position": [1.18, -0.13, -8.7]
|
"initial_position": [1.18, -0.13, -8.7]
|
||||||
|
@ -191,7 +191,7 @@
|
||||||
"type": "normal",
|
"type": "normal",
|
||||||
"initial_position": [1.35, -0.22, -8.6]
|
"initial_position": [1.35, -0.22, -8.6]
|
||||||
},
|
},
|
||||||
"big_text": [-0.23, -0.16, -8.7],
|
"big_text": [-0.15, -0.16, -8.7],
|
||||||
"medium_text": {
|
"medium_text": {
|
||||||
"position": [0.18, -0.25, -8.7],
|
"position": [0.18, -0.25, -8.7],
|
||||||
"initial_position": [1.18, -0.25, -8.7]
|
"initial_position": [1.18, -0.25, -8.7]
|
||||||
|
@ -213,7 +213,7 @@
|
||||||
"type": "mirrored",
|
"type": "mirrored",
|
||||||
"initial_position": [-1.35, 0.015, -8.6]
|
"initial_position": [-1.35, 0.015, -8.6]
|
||||||
},
|
},
|
||||||
"big_text": [0.18, 0.105, -8.7],
|
"big_text": [0.15, 0.06, -8.7],
|
||||||
"medium_text": {
|
"medium_text": {
|
||||||
"position": [-0.65, 0.02, -8.7],
|
"position": [-0.65, 0.02, -8.7],
|
||||||
"initial_position": [-1.65, 0.02, -8.7]
|
"initial_position": [-1.65, 0.02, -8.7]
|
||||||
|
@ -235,7 +235,7 @@
|
||||||
"type": "mirrored",
|
"type": "mirrored",
|
||||||
"initial_position": [-1.35, -0.12, -8.6]
|
"initial_position": [-1.35, -0.12, -8.6]
|
||||||
},
|
},
|
||||||
"big_text": [0.2, -0.025, -8.7],
|
"big_text": [0.15, -0.05, -8.7],
|
||||||
"medium_text": {
|
"medium_text": {
|
||||||
"position": [-0.65, -0.11, -8.7],
|
"position": [-0.65, -0.11, -8.7],
|
||||||
"initial_position": [-1.65, -0.11, -8.7]
|
"initial_position": [-1.65, -0.11, -8.7]
|
||||||
|
@ -257,7 +257,7 @@
|
||||||
"type": "mirrored",
|
"type": "mirrored",
|
||||||
"initial_position": [-1.25, -0.18, -8.6]
|
"initial_position": [-1.25, -0.18, -8.6]
|
||||||
},
|
},
|
||||||
"big_text": [0.2, -0.18, -8.7],
|
"big_text": [0.15, -0.16, -8.7],
|
||||||
"medium_text": {
|
"medium_text": {
|
||||||
"position": [-0.53, -0.2, -8.7],
|
"position": [-0.53, -0.2, -8.7],
|
||||||
"initial_position": [-1.53, -0.2, -8.7]
|
"initial_position": [-1.53, -0.2, -8.7]
|
||||||
|
|
|
@ -1,138 +0,0 @@
|
||||||
{
|
|
||||||
"play_select": {
|
|
||||||
"action": "play_media_element"
|
|
||||||
},
|
|
||||||
"exit_select": {
|
|
||||||
"action": "exit_media_scene"
|
|
||||||
},
|
|
||||||
|
|
||||||
"play_down": {
|
|
||||||
"action": "play_down",
|
|
||||||
"target_media_component": "exit"
|
|
||||||
},
|
|
||||||
"exit_up": {
|
|
||||||
"action": "exit_up",
|
|
||||||
"target_media_component": "play"
|
|
||||||
},
|
|
||||||
"play_right": {
|
|
||||||
"action": "switch_to_right_side_from_play",
|
|
||||||
"target_media_component": "last_active_right_media_component"
|
|
||||||
},
|
|
||||||
"exit_right": {
|
|
||||||
"action": "switch_to_right_side_from_exit",
|
|
||||||
"target_media_component": "last_active_right_media_component"
|
|
||||||
},
|
|
||||||
|
|
||||||
"fstWord_left": {
|
|
||||||
"action": "switch_to_left_side_from_fstWord",
|
|
||||||
"target_media_component": "last_active_left_media_component"
|
|
||||||
},
|
|
||||||
"fstWord_up": {
|
|
||||||
"action": "fstWord_up",
|
|
||||||
"target_media_component": "thirdWord"
|
|
||||||
},
|
|
||||||
"fstWord_down": {
|
|
||||||
"action": "fstWord_down",
|
|
||||||
"target_media_component": "sndWord"
|
|
||||||
},
|
|
||||||
"sndWord_up": {
|
|
||||||
"action": "sndWord_up",
|
|
||||||
"target_media_component": "fstWord"
|
|
||||||
},
|
|
||||||
"sndWord_down": {
|
|
||||||
"action": "sndWord_down",
|
|
||||||
"target_media_component": "thirdWord"
|
|
||||||
},
|
|
||||||
"sndWord_left": {
|
|
||||||
"action": "switch_to_left_side_from_sndWord",
|
|
||||||
"target_media_component": "last_active_left_media_component"
|
|
||||||
},
|
|
||||||
"thirdWord_down": {
|
|
||||||
"action": "thirdWord_down",
|
|
||||||
"target_media_component": "fstWord"
|
|
||||||
},
|
|
||||||
"thirdWord_up": {
|
|
||||||
"action": "thirdWord_up",
|
|
||||||
"target_media_component": "sndWord"
|
|
||||||
},
|
|
||||||
"thirdWord_left": {
|
|
||||||
"action": "switch_to_left_side_from_thirdWord",
|
|
||||||
"target_media_component": "last_active_left_media_component"
|
|
||||||
},
|
|
||||||
|
|
||||||
"0422_down": {
|
|
||||||
"action": "change_blue_orb",
|
|
||||||
"target_blue_orb_id": "0414",
|
|
||||||
"target_hud_id": "fg_hud_2"
|
|
||||||
},
|
|
||||||
"0422_right": {
|
|
||||||
"action": "change_blue_orb",
|
|
||||||
"target_blue_orb_id": "0417",
|
|
||||||
"target_hud_id": "bg_hud_1"
|
|
||||||
},
|
|
||||||
"0422_up": {
|
|
||||||
"action": "move_up",
|
|
||||||
"target_blue_orb_id": "0506",
|
|
||||||
"target_hud_id": "fg_hud_3"
|
|
||||||
},
|
|
||||||
"0422_select": {
|
|
||||||
"action": "select_blue_orb",
|
|
||||||
"target_blue_orb_id": "0422",
|
|
||||||
"target_hud_id": "fg_hud_1"
|
|
||||||
},
|
|
||||||
|
|
||||||
"0414_up": {
|
|
||||||
"action": "change_blue_orb",
|
|
||||||
"target_blue_orb_id": "0422",
|
|
||||||
"target_hud_id": "fg_hud_1"
|
|
||||||
},
|
|
||||||
"0414_right": {
|
|
||||||
"action": "change_blue_orb",
|
|
||||||
"target_blue_orb_id": "0417",
|
|
||||||
"target_hud_id": "bg_hud_1"
|
|
||||||
},
|
|
||||||
|
|
||||||
"0413_down": {
|
|
||||||
"action": "change_blue_orb",
|
|
||||||
"target_blue_orb_id": "0405",
|
|
||||||
"target_hud_id": "fg_hud_6"
|
|
||||||
},
|
|
||||||
"0413_left": {
|
|
||||||
"action": "change_blue_orb",
|
|
||||||
"target_blue_orb_id": "0417",
|
|
||||||
"target_hud_id": "bg_hud_1"
|
|
||||||
},
|
|
||||||
|
|
||||||
"0405_left": {
|
|
||||||
"action": "change_blue_orb",
|
|
||||||
"target_blue_orb_id": "0417",
|
|
||||||
"target_hud_id": "bg_hud_1"
|
|
||||||
},
|
|
||||||
"0405_up": {
|
|
||||||
"action": "change_blue_orb",
|
|
||||||
"target_blue_orb_id": "0413",
|
|
||||||
"target_hud_id": "fg_hud_5"
|
|
||||||
},
|
|
||||||
|
|
||||||
"0417_left": {
|
|
||||||
"action": "change_blue_orb",
|
|
||||||
"target_blue_orb_id": "0422",
|
|
||||||
"target_hud_id": "fg_hud_1"
|
|
||||||
},
|
|
||||||
"0417_down": {
|
|
||||||
"action": "change_blue_orb",
|
|
||||||
"target_blue_orb_id": "0414",
|
|
||||||
"target_hud_id": "fg_hud_2"
|
|
||||||
},
|
|
||||||
"0417_right": {
|
|
||||||
"action": "change_blue_orb",
|
|
||||||
"target_blue_orb_id": "0413",
|
|
||||||
"target_hud_id": "fg_hud_5"
|
|
||||||
},
|
|
||||||
|
|
||||||
"0506_down": {
|
|
||||||
"action": "move_down",
|
|
||||||
"target_blue_orb_id": "0422",
|
|
||||||
"target_hud_id": "fg_hud_1"
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -379,7 +379,7 @@ export const useMediaWordStore = create<MediaWordState>((set) => ({
|
||||||
}));
|
}));
|
||||||
|
|
||||||
export const useSceneStore = create<SceneState>((set) => ({
|
export const useSceneStore = create<SceneState>((set) => ({
|
||||||
currentScene: "main",
|
currentScene: "media",
|
||||||
setScene: (to) => set(() => ({ currentScene: to })),
|
setScene: (to) => set(() => ({ currentScene: to })),
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue