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
b8194124
Commit
b8194124
authored
Dec 21, 2022
by
Chunchi Che
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update CardModal.tsx and hands.ts
parent
c028135a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
50 additions
and
67 deletions
+50
-67
src/ui/Duel/simpleDuel/cardModal.tsx
src/ui/Duel/simpleDuel/cardModal.tsx
+16
-1
src/ui/Duel/simpleDuel/hands.ts
src/ui/Duel/simpleDuel/hands.ts
+34
-66
No files found.
src/ui/Duel/simpleDuel/cardModal.tsx
View file @
b8194124
...
@@ -6,9 +6,11 @@ import {
...
@@ -6,9 +6,11 @@ import {
selectCardModalName
,
selectCardModalName
,
selectCardModalDesc
,
selectCardModalDesc
,
selectCardModalImgUrl
,
selectCardModalImgUrl
,
selectCardModalInteractivies
,
}
from
"
../../../reducers/duel/modal
"
;
}
from
"
../../../reducers/duel/modal
"
;
import
{
setCardModalIsOpen
}
from
"
../../../reducers/duel/mod
"
;
import
{
setCardModalIsOpen
}
from
"
../../../reducers/duel/mod
"
;
import
{
Modal
,
Card
}
from
"
antd
"
;
import
{
Modal
,
Card
,
Button
}
from
"
antd
"
;
import
{
sendSelectIdleCmdResponse
}
from
"
../../../api/ocgcore/ocgHelper
"
;
const
{
Meta
}
=
Card
;
const
{
Meta
}
=
Card
;
const
CARD_WIDTH
=
240
;
const
CARD_WIDTH
=
240
;
...
@@ -19,6 +21,7 @@ const CardModal = () => {
...
@@ -19,6 +21,7 @@ const CardModal = () => {
const
name
=
useAppSelector
(
selectCardModalName
);
const
name
=
useAppSelector
(
selectCardModalName
);
const
desc
=
useAppSelector
(
selectCardModalDesc
);
const
desc
=
useAppSelector
(
selectCardModalDesc
);
const
imgUrl
=
useAppSelector
(
selectCardModalImgUrl
);
const
imgUrl
=
useAppSelector
(
selectCardModalImgUrl
);
const
interactivies
=
useAppSelector
(
selectCardModalInteractivies
);
const
handleOkOrCancel
=
()
=>
{
const
handleOkOrCancel
=
()
=>
{
dispatch
(
setCardModalIsOpen
(
false
));
dispatch
(
setCardModalIsOpen
(
false
));
...
@@ -35,6 +38,18 @@ const CardModal = () => {
...
@@ -35,6 +38,18 @@ const CardModal = () => {
<
Meta
title=
{
name
}
/>
<
Meta
title=
{
name
}
/>
<
p
>
{
desc
}
</
p
>
<
p
>
{
desc
}
</
p
>
</
Card
>
</
Card
>
{
interactivies
.
map
((
interactive
)
=>
{
return
(
<
Button
onClick=
{
()
=>
{
sendSelectIdleCmdResponse
(
interactive
.
response
);
dispatch
(
setCardModalIsOpen
(
false
));
}
}
>
{
interactive
.
desc
}
</
Button
>
);
})
}
</
Modal
>
</
Modal
>
</>
</>
);
);
...
...
src/ui/Duel/simpleDuel/hands.ts
View file @
b8194124
import
*
as
BABYLON
from
"
@babylonjs/core
"
;
import
*
as
BABYLON
from
"
@babylonjs/core
"
;
import
*
as
BABYLON_GUI
from
"
@babylonjs/gui
"
;
import
*
as
CONFIG
from
"
../../../config/ui
"
;
import
*
as
CONFIG
from
"
../../../config/ui
"
;
import
{
Card
,
InteractType
}
from
"
../../../reducers/duel/util
"
;
import
{
Card
,
InteractType
}
from
"
../../../reducers/duel/util
"
;
import
{
sendSelectIdleCmdResponse
}
from
"
../../../api/ocgcore/ocgHelper
"
;
import
{
import
{
setCardModalImgUrl
,
setCardModalImgUrl
,
setCardModalIsOpen
,
setCardModalIsOpen
,
setCardModalText
,
setCardModalText
,
setCardModalInteractivies
,
}
from
"
../../../reducers/duel/mod
"
;
}
from
"
../../../reducers/duel/mod
"
;
import
{
store
}
from
"
../../../store
"
;
import
{
store
}
from
"
../../../store
"
;
...
@@ -22,8 +21,6 @@ export default (hands: Card[], scene: BABYLON.Scene) => {
...
@@ -22,8 +21,6 @@ export default (hands: Card[], scene: BABYLON.Scene) => {
setupHandTransform
(
hand
,
item
);
setupHandTransform
(
hand
,
item
);
// 材质
// 材质
setupHandMaterial
(
hand
,
item
,
scene
);
setupHandMaterial
(
hand
,
item
,
scene
);
// 互动选项
setupHandInteractivity
(
hand
,
item
,
idx
,
scene
);
// 事件管理
// 事件管理
setupHandAction
(
hand
,
item
,
idx
,
scene
);
setupHandAction
(
hand
,
item
,
idx
,
scene
);
});
});
...
@@ -59,51 +56,6 @@ function setupHandMaterial(
...
@@ -59,51 +56,6 @@ function setupHandMaterial(
mesh
.
material
=
handMaterial
;
mesh
.
material
=
handMaterial
;
}
}
function
setupHandInteractivity
(
mesh
:
BABYLON
.
Mesh
,
state
:
Card
,
handIdx
:
number
,
scene
:
BABYLON
.
Scene
)
{
const
interactShape
=
CONFIG
.
HandInteractShape
();
const
interactivities
=
state
.
interactivities
;
for
(
let
i
=
0
;
i
<
interactivities
.
length
;
i
++
)
{
const
interact
=
BABYLON
.
MeshBuilder
.
CreatePlane
(
`handInteract_
${
handIdx
}
_
${
i
}
`
,
interactShape
,
scene
);
interact
.
parent
=
mesh
;
// 调整位置
interact
.
translate
(
new
BABYLON
.
Vector3
(
0
,
1
,
0
),
CONFIG
.
HandShape
().
height
/
2
+
interactShape
.
height
/
2
+
interactShape
.
height
*
i
);
const
advancedTexture
=
BABYLON_GUI
.
AdvancedDynamicTexture
.
CreateForMesh
(
interact
);
const
button
=
BABYLON_GUI
.
Button
.
CreateImageWithCenterTextButton
(
`handInteractButtion_
${
handIdx
}
_
${
i
}
`
,
interactTypeToString
(
interactivities
[
i
].
interactType
),
"
http://localhost:3030/images/interact_button.png
"
);
button
.
fontSize
=
CONFIG
.
HandInteractFontSize
;
button
.
color
=
"
white
"
;
button
.
onPointerClickObservable
.
add
(()
=>
{
console
.
log
(
`<Interact>hand
${
handIdx
}
`
);
sendSelectIdleCmdResponse
(
interactivities
[
i
].
response
);
});
advancedTexture
.
addControl
(
button
);
interact
.
visibility
=
0.01
;
// interact.setEnabled(false);
}
}
function
setupHandAction
(
function
setupHandAction
(
mesh
:
BABYLON
.
Mesh
,
mesh
:
BABYLON
.
Mesh
,
state
:
Card
,
state
:
Card
,
...
@@ -127,13 +79,21 @@ function setupHandAction(
...
@@ -127,13 +79,21 @@ function setupHandAction(
`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`
)
)
);
);
dispatch
(
setCardModalInteractivies
(
state
.
interactivities
.
map
((
interactive
)
=>
{
return
{
desc
:
interactTypeToString
(
interactive
.
interactType
),
response
:
interactive
.
response
,
};
})
)
);
dispatch
(
setCardModalIsOpen
(
true
));
dispatch
(
setCardModalIsOpen
(
true
));
}
}
)
)
);
);
// 监听`Hover`事件
// 监听`Hover`事件
//
// TODO: 应该在`Hover`的时候开启子组件(按钮),`Hover`离开的时候禁用
mesh
.
actionManager
.
registerAction
(
mesh
.
actionManager
.
registerAction
(
new
BABYLON
.
CombineAction
(
new
BABYLON
.
CombineAction
(
{
trigger
:
BABYLON
.
ActionManager
.
OnPointerOverTrigger
},
{
trigger
:
BABYLON
.
ActionManager
.
OnPointerOverTrigger
},
...
@@ -146,13 +106,6 @@ function setupHandAction(
...
@@ -146,13 +106,6 @@ function setupHandAction(
"
scaling
"
,
"
scaling
"
,
CONFIG
.
HandHoverScaling
()
CONFIG
.
HandHoverScaling
()
),
),
new
BABYLON
.
InterpolateValueAction
(
BABYLON
.
ActionManager
.
OnPointerOverTrigger
,
mesh
.
getChildMeshes
(),
"
visibility
"
,
1.0
,
10
),
]
]
)
)
);
);
...
@@ -169,18 +122,33 @@ function setupHandAction(
...
@@ -169,18 +122,33 @@ function setupHandAction(
"
scaling
"
,
"
scaling
"
,
CONFIG
.
HandHoverOutScaling
()
CONFIG
.
HandHoverOutScaling
()
),
),
new
BABYLON
.
InterpolateValueAction
(
BABYLON
.
ActionManager
.
OnPointerOverTrigger
,
mesh
.
getChildMeshes
(),
"
visibility
"
,
0.01
,
10
),
]
]
)
)
);
);
}
}
function
interactTypeToString
(
t
:
InteractType
):
string
{
function
interactTypeToString
(
t
:
InteractType
):
string
{
return
InteractType
[
t
];
switch
(
t
)
{
case
InteractType
.
SUMMON
:
{
return
"
普通召唤
"
;
}
case
InteractType
.
SP_SUMMON
:
{
return
"
特殊召唤
"
;
}
case
InteractType
.
POS_CHANGE
:
{
return
"
改变表示形式
"
;
}
case
InteractType
.
MSET
:
{
return
"
前场放置
"
;
}
case
InteractType
.
SSET
:
{
return
"
后场放置
"
;
}
case
InteractType
.
ACTIVATE
:
{
return
"
发动效果
"
;
}
default
:
{
return
"
未知选项
"
;
}
}
}
}
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