Commit da024111 authored by Chunchi Che's avatar Chunchi Che

update cemetery ui

parent 46794a85
Pipeline #19104 passed with stages
in 3 minutes and 41 seconds
import * as BABYLON from "@babylonjs/core"; import * as BABYLON from "@babylonjs/core";
import * as CONFIG from "../../config/ui"; import * as CONFIG from "../../config/ui";
import { Cemetery } from "../../reducers/duel/util";
import {
selectMeCemetery,
selectOpCemetery,
} from "../../reducers/duel/cemeretySlice";
import { useAppSelector } from "../../hook";
const Cemetery = () => { const shape = CONFIG.CemeterySlotShape();
const shape = CONFIG.CemeterySlotShape(); const depth = 0.2;
const position = new BABYLON.Vector3(
3.2, const Cemeteries = () => {
shape.depth / 2 + CONFIG.Floating, const meCemetery = useAppSelector(selectMeCemetery).cemetery;
-2.0 const opCemetery = useAppSelector(selectOpCemetery).cemetery;
return (
<>
<CCemetery
state={meCemetery}
position={cemeteryPosition(0, meCemetery.length)}
rotation={CONFIG.CardSlotRotation(false)}
/>
<CCemetery
state={opCemetery}
position={cemeteryPosition(1, opCemetery.length)}
rotation={CONFIG.CardSlotRotation(true)}
/>
</>
); );
const rotation = CONFIG.CemeterySlotRotation(); };
const CCemetery = (props: {
state: Cemetery[];
position: BABYLON.Vector3;
rotation: BABYLON.Vector3;
}) => {
return ( return (
<box <box
name="cemetery" name="cemetery"
width={shape.width} width={shape.width}
height={shape.height} height={shape.height}
depth={shape.depth} depth={depth * props.state.length}
position={position} position={props.position}
rotation={rotation} rotation={props.rotation}
> >
<standardMaterial <standardMaterial
name="cemetery-mat" name="cemetery-mat"
diffuseColor={CONFIG.CemeteryColor()} diffuseTexture={
new BABYLON.Texture(`http://localhost:3030/images/card_back.jpg`)
}
alpha={props.state.length == 0 ? 0 : 1}
/> />
</box> </box>
); );
}; };
export default Cemetery; const cemeteryPosition = (player: number, cemeteryLength: number) => {
const x = player == 0 ? 3.2 : -3.2;
const y = (depth * cemeteryLength) / 2 + CONFIG.Floating;
const z = player == 0 ? -2.0 : 2.0;
return new BABYLON.Vector3(x, y, z);
};
export default Cemeteries;
...@@ -11,6 +11,7 @@ import Magics from "./magics"; ...@@ -11,6 +11,7 @@ import Magics from "./magics";
import Field from "./field"; import Field from "./field";
import Deck from "./deck"; import Deck from "./deck";
import Exclusion from "./exclusion"; import Exclusion from "./exclusion";
import Cemeteries from "./cemetery";
// Ref: https://github.com/brianzinn/react-babylonjs/issues/126 // Ref: https://github.com/brianzinn/react-babylonjs/issues/126
const NeosDuel = () => ( const NeosDuel = () => (
...@@ -27,6 +28,7 @@ const NeosDuel = () => ( ...@@ -27,6 +28,7 @@ const NeosDuel = () => (
<Magics /> <Magics />
<Field /> <Field />
<Deck /> <Deck />
<Cemeteries />
<Exclusion /> <Exclusion />
<Ground /> <Ground />
</Provider> </Provider>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment