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
4
Merge Requests
4
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
a91c4476
Commit
a91c4476
authored
Nov 13, 2022
by
Chunchi Che
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rerange simpleDuel code
parent
25abb3f9
Pipeline
#17835
passed with stages
in 3 minutes and 3 seconds
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
58 additions
and
40 deletions
+58
-40
src/ui/Duel/main.tsx
src/ui/Duel/main.tsx
+1
-1
src/ui/Duel/simpleDuel/config.ts
src/ui/Duel/simpleDuel/config.ts
+14
-0
src/ui/Duel/simpleDuel/hands.ts
src/ui/Duel/simpleDuel/hands.ts
+37
-0
src/ui/Duel/simpleDuel/mod.tsx
src/ui/Duel/simpleDuel/mod.tsx
+6
-39
No files found.
src/ui/Duel/main.tsx
View file @
a91c4476
...
...
@@ -3,7 +3,7 @@
*
* */
import
SimpleDuelPlateImpl
from
"
./simpleDuel
"
;
import
SimpleDuelPlateImpl
from
"
./simpleDuel
/mod
"
;
export
default
function
Duel
()
{
return
new
SimpleDuelPlateImpl
().
render
();
...
...
src/ui/Duel/simpleDuel/config.ts
0 → 100644
View file @
a91c4476
/*
* SimpleDuelPlateImpl的一些配置
*
* */
import
*
as
BABYLON
from
"
@babylonjs/core
"
;
export
const
GroundShape
=
{
width
:
6
,
height
:
6
};
export
const
CardSlotShape
=
{
width
:
0.5
,
height
:
0.75
,
depth
:
0.05
};
export
const
CardSlotRotation
=
new
BABYLON
.
Vector3
(
1.5
,
0
,
0
);
// 手牌
export
const
HandShape
=
{
width
:
0.5
,
height
:
0.75
};
export
const
HandColor
=
BABYLON
.
Color3
.
White
();
src/ui/Duel/simpleDuel/hands.ts
0 → 100644
View file @
a91c4476
import
{
Card
}
from
"
../data
"
;
import
*
as
BABYLON
from
"
@babylonjs/core
"
;
import
*
as
CONFIG
from
"
./config
"
;
export
default
(
hands
:
Card
[],
scene
:
BABYLON
.
Scene
)
=>
{
const
gap
=
CONFIG
.
GroundShape
.
width
/
hands
.
length
;
const
left
=
-
(
CONFIG
.
GroundShape
.
width
/
2
);
hands
.
forEach
((
item
,
idx
,
_
)
=>
{
const
hand
=
BABYLON
.
MeshBuilder
.
CreatePlane
(
`hand
${
idx
}
`
,
CONFIG
.
HandShape
,
scene
);
// 位置
hand
.
position
=
new
BABYLON
.
Vector3
(
left
+
gap
*
idx
,
CONFIG
.
HandShape
.
height
/
2
,
-
(
CONFIG
.
GroundShape
.
height
/
2
)
-
1
);
// 材质
const
handMaterial
=
new
BABYLON
.
StandardMaterial
(
"
handMaterial
"
,
scene
);
// 材质颜色
handMaterial
.
diffuseColor
=
CONFIG
.
HandColor
;
hand
.
material
=
handMaterial
;
// 事件管理
hand
.
actionManager
=
new
BABYLON
.
ActionManager
(
scene
);
// 监听点击事件
hand
.
actionManager
.
registerAction
(
new
BABYLON
.
ExecuteCodeAction
(
BABYLON
.
ActionManager
.
OnPickTrigger
,
(
event
)
=>
{
console
.
log
(
`<Click>hand:
${
idx
}
`
,
"
card:
"
,
item
,
"
event:
"
,
event
);
}
)
);
});
};
src/ui/Duel/simpleDuel.tsx
→
src/ui/Duel/simpleDuel
/mod
.tsx
View file @
a91c4476
...
...
@@ -3,12 +3,13 @@
*
* */
import
{
IDuelPlate
,
TypeSelector
}
from
"
./duel
"
;
import
*
as
DuelData
from
"
./data
"
;
import
{
useAppSelector
}
from
"
../../hook
"
;
import
{
IDuelPlate
,
TypeSelector
}
from
"
.
.
/duel
"
;
import
*
as
DuelData
from
"
.
.
/data
"
;
import
{
useAppSelector
}
from
"
../../
../
hook
"
;
import
React
,
{
useEffect
,
useRef
}
from
"
react
"
;
import
type
{
RootState
}
from
"
../../store
"
;
import
type
{
RootState
}
from
"
../../
../
store
"
;
import
*
as
BABYLON
from
"
@babylonjs/core
"
;
import
renderHands
from
"
./hands
"
;
// CONFIG
const
GroundShape
=
{
width
:
6
,
height
:
6
};
...
...
@@ -53,36 +54,6 @@ export default class SimpleDuelPlateImpl implements IDuelPlate {
return
cardSlot
;
};
const
createHandSlot
=
(
name
:
string
,
position
:
BABYLON
.
Vector3
,
scene
:
BABYLON
.
Scene
)
=>
{
const
handSlot
=
BABYLON
.
MeshBuilder
.
CreatePlane
(
name
,
HandSlotShape
,
scene
);
handSlot
.
position
=
position
;
const
planeMaterial
=
new
BABYLON
.
StandardMaterial
(
"
planeMaterial
"
,
scene
);
planeMaterial
.
diffuseColor
=
BABYLON
.
Color3
.
White
();
handSlot
.
material
=
planeMaterial
;
handSlot
.
actionManager
=
new
BABYLON
.
ActionManager
(
scene
);
handSlot
.
actionManager
.
registerAction
(
new
BABYLON
.
ExecuteCodeAction
(
BABYLON
.
ActionManager
.
OnPickTrigger
,
(
event
)
=>
{
console
.
log
(
event
.
source
+
"
is clicked
"
);
}
)
);
return
handSlot
;
};
useEffect
(()
=>
{
// 初始化Scene
const
canvasCurrent
=
canvasRef
.
current
;
...
...
@@ -185,11 +156,7 @@ export default class SimpleDuelPlateImpl implements IDuelPlate {
);
// 创建手牌
createHandSlot
(
"
handSlot0
"
,
new
BABYLON
.
Vector3
(
-
2
,
0.5
,
-
4
),
scene
);
createHandSlot
(
"
handSlot1
"
,
new
BABYLON
.
Vector3
(
-
1
,
0.5
,
-
4
),
scene
);
createHandSlot
(
"
handSlot2
"
,
new
BABYLON
.
Vector3
(
0
,
0.5
,
-
4
),
scene
);
createHandSlot
(
"
handSlot3
"
,
new
BABYLON
.
Vector3
(
1
,
0.5
,
-
4
),
scene
);
createHandSlot
(
"
handSlot4
"
,
new
BABYLON
.
Vector3
(
2
,
0.5
,
-
4
),
scene
);
renderHands
(
hands
,
scene
);
// 创建地板
const
ground
=
BABYLON
.
MeshBuilder
.
CreateGround
(
...
...
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