Commit cecc5658 authored by chechunchi's avatar chechunchi

add field.tsx

parent fc04e90b
Pipeline #19470 passed with stages
in 5 minutes and 13 seconds
...@@ -7,6 +7,8 @@ import { ...@@ -7,6 +7,8 @@ import {
initMagics, initMagics,
initCemetery, initCemetery,
initDeck, initDeck,
initExclusion,
initField,
} from "../../reducers/duel/mod"; } from "../../reducers/duel/mod";
export default ( export default (
...@@ -42,4 +44,8 @@ export default ( ...@@ -42,4 +44,8 @@ export default (
dispatch(initCemetery(1)); dispatch(initCemetery(1));
dispatch(initDeck({ player: 0, deskSize: start.deckSize1 })); dispatch(initDeck({ player: 0, deskSize: start.deckSize1 }));
dispatch(initDeck({ player: 1, deskSize: start.deckSize2 })); dispatch(initDeck({ player: 1, deskSize: start.deckSize2 }));
dispatch(initExclusion(0));
dispatch(initExclusion(1));
dispatch(initField(0));
dispatch(initField(1));
}; };
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 { useAppSelector } from "../../hook";
import { selectMeField, selectOpField } from "../../reducers/duel/fieldSlice";
import SingleSlot, { Depth } from "./singleSlot";
const Field = () => { const Field = () => {
const shape = CONFIG.FieldSlotShape(); const meField = useAppSelector(selectMeField)?.inner;
const position = new BABYLON.Vector3( const opField = useAppSelector(selectOpField)?.inner;
-3.3,
shape.depth / 2 + CONFIG.Floating,
-2.0
);
const rotation = CONFIG.FieldSlotRotation();
return ( return (
<box <>
name="field" <SingleSlot
width={shape.width} state={meField ? [meField] : []}
height={shape.height} position={fieldPosition(0)}
depth={shape.depth} rotation={CONFIG.CardSlotRotation(false)}
position={position} />
rotation={rotation} <SingleSlot
> state={opField ? [opField] : []}
<standardMaterial name="field-mat" diffuseColor={CONFIG.FieldColor()} /> position={fieldPosition(1)}
</box> rotation={CONFIG.CardSlotRotation(true)}
/>
</>
); );
}; };
const fieldPosition = (player: number) => {
const x = player == 0 ? -3.3 : 3.3;
const y = Depth / 2 + CONFIG.Floating;
const z = player == 0 ? -2.0 : 2.0;
return new BABYLON.Vector3(x, y, z);
};
export default Field; export default Field;
...@@ -35,6 +35,7 @@ const NeosDuel = () => ( ...@@ -35,6 +35,7 @@ const NeosDuel = () => (
<Deck /> <Deck />
<Cemeteries /> <Cemeteries />
<Exclusion /> <Exclusion />
<Field />
<Ground /> <Ground />
</Provider> </Provider>
</Scene> </Scene>
......
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