Commit c598f38d authored by Chunchi Che's avatar Chunchi Che

Merge branch 'optimize/ui/monster' into 'main'

Optimize/ui/monster

See merge request mycard/Neos!87
parents 9fd24f08 3ad00630
Pipeline #19709 passed with stages
in 3 minutes and 56 seconds
...@@ -70,6 +70,22 @@ export const initMonstersImpl: CaseReducer<DuelState, PayloadAction<number>> = ( ...@@ -70,6 +70,22 @@ export const initMonstersImpl: CaseReducer<DuelState, PayloadAction<number>> = (
}, },
idleInteractivities: [], idleInteractivities: [],
}, },
{
location: {
controler: player,
location: ygopro.CardZone.MZONE,
sequence: 5,
},
idleInteractivities: [],
},
{
location: {
controler: player,
location: ygopro.CardZone.MZONE,
sequence: 6,
},
idleInteractivities: [],
},
], ],
}; };
......
...@@ -25,7 +25,7 @@ const Monsters = () => { ...@@ -25,7 +25,7 @@ const Monsters = () => {
<> <>
{zip(meMonsters, meMonsterPositions).map( {zip(meMonsters, meMonsterPositions).map(
([monster, position], sequence) => { ([monster, position], sequence) => {
return ( return sequence < 5 ? (
<FixedSlot <FixedSlot
state={monster} state={monster}
key={sequence} key={sequence}
...@@ -35,12 +35,14 @@ const Monsters = () => { ...@@ -35,12 +35,14 @@ const Monsters = () => {
deffenseRotation={CONFIG.CardSlotDefenceRotation()} deffenseRotation={CONFIG.CardSlotDefenceRotation()}
clearPlaceInteractivitiesAction={clearMonsterPlaceInteractivities} clearPlaceInteractivitiesAction={clearMonsterPlaceInteractivities}
/> />
) : (
<></>
); );
} }
)} )}
{zip(opMonsters, opMonsterPositions).map( {zip(opMonsters, opMonsterPositions).map(
([monster, position], sequence) => { ([monster, position], sequence) => {
return ( return sequence < 5 ? (
<FixedSlot <FixedSlot
state={monster} state={monster}
key={sequence} key={sequence}
...@@ -50,41 +52,92 @@ const Monsters = () => { ...@@ -50,41 +52,92 @@ const Monsters = () => {
deffenseRotation={CONFIG.CardSlotDefenceRotation()} deffenseRotation={CONFIG.CardSlotDefenceRotation()}
clearPlaceInteractivitiesAction={clearMonsterPlaceInteractivities} clearPlaceInteractivitiesAction={clearMonsterPlaceInteractivities}
/> />
) : (
<></>
); );
} }
)} )}
<ExtraMonsters /> <ExtraMonsters meMonsters={meMonsters} opMonsters={opMonsters} />
<ExtraMonsters />
</> </>
); );
}; };
// TODO: use props and redux // TODO: use props and redux
const ExtraMonsters = () => { const ExtraMonsters = (props: {
const xs = [-1.1, 1]; meMonsters: CardState[];
opMonsters: CardState[];
}) => {
const shape = CONFIG.CardSlotShape(); const shape = CONFIG.CardSlotShape();
const position = (x: number) =>
new BABYLON.Vector3(x, shape.depth / 2 + CONFIG.Floating, 0); const meLeft = props.meMonsters.find((_, sequence) => sequence == 5);
const rotation = CONFIG.CardSlotRotation(false); const meRight = props.meMonsters.find((_, sequence) => sequence == 6);
const opLeft = props.opMonsters.find((_, sequence) => sequence == 5);
const opRight = props.opMonsters.find((_, sequence) => sequence == 6);
const leftPosition = new BABYLON.Vector3(
-1.1,
shape.depth / 2 + CONFIG.Floating,
0
);
const rightPosition = new BABYLON.Vector3(
1.1,
shape.depth / 2 + CONFIG.Floating,
0
);
const meRotation = CONFIG.CardSlotRotation(false);
const opRotation = CONFIG.CardSlotRotation(true);
return ( return (
<> <>
{xs.map((x, idx) => ( {meLeft ? (
<plane <FixedSlot
name={`extra-monster-${idx}`} state={meLeft}
key={idx} sequence={5}
position={position(x)} position={leftPosition}
rotation={rotation} rotation={meRotation}
> deffenseRotation={CONFIG.CardSlotDefenceRotation()}
<standardMaterial clearPlaceInteractivitiesAction={clearMonsterPlaceInteractivities}
name={`extra-monster-mat-${idx}`} />
diffuseTexture={ ) : (
new BABYLON.Texture(`http://localhost:3030/images/card_slot.png`) <></>
} )}
alpha={0.2} {meRight ? (
></standardMaterial> <FixedSlot
</plane> state={meRight}
))} sequence={6}
position={rightPosition}
rotation={meRotation}
deffenseRotation={CONFIG.CardSlotDefenceRotation()}
clearPlaceInteractivitiesAction={clearMonsterPlaceInteractivities}
/>
) : (
<></>
)}
{opLeft ? (
<FixedSlot
state={opLeft}
sequence={5}
position={rightPosition}
rotation={opRotation}
deffenseRotation={CONFIG.CardSlotDefenceRotation()}
clearPlaceInteractivitiesAction={clearMonsterPlaceInteractivities}
/>
) : (
<></>
)}
{opRight ? (
<FixedSlot
state={opRight}
sequence={6}
position={leftPosition}
rotation={opRotation}
deffenseRotation={CONFIG.CardSlotDefenceRotation()}
clearPlaceInteractivitiesAction={clearMonsterPlaceInteractivities}
/>
) : (
<></>
)}
</> </>
); );
}; };
......
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