diff --git a/handtris/src/components/TetrisPlay.tsx b/handtris/src/components/TetrisPlay.tsx index cb8c8aa..fb270bd 100644 --- a/handtris/src/components/TetrisPlay.tsx +++ b/handtris/src/components/TetrisPlay.tsx @@ -69,6 +69,15 @@ const Home: React.FC = () => { const [isFlipping, setIsFlipping] = useState(false); const [isNextBlockDonut, setIsNextBlockDonut] = useState(false); const [showDonutWarning, setShowDonutWarning] = useState(false); + const [animationState, setAnimationState] = useState({ + opacity: 1, + y: 0, + }); + const [donutAttackToggle, setDonutAttackToggle] = useState( + tetrisGameRef.current?.isDonutAttackToggleOn + ? "/image/DropPressed.png" + : "/image/DropDefault.png", + ); const fetchRoomPlayers = useCallback(async () => { setIsLoading(true); try { @@ -911,6 +920,27 @@ const Home: React.FC = () => { } }); + useEffect(() => { + let timeoutId; + if ( + !tetrisGameRef.current?.isDonutAttackToggleOn && + tetrisGameRef.current?.linesCleared > 0 + ) { + setAnimationState({ opacity: 0, y: -500 }); + + // Change the image after 1 second if `isDonutAttackToggleOn` is false + timeoutId = setTimeout(() => { + setAnimationState({ opacity: 1, y: 0 }); + setDonutAttackToggle("/image/DropDefault.png"); + }, 1000); + } else if (tetrisGameRef.current?.linesCleared > 0) { + setAnimationState({ opacity: 1, y: 0 }); + setDonutAttackToggle("/image/DropPressed.png"); + } + + return () => clearTimeout(timeoutId); + }, [tetrisGameRef.current?.isDonutAttackToggleOn]); + const toggleShowFirstAttack = useCallback(() => { setShowFirstAttack(true); setTimeout(() => setShowFirstAttack(false), 500); @@ -1005,122 +1035,185 @@ const Home: React.FC = () => {
-
-
-
-
-
-
- {isDangerous && ( -
- DANGER! -
- )} - {isFlipping && ( -
- - FLIP! - -
- )} - {showDonutWarning && ( -
- DONUT INCOMING! -
- )} -
-
+
+
+
+ {/* 첫 번째 아이콘 */} + gauge indicator + + {/* 두 번째 아이콘 */} + gauge indicator + + {/* 세 번째 아이콘 */} + gauge indicator
- {showFirstAttacked && ( -
-
-
- -
+
+
+
+
+ {isDangerous && ( +
+ DANGER!
-
- )} - {!isHandDetected && ( -
-
- HANDS NOT DETECTED! -
- Please show your hands + )} + {isFlipping && ( +
+ + FLIP! +
-
- )} -
-
-
-
-
- {isNextBlockDonut ? "DONUT!" : "NEXT"} + )} + {showDonutWarning && ( +
+ DONUT INCOMING!
+ )} +
-
-
- Attack + {showFirstAttacked && ( +
+
+
+ +
+
-
- {linesCleared !== null ? linesCleared : 0} + )} + {!isHandDetected && ( +
+
+ HANDS NOT DETECTED! +
+ Please show your hands +
-
+ )}
-
-
- Your Hands -
-
-
+
+
+
+
+ {isNextBlockDonut ? "DONUT!" : "NEXT"} +
-
+
+
+ Attack +
+
+ {/* TODO - 공격 횟수로 수정이 필요함 */} + {linesCleared !== null ? linesCleared : 0} +
+
+
+
+
+ Your Hands +
+
+
+ +
+
+
@@ -1227,26 +1320,40 @@ const Home: React.FC = () => { ATTACK CMD
- Drop - Rotate + transition={{ duration: 1.0 }} + className="z-50" + > + gauge indicator + + + gauge indicator +