Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
N
Neos
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
1
Issues
1
List
Boards
Labels
Service Desk
Milestones
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
MyCard
Neos
Commits
669a8a7d
Commit
669a8a7d
authored
Dec 29, 2022
by
Chunchi Che
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add Monsters Compoment
parent
66fa8463
Pipeline
#18896
passed with stages
in 3 minutes and 54 seconds
Changes
3
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
92 additions
and
13 deletions
+92
-13
src/ui/Duel/babylon.tsx
src/ui/Duel/babylon.tsx
+10
-8
src/ui/Duel/hands_.tsx
src/ui/Duel/hands_.tsx
+5
-5
src/ui/Duel/monsters_.tsx
src/ui/Duel/monsters_.tsx
+77
-0
No files found.
src/ui/Duel/babylon.tsx
View file @
669a8a7d
...
...
@@ -3,7 +3,8 @@ import { Engine, Scene } from "react-babylonjs";
import
{
ReactReduxContext
,
Provider
}
from
"
react-redux
"
;
import
*
as
BABYLON
from
"
@babylonjs/core
"
;
import
*
as
CONFIG
from
"
../../config/ui
"
;
import
DuelHands
from
"
./hands_
"
;
import
Hands
from
"
./hands_
"
;
import
Monsters
from
"
./monsters_
"
;
import
CardModal
from
"
./cardModal
"
;
import
HintNotification
from
"
./hintNotification
"
;
...
...
@@ -14,10 +15,11 @@ const BabylonCanvas = () => (
<
Engine
antialias
adaptToDeviceRatio
canvasId=
"babylonJS"
>
<
Scene
>
<
Provider
store=
{
store
}
>
<
DuelCamera
/>
<
DuelLight
/>
<
DuelHands
/>
<
DuelGround
/>
<
Camera
/>
<
Light
/>
<
Hands
/>
<
Monsters
/>
<
Ground
/>
</
Provider
>
</
Scene
>
</
Engine
>
...
...
@@ -28,7 +30,7 @@ const BabylonCanvas = () => (
</>
);
const
Duel
Camera
=
()
=>
(
const
Camera
=
()
=>
(
<
freeCamera
name=
"duel-camera"
position=
{
new
BABYLON
.
Vector3
(
0
,
8
,
-
10
)
}
...
...
@@ -36,7 +38,7 @@ const DuelCamera = () => (
></
freeCamera
>
);
const
Duel
Light
=
()
=>
(
const
Light
=
()
=>
(
<
hemisphericLight
name=
"duel-light"
direction=
{
new
BABYLON
.
Vector3
(
1
,
2.5
,
1
)
}
...
...
@@ -44,7 +46,7 @@ const DuelLight = () => (
></
hemisphericLight
>
);
const
Duel
Ground
=
()
=>
{
const
Ground
=
()
=>
{
const
shape
=
CONFIG
.
GroundShape
();
const
texture
=
new
BABYLON
.
Texture
(
`http://localhost:3030/images/newfield.png`
...
...
src/ui/Duel/hands_.tsx
View file @
669a8a7d
...
...
@@ -14,19 +14,19 @@ import { useHover } from "react-babylonjs";
import
{
useClick
}
from
"
./hook
"
;
import
{
useState
,
useRef
}
from
"
react
"
;
const
Duel
Hands
=
()
=>
{
const
Hands
=
()
=>
{
const
hands
=
useAppSelector
(
selectMeHands
).
cards
;
return
(
<>
{
hands
.
map
((
hand
,
idx
)
=>
{
return
<
Duel
Hand
state=
{
hand
}
idx=
{
idx
}
key=
{
idx
}
/>;
return
<
Hand
state=
{
hand
}
idx=
{
idx
}
key=
{
idx
}
/>;
})
}
</>
);
};
const
Duel
Hand
=
(
props
:
{
state
:
Card
;
idx
:
number
})
=>
{
const
Hand
=
(
props
:
{
state
:
Card
;
idx
:
number
})
=>
{
const
handShape
=
CONFIG
.
HandShape
();
const
hoverScale
=
CONFIG
.
HandHoverScaling
();
const
defaultScale
=
new
BABYLON
.
Vector3
(
1
,
1
,
1
);
...
...
@@ -88,7 +88,7 @@ const DuelHand = (props: { state: Card; idx: number }) => {
}
>
<
standardMaterial
name=
{
`hand
Material
-${idx}`
}
name=
{
`hand
-mat
-${idx}`
}
diffuseTexture=
{
new
BABYLON
.
Texture
(
`https://cdn02.moecube.com:444/images/ygopro-images-zh-CN/${state.meta.id}.jpg`
...
...
@@ -126,4 +126,4 @@ function interactTypeToString(t: InteractType): string {
}
}
export
default
Duel
Hands
;
export
default
Hands
;
src/ui/Duel/monsters_.tsx
0 → 100644
View file @
669a8a7d
import
*
as
BABYLON
from
"
@babylonjs/core
"
;
import
*
as
CONFIG
from
"
../../config/ui
"
;
import
{
useClick
}
from
"
./hook
"
;
import
{
store
}
from
"
../../store
"
;
import
{
Monster
}
from
"
../../reducers/duel/util
"
;
import
"
react-babylonjs
"
;
import
{
useRef
}
from
"
react
"
;
import
{
sendSelectPlaceResponse
}
from
"
../../api/ocgcore/ocgHelper
"
;
import
{
clearMonsterSelectInfo
}
from
"
../../reducers/duel/mod
"
;
import
{
useAppSelector
}
from
"
../../hook
"
;
import
{
selectMeMonsters
}
from
"
../../reducers/duel/monstersSlice
"
;
const
left
=
-
2.15
;
// TODO: config
const
gap
=
1.05
;
const
Monsters
=
()
=>
{
const
monsters
=
useAppSelector
(
selectMeMonsters
).
monsters
;
return
(
<>
{
monsters
.
map
((
monster
,
idx
)
=>
{
return
<
CMonster
state=
{
monster
}
key=
{
idx
}
/>;
})
}
</>
);
};
const
CMonster
=
(
props
:
{
state
:
Monster
})
=>
{
const
planeRef
=
useRef
(
null
);
const
position
=
new
BABYLON
.
Vector3
(
left
+
gap
*
props
.
state
.
sequence
,
CONFIG
.
CardSlotShape
().
depth
/
2
+
CONFIG
.
Floating
,
-
1.35
);
const
rotation
=
CONFIG
.
CardSlotRotation
();
const
edgesWidth
=
2.0
;
const
edgesColor
=
BABYLON
.
Color4
.
FromColor3
(
BABYLON
.
Color3
.
Yellow
());
const
dispatch
=
store
.
dispatch
;
useClick
(
(
_event
)
=>
{
if
(
props
.
state
.
selectInfo
)
{
sendSelectPlaceResponse
(
props
.
state
.
selectInfo
?.
response
);
dispatch
(
clearMonsterSelectInfo
(
0
));
dispatch
(
clearMonsterSelectInfo
(
1
));
}
},
planeRef
,
[
props
.
state
]
);
return
(
<
plane
name=
{
`monster-${props.state.selectInfo}`
}
ref=
{
planeRef
}
position=
{
position
}
rotation=
{
rotation
}
enableEdgesRendering
edgesWidth=
{
props
.
state
.
selectInfo
?
edgesWidth
:
0
}
edgesColor=
{
edgesColor
}
>
<
standardMaterial
name=
{
`monster-mat-${props.state.sequence}`
}
diffuseTexture=
{
props
.
state
.
occupant
?
new
BABYLON
.
Texture
(
`https://cdn02.moecube.com:444/images/ygopro-images-zh-CN/${props.state.occupant.id}.jpg`
)
:
new
BABYLON
.
Texture
(
`http://localhost:3030/images/card_slot.png`
)
}
alpha=
{
0.2
}
></
standardMaterial
>
</
plane
>
);
};
export
default
Monsters
;
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment