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
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
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
love_飞影
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
Changes
3
Hide 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";
...
@@ -3,7 +3,8 @@ import { Engine, Scene } from "react-babylonjs";
import
{
ReactReduxContext
,
Provider
}
from
"
react-redux
"
;
import
{
ReactReduxContext
,
Provider
}
from
"
react-redux
"
;
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
DuelHands
from
"
./hands_
"
;
import
Hands
from
"
./hands_
"
;
import
Monsters
from
"
./monsters_
"
;
import
CardModal
from
"
./cardModal
"
;
import
CardModal
from
"
./cardModal
"
;
import
HintNotification
from
"
./hintNotification
"
;
import
HintNotification
from
"
./hintNotification
"
;
...
@@ -14,10 +15,11 @@ const BabylonCanvas = () => (
...
@@ -14,10 +15,11 @@ const BabylonCanvas = () => (
<
Engine
antialias
adaptToDeviceRatio
canvasId=
"babylonJS"
>
<
Engine
antialias
adaptToDeviceRatio
canvasId=
"babylonJS"
>
<
Scene
>
<
Scene
>
<
Provider
store=
{
store
}
>
<
Provider
store=
{
store
}
>
<
DuelCamera
/>
<
Camera
/>
<
DuelLight
/>
<
Light
/>
<
DuelHands
/>
<
Hands
/>
<
DuelGround
/>
<
Monsters
/>
<
Ground
/>
</
Provider
>
</
Provider
>
</
Scene
>
</
Scene
>
</
Engine
>
</
Engine
>
...
@@ -28,7 +30,7 @@ const BabylonCanvas = () => (
...
@@ -28,7 +30,7 @@ const BabylonCanvas = () => (
</>
</>
);
);
const
Duel
Camera
=
()
=>
(
const
Camera
=
()
=>
(
<
freeCamera
<
freeCamera
name=
"duel-camera"
name=
"duel-camera"
position=
{
new
BABYLON
.
Vector3
(
0
,
8
,
-
10
)
}
position=
{
new
BABYLON
.
Vector3
(
0
,
8
,
-
10
)
}
...
@@ -36,7 +38,7 @@ const DuelCamera = () => (
...
@@ -36,7 +38,7 @@ const DuelCamera = () => (
></
freeCamera
>
></
freeCamera
>
);
);
const
Duel
Light
=
()
=>
(
const
Light
=
()
=>
(
<
hemisphericLight
<
hemisphericLight
name=
"duel-light"
name=
"duel-light"
direction=
{
new
BABYLON
.
Vector3
(
1
,
2.5
,
1
)
}
direction=
{
new
BABYLON
.
Vector3
(
1
,
2.5
,
1
)
}
...
@@ -44,7 +46,7 @@ const DuelLight = () => (
...
@@ -44,7 +46,7 @@ const DuelLight = () => (
></
hemisphericLight
>
></
hemisphericLight
>
);
);
const
Duel
Ground
=
()
=>
{
const
Ground
=
()
=>
{
const
shape
=
CONFIG
.
GroundShape
();
const
shape
=
CONFIG
.
GroundShape
();
const
texture
=
new
BABYLON
.
Texture
(
const
texture
=
new
BABYLON
.
Texture
(
`http://localhost:3030/images/newfield.png`
`http://localhost:3030/images/newfield.png`
...
...
src/ui/Duel/hands_.tsx
View file @
669a8a7d
...
@@ -14,19 +14,19 @@ import { useHover } from "react-babylonjs";
...
@@ -14,19 +14,19 @@ import { useHover } from "react-babylonjs";
import
{
useClick
}
from
"
./hook
"
;
import
{
useClick
}
from
"
./hook
"
;
import
{
useState
,
useRef
}
from
"
react
"
;
import
{
useState
,
useRef
}
from
"
react
"
;
const
Duel
Hands
=
()
=>
{
const
Hands
=
()
=>
{
const
hands
=
useAppSelector
(
selectMeHands
).
cards
;
const
hands
=
useAppSelector
(
selectMeHands
).
cards
;
return
(
return
(
<>
<>
{
hands
.
map
((
hand
,
idx
)
=>
{
{
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
handShape
=
CONFIG
.
HandShape
();
const
hoverScale
=
CONFIG
.
HandHoverScaling
();
const
hoverScale
=
CONFIG
.
HandHoverScaling
();
const
defaultScale
=
new
BABYLON
.
Vector3
(
1
,
1
,
1
);
const
defaultScale
=
new
BABYLON
.
Vector3
(
1
,
1
,
1
);
...
@@ -88,7 +88,7 @@ const DuelHand = (props: { state: Card; idx: number }) => {
...
@@ -88,7 +88,7 @@ const DuelHand = (props: { state: Card; idx: number }) => {
}
}
>
>
<
standardMaterial
<
standardMaterial
name=
{
`hand
Material
-${idx}`
}
name=
{
`hand
-mat
-${idx}`
}
diffuseTexture=
{
diffuseTexture=
{
new
BABYLON
.
Texture
(
new
BABYLON
.
Texture
(
`https://cdn02.moecube.com:444/images/ygopro-images-zh-CN/${state.meta.id}.jpg`
`https://cdn02.moecube.com:444/images/ygopro-images-zh-CN/${state.meta.id}.jpg`
...
@@ -126,4 +126,4 @@ function interactTypeToString(t: InteractType): string {
...
@@ -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