2024-03-23 20:28:14 +08:00
|
|
|
|
/*
|
|
|
|
|
|
* @Author: WoNiu
|
|
|
|
|
|
* @Date: 2024-03-21 13:28:47
|
2024-03-25 19:50:16 +08:00
|
|
|
|
* @LastEditTime: 2024-03-25 19:44:01
|
2024-03-23 20:28:14 +08:00
|
|
|
|
* @LastEditors: WoNiu
|
|
|
|
|
|
* @Description:
|
|
|
|
|
|
*/
|
|
|
|
|
|
/*
|
|
|
|
|
|
* @Author: WoNiu
|
|
|
|
|
|
* @Date: 2024-03-21 13:28:47
|
|
|
|
|
|
* @LastEditTime: 2024-03-22 21:24:13
|
|
|
|
|
|
* @LastEditors: WoNiu
|
|
|
|
|
|
* @Description: 顺序选择卡片节点
|
|
|
|
|
|
*/
|
2024-03-25 19:50:16 +08:00
|
|
|
|
import { _decorator, Director, director, Node } from "cc";
|
2024-03-23 20:28:14 +08:00
|
|
|
|
import { BaseSprite } from "../../GlobalScript/CommonComponent/BaseSprite";
|
|
|
|
|
|
import { NpkImage } from "../../Tool/NPKImage";
|
|
|
|
|
|
import { BaseButtonAction } from "../../GlobalScript/CommonComponent/BaseButtonAction";
|
|
|
|
|
|
import { CardNode } from "./CardNode";
|
|
|
|
|
|
import { TimingProgressBar } from "../Common/TimingProgressBar";
|
|
|
|
|
|
const { ccclass, property } = _decorator;
|
|
|
|
|
|
|
|
|
|
|
|
/// 选择顺序卡牌Node
|
|
|
|
|
|
@ccclass("SelectNumberNode")
|
|
|
|
|
|
export class SelectNumberNode extends Node {
|
|
|
|
|
|
oneCard: CardNode;
|
|
|
|
|
|
twoCard: CardNode;
|
|
|
|
|
|
threeCard: CardNode;
|
2024-03-25 19:50:16 +08:00
|
|
|
|
doneFunc: Function;
|
2024-03-23 20:28:14 +08:00
|
|
|
|
|
|
|
|
|
|
constructor() {
|
|
|
|
|
|
super();
|
|
|
|
|
|
|
|
|
|
|
|
this.initBackground();
|
|
|
|
|
|
this.initCards();
|
|
|
|
|
|
this.initTiming();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
initBackground() {
|
|
|
|
|
|
const node = new Node();
|
|
|
|
|
|
node.setPosition(184.5, -181.5);
|
|
|
|
|
|
|
|
|
|
|
|
const bs = node.addComponent(BaseSprite);
|
|
|
|
|
|
bs.updateSpriteFrame(NpkImage.ingame, 46);
|
|
|
|
|
|
this.addChild(node);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
initCards() {
|
|
|
|
|
|
this.oneCard = new CardNode();
|
2024-03-24 17:55:56 +08:00
|
|
|
|
this.oneCard.setPosition(339, -220);
|
2024-03-23 20:28:14 +08:00
|
|
|
|
this.addChild(this.oneCard);
|
|
|
|
|
|
const Onebba = this.oneCard.addComponent(BaseButtonAction);
|
2024-03-25 19:50:16 +08:00
|
|
|
|
Onebba.onMouseLeftDown = () => {
|
|
|
|
|
|
this.onMouseLeftDown(0);
|
|
|
|
|
|
};
|
2024-03-23 20:28:14 +08:00
|
|
|
|
|
|
|
|
|
|
this.twoCard = new CardNode();
|
2024-03-24 17:55:56 +08:00
|
|
|
|
this.twoCard.setPosition(533.5, -220);
|
2024-03-23 20:28:14 +08:00
|
|
|
|
this.addChild(this.twoCard);
|
|
|
|
|
|
const twoBba = this.twoCard.addComponent(BaseButtonAction);
|
2024-03-25 19:50:16 +08:00
|
|
|
|
twoBba.onMouseLeftDown = () => {
|
|
|
|
|
|
this.onMouseLeftDown(1);
|
|
|
|
|
|
};
|
2024-03-23 20:28:14 +08:00
|
|
|
|
|
|
|
|
|
|
this.threeCard = new CardNode();
|
2024-03-24 17:55:56 +08:00
|
|
|
|
this.threeCard.setPosition(728, -220);
|
2024-03-23 20:28:14 +08:00
|
|
|
|
this.addChild(this.threeCard);
|
|
|
|
|
|
const threeBba = this.threeCard.addComponent(BaseButtonAction);
|
2024-03-25 19:50:16 +08:00
|
|
|
|
threeBba.onMouseLeftDown = () => {
|
|
|
|
|
|
this.onMouseLeftDown(2);
|
|
|
|
|
|
};
|
2024-03-23 20:28:14 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2024-03-25 19:50:16 +08:00
|
|
|
|
//* 倒计时
|
|
|
|
|
|
initTiming() {
|
|
|
|
|
|
// 倒计时
|
2024-03-23 20:28:14 +08:00
|
|
|
|
const time = new TimingProgressBar();
|
|
|
|
|
|
this.addChild(time);
|
2024-03-25 19:50:16 +08:00
|
|
|
|
|
|
|
|
|
|
time.tweenerStart(3, () => {
|
|
|
|
|
|
//倒计时缓动完成
|
|
|
|
|
|
//开始翻转动画,需要1秒完成动画
|
2024-03-24 17:55:56 +08:00
|
|
|
|
this.flipsCard();
|
2024-03-25 19:50:16 +08:00
|
|
|
|
|
|
|
|
|
|
//* 2秒后关闭node
|
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
|
this.doneFunc();
|
|
|
|
|
|
/// 这一帧结束之后调用
|
|
|
|
|
|
director.once(Director.EVENT_END_FRAME, () => {
|
|
|
|
|
|
// 销毁,销毁节点只能在当前帧结束后
|
|
|
|
|
|
this.destroy();
|
|
|
|
|
|
});
|
|
|
|
|
|
}, 2000);
|
|
|
|
|
|
|
2024-03-23 20:28:14 +08:00
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-03-24 17:55:56 +08:00
|
|
|
|
//* 翻转卡片
|
2024-03-25 19:50:16 +08:00
|
|
|
|
flipsCard() {
|
|
|
|
|
|
const cards = [this.oneCard, this.twoCard, this.threeCard];
|
2024-03-24 17:55:56 +08:00
|
|
|
|
for (let i = 0; i < cards.length; i++) {
|
|
|
|
|
|
const card = cards[i];
|
|
|
|
|
|
card.Disable = true;
|
2024-03-25 19:50:16 +08:00
|
|
|
|
card.flipsAnimation.animationStart(i, "玩家" + i);
|
2024-03-24 17:55:56 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-03-25 19:50:16 +08:00
|
|
|
|
onMouseLeftDown(tag: number) {
|
|
|
|
|
|
const cards = [this.oneCard, this.twoCard, this.threeCard];
|
|
|
|
|
|
cards.forEach((card) => {
|
2024-03-23 20:28:14 +08:00
|
|
|
|
card.Disable = true;
|
|
|
|
|
|
});
|
2024-03-25 19:50:16 +08:00
|
|
|
|
}
|
2024-03-23 20:28:14 +08:00
|
|
|
|
|
|
|
|
|
|
update(deltaTime: number) {}
|
|
|
|
|
|
}
|