Commit bde8faa6 authored by haiyoucuv's avatar haiyoucuv

init

parent 5401b2b4
...@@ -4,6 +4,9 @@ import Panel from "db://assets/core/Module/Panel"; ...@@ -4,6 +4,9 @@ import Panel from "db://assets/core/Module/Panel";
import { changeScene } from "db://assets/core/Module/UIFast"; import { changeScene } from "db://assets/core/Module/UIFast";
import { HomeScene } from "db://assets/Scripts/Scenes/HomeScene"; import { HomeScene } from "db://assets/Scripts/Scenes/HomeScene";
import store from "db://assets/Scripts/store/store"; import store from "db://assets/Scripts/store/store";
import gameStore from "db://assets/Scripts/store/gameStore";
import { MainGame } from "db://assets/Scripts/Scenes/MainGame/MainGame";
import { _asyncThrottle } from "db://assets/Scripts/Utils/Utils";
const { ccclass, property } = _decorator; const { ccclass, property } = _decorator;
...@@ -25,25 +28,29 @@ export class OverPanel extends Panel { ...@@ -25,25 +28,29 @@ export class OverPanel extends Panel {
start(): void { start(): void {
this.tip.string = `第${this.data.passLevel}关`; this.tip.string = `第${this.data.passLevel}关`;
if (store.homeInfo.freeTimes) { if (store.homeInfo.freeTimes) {
this.tip2.string = `免费次数:${store.homeInfo.freeTimes}`; this.tip2.string = `免费次数:${store.homeInfo.freeTimes}`;
} else { } else {
this.tip2.string = `${store.homeInfo.gameCreditsEach}积分/次`; this.tip2.string = `${store.homeInfo.gameCreditsEach}积分/次`;
} }
} }
cancel = () => { cancel = () => {
AudioMgr.ins.playOneShot(AudioClipName.button_ok); AudioMgr.ins.playOneShot(AudioClipName.button_ok);
this.hidePanel(); this.hidePanel();
changeScene(HomeScene);
} }
ok = () => { ok = _asyncThrottle(async () => {
AudioMgr.ins.playOneShot(AudioClipName.button_ok); AudioMgr.ins.playOneShot(AudioClipName.button_ok);
// changeScene(HomeScene);
const suc = await gameStore.start();
if (!suc) return
this.hidePanel(); this.hidePanel();
changeScene(HomeScene); changeScene(MainGame);
} })
} }
......
...@@ -78,12 +78,13 @@ export class HomeScene extends Scene { ...@@ -78,12 +78,13 @@ export class HomeScene extends Scene {
const { const {
freeTimes = 0, freeTimes = 0,
boxConfigs = [], boxConfigs = [],
gameCreditsEach,
} = store.homeInfo || {}; } = store.homeInfo || {};
if (+freeTimes) { if (+freeTimes) {
this.timesLabel.string = `免费次数:${freeTimes}`; this.timesLabel.string = `免费次数:${freeTimes}`;
} else { } else {
this.timesLabel.string = `20积分/次`; this.timesLabel.string = `${gameCreditsEach}积分/次`;
} }
this.boxRoot.removeAllChildren(); this.boxRoot.removeAllChildren();
...@@ -116,9 +117,11 @@ export class HomeScene extends Scene { ...@@ -116,9 +117,11 @@ export class HomeScene extends Scene {
} }
openBox = _asyncThrottle(async function (item) { openBox = _asyncThrottle(async function (item) {
if (!store.checkActTime()) return;
const { id, status, targetLevel } = item; const { id, status, targetLevel } = item;
if (+status != 1) return; if (+status != 1) return;
const { success, data } = await sendWebNet(WebNetName.openBox, { id }); const { success, data } = await sendWebNet(WebNetName.openBox, { id });
store.updateIndex();
if (!success) return; if (!success) return;
await showPanel(BoxPanel, data); await showPanel(BoxPanel, data);
}, 500) }, 500)
......
...@@ -37,11 +37,15 @@ class GameStore { ...@@ -37,11 +37,15 @@ class GameStore {
} }
const { success, ticket } = await creditsCost("main", "start", "deduct_credits_desc", gameCreditsEach); const { success, ticket } = await creditsCost("main", "start", "deduct_credits_desc", gameCreditsEach);
if (!success) return false; if (!success) {
await store.updateIndex();
return false;
}
params.ticketNum = ticket; params.ticketNum = ticket;
} }
const { success, data } = await sendWebNet(WebNetName.start, params); const { success, data } = await sendWebNet(WebNetName.start, params);
store.updateIndex();
if (!success) return false; if (!success) return false;
...@@ -74,11 +78,15 @@ class GameStore { ...@@ -74,11 +78,15 @@ class GameStore {
if (type === "credits") { if (type === "credits") {
const { success, ticket } = await creditsCost("main", "unlockPark", "deduct_credits_desc", unparkCreditsNum); const { success, ticket } = await creditsCost("main", "unlockPark", "deduct_credits_desc", unparkCreditsNum);
if (!success) return false; if (!success) {
await store.updateIndex();
return false;
}
params.ticketNum = ticket; params.ticketNum = ticket;
} }
const { success, data } = await sendWebNet(WebNetName.unlockPark, params); const { success, data } = await sendWebNet(WebNetName.unlockPark, params);
store.updateIndex();
if (!success) return false; if (!success) return false;
......
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