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
041f33c1
Commit
041f33c1
authored
Dec 25, 2022
by
Chunchi Che
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update monster ui
parent
749e0dbd
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
54 additions
and
30 deletions
+54
-30
src/reducers/duel/monstersSlice.ts
src/reducers/duel/monstersSlice.ts
+27
-21
src/ui/Duel/mod.tsx
src/ui/Duel/mod.tsx
+4
-2
src/ui/Duel/monsters.ts
src/ui/Duel/monsters.ts
+23
-7
No files found.
src/reducers/duel/monstersSlice.ts
View file @
041f33c1
...
@@ -2,6 +2,7 @@ import { judgeSelf, Monster, InteractType } from "./util";
...
@@ -2,6 +2,7 @@ import { judgeSelf, Monster, InteractType } from "./util";
import
{
PayloadAction
,
CaseReducer
}
from
"
@reduxjs/toolkit
"
;
import
{
PayloadAction
,
CaseReducer
}
from
"
@reduxjs/toolkit
"
;
import
{
DuelState
}
from
"
./mod
"
;
import
{
DuelState
}
from
"
./mod
"
;
import
{
ygopro
}
from
"
../../api/ocgcore/idl/ocgcore
"
;
import
{
ygopro
}
from
"
../../api/ocgcore/idl/ocgcore
"
;
import
{
RootState
}
from
"
../../store
"
;
export
interface
MonsterState
{
export
interface
MonsterState
{
monsters
:
Monster
[];
monsters
:
Monster
[];
...
@@ -13,28 +14,30 @@ export const initMonstersImpl: CaseReducer<DuelState, PayloadAction<number>> = (
...
@@ -13,28 +14,30 @@ export const initMonstersImpl: CaseReducer<DuelState, PayloadAction<number>> = (
action
action
)
=>
{
)
=>
{
const
player
=
action
.
payload
;
const
player
=
action
.
payload
;
let
monsters
=
judgeSelf
(
player
,
state
)
?
state
.
meMonsters
:
state
.
opMonsters
;
const
monsters
=
{
monsters
:
[
{
sequence
:
0
,
},
{
sequence
:
1
,
},
{
sequence
:
2
,
},
{
sequence
:
3
,
},
{
sequence
:
4
,
},
],
};
if
(
!
monsters
)
{
if
(
judgeSelf
(
player
,
state
))
{
monsters
=
{
state
.
meMonsters
=
monsters
;
monsters
:
[
}
else
{
{
state
.
opMonsters
=
monsters
;
sequence
:
0
,
},
{
sequence
:
1
,
},
{
sequence
:
2
,
},
{
sequence
:
3
,
},
{
sequence
:
4
,
},
],
};
}
}
};
};
...
@@ -78,3 +81,6 @@ export const clearMonsterSelectInfoImpl: CaseReducer<
...
@@ -78,3 +81,6 @@ export const clearMonsterSelectInfoImpl: CaseReducer<
monsters
.
monsters
=
[];
monsters
.
monsters
=
[];
}
}
};
};
export
const
selectMeMonsters
=
(
state
:
RootState
)
=>
state
.
duel
.
meMonsters
||
{
monsters
:
[]
};
src/ui/Duel/mod.tsx
View file @
041f33c1
...
@@ -21,6 +21,7 @@ import { selectCurrentPlayer } from "../../reducers/duel/turnSlice";
...
@@ -21,6 +21,7 @@ import { selectCurrentPlayer } from "../../reducers/duel/turnSlice";
import
CardModal
from
"
./cardModal
"
;
import
CardModal
from
"
./cardModal
"
;
import
HintNotification
from
"
./hintNotification
"
;
import
HintNotification
from
"
./hintNotification
"
;
import
{
selectMeHands
}
from
"
../../reducers/duel/handsSlice
"
;
import
{
selectMeHands
}
from
"
../../reducers/duel/handsSlice
"
;
import
{
selectMeMonsters
}
from
"
../../reducers/duel/monstersSlice
"
;
// CONFIG
// CONFIG
...
@@ -28,6 +29,7 @@ const Duel = () => {
...
@@ -28,6 +29,7 @@ const Duel = () => {
// ----- 数据获取 -----
// ----- 数据获取 -----
const
hands
=
useAppSelector
(
selectMeHands
).
cards
;
const
hands
=
useAppSelector
(
selectMeHands
).
cards
;
const
monsters
=
useAppSelector
(
selectMeMonsters
).
monsters
;
const
currentPlayer
=
useAppSelector
(
selectCurrentPlayer
);
const
currentPlayer
=
useAppSelector
(
selectCurrentPlayer
);
// ----- WebGL渲染 -----
// ----- WebGL渲染 -----
...
@@ -60,7 +62,7 @@ const Duel = () => {
...
@@ -60,7 +62,7 @@ const Duel = () => {
renderMagics
(
scene
);
renderMagics
(
scene
);
// 怪兽区
// 怪兽区
renderMonsters
(
scene
);
renderMonsters
(
monsters
,
scene
);
// 创建额外怪兽区
// 创建额外怪兽区
renderExtraMonsters
(
scene
);
renderExtraMonsters
(
scene
);
...
@@ -105,7 +107,7 @@ const Duel = () => {
...
@@ -105,7 +107,7 @@ const Duel = () => {
engine
.
runRenderLoop
(()
=>
{
engine
.
runRenderLoop
(()
=>
{
scene
.
render
();
scene
.
render
();
});
});
},
[
canvasRef
,
hands
,
currentPlayer
]);
},
[
canvasRef
,
hands
,
monsters
,
currentPlayer
]);
// FIXME: 这里需要优化,应该分组件按需渲染
useEffect
(()
=>
{
useEffect
(()
=>
{
// 监听状态变化,并实现动画
// 监听状态变化,并实现动画
...
...
src/ui/Duel/monsters.ts
View file @
041f33c1
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
{
Monster
}
from
"
../../reducers/duel/util
"
;
export
default
(
scene
:
BABYLON
.
Scene
)
=>
{
export
default
(
monsters
:
Monster
[],
scene
:
BABYLON
.
Scene
)
=>
{
const
left
=
-
2.15
;
const
left
=
-
2.15
;
const
gap
=
1.05
;
const
gap
=
1.05
;
const
shape
=
CONFIG
.
CardSlotShape
();
const
shape
=
CONFIG
.
CardSlotShape
();
for
(
let
i
=
0
;
i
<
5
;
i
++
)
{
for
(
const
monster
of
monsters
)
{
const
slot
=
BABYLON
.
MeshBuilder
.
CreatePlane
(
`monster
${
i
}
`
,
shape
,
scene
);
const
sequence
=
monster
.
sequence
;
const
slot
=
BABYLON
.
MeshBuilder
.
CreatePlane
(
`monster
${
sequence
}
`
,
shape
,
scene
);
// 位置
// 位置
slot
.
position
=
new
BABYLON
.
Vector3
(
slot
.
position
=
new
BABYLON
.
Vector3
(
left
+
gap
*
i
,
left
+
gap
*
sequence
,
shape
.
depth
/
2
+
CONFIG
.
Floating
,
shape
.
depth
/
2
+
CONFIG
.
Floating
,
-
1.35
-
1.35
);
);
...
@@ -21,10 +27,20 @@ export default (scene: BABYLON.Scene) => {
...
@@ -21,10 +27,20 @@ export default (scene: BABYLON.Scene) => {
"
monsterMaterial
"
,
"
monsterMaterial
"
,
scene
scene
);
);
monsterMaterial
.
diffuseTexture
=
new
BABYLON
.
Texture
(
monsterMaterial
.
diffuseTexture
=
monster
.
occupant
`http://localhost:3030/images/card_slot.png`
?
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
;
monsterMaterial
.
diffuseTexture
.
hasAlpha
=
true
;
slot
.
material
=
monsterMaterial
;
slot
.
material
=
monsterMaterial
;
if
(
monster
.
selectInfo
)
{
slot
.
enableEdgesRendering
();
slot
.
edgesWidth
=
2.0
;
slot
.
edgesColor
=
BABYLON
.
Color4
.
FromColor3
(
BABYLON
.
Color3
.
Yellow
());
}
else
{
slot
.
disableEdgesRendering
();
}
}
}
};
};
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