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
553039ec
Commit
553039ec
authored
Dec 25, 2022
by
Chunchi Che
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update small
parent
041f33c1
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
72 additions
and
26 deletions
+72
-26
src/ui/Duel/monsters.ts
src/ui/Duel/monsters.ts
+72
-26
No files found.
src/ui/Duel/monsters.ts
View file @
553039ec
import
*
as
BABYLON
from
"
@babylonjs/core
"
;
import
*
as
CONFIG
from
"
../../config/ui
"
;
import
{
Monster
}
from
"
../../reducers/duel/util
"
;
import
{
clearMonsterSelectInfo
}
from
"
../../reducers/duel/mod
"
;
import
{
store
}
from
"
../../store
"
;
export
default
(
monsters
:
Monster
[],
scene
:
BABYLON
.
Scene
)
=>
{
const
left
=
-
2.15
;
...
...
@@ -8,39 +10,83 @@ export default (monsters: Monster[], scene: BABYLON.Scene) => {
const
shape
=
CONFIG
.
CardSlotShape
();
for
(
const
monster
of
monsters
)
{
const
sequence
=
monster
.
sequence
;
const
slot
=
BABYLON
.
MeshBuilder
.
CreatePlane
(
`monster
${
sequence
}
`
,
`monster
${
monster
.
sequence
}
`
,
shape
,
scene
);
// 位置
slot
.
position
=
new
BABYLON
.
Vector3
(
left
+
gap
*
sequence
,
shape
.
depth
/
2
+
CONFIG
.
Floating
,
-
1.35
);
setupMonsterTransform
(
slot
,
monster
,
left
,
gap
,
shape
);
// 旋转
slot
.
rotation
=
CONFIG
.
CardSlotRotation
();
// 材质
const
monsterMaterial
=
new
BABYLON
.
StandardMaterial
(
"
monsterMaterial
"
,
scene
);
monsterMaterial
.
diffuseTexture
=
monster
.
occupant
?
new
BABYLON
.
Texture
(
`https://cdn02.moecube.com:444/images/ygopro-images-zh-CN/
${
monster
.
occupant
.
id
}
.jpg`
)
:
new
BABYLON
.
Texture
(
`http://localhost:3030/images/card_slot.png`
);
monsterMaterial
.
diffuseTexture
.
hasAlpha
=
true
;
slot
.
material
=
monsterMaterial
;
if
(
monster
.
selectInfo
)
{
slot
.
enableEdgesRendering
();
slot
.
edgesWidth
=
2.0
;
slot
.
edgesColor
=
BABYLON
.
Color4
.
FromColor3
(
BABYLON
.
Color3
.
Yellow
());
}
else
{
slot
.
disableEdgesRendering
();
}
setupMonsterMaterial
(
slot
,
monster
,
scene
);
// 高亮
setupHintEdge
(
slot
,
monster
);
// 事件管理
setupMonsterAction
(
slot
,
monster
,
scene
);
}
};
function
setupMonsterTransform
(
mesh
:
BABYLON
.
Mesh
,
state
:
Monster
,
left
:
number
,
gap
:
number
,
shape
:
{
width
:
number
;
height
:
number
;
depth
:
number
}
)
{
mesh
.
position
=
new
BABYLON
.
Vector3
(
left
+
gap
*
state
.
sequence
,
shape
.
depth
/
2
+
CONFIG
.
Floating
,
-
1.35
);
}
function
setupMonsterMaterial
(
mesh
:
BABYLON
.
Mesh
,
state
:
Monster
,
scene
:
BABYLON
.
Scene
)
{
const
monsterMaterial
=
new
BABYLON
.
StandardMaterial
(
"
monsterMaterial
"
,
scene
);
monsterMaterial
.
diffuseTexture
=
state
.
occupant
?
new
BABYLON
.
Texture
(
`https://cdn02.moecube.com:444/images/ygopro-images-zh-CN/
${
state
.
occupant
.
id
}
.jpg`
)
:
new
BABYLON
.
Texture
(
`http://localhost:3030/images/card_slot.png`
);
monsterMaterial
.
diffuseTexture
.
hasAlpha
=
true
;
mesh
.
material
=
monsterMaterial
;
}
function
setupHintEdge
(
mesh
:
BABYLON
.
Mesh
,
state
:
Monster
)
{
if
(
state
.
selectInfo
)
{
mesh
.
enableEdgesRendering
();
mesh
.
edgesWidth
=
2.0
;
mesh
.
edgesColor
=
BABYLON
.
Color4
.
FromColor3
(
BABYLON
.
Color3
.
Yellow
());
}
else
{
mesh
.
disableEdgesRendering
();
}
}
function
setupMonsterAction
(
mesh
:
BABYLON
.
Mesh
,
state
:
Monster
,
scene
:
BABYLON
.
Scene
)
{
const
dispatch
=
store
.
dispatch
;
mesh
.
actionManager
=
new
BABYLON
.
ActionManager
(
scene
);
// 监听点击事件
mesh
.
actionManager
.
registerAction
(
new
BABYLON
.
ExecuteCodeAction
(
BABYLON
.
ActionManager
.
OnPickTrigger
,
(
_event
)
=>
{
// TODO: send response
dispatch
(
clearMonsterSelectInfo
(
0
));
dispatch
(
clearMonsterSelectInfo
(
1
));
}
)
);
}
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