fix : lint
🔍 Lint / 🪄 Check lint (pull_request) Has been cancelled
🔍 Lint / 🎨 Check format (pull_request) Has been cancelled
🔍 Lint / 🔎 Typecheck (pull_request) Has been cancelled
🔍 Lint / 🏗 Build (pull_request) Has been cancelled
📊 Quality / 🔒 Security Audit (pull_request) Has been cancelled
📊 Quality / 📋 Dependency Freshness (pull_request) Has been cancelled
📊 Quality / 📦 Bundle Size (pull_request) Has been cancelled
🔍 Lint / 🪄 Check lint (pull_request) Has been cancelled
🔍 Lint / 🎨 Check format (pull_request) Has been cancelled
🔍 Lint / 🔎 Typecheck (pull_request) Has been cancelled
🔍 Lint / 🏗 Build (pull_request) Has been cancelled
📊 Quality / 🔒 Security Audit (pull_request) Has been cancelled
📊 Quality / 📋 Dependency Freshness (pull_request) Has been cancelled
📊 Quality / 📦 Bundle Size (pull_request) Has been cancelled
This commit is contained in:
@@ -11,22 +11,16 @@ export function GameFlow(): null {
|
|||||||
const hasInitialized = useRef(false);
|
const hasInitialized = useRef(false);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
console.log("[GameFlow] Current step:", step);
|
|
||||||
if (!hasInitialized.current && step === "intro") {
|
if (!hasInitialized.current && step === "intro") {
|
||||||
hasInitialized.current = true;
|
hasInitialized.current = true;
|
||||||
console.log("[GameFlow] Transition to start-intro");
|
|
||||||
setStep("start-intro");
|
setStep("start-intro");
|
||||||
}
|
}
|
||||||
}, [step, setStep]);
|
}, [step, setStep]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
console.log("[GameFlow] useEffect triggered, step:", step);
|
|
||||||
|
|
||||||
if (step === "start-intro") {
|
if (step === "start-intro") {
|
||||||
console.log("[GameFlow] Playing intro audio");
|
|
||||||
const audio = AudioManager.getInstance();
|
const audio = AudioManager.getInstance();
|
||||||
audio.playSoundWithCallback(AUDIO_PATHS.intro, 0.5, () => {
|
audio.playSoundWithCallback(AUDIO_PATHS.intro, 0.5, () => {
|
||||||
console.log("[GameFlow] Intro audio ended, transition to naming");
|
|
||||||
setStep("naming");
|
setStep("naming");
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -34,10 +28,8 @@ export function GameFlow(): null {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (step === "bienvenue") {
|
if (step === "bienvenue") {
|
||||||
console.log("[GameFlow] Playing bienvenue audio");
|
|
||||||
const audio = AudioManager.getInstance();
|
const audio = AudioManager.getInstance();
|
||||||
audio.playSoundWithCallback(AUDIO_PATHS.bienvenue, 0.5, () => {
|
audio.playSoundWithCallback(AUDIO_PATHS.bienvenue, 0.5, () => {
|
||||||
console.log("[GameFlow] Bienvenue audio ended, enable movement");
|
|
||||||
setCanMove(true);
|
setCanMove(true);
|
||||||
setStep("star-move");
|
setStep("star-move");
|
||||||
});
|
});
|
||||||
@@ -46,30 +38,22 @@ export function GameFlow(): null {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (step === "mission2") {
|
if (step === "mission2") {
|
||||||
console.log("[GameFlow] mission2 - setting activityCity to false");
|
|
||||||
setActivityCity(false);
|
setActivityCity(false);
|
||||||
const audio = AudioManager.getInstance();
|
const audio = AudioManager.getInstance();
|
||||||
audio.playSound(AUDIO_PATHS.alertCentral, 0.5);
|
audio.playSound(AUDIO_PATHS.alertCentral, 0.5);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (step === "searching") {
|
if (step === "searching") {
|
||||||
console.log("[GameFlow] Playing searching audio");
|
|
||||||
const audio = AudioManager.getInstance();
|
const audio = AudioManager.getInstance();
|
||||||
audio.playSoundWithCallback(AUDIO_PATHS.searching, 0.5, () => {
|
audio.playSound(AUDIO_PATHS.searching, 0.5);
|
||||||
console.log("[GameFlow] searching audio ended");
|
|
||||||
});
|
|
||||||
|
|
||||||
return () => {};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (step === "helped") {
|
if (step === "helped") {
|
||||||
console.log("[GameFlow] Playing helped audio");
|
|
||||||
const audio = AudioManager.getInstance();
|
const audio = AudioManager.getInstance();
|
||||||
audio.playSound(AUDIO_PATHS.helped, 0.5);
|
audio.playSound(AUDIO_PATHS.helped, 0.5);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (step === "manipulation") {
|
if (step === "manipulation") {
|
||||||
console.log("[GameFlow] manipulation - blocking movement");
|
|
||||||
setCanMove(false);
|
setCanMove(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -12,11 +12,8 @@ export function IntroUI(): React.JSX.Element | null {
|
|||||||
const handleSubmit = (): void => {
|
const handleSubmit = (): void => {
|
||||||
if (inputValue.trim() === "") return;
|
if (inputValue.trim() === "") return;
|
||||||
|
|
||||||
console.log("[IntroUI] Submitting, name:", inputValue.trim());
|
|
||||||
setPlayerName(inputValue.trim());
|
setPlayerName(inputValue.trim());
|
||||||
console.log("[IntroUI] Calling transitionTo('bienvenue')");
|
|
||||||
setStep("bienvenue");
|
setStep("bienvenue");
|
||||||
console.log("[IntroUI] After transitionTo, step should be:", step);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleKeyDown = (e: React.KeyboardEvent): void => {
|
const handleKeyDown = (e: React.KeyboardEvent): void => {
|
||||||
@@ -59,14 +56,14 @@ export function IntroUI(): React.JSX.Element | null {
|
|||||||
textAlign: "center",
|
textAlign: "center",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
Quel est votre prénom ?
|
Quel est votre prenom ?
|
||||||
</h2>
|
</h2>
|
||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
value={inputValue}
|
value={inputValue}
|
||||||
onChange={(e) => setInputValue(e.target.value)}
|
onChange={(e) => setInputValue(e.target.value)}
|
||||||
onKeyDown={handleKeyDown}
|
onKeyDown={handleKeyDown}
|
||||||
placeholder="Votre prénom"
|
placeholder="Votre prenom"
|
||||||
autoFocus
|
autoFocus
|
||||||
style={{
|
style={{
|
||||||
padding: "0.75rem",
|
padding: "0.75rem",
|
||||||
|
|||||||
@@ -4,20 +4,7 @@ import {
|
|||||||
useGameStore,
|
useGameStore,
|
||||||
} from "@/managers/stores/useGameStore";
|
} from "@/managers/stores/useGameStore";
|
||||||
import { isMissionStep, MISSION_STEPS } from "@/types/gameplay/repairMission";
|
import { isMissionStep, MISSION_STEPS } from "@/types/gameplay/repairMission";
|
||||||
import { type GameStep } from "@/types/game";
|
import { GAME_STEPS, type GameStep } from "@/types/game";
|
||||||
|
|
||||||
const GAME_STEPS: GameStep[] = [
|
|
||||||
"intro",
|
|
||||||
"start-intro",
|
|
||||||
"naming",
|
|
||||||
"bienvenue",
|
|
||||||
"star-move",
|
|
||||||
"mission2",
|
|
||||||
"searching",
|
|
||||||
"helped",
|
|
||||||
"manipulation",
|
|
||||||
"outOfFabrik",
|
|
||||||
];
|
|
||||||
|
|
||||||
const MAIN_STATES: MainGameState[] = [
|
const MAIN_STATES: MainGameState[] = [
|
||||||
"intro",
|
"intro",
|
||||||
|
|||||||
@@ -4,24 +4,11 @@ import * as THREE from "three";
|
|||||||
import { ZONES } from "@/data/zones";
|
import { ZONES } from "@/data/zones";
|
||||||
import { useGameStore } from "@/managers/stores/useGameStore";
|
import { useGameStore } from "@/managers/stores/useGameStore";
|
||||||
import { Debug } from "@/utils/debug/Debug";
|
import { Debug } from "@/utils/debug/Debug";
|
||||||
import type { GameStep } from "@/types/game";
|
import { GAME_STEPS } from "@/types/game";
|
||||||
|
|
||||||
const _playerPos = new THREE.Vector3();
|
const _playerPos = new THREE.Vector3();
|
||||||
const _zonePos = new THREE.Vector3();
|
const _zonePos = new THREE.Vector3();
|
||||||
|
|
||||||
const GAME_STEPS: GameStep[] = [
|
|
||||||
"intro",
|
|
||||||
"start-intro",
|
|
||||||
"naming",
|
|
||||||
"bienvenue",
|
|
||||||
"star-move",
|
|
||||||
"mission2",
|
|
||||||
"searching",
|
|
||||||
"helped",
|
|
||||||
"manipulation",
|
|
||||||
"outOfFabrik",
|
|
||||||
];
|
|
||||||
|
|
||||||
export function ZoneDetection(): null {
|
export function ZoneDetection(): null {
|
||||||
const camera = useThree((state) => state.camera);
|
const camera = useThree((state) => state.camera);
|
||||||
const triggeredZones = useRef<Set<string>>(new Set());
|
const triggeredZones = useRef<Set<string>>(new Set());
|
||||||
@@ -88,41 +75,6 @@ export function ZoneDetection(): null {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface ZoneVisualProps {
|
|
||||||
position: [number, number, number];
|
|
||||||
radius: number;
|
|
||||||
height: number;
|
|
||||||
triggered: boolean;
|
|
||||||
}
|
|
||||||
|
|
||||||
function ZoneVisual({
|
|
||||||
position,
|
|
||||||
radius,
|
|
||||||
height,
|
|
||||||
triggered,
|
|
||||||
}: ZoneVisualProps): React.JSX.Element {
|
|
||||||
const color = triggered ? "#00ff00" : "#ff0000";
|
|
||||||
|
|
||||||
return (
|
|
||||||
<group position={position}>
|
|
||||||
<mesh rotation={[-Math.PI / 2, 0, 0]}>
|
|
||||||
<ringGeometry args={[radius - 0.3, radius, 32]} />
|
|
||||||
<meshBasicMaterial color={color} side={THREE.DoubleSide} />
|
|
||||||
</mesh>
|
|
||||||
<mesh position={[0, height / 2, 0]}>
|
|
||||||
<cylinderGeometry args={[radius, radius, height, 32, 1, true]} />
|
|
||||||
<meshBasicMaterial
|
|
||||||
color={color}
|
|
||||||
transparent
|
|
||||||
opacity={0.15}
|
|
||||||
side={THREE.DoubleSide}
|
|
||||||
depthWrite={false}
|
|
||||||
/>
|
|
||||||
</mesh>
|
|
||||||
</group>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
export function ZoneDebugVisuals(): React.JSX.Element | null {
|
export function ZoneDebugVisuals(): React.JSX.Element | null {
|
||||||
const debug = Debug.getInstance();
|
const debug = Debug.getInstance();
|
||||||
const camera = useThree((state) => state.camera);
|
const camera = useThree((state) => state.camera);
|
||||||
@@ -161,3 +113,36 @@ export function ZoneDebugVisuals(): React.JSX.Element | null {
|
|||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function ZoneVisual({
|
||||||
|
position,
|
||||||
|
radius,
|
||||||
|
height,
|
||||||
|
triggered,
|
||||||
|
}: {
|
||||||
|
position: [number, number, number];
|
||||||
|
radius: number;
|
||||||
|
height: number;
|
||||||
|
triggered: boolean;
|
||||||
|
}): React.JSX.Element {
|
||||||
|
const color = triggered ? "#00ff00" : "#ff0000";
|
||||||
|
|
||||||
|
return (
|
||||||
|
<group position={position}>
|
||||||
|
<mesh rotation={[-Math.PI / 2, 0, 0]}>
|
||||||
|
<ringGeometry args={[radius - 0.3, radius, 32]} />
|
||||||
|
<meshBasicMaterial color={color} side={THREE.DoubleSide} />
|
||||||
|
</mesh>
|
||||||
|
<mesh position={[0, height / 2, 0]}>
|
||||||
|
<cylinderGeometry args={[radius, radius, height, 32, 1, true]} />
|
||||||
|
<meshBasicMaterial
|
||||||
|
color={color}
|
||||||
|
transparent
|
||||||
|
opacity={0.15}
|
||||||
|
side={THREE.DoubleSide}
|
||||||
|
depthWrite={false}
|
||||||
|
/>
|
||||||
|
</mesh>
|
||||||
|
</group>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,27 +0,0 @@
|
|||||||
import { useState } from "react";
|
|
||||||
|
|
||||||
interface DialogState {
|
|
||||||
message: string;
|
|
||||||
visible: boolean;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function useDialog(): {
|
|
||||||
dialog: DialogState;
|
|
||||||
showDialog: (message: string) => void;
|
|
||||||
hideDialog: () => void;
|
|
||||||
} {
|
|
||||||
const [dialog, setDialog] = useState<DialogState>({
|
|
||||||
message: "",
|
|
||||||
visible: false,
|
|
||||||
});
|
|
||||||
|
|
||||||
const showDialog = (message: string): void => {
|
|
||||||
setDialog({ message, visible: true });
|
|
||||||
};
|
|
||||||
|
|
||||||
const hideDialog = (): void => {
|
|
||||||
setDialog((prev) => ({ ...prev, visible: false }));
|
|
||||||
};
|
|
||||||
|
|
||||||
return { dialog, showDialog, hideDialog };
|
|
||||||
}
|
|
||||||
@@ -2,6 +2,8 @@ import { create } from "zustand";
|
|||||||
import type { GameStep } from "@/types/game";
|
import type { GameStep } from "@/types/game";
|
||||||
import {
|
import {
|
||||||
isRepairMissionId,
|
isRepairMissionId,
|
||||||
|
getNextMissionStep,
|
||||||
|
getPreviousMissionStep,
|
||||||
type MissionStep,
|
type MissionStep,
|
||||||
type RepairMissionId,
|
type RepairMissionId,
|
||||||
} from "@/types/gameplay/repairMission";
|
} from "@/types/gameplay/repairMission";
|
||||||
@@ -77,46 +79,6 @@ interface GameActions {
|
|||||||
type GameStore = GameState & GameActions;
|
type GameStore = GameState & GameActions;
|
||||||
type GameStateUpdate = Partial<GameState>;
|
type GameStateUpdate = Partial<GameState>;
|
||||||
|
|
||||||
function getNextMissionStep(step: MissionStep): MissionStep {
|
|
||||||
switch (step) {
|
|
||||||
case "locked":
|
|
||||||
return "waiting";
|
|
||||||
case "waiting":
|
|
||||||
return "inspected";
|
|
||||||
case "inspected":
|
|
||||||
return "fragmented";
|
|
||||||
case "fragmented":
|
|
||||||
return "scanning";
|
|
||||||
case "scanning":
|
|
||||||
return "repairing";
|
|
||||||
case "repairing":
|
|
||||||
return "reassembling";
|
|
||||||
case "reassembling":
|
|
||||||
case "done":
|
|
||||||
return "done";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function getPreviousMissionStep(step: MissionStep): MissionStep {
|
|
||||||
switch (step) {
|
|
||||||
case "locked":
|
|
||||||
case "waiting":
|
|
||||||
return "locked";
|
|
||||||
case "inspected":
|
|
||||||
return "waiting";
|
|
||||||
case "fragmented":
|
|
||||||
return "inspected";
|
|
||||||
case "scanning":
|
|
||||||
return "fragmented";
|
|
||||||
case "repairing":
|
|
||||||
return "scanning";
|
|
||||||
case "reassembling":
|
|
||||||
return "repairing";
|
|
||||||
case "done":
|
|
||||||
return "reassembling";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function completeIntroState(state: GameState): GameStateUpdate {
|
function completeIntroState(state: GameState): GameStateUpdate {
|
||||||
return {
|
return {
|
||||||
mainState: "bike",
|
mainState: "bike",
|
||||||
|
|||||||
+13
-4
@@ -12,6 +12,19 @@ export type GameStep =
|
|||||||
| "manipulation"
|
| "manipulation"
|
||||||
| "outOfFabrik";
|
| "outOfFabrik";
|
||||||
|
|
||||||
|
export const GAME_STEPS: readonly GameStep[] = [
|
||||||
|
"intro",
|
||||||
|
"start-intro",
|
||||||
|
"naming",
|
||||||
|
"bienvenue",
|
||||||
|
"star-move",
|
||||||
|
"mission2",
|
||||||
|
"searching",
|
||||||
|
"helped",
|
||||||
|
"manipulation",
|
||||||
|
"outOfFabrik",
|
||||||
|
] as const;
|
||||||
|
|
||||||
export interface Zone {
|
export interface Zone {
|
||||||
id: string;
|
id: string;
|
||||||
position: Vector3Tuple;
|
position: Vector3Tuple;
|
||||||
@@ -19,7 +32,3 @@ export interface Zone {
|
|||||||
height: number;
|
height: number;
|
||||||
targetStep: GameStep;
|
targetStep: GameStep;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface GameState {
|
|
||||||
step: GameStep;
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -30,3 +30,43 @@ export function isRepairMissionId(value: string): value is RepairMissionId {
|
|||||||
export function isMissionStep(value: string): value is MissionStep {
|
export function isMissionStep(value: string): value is MissionStep {
|
||||||
return (MISSION_STEPS as readonly string[]).includes(value);
|
return (MISSION_STEPS as readonly string[]).includes(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function getNextMissionStep(step: MissionStep): MissionStep {
|
||||||
|
switch (step) {
|
||||||
|
case "locked":
|
||||||
|
return "waiting";
|
||||||
|
case "waiting":
|
||||||
|
return "inspected";
|
||||||
|
case "inspected":
|
||||||
|
return "fragmented";
|
||||||
|
case "fragmented":
|
||||||
|
return "scanning";
|
||||||
|
case "scanning":
|
||||||
|
return "repairing";
|
||||||
|
case "repairing":
|
||||||
|
return "reassembling";
|
||||||
|
case "reassembling":
|
||||||
|
case "done":
|
||||||
|
return "done";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getPreviousMissionStep(step: MissionStep): MissionStep {
|
||||||
|
switch (step) {
|
||||||
|
case "locked":
|
||||||
|
case "waiting":
|
||||||
|
return "locked";
|
||||||
|
case "inspected":
|
||||||
|
return "waiting";
|
||||||
|
case "fragmented":
|
||||||
|
return "inspected";
|
||||||
|
case "scanning":
|
||||||
|
return "fragmented";
|
||||||
|
case "repairing":
|
||||||
|
return "scanning";
|
||||||
|
case "reassembling":
|
||||||
|
return "repairing";
|
||||||
|
case "done":
|
||||||
|
return "reassembling";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user