make selectCharacterPage usable and create template for dialog
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
This commit is contained in:
parent
4d22f2ca0b
commit
7529dc0fcb
7 changed files with 160 additions and 137 deletions
BIN
src/assets/arrow.png
Normal file
BIN
src/assets/arrow.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.1 KiB |
35
src/css/selectCharacter.css
Normal file
35
src/css/selectCharacter.css
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
/* Ensure you include global units, responsive layout and class targeting */
|
||||||
|
.selection-container {
|
||||||
|
position: fixed;
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
width: 100vw;
|
||||||
|
height: 100vh;
|
||||||
|
z-index: 1;
|
||||||
|
margin-top: 25vh;
|
||||||
|
}
|
||||||
|
|
||||||
|
.button {
|
||||||
|
width: 10vw;
|
||||||
|
height: 20vh;
|
||||||
|
}
|
||||||
|
|
||||||
|
.button img {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.textBox {
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
width: 60vw;
|
||||||
|
height: 20vh;
|
||||||
|
background-color: white;
|
||||||
|
color: #8391b8;
|
||||||
|
border-style: solid;
|
||||||
|
border-color: #8391b8;
|
||||||
|
border-width: 5px;
|
||||||
|
border-radius: 30px;
|
||||||
|
}
|
30
src/pages/class/DialogPorsche.jsx
Normal file
30
src/pages/class/DialogPorsche.jsx
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
const dialogData = [
|
||||||
|
{
|
||||||
|
type: "conversation",
|
||||||
|
name: "Porsche",
|
||||||
|
text: "Hi",
|
||||||
|
sprite: "M_Porsche_cross_arm.zip",
|
||||||
|
background: "hallway.png",
|
||||||
|
goTo: 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: "option",
|
||||||
|
name: "Porsche",
|
||||||
|
option: [
|
||||||
|
{ text: "option1", goTo: 2 },
|
||||||
|
{ text: "option2", goTo: 3 }
|
||||||
|
],
|
||||||
|
sprite: "M_Porsche_cross_arm.zip",
|
||||||
|
background: "hallway.png"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: "story",
|
||||||
|
text: "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magnam aliquam quaerat voluptatem.",
|
||||||
|
background: "hallway.png",
|
||||||
|
goTo: 4
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
|
|
||||||
|
export default dialogData;
|
||||||
|
|
11
src/pages/class/character.jsx
Normal file
11
src/pages/class/character.jsx
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
class Character {
|
||||||
|
name(num) {
|
||||||
|
return ["Invalid", "Porsche", "Pie", "Patt"][num] || "Invalid";
|
||||||
|
}
|
||||||
|
|
||||||
|
position(num) {
|
||||||
|
return ["Invalid", "right", "left", "middle"][num] || "Invalid";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default Character;
|
28
src/pages/components/introductionData.jsx
Normal file
28
src/pages/components/introductionData.jsx
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
function IntroductionData({ onClickedIntroduction }) {
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
onClick={onClickedIntroduction}
|
||||||
|
style={{
|
||||||
|
position: "fixed",
|
||||||
|
top: 0,
|
||||||
|
left: 0,
|
||||||
|
width: "100vw",
|
||||||
|
height: "100vh",
|
||||||
|
background: "rgba(var(--black), 0.5)",
|
||||||
|
display: 'flex',
|
||||||
|
justifyContent: 'center',
|
||||||
|
alignItems: 'center',
|
||||||
|
zIndex: 1
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<label style={{ color: "rgb(var(--white))", fontWeight: "bold" }}>
|
||||||
|
You are a new student who just <br />
|
||||||
|
transferred to this school not long ago. <br />
|
||||||
|
You don't know anyone yet, <br />
|
||||||
|
but eventually you meet...
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default IntroductionData;
|
21
src/pages/components/selectionCharacter.jsx
Normal file
21
src/pages/components/selectionCharacter.jsx
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
import '../../css/selectCharacter.css';
|
||||||
|
import arrowPic from '../../assets/arrow.png'
|
||||||
|
|
||||||
|
function SelectionCharacter({ onClickedLeft, onClickedRight, nameChar, onClickedButton }) {
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="selection-container">
|
||||||
|
<div className="button left" onClick={onClickedLeft}>
|
||||||
|
<img src={arrowPic} alt="Left Character" />
|
||||||
|
</div>
|
||||||
|
<button onClick={onClickedButton} className="textBox">
|
||||||
|
{nameChar}
|
||||||
|
</button>
|
||||||
|
<div className="button right" onClick={onClickedRight}>
|
||||||
|
<img src={arrowPic} alt="Right Character" style={{ transform: 'rotate(180deg)' }}/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default SelectionCharacter;
|
|
@ -1,166 +1,64 @@
|
||||||
import { useState } from 'react'
|
import { useState } from 'react';
|
||||||
import '../css/global.css'
|
import '../css/global.css';
|
||||||
import BlackButton from './components/customButton'
|
import BlackButton from './components/customButton';
|
||||||
import Animation from './components/animation.jsx';
|
import Animation from './components/animation.jsx';
|
||||||
import PlayVideo from './components/playVideo.jsx';
|
import PlayVideo from './components/playVideo.jsx';
|
||||||
import LoadingScene from './components/loadingScene.jsx';
|
import LoadingScene from './components/loadingScene.jsx';
|
||||||
|
import IntroductionData from './components/introductionData.jsx';
|
||||||
function IntroductionData({onClickedIntroduction}){
|
import SelectionCharacter from './components/selectionCharacter.jsx';
|
||||||
|
import Character from './class/character.jsx';
|
||||||
return(
|
|
||||||
<div
|
|
||||||
onClick={onClickedIntroduction}
|
|
||||||
style={{
|
|
||||||
position: "fixed",
|
|
||||||
top: 0,
|
|
||||||
left: 0,
|
|
||||||
width: "100vw",
|
|
||||||
height: "100vh",
|
|
||||||
background: "rgba(var(--black), 0.5)",
|
|
||||||
display: 'flex',
|
|
||||||
justifyContent: 'center',
|
|
||||||
alignItems: 'center',
|
|
||||||
zIndex: 1 // Ensure this is above other elements
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<label style={{color:"rgb(var(--white))", fontWeight:"bold"}}>
|
|
||||||
You are a new student who just <br />
|
|
||||||
transfered to this school not long ago. <br />
|
|
||||||
You don't know anyone yet, <br />
|
|
||||||
but eventually you meet...
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
function SelectionCharacter(){
|
|
||||||
const [numChar, setNumChar] = useState(1);
|
|
||||||
|
|
||||||
const handleLeftClicked = () => {
|
|
||||||
var temp = numChar - 1
|
|
||||||
if (temp<1){
|
|
||||||
setNumChar(3)
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
setNumChar(temp)
|
|
||||||
}
|
|
||||||
};
|
|
||||||
const handleRightClicked = () => {
|
|
||||||
var temp = numChar + 1
|
|
||||||
if (temp>3){
|
|
||||||
setNumChar(1)
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
setNumChar(temp)
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
class Character {
|
|
||||||
name(num) {
|
|
||||||
if (num === 1) {
|
|
||||||
return "Porsche";
|
|
||||||
} else if (num === 2) {
|
|
||||||
return "Pie";
|
|
||||||
} else if (num === 3) {
|
|
||||||
return "Patt";
|
|
||||||
} else {
|
|
||||||
return "Invalid";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
position(num) {
|
|
||||||
if (num === 1) {
|
|
||||||
return "left";
|
|
||||||
} else if (num === 2) {
|
|
||||||
return "middle";
|
|
||||||
} else if (num === 3) {
|
|
||||||
return "right";
|
|
||||||
} else {
|
|
||||||
return "Invalid";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const character = new Character();;
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div style={{
|
|
||||||
position: "fixed",
|
|
||||||
display: 'flex',
|
|
||||||
justifyContent: 'center',
|
|
||||||
alignItems: 'center',
|
|
||||||
width: "100vw",
|
|
||||||
height: "100vh",
|
|
||||||
zIndex: 1,
|
|
||||||
}}>
|
|
||||||
<div className="button left"
|
|
||||||
onClick={handleLeftClicked}
|
|
||||||
style={{
|
|
||||||
// background: 'white',
|
|
||||||
width:'10vw',
|
|
||||||
height:'20vh'
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<img src="https://placehold.co/400x600" style={{width:'100%',height:'100%'}}/>
|
|
||||||
</div>
|
|
||||||
<div className="textBox"
|
|
||||||
style={{
|
|
||||||
display: 'flex',
|
|
||||||
justifyContent: 'center',
|
|
||||||
alignItems: 'center',
|
|
||||||
width:'10vw',
|
|
||||||
height:'20vh'
|
|
||||||
}}>
|
|
||||||
{character.name(numChar)}
|
|
||||||
</div>
|
|
||||||
<div className="button right"
|
|
||||||
onClick={handleRightClicked}
|
|
||||||
style={{
|
|
||||||
// background: 'white',
|
|
||||||
width:'10vw',
|
|
||||||
height:'20vh'
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<img src="https://placehold.co/400x600" style={{width:'100%',height:'100%'}}/>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
function IntroductionPage() {
|
function IntroductionPage() {
|
||||||
|
|
||||||
const [loading, setLoading] = useState(true);
|
const [loading, setLoading] = useState(true);
|
||||||
const [positionState, setPositionState] = useState("middle");
|
const [positionState, setPositionState] = useState("middle");
|
||||||
const [isClickedIntroduction, setIsClickedIntroduction] = useState(false);
|
const [isClickedIntroduction, setIsClickedIntroduction] = useState(false);
|
||||||
|
const [numChar, setNumChar] = useState(1);
|
||||||
|
const character = new Character();
|
||||||
|
|
||||||
|
const handleLeftClicked = () => {
|
||||||
|
setNumChar(prev => (prev - 1 < 1 ? 3 : prev - 1));
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleRightClicked = () => {
|
||||||
|
setNumChar(prev => (prev + 1 > 3 ? 1 : prev + 1));
|
||||||
|
};
|
||||||
|
|
||||||
const handleClickIntroduction = () => {
|
const handleClickIntroduction = () => {
|
||||||
setIsClickedIntroduction(true);
|
setIsClickedIntroduction(true);
|
||||||
console.log(isClickedIntroduction)
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleVideoReady = () => {
|
const handleVideoReady = () => {
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleClickedButton = () => {
|
||||||
|
console.log(character.name(numChar))
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div style={{
|
<div style={{ width: "100vw", height: "100vh" }}>
|
||||||
width: "100vw",
|
|
||||||
height: "100vh",
|
|
||||||
}}>
|
|
||||||
{loading ? (
|
{loading ? (
|
||||||
<LoadingScene />
|
<LoadingScene />
|
||||||
) : (
|
) : (
|
||||||
!isClickedIntroduction ? (
|
!isClickedIntroduction ? (
|
||||||
<IntroductionData onClickedIntroduction={handleClickIntroduction} />
|
<IntroductionData onClickedIntroduction={handleClickIntroduction} />
|
||||||
) : (
|
) : (
|
||||||
<SelectionCharacter />
|
<SelectionCharacter
|
||||||
|
onClickedLeft={handleLeftClicked}
|
||||||
|
onClickedRight={handleRightClicked}
|
||||||
|
nameChar={character.name(numChar)}
|
||||||
|
onClickedButton={handleClickedButton}
|
||||||
|
/>
|
||||||
)
|
)
|
||||||
)}
|
)}
|
||||||
|
<PlayVideo
|
||||||
<PlayVideo src='hallway_FFF.mp4' side='middle' onVideoReady={handleVideoReady} />
|
src='hallway_FFF.mp4'
|
||||||
|
side={character.position(numChar)}
|
||||||
|
onVideoReady={handleVideoReady}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export default IntroductionPage;
|
||||||
|
|
||||||
export default IntroductionPage
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue