消消方块阵换皮表情
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

43 lines
1.3 KiB

1 week ago
import { Node, sp } from 'cc';
/** 方块表情 Spine 动画状态 */
export enum TetriBlockSpineState {
Shop = '1选项待机',
Falling = '2降落待机',
Settled = '3落地待机',
}
/** 是否在商店卡牌槽内(cardItem / ui_box*) */
export function isTetriBlockInShop(node: Node | null): boolean {
let cur = node?.parent ?? null;
while (cur?.isValid) {
if (cur.name === 'cardItem' || /^ui_box\d+$/.test(cur.name)) {
return true;
}
cur = cur.parent;
}
return false;
}
/** 是否已在地图堆叠区(引导预设块等) */
export function isTetriBlockOnTetrisTable(node: Node | null): boolean {
const table = gg?.game?.CurentBattle?.TetraMap?._tetrisTable;
if (!table?.isValid || !node?.isValid) return false;
let cur: Node | null = node;
while (cur?.isValid) {
if (cur === table) return true;
cur = cur.parent;
}
return false;
}
/** 播放方块根节点下 `spine` 子节点的循环动画 */
export function playTetriBlockSpine(node: Node | null, state: TetriBlockSpineState): void {
if (!node?.isValid) return;
const spineNode = node.getChildByName('spine');
if (!spineNode?.isValid) return;
const sk = spineNode.getComponent(sp.Skeleton);
if (!sk?.isValid) return;
sk.setAnimation(0, state, true);
}