Commit 4a16775c authored by timel's avatar timel

feat: animation

parent c4c2246c
...@@ -160,11 +160,17 @@ export default async (move: MsgMove) => { ...@@ -160,11 +160,17 @@ export default async (move: MsgMove) => {
await eventbus.call(Task.Move, target.uuid); await eventbus.call(Task.Move, target.uuid);
// 如果from或者to是手卡,那么需要刷新除了这张卡之外,这个玩家的所有手卡 // 如果from或者to是手卡,那么需要刷新除了这张卡之外,这个玩家的所有手卡
if ([from.zone, to.zone].includes(HAND)) { if ([from.zone, to.zone].includes(HAND)) {
for (const card of cardStore.at(HAND, target.location.controller)) { // for (const card of cardStore.at(HAND, target.location.controller)) {
if (card.uuid !== target.uuid) { // if (card.uuid !== target.uuid) {
await eventbus.call(Task.Move, card.uuid); // await eventbus.call(Task.Move, card.uuid);
} // }
} // }
Promise.all(
cardStore
.at(HAND, target.location.controller)
.filter((c) => c.uuid !== target.uuid)
.map(async (c) => await eventbus.call(Task.Move, c.uuid))
);
} }
// 超量素材位置跟随超量怪兽移动 // 超量素材位置跟随超量怪兽移动
......
...@@ -13,7 +13,7 @@ section#mat { ...@@ -13,7 +13,7 @@ section#mat {
top: 2%; top: 2%;
height: 96%; height: 96%;
width: 96%; width: 96%;
transform: translateZ(calc(var(--z) * 1px + 0.1px)) transform: translateZ(calc((var(--z) + var(--sub-z)) * 1px + 0.1px))
rotateY(calc(var(--ry) * 1deg)); rotateY(calc(var(--ry) * 1deg));
transition: 0.2s scale; transition: 0.2s scale;
cursor: pointer; cursor: pointer;
......
...@@ -55,6 +55,7 @@ export const Card: React.FC<{ idx: number }> = React.memo(({ idx }) => { ...@@ -55,6 +55,7 @@ export const Card: React.FC<{ idx: number }> = React.memo(({ idx }) => {
focusScale: 1, focusScale: 1,
focusDisplay: "none", focusDisplay: "none",
focusOpacity: 1, focusOpacity: 1,
subZ: 0,
} satisfies SpringApiProps) } satisfies SpringApiProps)
); );
...@@ -299,6 +300,7 @@ export const Card: React.FC<{ idx: number }> = React.memo(({ idx }) => { ...@@ -299,6 +300,7 @@ export const Card: React.FC<{ idx: number }> = React.memo(({ idx }) => {
`translate(${x}px, ${y}px) rotateX(${rx}deg) rotateZ(${rz}deg)` `translate(${x}px, ${y}px) rotateX(${rx}deg) rotateZ(${rz}deg)`
), ),
"--z": styles.z, "--z": styles.z,
"--sub-z": styles.subZ.to([0, 50, 100], [0, 200, 0]), // 中间高,两边低
"--ry": styles.ry, "--ry": styles.ry,
height: styles.height, height: styles.height,
zIndex: styles.zIndex, zIndex: styles.zIndex,
......
...@@ -3,6 +3,7 @@ import { type CardType, isMe } from "@/stores"; ...@@ -3,6 +3,7 @@ import { type CardType, isMe } from "@/stores";
import { matConfig } from "../../utils"; import { matConfig } from "../../utils";
import { SpringApi } from "./types"; import { SpringApi } from "./types";
import { asyncStart } from "./utils";
const { const {
BLOCK_WIDTH, BLOCK_WIDTH,
...@@ -41,7 +42,8 @@ export const moveToDeck = async (props: { card: CardType; api: SpringApi }) => { ...@@ -41,7 +42,8 @@ export const moveToDeck = async (props: { card: CardType; api: SpringApi }) => {
let rz = zone === EXTRA ? DECK_ROTATE_Z.value : -DECK_ROTATE_Z.value; let rz = zone === EXTRA ? DECK_ROTATE_Z.value : -DECK_ROTATE_Z.value;
rz += isMe(controller) ? 0 : 180; rz += isMe(controller) ? 0 : 180;
const z = sequence; const z = sequence;
api.start({
await asyncStart(api)({
x, x,
y, y,
z, z,
......
...@@ -3,6 +3,7 @@ import { cardStore, type CardType, isMe } from "@/stores"; ...@@ -3,6 +3,7 @@ import { cardStore, type CardType, isMe } from "@/stores";
import { matConfig } from "../../utils"; import { matConfig } from "../../utils";
import { SpringApi } from "./types"; import { SpringApi } from "./types";
import { asyncStart } from "./utils";
const { const {
BLOCK_HEIGHT_M, BLOCK_HEIGHT_M,
...@@ -44,14 +45,15 @@ export const moveToHand = async (props: { card: CardType; api: SpringApi }) => { ...@@ -44,14 +45,15 @@ export const moveToHand = async (props: { card: CardType; api: SpringApi }) => {
const negativeX = Math.sin(angle) * r; const negativeX = Math.sin(angle) * r;
const negativeY = Math.cos(angle) * r + HAND_CARD_HEIGHT.value / 2; const negativeY = Math.cos(angle) * r + HAND_CARD_HEIGHT.value / 2;
const x = hand_circle_center_x + negativeX * (isMe(controller) ? 1 : -1); const x = hand_circle_center_x + negativeX * (isMe(controller) ? 1 : -1);
const y = hand_circle_center_y - negativeY + 140; // 常量 是手动调的 这里肯定有问题 有空来修 const y = hand_circle_center_y - negativeY + 140; // FIXME: 常量 是手动调的 这里肯定有问题 有空来修
const _rz = (angle * 180) / Math.PI; const _rz = (angle * 180) / Math.PI;
api.start({ // FIXME: 这里加上await会导致有些手卡会卡住不动,为什么呢?
asyncStart(api)({
x: isMe(controller) ? x : -x, x: isMe(controller) ? x : -x,
y: isMe(controller) ? y : -y, y: isMe(controller) ? y : -y,
z: 0, z: 15,
rz: isMe(controller) ? _rz : 180 - _rz, rz: isMe(controller) ? _rz : 180 - _rz,
ry: isMe(controller) ? 0 : 180, ry: isMe(controller) ? 0 : 180,
height: HAND_CARD_HEIGHT.value, height: HAND_CARD_HEIGHT.value,
......
...@@ -3,6 +3,7 @@ import { type CardType, isMe } from "@/stores"; ...@@ -3,6 +3,7 @@ import { type CardType, isMe } from "@/stores";
import { matConfig } from "../../utils"; import { matConfig } from "../../utils";
import { SpringApi } from "./types"; import { SpringApi } from "./types";
import { asyncStart } from "./utils";
const { BLOCK_WIDTH, BLOCK_HEIGHT_M, BLOCK_HEIGHT_S, COL_GAP, ROW_GAP } = const { BLOCK_WIDTH, BLOCK_HEIGHT_M, BLOCK_HEIGHT_S, COL_GAP, ROW_GAP } =
matConfig; matConfig;
...@@ -15,7 +16,7 @@ export const moveToOutside = async (props: { ...@@ -15,7 +16,7 @@ export const moveToOutside = async (props: {
}) => { }) => {
const { card, api } = props; const { card, api } = props;
// report // report
const { zone, controller, position } = card.location; const { zone, controller, position, sequence } = card.location;
let x = (BLOCK_WIDTH.value + COL_GAP.value) * 3, let x = (BLOCK_WIDTH.value + COL_GAP.value) * 3,
y = zone === GRAVE ? BLOCK_HEIGHT_M.value + ROW_GAP.value : 0; y = zone === GRAVE ? BLOCK_HEIGHT_M.value + ROW_GAP.value : 0;
...@@ -23,12 +24,15 @@ export const moveToOutside = async (props: { ...@@ -23,12 +24,15 @@ export const moveToOutside = async (props: {
x = -x; x = -x;
y = -y; y = -y;
} }
api.start({ await asyncStart(api)({
x, x,
y, y,
z: 0, z: 0,
height: BLOCK_HEIGHT_S.value, height: BLOCK_HEIGHT_S.value,
rz: isMe(controller) ? 0 : 180, rz: isMe(controller) ? 0 : 180,
ry: [ygopro.CardPosition.FACEDOWN].includes(position) ? 180 : 0, ry: [ygopro.CardPosition.FACEDOWN].includes(position) ? 180 : 0,
subZ: 100,
zIndex: sequence,
}); });
api.set({ subZ: 0 });
}; };
...@@ -14,6 +14,8 @@ export interface SpringApiProps { ...@@ -14,6 +14,8 @@ export interface SpringApiProps {
focusDisplay: string; focusDisplay: string;
focusOpacity: number; focusOpacity: number;
// <<< focus // <<< focus
subZ: number; // 0 -> 100,这是为了让卡片移动过程中,稍微上浮一些,避免一些奇怪的遮挡问题
} }
export type SpringApi = SpringRef<SpringApiProps>; export type SpringApi = SpringRef<SpringApiProps>;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment