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
a2519c13
Commit
a2519c13
authored
Dec 30, 2022
by
Chunchi Che
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update hand slice and hand ui
parent
5020a162
Pipeline
#18942
passed with stages
in 2 minutes and 38 seconds
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
26 additions
and
54 deletions
+26
-54
src/reducers/duel/handsSlice.ts
src/reducers/duel/handsSlice.ts
+0
-23
src/reducers/duel/util.ts
src/reducers/duel/util.ts
+0
-14
src/ui/Duel/cardModal.tsx
src/ui/Duel/cardModal.tsx
+5
-1
src/ui/Duel/hands.tsx
src/ui/Duel/hands.tsx
+21
-16
No files found.
src/reducers/duel/handsSlice.ts
View file @
a2519c13
...
@@ -8,7 +8,6 @@ import { DuelState } from "./mod";
...
@@ -8,7 +8,6 @@ import { DuelState } from "./mod";
import
{
RootState
}
from
"
../../store
"
;
import
{
RootState
}
from
"
../../store
"
;
import
{
fetchCard
,
CardMeta
}
from
"
../../api/cards
"
;
import
{
fetchCard
,
CardMeta
}
from
"
../../api/cards
"
;
import
{
judgeSelf
,
Hand
,
Interactivity
}
from
"
./util
"
;
import
{
judgeSelf
,
Hand
,
Interactivity
}
from
"
./util
"
;
import
*
as
UICONFIG
from
"
../../config/ui
"
;
export
interface
Hands
{
export
interface
Hands
{
// 注意:手牌的位置顺序是有约束的
// 注意:手牌的位置顺序是有约束的
...
@@ -56,7 +55,6 @@ export const handsCase = (builder: ActionReducerMapBuilder<DuelState>) => {
...
@@ -56,7 +55,6 @@ export const handsCase = (builder: ActionReducerMapBuilder<DuelState>) => {
}
else
{
}
else
{
state
.
meHands
=
{
cards
};
state
.
meHands
=
{
cards
};
}
}
setHandsTransform
(
state
.
meHands
.
cards
);
}
else
{
}
else
{
if
(
state
.
opHands
)
{
if
(
state
.
opHands
)
{
state
.
opHands
.
cards
=
state
.
opHands
.
cards
.
concat
(
cards
);
state
.
opHands
.
cards
=
state
.
opHands
.
cards
.
concat
(
cards
);
...
@@ -83,27 +81,6 @@ export const handsCase = (builder: ActionReducerMapBuilder<DuelState>) => {
...
@@ -83,27 +81,6 @@ export const handsCase = (builder: ActionReducerMapBuilder<DuelState>) => {
});
});
};
};
// 更新手牌的位置和旋转信息
//
// TODO: 兼容对方手牌
function
setHandsTransform
(
hands
:
Hand
[]):
void
{
const
groundShape
=
UICONFIG
.
GroundShape
();
const
handShape
=
UICONFIG
.
HandShape
();
const
gap
=
groundShape
.
width
/
(
hands
.
length
-
1
);
const
left
=
-
(
groundShape
.
width
/
2
);
hands
.
forEach
((
hand
,
idx
,
_
)
=>
{
hand
.
transform
.
position
=
{
x
:
left
+
gap
*
idx
,
y
:
handShape
.
height
/
2
,
z
:
-
(
groundShape
.
height
/
2
)
-
1
,
};
const
rotation
=
UICONFIG
.
HandRotation
();
hand
.
transform
.
rotation
=
{
x
:
rotation
.
x
,
y
:
rotation
.
y
,
z
:
rotation
.
z
};
});
}
// 清空手牌互动性
// 清空手牌互动性
export
const
clearHandsInteractivityImpl
:
CaseReducer
<
export
const
clearHandsInteractivityImpl
:
CaseReducer
<
DuelState
,
DuelState
,
...
...
src/reducers/duel/util.ts
View file @
a2519c13
...
@@ -27,23 +27,9 @@ export function judgeSelf(player: number, state: Draft<DuelState>): boolean {
...
@@ -27,23 +27,9 @@ export function judgeSelf(player: number, state: Draft<DuelState>): boolean {
export
interface
Hand
{
export
interface
Hand
{
meta
:
CardMeta
;
meta
:
CardMeta
;
transform
:
CardTransform
;
interactivities
:
Interactivity
<
number
>
[];
interactivities
:
Interactivity
<
number
>
[];
}
}
interface
CardTransform
{
position
?:
{
x
:
number
;
y
:
number
;
z
:
number
;
};
rotation
?:
{
x
:
number
;
y
:
number
;
z
:
number
;
};
}
export
enum
InteractType
{
export
enum
InteractType
{
// 可普通召唤
// 可普通召唤
SUMMON
=
1
,
SUMMON
=
1
,
...
...
src/ui/Duel/cardModal.tsx
View file @
a2519c13
...
@@ -8,7 +8,10 @@ import {
...
@@ -8,7 +8,10 @@ import {
selectCardModalImgUrl
,
selectCardModalImgUrl
,
selectCardModalInteractivies
,
selectCardModalInteractivies
,
}
from
"
../../reducers/duel/modalSlice
"
;
}
from
"
../../reducers/duel/modalSlice
"
;
import
{
setCardModalIsOpen
}
from
"
../../reducers/duel/mod
"
;
import
{
setCardModalIsOpen
,
clearHandsInteractivity
,
}
from
"
../../reducers/duel/mod
"
;
import
{
Modal
,
Card
,
Button
}
from
"
antd
"
;
import
{
Modal
,
Card
,
Button
}
from
"
antd
"
;
import
{
sendSelectIdleCmdResponse
}
from
"
../../api/ocgcore/ocgHelper
"
;
import
{
sendSelectIdleCmdResponse
}
from
"
../../api/ocgcore/ocgHelper
"
;
...
@@ -45,6 +48,7 @@ const CardModal = () => {
...
@@ -45,6 +48,7 @@ const CardModal = () => {
onClick=
{
()
=>
{
onClick=
{
()
=>
{
sendSelectIdleCmdResponse
(
interactive
.
response
);
sendSelectIdleCmdResponse
(
interactive
.
response
);
dispatch
(
setCardModalIsOpen
(
false
));
dispatch
(
setCardModalIsOpen
(
false
));
dispatch
(
clearHandsInteractivity
(
0
));
}
}
}
}
>
>
{
interactive
.
desc
}
{
interactive
.
desc
}
...
...
src/ui/Duel/hands.tsx
View file @
a2519c13
...
@@ -14,20 +14,37 @@ import { useHover } from "react-babylonjs";
...
@@ -14,20 +14,37 @@ import { useHover } from "react-babylonjs";
import
{
useClick
}
from
"
./hook
"
;
import
{
useClick
}
from
"
./hook
"
;
import
{
useState
,
useRef
}
from
"
react
"
;
import
{
useState
,
useRef
}
from
"
react
"
;
const
groundShape
=
CONFIG
.
GroundShape
();
const
left
=
-
(
groundShape
.
width
/
2
);
const
Hands
=
()
=>
{
const
Hands
=
()
=>
{
const
hands
=
useAppSelector
(
selectMeHands
).
cards
;
const
hands
=
useAppSelector
(
selectMeHands
).
cards
;
return
(
return
(
<>
<>
{
hands
.
map
((
hand
,
idx
)
=>
{
{
hands
.
map
((
hand
,
idx
)
=>
{
return
<
CHand
state=
{
hand
}
idx=
{
idx
}
key=
{
idx
}
/>;
return
(
<
CHand
state=
{
hand
}
idx=
{
idx
}
key=
{
idx
}
gap=
{
groundShape
.
width
/
(
hands
.
length
-
1
)
}
/>
);
})
}
})
}
</>
</>
);
);
};
};
const
CHand
=
(
props
:
{
state
:
Hand
;
idx
:
number
})
=>
{
const
CHand
=
(
props
:
{
state
:
Hand
;
idx
:
number
;
gap
:
number
})
=>
{
const
handShape
=
CONFIG
.
HandShape
();
const
handShape
=
CONFIG
.
HandShape
();
const
position
=
new
BABYLON
.
Vector3
(
left
+
props
.
gap
*
props
.
idx
,
handShape
.
height
/
2
,
-
(
groundShape
.
height
/
2
)
-
1
);
const
rotation
=
CONFIG
.
HandRotation
();
const
hoverScale
=
CONFIG
.
HandHoverScaling
();
const
hoverScale
=
CONFIG
.
HandHoverScaling
();
const
defaultScale
=
new
BABYLON
.
Vector3
(
1
,
1
,
1
);
const
defaultScale
=
new
BABYLON
.
Vector3
(
1
,
1
,
1
);
const
planeRef
=
useRef
(
null
);
const
planeRef
=
useRef
(
null
);
...
@@ -72,20 +89,8 @@ const CHand = (props: { state: Hand; idx: number }) => {
...
@@ -72,20 +89,8 @@ const CHand = (props: { state: Hand; idx: number }) => {
width=
{
handShape
.
width
}
width=
{
handShape
.
width
}
height=
{
handShape
.
height
}
height=
{
handShape
.
height
}
scaling=
{
hovered
?
hoverScale
:
defaultScale
}
scaling=
{
hovered
?
hoverScale
:
defaultScale
}
position=
{
position=
{
position
}
new
BABYLON
.
Vector3
(
rotation=
{
rotation
}
state
.
transform
.
position
?.
x
,
state
.
transform
.
position
?.
y
,
state
.
transform
.
position
?.
z
)
}
rotation=
{
new
BABYLON
.
Vector3
(
state
.
transform
.
rotation
?.
x
,
state
.
transform
.
rotation
?.
y
,
state
.
transform
.
rotation
?.
z
)
}
>
>
<
standardMaterial
<
standardMaterial
name=
{
`hand-mat-${idx}`
}
name=
{
`hand-mat-${idx}`
}
...
...
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