Commit 369d8f09 authored by haiyoucuv's avatar haiyoucuv

init

parent 23b36405
...@@ -5,6 +5,8 @@ import Panel from "db://assets/core/Module/Panel"; ...@@ -5,6 +5,8 @@ import Panel from "db://assets/core/Module/Panel";
import { showPanel, showShareGuide } from "db://assets/core/Module/UIFast"; import { showPanel, showShareGuide } from "db://assets/core/Module/UIFast";
import { MainGame } from "db://assets/Scripts/Scenes/MainGame/MainGame"; import { MainGame } from "db://assets/Scripts/Scenes/MainGame/MainGame";
import { FailPage } from "db://assets/Scripts/Panels/FailPage"; import { FailPage } from "db://assets/Scripts/Panels/FailPage";
import gameStore from "db://assets/Scripts/store/gameStore";
import { _asyncThrottle } from "db://assets/Scripts/Utils/Utils";
const { ccclass, property } = _decorator; const { ccclass, property } = _decorator;
...@@ -42,14 +44,15 @@ export class ReviewPanel extends Panel { ...@@ -42,14 +44,15 @@ export class ReviewPanel extends Panel {
super.hidePanel(); super.hidePanel();
} }
cancel = () => { cancel = _asyncThrottle(() => {
this.hidePanel(); this.hidePanel();
AudioMgr.ins.playOneShot(AudioClipName.button_ok); AudioMgr.ins.playOneShot(AudioClipName.button_ok);
showPanel(FailPage); gameStore.submit(false);
} })
ok = () => { ok = _asyncThrottle(() => {
const { type } = this.data; const { type } = this.data;
AudioMgr.ins.playOneShot(AudioClipName.button_ok);
if (type == "share") { if (type == "share") {
showShareGuide(); showShareGuide();
...@@ -62,8 +65,7 @@ export class ReviewPanel extends Panel { ...@@ -62,8 +65,7 @@ export class ReviewPanel extends Panel {
} }
AudioMgr.ins.playOneShot(AudioClipName.button_ok); })
}
} }
......
...@@ -8,6 +8,7 @@ import { RoleCarColorsSysterm } from "db://assets/CarColorsGame/Scrips/Systerms/ ...@@ -8,6 +8,7 @@ import { RoleCarColorsSysterm } from "db://assets/CarColorsGame/Scrips/Systerms/
import { CarCarColorsSysterm } from "db://assets/CarColorsGame/Scrips/Systerms/CarCarColorsSysterm"; import { CarCarColorsSysterm } from "db://assets/CarColorsGame/Scrips/Systerms/CarCarColorsSysterm";
import { SuccessPage } from "db://assets/Scripts/Panels/SuccessPage"; import { SuccessPage } from "db://assets/Scripts/Panels/SuccessPage";
import { PlatformManager } from "db://assets/ScriptFrame/Frame/platformManager"; import { PlatformManager } from "db://assets/ScriptFrame/Frame/platformManager";
import gameStore from "db://assets/Scripts/store/gameStore";
const { ccclass, property } = _decorator; const { ccclass, property } = _decorator;
...@@ -19,8 +20,6 @@ export class MainGame extends Scene { ...@@ -19,8 +20,6 @@ export class MainGame extends Scene {
static skin: string = "MainGame"; static skin: string = "MainGame";
static bundle: string = "MainGame"; static bundle: string = "MainGame";
level: number = 0;
@property(Node) gamePre: Node = null; @property(Node) gamePre: Node = null;
@property(Node) parkPoints: Node = null; @property(Node) parkPoints: Node = null;
...@@ -47,10 +46,10 @@ export class MainGame extends Scene { ...@@ -47,10 +46,10 @@ export class MainGame extends Scene {
showPre() { showPre() {
this.gamePre.active = true; this.gamePre.active = true;
const isLevel1 = this.level === 1; const isLevel1 = gameStore.startInfo.level === 1;
this.gamePre.getChildByName("第二关").active = !isLevel1; this.gamePre.getChildByName("第二关").active = !isLevel1;
this.gamePre.getChildByName("第一关").active = isLevel1; this.gamePre.getChildByName("第一关").active = isLevel1;
this.gamePre.getChildByName("txt").getComponent(Label).string = `第 ${this.level} 关`; this.gamePre.getChildByName("txt").getComponent(Label).string = `第 ${gameStore.startInfo.level} 关`;
this.scheduleOnce(() => { this.scheduleOnce(() => {
this.gamePre.active = false; this.gamePre.active = false;
}, 2); }, 2);
...@@ -108,22 +107,25 @@ export class MainGame extends Scene { ...@@ -108,22 +107,25 @@ export class MainGame extends Scene {
} }
async nextLevel() { async nextLevel() {
if (this.level >= 5) { if (gameStore.startInfo.level >= 5) {
showPanel(SuccessPage); gameStore.submit(true);
return; return;
} }
this.level++; if (gameStore.startInfo.level != 0) {
gameStore.middleSubmit();
}
gameStore.startInfo.level++;
this.showPre(); this.showPre();
CarColorsGlobalInstance.instance.roleSysterm.clearAll(); CarColorsGlobalInstance.instance.roleSysterm.clearAll();
CarColorsGlobalInstance.instance.carSysterm.clearAll(); CarColorsGlobalInstance.instance.carSysterm.clearAll();
const level = await new Promise<Prefab>((resolve) => { const level = await new Promise<Prefab>((resolve) => {
assetManager.getBundle("MainGame") assetManager.getBundle("MainGame")
.load(`Levels/level${this.level}`, Prefab, (err, prefab: Prefab) => { .load(`Levels/level${gameStore.startInfo.level}`, Prefab, (err, prefab: Prefab) => {
if (err) { if (err) {
resolve(null); resolve(null);
return; return;
......
...@@ -5,12 +5,14 @@ import { creditsCost, sendWebNet, WebNetName } from "db://assets/Scripts/Utils/W ...@@ -5,12 +5,14 @@ import { creditsCost, sendWebNet, WebNetName } from "db://assets/Scripts/Utils/W
const { makeAutoObservable } = mobx; const { makeAutoObservable } = mobx;
export interface IStartInfo { export interface IStartInfo {
level: number,
startId: string, startId: string,
} }
class GameStore { class GameStore {
startInfo: IStartInfo = { startInfo: IStartInfo = {
level: 0,
startId: "", startId: "",
} }
...@@ -31,6 +33,7 @@ class GameStore { ...@@ -31,6 +33,7 @@ class GameStore {
if (!success) return false; if (!success) return false;
this.startInfo = data; this.startInfo = data;
this.startInfo.level = 0;
return success; return success;
} }
...@@ -51,11 +54,11 @@ class GameStore { ...@@ -51,11 +54,11 @@ class GameStore {
async middleSubmit() { async middleSubmit() {
const { startId } = this.startInfo; const { startId, level } = this.startInfo;
const { success, data } = await sendWebNet(WebNetName.middleSubmit, { const { success, data } = await sendWebNet(WebNetName.middleSubmit, {
startId, startId,
level: 1, level,
}); });
if (!success) return false; if (!success) return false;
...@@ -63,13 +66,13 @@ class GameStore { ...@@ -63,13 +66,13 @@ class GameStore {
this.startInfo = data; this.startInfo = data;
} }
async submit() { async submit(suc: boolean) {
const { startId } = this.startInfo; const { startId, level } = this.startInfo;
const { success, data } = await sendWebNet(WebNetName.middleSubmit, { const { success, data } = await sendWebNet(WebNetName.middleSubmit, {
startId, startId,
level: 1, level: suc ? level : level - 1,
}); });
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