Skip to content

Commit

Permalink
Merge branch 'feat-mvp' of github.com:Mississippi-Labs/mississippi in…
Browse files Browse the repository at this point in the history
…to feat-mvp
  • Loading branch information
LidamaoHub committed Nov 27, 2023
2 parents b18ac6a + 6cb416e commit 403fe30
Show file tree
Hide file tree
Showing 21 changed files with 376 additions and 60 deletions.
8 changes: 8 additions & 0 deletions packages/client/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,17 @@ import Test from './pages/test';
import Home from '@/pages/home';
import HeroEdit from '@/pages/heroEdit';
import PIXIAPP from '@/components/PIXIAPP';
import { useEffect } from 'react';

export const App = () => {

useEffect(() => {
document.body.addEventListener('contextmenu', (e) => {
e.preventDefault();
return false;
})
}, [])

return (
<div className="mi-app">
<BrowserRouter>
Expand Down
36 changes: 36 additions & 0 deletions packages/client/src/components/Equipment/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import React from 'react';
import './styles.scss';

export interface IEquipment {
type: string;
name?: string | undefined;
}

const Equipment = (props: IEquipment) => {

const { name, type } = props;

if (!name) {
return null;
}

return (
<div className={'mi-equipment'} style={{
backgroundImage: `url("/assets/img/hero/${type}/${name}.png")`,
}}>
<div className="equipment-info">
<div className="equipment-info-content">
<ul className="loot-list">
<li className="loot-item"></li>
<li className="loot-item"></li>
<li className="loot-item"></li>
</ul>

<p className="equipment-desc">This piece of equipment is synthesized from 3 pieces of loot</p>
</div>
</div>
</div>
);
};

export default Equipment;
72 changes: 72 additions & 0 deletions packages/client/src/components/Equipment/styles.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
.mi-equipment {
position: relative;
width: 64px;
height: 64px;
background-repeat: no-repeat;
image-rendering: pixelated;
background-size: 1600%;
background-position: 2px 4px;

.equipment-info {
display: none;
position: absolute;
z-index: 1;
top: -80px;
left: 99%;
width: 440px;
padding-left: 20px;
height: 226px;


.equipment-info-content {
position: relative;
width: 420px;
height: 100%;
padding: 12px;
border-radius: 10px;
border: 5px solid #DCC7AF;
background: #FFF5E9;

&::before, &::after {
content: '';
position: absolute;
right: 100%;
top: 50%;
transform: translate3d(0, -50%, 0);
}

&::before {
border: 20px solid;
border-color: transparent #DCC7AF transparent transparent;
}

&::after {
border: 14px solid;
transform: translate3d(1px, -50%, 0);
border-color: transparent #FFF5E9 transparent transparent;
}
}

.loot-list {
display: flex;
justify-content: space-between;

.loot-item {
width: 120px;
height: 120px;
background: #000;
}
}

.equipment-desc {
margin-top: 12px;
font-size: 12px;
line-height: 1.57;
color: #BC8C61;
}
}

&:hover .equipment-info {
//display: block;
}
}
15 changes: 7 additions & 8 deletions packages/client/src/components/Log/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ const Log = () => {

useEffect(() => {
function addLogCb(e) {
console.log('e', e);
console.log('logsTemp', logs);
let index = logs.findIndex(log => log.time === e.time);
if (index > -1) {
logs[index] = e;
Expand All @@ -28,16 +26,17 @@ const Log = () => {
}
setLogs([...logs]);
}
eventEmitter.on('log', addLogCb);
return () => {
eventEmitter.off('log', addLogCb);
};
try {
eventEmitter?.on('log', addLogCb);
} catch (error) {
console.log('eventEmitter.on error', error);
}
}, []);

return (
<div style={{ fontFamily: 'MISS', height: '200px', position: 'fixed', bottom: '40px', left: '18px', zIndex: '99' }}>
<div style={{ fontFamily: 'MISS', height: '200px', position: 'fixed', bottom: '40px', left: '18px', zIndex: '99', width: '250px' }}>
<div className="title" style={{ width: '249px', height: '32px', color: '#FFF', fontSize: '18px' }}>Log</div>
<div ref={myLog} style={{height: '168px',overflow: 'auto'}}>
<div className='log-content' ref={myLog} style={{height: '168px',overflow: 'auto', width: '250px'}}>
{
logs.map((log, index) => (
<div key={index} style={{ color: log?.type == 'error' ? '#F00' : log.block ? '#FFF' : '#FFE303', fontSize: '10px', lineHeight: '1.4', marginBottom: '10px' }}>{log?.type == 'error' ? 'Error' : log.block || 'waiting'} {log.msg}</div>
Expand Down
7 changes: 7 additions & 0 deletions packages/client/src/components/Log/styles.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.log-content {
scrollbar-width: none;
-ms-overflow-style: none;
&::-webkit-scrollbar {
display: none; /* Chrome Safari */
}
}
2 changes: 1 addition & 1 deletion packages/client/src/components/PIXIAPP/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ const PIXIAPP = () => {
break;
case 'click':
targetChests = treasureChest.filter(item => item.x === coordinate.x && item.y === coordinate.y);
if (targetChests.length > 0 && getDistance(curPlayer, coordinate) <= 1) {
if (targetChests.length > 0 && getDistance(curPlayer, coordinate) < 2) {
openTreasureChest(targetChests[0].id);
return;
}
Expand Down
1 change: 1 addition & 0 deletions packages/client/src/components/PIXIPlayers/Player.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export interface IPlayer {
strength: number;
space: number;
oreBalance: number;
seasonOreBalance: number;
treasureBalance: number;
state: number;
lastBattleTime: number;
Expand Down
36 changes: 36 additions & 0 deletions packages/client/src/components/Talk/index.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
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 = 'I used to be an adventurer like you, then I took an arrow in the knee', curPlayer } = props;
console.log('curPlayer', curPlayer);
return (
<div className='talk'>
<div className='talk-main'>
<div className='player'>
{
curPlayer?.equip ? (
<Stage width={238} height={281} options={{ resolution: 1, backgroundAlpha: 0 }} style={{transform: 'rotateY(180deg)', marginLeft: 'auto'}} >
<Player
size={128}
x={0.5}
y={0.5}
equip={curPlayer?.equip}
/>
</Stage>
) : <img src={dark} className='dark' />
}
</div>
<div className='text'>
<Typewriter text={text} typingSpeed={50} name={curPlayer?.name || ''} />
</div>
</div>
</div>
);
};

export default Talk;
42 changes: 42 additions & 0 deletions packages/client/src/components/Talk/styles.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
.talk {
position: fixed;
top: 0;
bottom: 0;
left: 0;
right: 0;
z-index: 999;
background: rgba(0, 0, 0, 0.5);
.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';
}
}
}
34 changes: 34 additions & 0 deletions packages/client/src/components/Typewriter/index.jsx
Original file line number Diff line number Diff line change
@@ -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 <div style={{width: '100%', height: '100%', position: 'relative'}}>
<div className='name' style={{marginBottom: '18px'}}>{name || 'Mistery Duck'}:</div>
{displayText}
<div style={{position: 'absolute', bottom: '0px', right: '0px', fontSize: '12px', color: 'rgba(255, 255, 255, 0.80)'}}>Click any button to continue</div>
</div>;
}

export default Typewriter;
3 changes: 1 addition & 2 deletions packages/client/src/components/UserAvatar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ interface IProps extends IPlayer {
const UserAvatar = (props: IProps) => {
const [diffHp, setDiffHp] = useState(0);
const { address, balance, ...rest } = props;
console.log(props, 'props')
useEffect(() => {
setDiffHp(props.diffHp)
setTimeout(() => {
Expand All @@ -29,7 +28,7 @@ const UserAvatar = (props: IProps) => {

<div className='user-info'>
<div className='user-hp'>
<div className='now-hp' style={{width: (props.hp / props.maxHp) * 100 + '%'}}></div>
<div className='now-hp' ><div className='hp' style={{width: (props.hp / props.maxHp) * 100 + '%'}}></div></div>
{
diffHp > 0 ? <div className='diff-hp'>+{diffHp}</div> : null
}
Expand Down
14 changes: 11 additions & 3 deletions packages/client/src/components/UserAvatar/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
.user-hp {
border-radius: 5px;
border: 5px solid #DDC9B2;
background: #FFF;
background: #DDC9B2;
width: 300px;
height: 25px;
box-sizing: border-box;
Expand All @@ -56,10 +56,18 @@
position: absolute;
left: 0;
top: 0;
right: 0;
height: 15px;
background: #FF0000;
background: #fff;
border-radius: 5px;
width: 50%;
.hp {
position: absolute;
left: 0;
top: 0;
height: 15px;
background: #f00;
border-radius: 5px;
}
}
.diff-hp {
font-family: MISS;
Expand Down
Loading

0 comments on commit 403fe30

Please sign in to comment.