From 6cb416e2fd785df49318f1cb62a150b7a3427c2e Mon Sep 17 00:00:00 2001 From: Tiyo Date: Mon, 27 Nov 2023 22:22:33 +0800 Subject: [PATCH] fix: fix bug --- packages/client/src/components/Log/index.jsx | 4 +-- .../client/src/components/Log/styles.scss | 7 ++++ packages/client/src/components/Talk/index.jsx | 9 +++-- .../client/src/components/Talk/styles.scss | 29 ++++++++++++++++ .../src/components/Typewriter/index.jsx | 34 +++++++++++++++++++ packages/client/src/pages/game/index.tsx | 1 - 6 files changed, 79 insertions(+), 5 deletions(-) create mode 100644 packages/client/src/components/Typewriter/index.jsx diff --git a/packages/client/src/components/Log/index.jsx b/packages/client/src/components/Log/index.jsx index 4a316c47..a46203bb 100644 --- a/packages/client/src/components/Log/index.jsx +++ b/packages/client/src/components/Log/index.jsx @@ -34,9 +34,9 @@ const Log = () => { }, []); return ( -
+
Log
-
+
{ logs.map((log, index) => (
{log?.type == 'error' ? 'Error' : log.block || 'waiting'} {log.msg}
diff --git a/packages/client/src/components/Log/styles.scss b/packages/client/src/components/Log/styles.scss index e69de29b..f84b35ac 100644 --- a/packages/client/src/components/Log/styles.scss +++ b/packages/client/src/components/Log/styles.scss @@ -0,0 +1,7 @@ +.log-content { + scrollbar-width: none; + -ms-overflow-style: none; + &::-webkit-scrollbar { + display: none; /* Chrome Safari */ + } +} \ No newline at end of file diff --git a/packages/client/src/components/Talk/index.jsx b/packages/client/src/components/Talk/index.jsx index c48de982..9f5a8bff 100644 --- a/packages/client/src/components/Talk/index.jsx +++ b/packages/client/src/components/Talk/index.jsx @@ -1,10 +1,12 @@ import React, { useState } from 'react'; import './styles.scss'; import Player from '@/components/PIXIPlayers/Player'; +import Typewriter from '@/components/Typewriter'; import { Stage } from '@pixi/react'; +import dark from '@/assets/img/duck_index.png'; const Talk = (props) => { - const {position, text, curPlayer } = props; + const {position, text = 'I used to be an adventurer like you, then I took an arrow in the knee', curPlayer } = props; console.log('curPlayer', curPlayer); return (
@@ -20,9 +22,12 @@ const Talk = (props) => { equip={curPlayer?.equip} /> - ) : null + ) : }
+
+ +
); diff --git a/packages/client/src/components/Talk/styles.scss b/packages/client/src/components/Talk/styles.scss index 41a53733..41abcf68 100644 --- a/packages/client/src/components/Talk/styles.scss +++ b/packages/client/src/components/Talk/styles.scss @@ -9,5 +9,34 @@ .talk-main { width: 1280px; margin: auto; + position: absolute; + bottom: 40px; + left: 0; + right: 0; + .player { + + } + .dark { + transform: rotateY(180deg) translateY(-80px); + width: 200px; + height: auto; + margin-top: -100px; + } + .text { + border-radius: 20px; + border: 10px solid #DCC7AF; + background: #6F391E; + box-shadow: 0px 4px 4px 0px rgba(0, 0, 0, 0.25); + width: 1280px; + height: 190px; + box-sizing: border-box; + margin-top: -100px; + position: relative; + z-index: 9; + padding: 16px 20px; + color: #FFF; + font-size: 22px; + font-family: 'MISS'; + } } } \ No newline at end of file diff --git a/packages/client/src/components/Typewriter/index.jsx b/packages/client/src/components/Typewriter/index.jsx new file mode 100644 index 00000000..e486f10d --- /dev/null +++ b/packages/client/src/components/Typewriter/index.jsx @@ -0,0 +1,34 @@ +import React, { useState, useEffect } from 'react'; + +function Typewriter({ text, typingSpeed, step, name }) { + const [displayText, setDisplayText] = useState(''); + const [currentIndex, setCurrentIndex] = useState(0); + + useEffect(() => { + const interval = setInterval(() => { + if (currentIndex < text.length) { + setDisplayText((prevText) => prevText + text[currentIndex]); + setCurrentIndex((prevIndex) => prevIndex + 1); + } else { + clearInterval(interval); + } + }, typingSpeed); + + return () => { + clearInterval(interval); + }; + }, [text, typingSpeed, currentIndex]); + + useEffect(() => { + setDisplayText(''); + setCurrentIndex(0); + }, [step]); + + return
+
{name || 'Mistery Duck'}:
+ {displayText} +
Click any button to continue
+
; +} + +export default Typewriter; \ No newline at end of file diff --git a/packages/client/src/pages/game/index.tsx b/packages/client/src/pages/game/index.tsx index cb53e399..1304c32d 100644 --- a/packages/client/src/pages/game/index.tsx +++ b/packages/client/src/pages/game/index.tsx @@ -487,7 +487,6 @@ const Game = () => { : } -