Skip to content

Commit

Permalink
talk add skip
Browse files Browse the repository at this point in the history
  • Loading branch information
TiyoSheng committed Dec 1, 2023
1 parent 6fef9c9 commit bb57a85
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
8 changes: 7 additions & 1 deletion packages/client/src/components/Talk/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ import dark from '@/assets/img/duck_index.png';

const Talk = (props) => {
const {position, text, curPlayer, step, sample } = props;

const skip = () => {
// 阻止冒泡
event.stopPropagation();
props.onSkip();
};
return (
<div className='talk'>
<div className='talk-main'>
Expand All @@ -31,7 +37,7 @@ const Talk = (props) => {
<div className='step'>{step} / 9</div>
<div className='name' style={{marginBottom: '18px'}}>{curPlayer?.name || 'Mistery Duck'}:</div>
<Typewriter text={text} typingSpeed={30} step={step} />
<div style={{position: 'absolute', bottom: '18px', right: '18px', fontSize: '12px', color: 'rgba(255, 255, 255, 0.80)'}}>Click any button to continue</div>
<div style={{position: 'absolute', bottom: '18px', right: '18px', fontSize: '12px', color: 'rgba(255, 255, 255, 0.80)', cursor: 'pointer'}} onClick={skip}>Skip The Tutorial {'>'}</div>
</div>
</div>
</div>
Expand Down
2 changes: 2 additions & 0 deletions packages/client/src/components/Talk/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@
position: absolute;
top: -40px;
right: 0px;
display: flex;
align-items: center;
}
}
}
Expand Down
8 changes: 7 additions & 1 deletion packages/client/src/pages/game/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,12 @@ const Game = () => {
}
}

const onSkip = async () => {
setTalked('true')
localStorage.setItem('talked', 'true')
return
}

const blockTime = BLOCK_TIME[network?.publicClient?.chain?.id]
return (
<GameContext.Provider
Expand Down Expand Up @@ -497,7 +503,7 @@ const Game = () => {
<PIXIAPP/>
}
{
(curPlayer && percentage == 100 && (talked == 'false')) ? <Talk onNext={onNext} text={TALK_MAIN[step].text} sample={TALK_MAIN[step].img} step={step + 1} /> : null
(curPlayer && percentage == 100 && (talked == 'false')) ? <Talk onNext={onNext} onSkip={onSkip} text={TALK_MAIN[step].text} sample={TALK_MAIN[step].img} step={step + 1} /> : null
}
<div className="discord">
<a href="https://discord.gg/UkarGN9Fjn" target="_blank"><img src={discordImg} /></a>
Expand Down

0 comments on commit bb57a85

Please sign in to comment.