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
e9e4d11c
Commit
e9e4d11c
authored
Jun 10, 2023
by
Chunchi Che
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add attack animation
parent
5bbb6526
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
84 additions
and
11 deletions
+84
-11
src/service/duel/attack.ts
src/service/duel/attack.ts
+8
-7
src/ui/Duel/PlayMat/Card/index.tsx
src/ui/Duel/PlayMat/Card/index.tsx
+3
-1
src/ui/Duel/PlayMat/Card/springs/attack.ts
src/ui/Duel/PlayMat/Card/springs/attack.ts
+73
-3
No files found.
src/service/duel/attack.ts
View file @
e9e4d11c
import
{
ygopro
}
from
"
@/api
"
;
import
{
eventbus
,
Task
}
from
"
@/infra
"
;
import
{
eventbus
,
sleep
,
Task
}
from
"
@/infra
"
;
import
{
cardStore
,
fetchEsHintMeta
}
from
"
@/stores
"
;
export
default
async
(
attack
:
ygopro
.
StocGameMessage
.
MsgAttack
)
=>
{
...
...
@@ -18,15 +18,16 @@ export default async (attack: ygopro.StocGameMessage.MsgAttack) => {
if
(
attack
.
direct_attack
)
{
await
eventbus
.
call
(
Task
.
Attack
,
attacker
.
uuid
,
true
);
}
else
{
const
target
=
cardStore
.
at
(
attack
.
target_location
.
zone
,
attack
.
target_location
.
controller
,
attack
.
target_location
.
sequence
await
eventbus
.
call
(
Task
.
Attack
,
attacker
.
uuid
,
false
,
attack
.
target_location
);
await
eventbus
.
call
(
Task
.
Attack
,
attacker
.
uuid
,
false
,
target
);
}
}
else
{
console
.
warn
(
`<Attack>attacker from
${
attack
.
attacker_location
}
is null`
);
}
await
sleep
(
1000
);
};
src/ui/Duel/PlayMat/Card/index.tsx
View file @
e9e4d11c
...
...
@@ -100,7 +100,9 @@ export const Card: FC<{ idx: number }> = React.memo(({ idx }) => {
target
?:
ygopro
.
CardLocation
)
=>
{
if
(
uuid
===
state
.
uuid
)
{
await
attack
({
card
:
state
,
api
,
target
,
directAttack
});
await
addToAnimation
(()
=>
attack
({
card
:
state
,
api
,
target
,
directAttack
})
);
}
}
);
...
...
src/ui/Duel/PlayMat/Card/springs/attack.ts
View file @
e9e4d11c
// 暂时先简单实现攻击动画,后面有时间再慢慢优化
import
{
easings
}
from
"
@react-spring/web
"
;
import
{
ygopro
}
from
"
@/api
"
;
import
{
CardType
}
from
"
@/stores
"
;
import
{
CardType
,
isMe
}
from
"
@/stores
"
;
import
{
matConfig
}
from
"
../../utils
"
;
import
{
SpringApi
}
from
"
./types
"
;
import
{
asyncStart
}
from
"
./utils
"
;
const
{
BLOCK_WIDTH
,
BLOCK_HEIGHT_M
,
BLOCK_HEIGHT_S
,
COL_GAP
,
ROW_GAP
}
=
matConfig
;
export
const
attack
=
async
(
props
:
{
card
:
CardType
;
api
:
SpringApi
;
target
?:
ygopro
.
CardLocation
;
directAttack
:
boolean
;
target
?:
ygopro
.
CardLocation
;
})
=>
{
// TODO
const
{
card
,
api
,
directAttack
,
target
}
=
props
;
const
current
=
api
.
current
[
0
].
get
();
let
x
=
current
.
x
;
let
y
=
current
.
y
;
if
(
directAttack
)
{
// 直接攻击
y
=
BLOCK_HEIGHT_M
.
value
+
BLOCK_HEIGHT_S
.
value
;
if
(
isMe
(
card
.
location
.
controller
))
{
y
=
-
y
;
}
}
else
if
(
target
)
{
// 攻击`target`
const
{
controller
,
sequence
}
=
target
;
if
(
sequence
>
4
)
{
// 额外怪兽区
x
=
(
sequence
>
5
?
1
:
-
1
)
*
(
BLOCK_WIDTH
.
value
+
COL_GAP
.
value
);
y
=
0
;
}
else
{
x
=
(
sequence
-
2
)
*
(
BLOCK_WIDTH
.
value
+
COL_GAP
.
value
);
y
=
BLOCK_HEIGHT_M
.
value
+
ROW_GAP
.
value
;
}
// 往下偏移半个卡位
y
-=
BLOCK_HEIGHT_M
.
value
/
2
;
if
(
!
isMe
(
controller
))
{
x
=
-
x
;
y
=
-
y
;
}
}
else
{
console
.
error
(
`<Spring/Attack>directAttack is false and target is null.`
);
return
;
}
// 先浮空
await
asyncStart
(
api
)({
z
:
200
,
});
// 后撤半个卡位
await
asyncStart
(
api
)({
y
:
current
.
y
+
(
BLOCK_HEIGHT_M
.
value
/
2
)
*
(
isMe
(
card
.
location
.
controller
)
?
1
:
-
1
),
});
// 加速前冲
await
asyncStart
(
api
)({
x
,
y
,
config
:
{
easing
:
easings
.
easeInOutSine
,
},
});
// 减速归位
await
asyncStart
(
api
)({
x
:
current
.
x
,
y
:
current
.
y
,
z
:
current
.
z
,
config
:
{
easing
:
easings
.
easeInOutQuad
,
},
});
};
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