717 lines
23 KiB
TypeScript
717 lines
23 KiB
TypeScript
import { _decorator, Animation, Button, Component, Label, Node, sp, Sprite, tween, Tween, UIOpacity, Vec3, } from "cc";
|
|
import { SLOT_BAR_EVENT } from "./Define";
|
|
import { gold2cash } from "../../Main/Scripts/main/comm";
|
|
import { AudioManager } from "../../Main/Scripts/managers/AudioManager";
|
|
import { GameDataManager } from "../../Main/Scripts/managers/GameDataManager";
|
|
import { I18nManager } from "../../Main/Scripts/managers/I18nManager";
|
|
import { UIManager } from "../../Main/Scripts/managers/UIManager";
|
|
import { NodePoolManager } from "../../Main/Scripts/managers/NodePoolManager";
|
|
import { webView } from "./WebView";
|
|
import { AutoSpinPanel } from "./AutoSpinPanel";
|
|
const { ccclass, property } = _decorator;
|
|
|
|
export let Btn_Key = {
|
|
SpinBtn: "SpinBtn",
|
|
AddBetBtn: "AddBetBtn",
|
|
SubBetBtn: "SubBetBtn",
|
|
FastSpinBtn: "FastSpinBtn",
|
|
AutoSpinBtn: "AutoSpinBtn",
|
|
MenuBtn: "MenuBtn",
|
|
QuitBtn: "QuitBtn",
|
|
SoundBtn: "SoundBtn",
|
|
PaytableBtn: "PaytableBtn",
|
|
RuleBtn: "RuleBtn",
|
|
HistoryBtn: "HistoryBtn",
|
|
CloseL2Btn: "CloseL2Btn",
|
|
StopAutoSpinBtn: "StopAutoSpinBtn",
|
|
ChooseDiffBtn: "ChooseDiffBtn",
|
|
};
|
|
|
|
// 使用 @ccclass 装饰器
|
|
@ccclass("BtnConfig")
|
|
export class BtnConfig {
|
|
@property
|
|
key: string = "";
|
|
|
|
@property(Node)
|
|
btnNode: Node = null;
|
|
}
|
|
|
|
@ccclass("SlotBar")
|
|
export class SlotBar extends Component {
|
|
@property({ type: [BtnConfig] })
|
|
btnTable: BtnConfig[] = [];
|
|
|
|
hasClickSpin: boolean = false;
|
|
hasClickManualStop: boolean = false;
|
|
private isFastSpin: boolean = false;
|
|
private isAutoSpin: boolean = false;
|
|
|
|
gameInfo: any = null;
|
|
betGrade: number[] = [];
|
|
curBalance: number = 0;
|
|
curBet: number = 0;
|
|
curWin: number = 0;
|
|
betIndex: number = 0;
|
|
|
|
freeSpinMsgNode: Node = null;
|
|
lastFreeSpinNode: Node = null;
|
|
remainingFreeSpinNode: Node = null;
|
|
remainCountLabel: Label = null;
|
|
|
|
playerMsgNode: Node = null;
|
|
balanceLabel: Label = null;
|
|
betLabel: Label = null;
|
|
winLabel: Label = null;
|
|
|
|
freeSpinPlayerMsgNode: Node = null;
|
|
freeSpinBalanceLabel: Label = null;
|
|
freeSpinBetLabel: Label = null;
|
|
freeSpinWinLabel: Label = null;
|
|
|
|
btn_L1: Node = null;
|
|
btn_L2: Node = null;
|
|
|
|
curFreeSpinScore = 0;
|
|
|
|
onLoad(): void {
|
|
this.playerMsgNode = this.node.getChildByName("PlayerMsg");
|
|
let playerMsgLabs = this.playerMsgNode.getChildByName("lab");
|
|
this.balanceLabel = playerMsgLabs.getChildByName("balanceCount").getComponent(Label);
|
|
this.betLabel = playerMsgLabs.getChildByName("betCount").getComponent(Label);
|
|
this.winLabel = playerMsgLabs.getChildByName("winCount").getComponent(Label);
|
|
|
|
this.freeSpinMsgNode = this.node.getChildByName("FreeSpinMsg");
|
|
this.lastFreeSpinNode = this.freeSpinMsgNode.getChildByName("lastFreeSpin");
|
|
this.remainingFreeSpinNode = this.freeSpinMsgNode.getChildByName("remainingFreeSpin");
|
|
this.remainCountLabel = this.remainingFreeSpinNode.getChildByName("remainCount").getComponent(Label);
|
|
|
|
this.freeSpinPlayerMsgNode = this.node.getChildByName("FreeSpinPlayerMsg");
|
|
let freeSpinPlayerMsgLabs = this.freeSpinPlayerMsgNode.getChildByName("lab");
|
|
this.freeSpinBalanceLabel = freeSpinPlayerMsgLabs.getChildByName("balanceCount").getComponent(Label);
|
|
this.freeSpinBetLabel = freeSpinPlayerMsgLabs.getChildByName("betCount").getComponent(Label);
|
|
this.freeSpinWinLabel = freeSpinPlayerMsgLabs.getChildByName("winCount").getComponent(Label);
|
|
this.getBtnButton(Btn_Key.AutoSpinBtn).node.on(Node.EventType.TOUCH_START, this.autoAin, this);
|
|
this.getBtnButton(Btn_Key.AutoSpinBtn).node.on(Node.EventType.MOUSE_ENTER, this.autoAin, this);
|
|
this.getBtnButton(Btn_Key.FastSpinBtn).node.on(Node.EventType.TOUCH_START, this.fastAni, this);
|
|
this.getBtnButton(Btn_Key.FastSpinBtn).node.on(Node.EventType.MOUSE_ENTER, this.fastAni, this);
|
|
this.btn_L1 = this.node.getChildByName("Btn_L1");
|
|
this.btn_L2 = this.node.getChildByName("Btn_L2");
|
|
}
|
|
|
|
getBtnNode(key: string): Node {
|
|
return this.btnTable.find((btn) => btn.key === key)?.btnNode;
|
|
}
|
|
|
|
getBtnButton(key: string): Button {
|
|
return this.btnTable.find((btn) => btn.key === key)?.btnNode.getComponent(Button);
|
|
}
|
|
|
|
setGameInfo(gameInfo: any) {
|
|
this.gameInfo = gameInfo;
|
|
this.betGrade = gameInfo.BetGrade;
|
|
this.setBalance(gameInfo.Balance);
|
|
this.setBet(gameInfo.Data.Bet);
|
|
this.setWin(gameInfo.Data.AllScore);
|
|
|
|
this.hasClickSpin = true;
|
|
this.hasClickManualStop = true;
|
|
this.setBtnEnable(this.getBtnButton(Btn_Key.SpinBtn), false);
|
|
this.setBtnEnable(this.getBtnButton(Btn_Key.AddBetBtn), false);
|
|
this.setBtnEnable(this.getBtnButton(Btn_Key.SubBetBtn), false);
|
|
this.setBtnEnable(this.getBtnButton(Btn_Key.AutoSpinBtn), false);
|
|
this.setBtnEnable(this.getBtnButton(Btn_Key.MenuBtn), false);
|
|
this.updateChooseDiff();
|
|
}
|
|
|
|
updateChooseDiff() {
|
|
let diff = GameDataManager.instance.chooseDiff;
|
|
this.node.getChildByName('Btn_L1').getChildByName('Choose').children.forEach((child: Node, index: number) => {
|
|
child.active = index == diff - 1;
|
|
})
|
|
|
|
// this.getBtnNode(Btn_Key.SpinBtn).children.forEach((child: Node, index: number) => {
|
|
// child.getComponent(sp.Skeleton).setAnimation(0, '1', true);
|
|
// })
|
|
}
|
|
|
|
updatePlayerMsg(spinData: any, isReconnect: boolean, callBack: () => void) {
|
|
if (spinData.AllScore == 0) {
|
|
this.setWin(spinData.AllScore);
|
|
this.setBalance(spinData.Balance);
|
|
if (callBack) callBack();
|
|
return;
|
|
}
|
|
|
|
this.updateWinMsg(spinData.AllScore, isReconnect);
|
|
this.updateBalanceMsg(spinData.Balance, isReconnect, callBack);
|
|
}
|
|
|
|
updateWinMsg(winCount: number, isReconnect: boolean) {
|
|
let time = isReconnect ? 0 : 1;
|
|
let startScore = this.curWin;
|
|
let tw = UIManager.instance.tweenScorelinear(startScore, winCount, time);
|
|
if (tw !== null) {
|
|
tw.onUpdate((v) => this.setWin(v))
|
|
.onComplete(() => this.setWin(winCount))
|
|
.start();
|
|
}
|
|
}
|
|
|
|
updateBalanceMsg(balance: number, isReconnect: boolean, callBack: () => void) {
|
|
let time = isReconnect ? 0 : 1;
|
|
let tw = UIManager.instance.tweenScorelinear(this.getBalance(), balance, time);
|
|
if (tw !== null) {
|
|
tw.onUpdate((v) => this.setBalance(v))
|
|
.onComplete(() => {
|
|
this.setBalance(balance);
|
|
if (callBack) callBack();
|
|
})
|
|
.start();
|
|
}
|
|
}
|
|
|
|
updateIsFreeSpin(bol: boolean) {
|
|
if (bol) {
|
|
this.playerMsgNode.active = false;
|
|
this.btn_L1.active = false;
|
|
this.btn_L2.active = false;
|
|
this.freeSpinMsgNode.active = true;
|
|
this.freeSpinPlayerMsgNode.active = true;
|
|
} else {
|
|
this.playerMsgNode.active = true;
|
|
this.btn_L1.active = true;
|
|
this.freeSpinMsgNode.active = false;
|
|
this.freeSpinPlayerMsgNode.active = false;
|
|
}
|
|
}
|
|
|
|
setLeftCount(leftCount: number) {
|
|
if (leftCount > 0) {
|
|
this.remainingFreeSpinNode.active = true;
|
|
this.lastFreeSpinNode.active = false;
|
|
this.remainCountLabel.string = leftCount.toString();
|
|
} else {
|
|
this.remainingFreeSpinNode.active = false;
|
|
this.lastFreeSpinNode.active = true;
|
|
}
|
|
}
|
|
|
|
updateFreeSpinPlayerMsg(spinData: any, callBack: () => void) {
|
|
if (spinData.AllScore == 0) {
|
|
}
|
|
}
|
|
|
|
setBalance(balance: number) {
|
|
if (balance < 0) {
|
|
console.error("balance is less than 0,金币不足-->SlotBar");
|
|
return;
|
|
}
|
|
this.curBalance = balance;
|
|
this.balanceLabel.string = gold2cash(balance);
|
|
this.freeSpinBalanceLabel.string = gold2cash(balance);
|
|
}
|
|
|
|
getBalance(): number {
|
|
return this.curBalance;
|
|
}
|
|
|
|
betScale: Vec3 = new Vec3(1, 1, 1);
|
|
betScale1: Vec3 = new Vec3(1.2, 1.2, 1);
|
|
displayBet: number = 0;
|
|
setBet(bet: number, isSystemGift: boolean = false) {
|
|
this.curBet = bet;
|
|
this.displayBet = bet;
|
|
GameDataManager.instance.curBet = bet;
|
|
this.betLabel.string = gold2cash(bet);
|
|
this.freeSpinBetLabel.string = gold2cash(bet);
|
|
this.node.emit(SLOT_BAR_EVENT.BET_CHANGE, bet);
|
|
|
|
this.betIndex = this.betGrade.indexOf(bet);
|
|
if (isSystemGift) {
|
|
this.betIndex = -1;
|
|
} else {
|
|
if (this.betIndex == -1) {
|
|
this.betIndex = 0;
|
|
console.error(
|
|
"betIndex is -1,服务器发的信息不对,没有对应的betIndex-->SlotBar"
|
|
);
|
|
}
|
|
}
|
|
|
|
Tween.stopAllByTarget(this.betLabel.node);
|
|
tween(this.betLabel.node)
|
|
.set({ scale: this.betScale })
|
|
.to(0.15, { scale: this.betScale1 })
|
|
.to(0.015, { scale: this.betScale })
|
|
.start();
|
|
}
|
|
|
|
setDisplayBet(bet: number) {
|
|
this.displayBet = bet;
|
|
this.betLabel.string = gold2cash(bet);
|
|
this.freeSpinBetLabel.string = gold2cash(bet);
|
|
}
|
|
|
|
getBet(): number {
|
|
return this.curBet;
|
|
}
|
|
|
|
setWin(win: number) {
|
|
this.curWin = win;
|
|
this.winLabel.string = gold2cash(win);
|
|
this.freeSpinWinLabel.string = gold2cash(win);
|
|
}
|
|
|
|
getWin(): number {
|
|
return this.curWin;
|
|
}
|
|
|
|
onClickAddChips() {
|
|
AudioManager.instance.playSFX("Click_Menu");
|
|
this.betIndex += 1;
|
|
this.setNodeOpacityForBol(
|
|
this.getBtnButton(Btn_Key.AddBetBtn).node,
|
|
this.betIndex != this.betGrade.length
|
|
);
|
|
this.setNodeOpacityForBol(
|
|
this.getBtnButton(Btn_Key.SubBetBtn).node,
|
|
this.betIndex > 0
|
|
);
|
|
if (this.betIndex == this.betGrade.length) {
|
|
this.node.emit(SLOT_BAR_EVENT.MAX_BET);
|
|
this.betIndex = this.betGrade.length - 1; // 确保 betIndex 不超出范围
|
|
return;
|
|
}
|
|
this.setBet(this.betGrade[this.betIndex]);
|
|
}
|
|
|
|
onClickSubChips() {
|
|
AudioManager.instance.playSFX("Click_Menu");
|
|
this.betIndex -= 1;
|
|
this.setNodeOpacityForBol(
|
|
this.getBtnButton(Btn_Key.SubBetBtn).node,
|
|
this.betIndex > 0
|
|
);
|
|
this.setNodeOpacityForBol(
|
|
this.getBtnButton(Btn_Key.AddBetBtn).node,
|
|
this.betIndex != this.betGrade.length
|
|
);
|
|
if (this.betIndex < 0) {
|
|
this.node.emit(SLOT_BAR_EVENT.MIN_BET);
|
|
this.betIndex = 0; // 确保 betIndex 不低于0
|
|
return;
|
|
}
|
|
this.setBet(this.betGrade[this.betIndex]);
|
|
}
|
|
|
|
isAnimating: boolean = false;
|
|
btnPos1: Vec3 = new Vec3(0, -815, 0);
|
|
btnPos2: Vec3 = new Vec3(0, -1105, 0);
|
|
menuMoveTime: number = 0.1;
|
|
openMenu() {
|
|
if (this.isAnimating) return;
|
|
this.node.emit(SLOT_BAR_EVENT.OPEN_MENU);
|
|
AudioManager.instance.playSFX("Click_Menu");
|
|
this.isAnimating = true;
|
|
|
|
let btn_L1_opacity = this.btn_L1.getComponent(UIOpacity);
|
|
let btn_L2_opacity = this.btn_L2.getComponent(UIOpacity);
|
|
|
|
Tween.stopAllByTarget(this.btn_L1);
|
|
Tween.stopAllByTarget(this.btn_L2);
|
|
Tween.stopAllByTarget(btn_L1_opacity);
|
|
Tween.stopAllByTarget(btn_L2_opacity);
|
|
|
|
tween(this.btn_L1)
|
|
.set({ position: this.btnPos1 })
|
|
.to(this.menuMoveTime, { position: this.btnPos2 })
|
|
.call(() => {
|
|
this.btn_L1.active = false;
|
|
tween(this.btn_L2)
|
|
.set({ position: this.btnPos2 })
|
|
.call(() => {
|
|
this.btn_L2.active = true;
|
|
})
|
|
.to(this.menuMoveTime, { position: this.btnPos1 })
|
|
.call(() => {
|
|
this.isAnimating = false;
|
|
})
|
|
.start();
|
|
})
|
|
.start();
|
|
|
|
tween(btn_L1_opacity)
|
|
.set({ opacity: 255 })
|
|
.to(this.menuMoveTime, { opacity: 0 })
|
|
.call(() => {
|
|
tween(btn_L2_opacity)
|
|
.set({ opacity: 0 })
|
|
.to(this.menuMoveTime, { opacity: 255 })
|
|
.start();
|
|
})
|
|
.start();
|
|
}
|
|
|
|
closeMenu() {
|
|
if (this.isAnimating) return;
|
|
this.node.emit(SLOT_BAR_EVENT.CLOSE_MENU);
|
|
AudioManager.instance.playSFX("Click_Menu");
|
|
this.isAnimating = true;
|
|
|
|
let btn_L1_opacity = this.btn_L1.getComponent(UIOpacity);
|
|
let btn_L2_opacity = this.btn_L2.getComponent(UIOpacity);
|
|
|
|
Tween.stopAllByTarget(this.btn_L1);
|
|
Tween.stopAllByTarget(this.btn_L2);
|
|
Tween.stopAllByTarget(btn_L1_opacity);
|
|
Tween.stopAllByTarget(btn_L2_opacity);
|
|
|
|
tween(this.btn_L2)
|
|
.set({ position: this.btnPos1 })
|
|
.to(this.menuMoveTime, { position: this.btnPos2 })
|
|
.call(() => {
|
|
this.btn_L2.active = false;
|
|
tween(this.btn_L1)
|
|
.set({ position: this.btnPos2 })
|
|
.call(() => {
|
|
this.btn_L1.active = true;
|
|
})
|
|
.to(this.menuMoveTime, { position: this.btnPos1 })
|
|
.call(() => {
|
|
this.isAnimating = false;
|
|
})
|
|
.start();
|
|
})
|
|
.start();
|
|
|
|
tween(btn_L2_opacity)
|
|
.set({ opacity: 255 })
|
|
.to(this.menuMoveTime, { opacity: 0 })
|
|
.call(() => {
|
|
tween(btn_L1_opacity)
|
|
.set({ opacity: 0 })
|
|
.to(this.menuMoveTime, { opacity: 255 })
|
|
.start();
|
|
})
|
|
.start();
|
|
}
|
|
|
|
firstClickSpinState() {
|
|
this.getBtnNode(Btn_Key.SpinBtn).children.forEach(child => {
|
|
child.getComponent(sp.Skeleton).setAnimation(0, "2", true);
|
|
})
|
|
|
|
this.hasClickSpin = true;
|
|
|
|
this.setBtnEnable(this.getBtnButton(Btn_Key.AddBetBtn), false);
|
|
this.setBtnEnable(this.getBtnButton(Btn_Key.SubBetBtn), false);
|
|
this.setBtnEnable(this.getBtnButton(Btn_Key.AutoSpinBtn), false);
|
|
this.setBtnEnable(this.getBtnButton(Btn_Key.MenuBtn), false);
|
|
this.setBtnEnable(this.getBtnButton(Btn_Key.ChooseDiffBtn), false);
|
|
|
|
this.node.getChildByName("stopBtn").active = true;
|
|
}
|
|
|
|
onClickSpin(event, buyType: number = 0, changeDiff: boolean = false) {
|
|
if (!this.hasClickSpin && !this.hasClickManualStop) {
|
|
AudioManager.instance.playSFX("Click_Spin");
|
|
this.node.emit(SLOT_BAR_EVENT.ON_SPIN_CLICK, buyType, changeDiff, true);
|
|
this.firstClickSpinState();
|
|
}
|
|
// 第二次手动停止
|
|
else if (this.hasClickSpin && !this.hasClickManualStop) {
|
|
this.node.emit(SLOT_BAR_EVENT.ON_MANUAL_STOP);
|
|
}
|
|
}
|
|
|
|
featureBuySpin() {
|
|
// 第一次点击 旋转
|
|
if (!this.hasClickSpin && !this.hasClickManualStop) {
|
|
AudioManager.instance.playSFX("Click_Spin");
|
|
this.firstClickSpinState();
|
|
}
|
|
// 第二次点击 手动停止
|
|
else if (this.hasClickSpin && !this.hasClickManualStop) {
|
|
this.node.emit(SLOT_BAR_EVENT.ON_MANUAL_STOP);
|
|
this.node.getChildByName("stopBtn").active = false;
|
|
}
|
|
}
|
|
|
|
manualStop(hasWin: boolean) {
|
|
this.getBtnNode(Btn_Key.SpinBtn).children.forEach(child => {
|
|
child.getComponent(sp.Skeleton).setAnimation(0, '1', true);
|
|
})
|
|
this.setBtnEnable(this.getBtnButton(Btn_Key.SpinBtn), false);
|
|
this.hasClickManualStop = true;
|
|
}
|
|
|
|
spinBtnSpineEliminate() {
|
|
this.getBtnNode(Btn_Key.SpinBtn).children.forEach(child => {
|
|
child.getComponent(sp.Skeleton).setAnimation(0, '1', true);
|
|
})
|
|
this.setBtnEnable(this.getBtnButton(Btn_Key.SpinBtn), false);
|
|
}
|
|
|
|
onClickFastSpin() {
|
|
this.unscheduleAllCallbacks();
|
|
let btnAni = this.getBtnButton(Btn_Key.FastSpinBtn).getComponent(Animation);
|
|
AudioManager.instance.playSFX("Click_Menu");
|
|
if (this.isFastSpin) {
|
|
this.isFastSpin = false;
|
|
btnAni.play("turbo_Pressed_animation");
|
|
this.scheduleOnce(() => {
|
|
btnAni.play("turbo_Normal_animation");
|
|
}, 0.4);
|
|
} else {
|
|
this.isFastSpin = true;
|
|
btnAni.play("turbo_Pressed_animation");
|
|
this.scheduleOnce(() => {
|
|
btnAni.play("turbo_Enable_animation");
|
|
}, 0.4);
|
|
}
|
|
|
|
this.node.emit(SLOT_BAR_EVENT.FAST_SPIN, this.isFastSpin);
|
|
}
|
|
|
|
onClickRules() {
|
|
AudioManager.instance.playSFX("Click_Menu");
|
|
UIManager.instance.showPopup("WebView", "history/prefabs/rules", "Game", null);
|
|
}
|
|
|
|
onClickPaytable() {
|
|
AudioManager.instance.playSFX("Click_Menu");
|
|
UIManager.instance.showPopup("WebView", "history/prefabs/paytable", "Game", null);
|
|
}
|
|
|
|
onClickHistory() {
|
|
AudioManager.instance.playSFX("Click_Menu");
|
|
UIManager.instance.showPopup("WebView", "history/prefabs/history", "Game", null);
|
|
}
|
|
|
|
isON = true;
|
|
onClickBtnSound() {
|
|
AudioManager.instance.playSFX("Click_Menu");
|
|
let btns2 = this.btn_L2;
|
|
let sound = btns2.getChildByName("soundBtn");
|
|
let on = sound.getChildByName("Btn_SoundON_01");
|
|
let off = sound.getChildByName("Btn_SoundOFF_01");
|
|
this.isON = !this.isON;
|
|
on.active = this.isON;
|
|
off.active = !this.isON;
|
|
AudioManager.instance.setMute(off.active);
|
|
}
|
|
|
|
onBtnExit() {
|
|
this.node.emit(SLOT_BAR_EVENT.ON_EXIT_CLICK);
|
|
UIManager.instance.showTipMessagePanel(
|
|
I18nManager.instance.t("AID_QUIT_TITLE"),
|
|
I18nManager.instance.t("AID_QUIT_CONTENT"),
|
|
false,
|
|
null,
|
|
() => {
|
|
window.close();
|
|
},
|
|
I18nManager.instance.t("AID_QUIT_LEFT_BUTTON"),
|
|
I18nManager.instance.t("AID_ERROR_QUIT_BUTTON")
|
|
);
|
|
AudioManager.instance.playSFX("Click_Menu");
|
|
}
|
|
|
|
onClickAutoSpin() {
|
|
AudioManager.instance.playSFX("Click_Menu");
|
|
let btnAni = this.getBtnButton(Btn_Key.AutoSpinBtn).getComponent(Animation);
|
|
btnAni.play("autoSpin_Pressed_animation");
|
|
NodePoolManager.instance
|
|
.getNodeFromPoolDynamic("AutoSpinPanel", "Prefab/AutoSpinPanel", "Game")
|
|
.then((prefab: Node) => {
|
|
this.node.addChild(prefab);
|
|
prefab.getComponent(AutoSpinPanel).setCloseCallback(() => {
|
|
AudioManager.instance.playSFX("Click_Menu");
|
|
this.startAutoSpin(GameDataManager.instance.autoCount);
|
|
});
|
|
prefab.getComponent(AutoSpinPanel).showTween();
|
|
});
|
|
}
|
|
|
|
setLeftAutoCount(count: number) {
|
|
let num = this.getBtnNode(Btn_Key.StopAutoSpinBtn)
|
|
.getChildByName("num")
|
|
.getComponent(Label);
|
|
num.string = count.toString();
|
|
}
|
|
|
|
startAutoSpin(count: number) {
|
|
this.unscheduleAllCallbacks();
|
|
let btnAni = this.getBtnButton(Btn_Key.AutoSpinBtn).getComponent(Animation);
|
|
|
|
let circle01 = this.getBtnButton(Btn_Key.AutoSpinBtn)
|
|
.node.getChildByName("AutoSpinCircle01")
|
|
.getComponent(Sprite);
|
|
let circle02 = this.getBtnButton(Btn_Key.AutoSpinBtn)
|
|
.node.getChildByName("AutoSpinCircle02")
|
|
.getComponent(Sprite);
|
|
circle01.fillStart = 0;
|
|
circle01.fillRange = 0;
|
|
circle02.fillStart = 0;
|
|
circle02.fillRange = 0;
|
|
|
|
AudioManager.instance.playSFX("Click_Menu");
|
|
|
|
this.isAutoSpin = true;
|
|
|
|
this.scheduleOnce(() => {
|
|
btnAni.play("autoSpin_Enable_animation");
|
|
}, 0.4);
|
|
|
|
GameDataManager.instance.autoCount = count;
|
|
this.setLeftAutoCount(count);
|
|
|
|
this.setBtnEnable(this.getBtnButton(Btn_Key.SubBetBtn), false);
|
|
this.setBtnEnable(this.getBtnButton(Btn_Key.AddBetBtn), false);
|
|
this.setBtnEnable(this.getBtnButton(Btn_Key.AutoSpinBtn), false);
|
|
this.setBtnEnable(this.getBtnButton(Btn_Key.MenuBtn), false);
|
|
this.setBtnEnable(this.getBtnButton(Btn_Key.ChooseDiffBtn), false);
|
|
|
|
this.getBtnButton(Btn_Key.SpinBtn).node.active = false;
|
|
this.getBtnButton(Btn_Key.StopAutoSpinBtn).node.active = true;
|
|
|
|
this.node.emit(SLOT_BAR_EVENT.ON_AUTO_SPIN_CLICK, this.isAutoSpin);
|
|
}
|
|
|
|
closeAutoSpin() {
|
|
this.unscheduleAllCallbacks();
|
|
let btnAni = this.getBtnButton(Btn_Key.AutoSpinBtn).getComponent(Animation);
|
|
|
|
let circle01 = this.getBtnButton(Btn_Key.AutoSpinBtn)
|
|
.node.getChildByName("AutoSpinCircle01")
|
|
.getComponent(Sprite);
|
|
let circle02 = this.getBtnButton(Btn_Key.AutoSpinBtn)
|
|
.node.getChildByName("AutoSpinCircle02")
|
|
.getComponent(Sprite);
|
|
circle01.fillStart = 0;
|
|
circle01.fillRange = 0;
|
|
circle02.fillStart = 0;
|
|
circle02.fillRange = 0;
|
|
|
|
AudioManager.instance.playSFX("Click_Menu");
|
|
|
|
this.isAutoSpin = false;
|
|
btnAni.stop();
|
|
btnAni.play("autoSpin_Normal_animation");
|
|
|
|
this.getBtnButton(Btn_Key.SpinBtn).node.active = true;
|
|
this.getBtnButton(Btn_Key.StopAutoSpinBtn).node.active = false;
|
|
|
|
this.setBtnEnable(this.getBtnButton(Btn_Key.SpinBtn), false);
|
|
|
|
this.node.emit(SLOT_BAR_EVENT.ON_AUTO_SPIN_CLICK, this.isAutoSpin);
|
|
}
|
|
|
|
resetAllBtn() {
|
|
this.hasClickSpin = false;
|
|
this.hasClickManualStop = false;
|
|
this.isAutoSpin = false;
|
|
this.node.getChildByName("stopBtn").active = false;
|
|
|
|
this.getBtnButton(Btn_Key.SpinBtn).node.active = true;
|
|
this.getBtnButton(Btn_Key.StopAutoSpinBtn).node.active = false;
|
|
|
|
this.setBtnEnable(this.getBtnButton(Btn_Key.AddBetBtn), true);
|
|
this.setBtnEnable(this.getBtnButton(Btn_Key.SubBetBtn), true);
|
|
this.setBtnEnable(this.getBtnButton(Btn_Key.AutoSpinBtn), true);
|
|
this.setBtnEnable(this.getBtnButton(Btn_Key.MenuBtn), true);
|
|
this.setBtnEnable(this.getBtnButton(Btn_Key.ChooseDiffBtn), true);
|
|
|
|
this.setNodeOpacityForBol(
|
|
this.getBtnButton(Btn_Key.AddBetBtn).node,
|
|
this.betIndex != this.betGrade.length
|
|
);
|
|
this.setNodeOpacityForBol(
|
|
this.getBtnButton(Btn_Key.SubBetBtn).node,
|
|
this.betIndex > 0
|
|
);
|
|
|
|
this.setBtnEnable(this.getBtnButton(Btn_Key.SpinBtn), true);
|
|
this.getBtnNode(Btn_Key.SpinBtn).children.forEach((child: Node, index: number) => {
|
|
child.getComponent(sp.Skeleton).setAnimation(0, '1', true);
|
|
})
|
|
|
|
GameDataManager.instance.canClickIconMsg = true;
|
|
}
|
|
|
|
// 设置按钮可以点击并且置灰的函数
|
|
setBtnEnable(btn: Button | Node, enable: boolean) {
|
|
if (btn instanceof Button) {
|
|
btn.interactable = enable;
|
|
if (btn.name != Btn_Key.SpinBtn)
|
|
this.setNodeOpacity(btn.node, enable ? 255 : 128);
|
|
} else {
|
|
btn.getComponent(Button).interactable = enable;
|
|
if (btn.name != Btn_Key.SpinBtn)
|
|
this.setNodeOpacity(btn, enable ? 255 : 128);
|
|
}
|
|
}
|
|
|
|
setNodeOpacity(node: Node, opacity: number) {
|
|
node.getComponent(UIOpacity).opacity = opacity;
|
|
}
|
|
|
|
setNodeOpacityForBol(node: Node, bol: boolean) {
|
|
this.setNodeOpacity(node, bol ? 255 : 128);
|
|
}
|
|
autoAin() {
|
|
let autoBtn = this.getBtnButton(Btn_Key.AutoSpinBtn).node;
|
|
|
|
if (autoBtn.getComponent(Button).interactable) {
|
|
autoBtn.getComponent(Animation).play("autoSpin_Hover_animation");
|
|
}
|
|
}
|
|
fastAni() {
|
|
let turboBtn = this.getBtnButton(Btn_Key.FastSpinBtn).node;
|
|
let turboBtnAni = turboBtn.getComponent(Animation);
|
|
|
|
if (turboBtn.getComponent(Button).interactable && !this.isFastSpin) {
|
|
turboBtnAni.play("turbo_Hover_animation");
|
|
turboBtnAni.once(Animation.EventType.FINISHED, () => {
|
|
turboBtnAni.play("turbo_Normal_animation");
|
|
});
|
|
}
|
|
}
|
|
protected onDestroy(): void {
|
|
this.getBtnButton(Btn_Key.AutoSpinBtn).node.off(Node.EventType.TOUCH_START, this.autoAin, this);
|
|
this.getBtnButton(Btn_Key.AutoSpinBtn).node.off(Node.EventType.MOUSE_ENTER, this.autoAin, this);
|
|
this.getBtnButton(Btn_Key.FastSpinBtn).node.off(Node.EventType.TOUCH_START, this.fastAni, this);
|
|
this.getBtnButton(Btn_Key.FastSpinBtn).node.off(Node.EventType.MOUSE_ENTER, this.fastAni, this);
|
|
}
|
|
|
|
// =----------------------------------------=
|
|
setSysGiftBet(bet: number) {
|
|
let betIndex = this.betGrade.indexOf(bet);
|
|
if (betIndex == -1) {
|
|
betIndex = 0;
|
|
this.setBet(bet, true);
|
|
return;
|
|
}
|
|
this.setBet(this.betGrade[betIndex], true);
|
|
}
|
|
|
|
setSystemGiftContinue() {
|
|
this.setBtnEnable(this.getBtnButton(Btn_Key.SubBetBtn), false);
|
|
this.setBtnEnable(this.getBtnButton(Btn_Key.AddBetBtn), false);
|
|
this.setBtnEnable(this.getBtnButton(Btn_Key.AutoSpinBtn), false);
|
|
this.setBtnEnable(this.getBtnButton(Btn_Key.MenuBtn), false);
|
|
this.setBtnEnable(this.getBtnButton(Btn_Key.ChooseDiffBtn), false);
|
|
}
|
|
|
|
setSystemGiftConfirm() {
|
|
this.setBtnEnable(this.getBtnButton(Btn_Key.SubBetBtn), true);
|
|
this.setBtnEnable(this.getBtnButton(Btn_Key.AddBetBtn), true);
|
|
this.setBtnEnable(this.getBtnButton(Btn_Key.AutoSpinBtn), true);
|
|
this.setBtnEnable(this.getBtnButton(Btn_Key.MenuBtn), true);
|
|
this.setBtnEnable(this.getBtnButton(Btn_Key.ChooseDiffBtn), false);
|
|
this.betIndex = 0;
|
|
this.setBet(this.betGrade[this.betIndex]);
|
|
}
|
|
}
|