Commit df9589be authored by haiyoucuv's avatar haiyoucuv

init

parent 63fcc854
This diff is collapsed.
import { _decorator, Button, Label, Node, Sprite, SpriteFrame } from 'cc'; import { _decorator, Button, Label, Node, Sprite, SpriteFrame } from 'cc';
import { AudioClipName, AudioMgr } from "db://assets/core/base/AudioMgr"; import { AudioClipName, AudioMgr } from "db://assets/core/base/AudioMgr";
import Panel from "db://assets/core/Module/Panel"; import Panel from "db://assets/core/Module/Panel";
import { showShareGuide } from "db://assets/core/Module/UIFast";
import { MainGame } from "db://assets/Scripts/Scenes/MainGame/MainGame";
import { CarColorsGlobalInstance } from "db://assets/Scripts/Scenes/MainGame/CarColorsGlobalInstance"; import { CarColorsGlobalInstance } from "db://assets/Scripts/Scenes/MainGame/CarColorsGlobalInstance";
import store from "db://assets/Scripts/store/store";
import gameStore from "db://assets/Scripts/store/gameStore";
import { _asyncThrottle } from "db://assets/Scripts/Utils/Utils";
const { ccclass, property } = _decorator; const { ccclass, property } = _decorator;
...@@ -29,11 +30,16 @@ export class UnlockPanel extends Panel { ...@@ -29,11 +30,16 @@ export class UnlockPanel extends Panel {
start(): void { start(): void {
const { type } = this.data; const { type } = this.data;
const { unparkQgNum, unparkCreditsNum } = store.homeInfo;
this.okBtn.getComponent(Sprite).spriteFrame = type == "share" ? this.shareSf : this.exchangeSf; this.okBtn.getComponent(Sprite).spriteFrame = type == "share" ? this.shareSf : this.exchangeSf;
// 消耗x积分 即可解锁1个车位 if (type == "share") {
// 消耗x青果 即可解锁1个车位 this.tip.string = "分享好友\n即可解锁1个车位";
// 分享好友 即可解锁1个车位 } else if (type == "green") {
this.tip.string = `消耗${unparkQgNum}青果\n即可解锁1个车位`;
} else if (type == "credits") {
this.tip.string = `消耗${unparkCreditsNum}积分\n即可解锁1个车位`;
}
} }
hidePanel() { hidePanel() {
...@@ -46,23 +52,16 @@ export class UnlockPanel extends Panel { ...@@ -46,23 +52,16 @@ export class UnlockPanel extends Panel {
this.hidePanel(); this.hidePanel();
} }
ok = () => { ok = _asyncThrottle(async () => {
const { type } = this.data; AudioMgr.ins.playOneShot(AudioClipName.button_ok);
if (type == "share") {
showShareGuide();
this.scheduleOnce(() => {
MainGame.ins.shareUnlock();
this.hidePanel();
CarColorsGlobalInstance.instance.roleSysterm.isGaming = true
}, 2500);
} else {
} const { type, onSuccess } = this.data;
const suc = await gameStore.unlockPark(type);
if (!suc) return;
AudioMgr.ins.playOneShot(AudioClipName.button_ok); onSuccess?.();
} })
} }
......
...@@ -24,6 +24,8 @@ import { showPanel, showToast } from "db://assets/core/Module/UIFast"; ...@@ -24,6 +24,8 @@ import { showPanel, showToast } from "db://assets/core/Module/UIFast";
import { AudioClipName, AudioMgr } from "db://assets/core/base/AudioMgr"; import { AudioClipName, AudioMgr } from "db://assets/core/base/AudioMgr";
import { UnlockPanel } from "db://assets/Scripts/Panels/UnlockPanel"; import { UnlockPanel } from "db://assets/Scripts/Panels/UnlockPanel";
import { CarColorsGlobalInstance } from "db://assets/Scripts/Scenes/MainGame/CarColorsGlobalInstance"; import { CarColorsGlobalInstance } from "db://assets/Scripts/Scenes/MainGame/CarColorsGlobalInstance";
import gameStore from "db://assets/Scripts/store/gameStore";
import { MainGame } from "db://assets/Scripts/Scenes/MainGame/MainGame";
const { ccclass, property } = _decorator; const { ccclass, property } = _decorator;
...@@ -88,11 +90,11 @@ export class GamePage extends Component { ...@@ -88,11 +90,11 @@ export class GamePage extends Component {
CarColorsGlobalInstance.instance.roleSysterm.isGaming = false; CarColorsGlobalInstance.instance.roleSysterm.isGaming = false;
if (parkIndex === 4) { if (parkIndex === 4) {
showPanel(UnlockPanel, { type: "share" }); MainGame.ins.shareUnlock();
} else if (parkIndex === 5) { } else if (parkIndex === 5) {
showPanel(UnlockPanel, { type: "exchange" }); MainGame.ins.videoUnlock1();
} else if (parkIndex === 6) { } else if (parkIndex === 6) {
showPanel(UnlockPanel, { type: "exchange" }); MainGame.ins.videoUnlock2();
} }
return; return;
} }
......
import { _decorator, assetManager, find, instantiate, Prefab, Node, Label } from 'cc'; import { _decorator, assetManager, find, instantiate, Prefab, Node, Label } from 'cc';
import Scene from "db://assets/core/Module/Scene"; import Scene from "db://assets/core/Module/Scene";
import { changeScene, showPanel, showToast } from "db://assets/core/Module/UIFast"; import { changeScene, showPanel, showShareGuide, showToast } from "db://assets/core/Module/UIFast";
import { AudioClipName, AudioMgr } from "db://assets/core/base/AudioMgr"; import { AudioClipName, AudioMgr } from "db://assets/core/base/AudioMgr";
import { HomeScene } from "db://assets/Scripts/Scenes/HomeScene"; import { HomeScene } from "db://assets/Scripts/Scenes/HomeScene";
import { RoleCarColorsSysterm } from "./Systerms/RoleCarColorsSysterm"; import { RoleCarColorsSysterm } from "./Systerms/RoleCarColorsSysterm";
...@@ -8,6 +8,7 @@ import { CarCarColorsSysterm } from "./Systerms/CarCarColorsSysterm"; ...@@ -8,6 +8,7 @@ import { CarCarColorsSysterm } from "./Systerms/CarCarColorsSysterm";
import { PlatformManager } from "db://assets/ScriptFrame/Frame/platformManager"; import { PlatformManager } from "db://assets/ScriptFrame/Frame/platformManager";
import gameStore from "db://assets/Scripts/store/gameStore"; import gameStore from "db://assets/Scripts/store/gameStore";
import { CarColorsGlobalInstance } from "db://assets/Scripts/Scenes/MainGame/CarColorsGlobalInstance"; import { CarColorsGlobalInstance } from "db://assets/Scripts/Scenes/MainGame/CarColorsGlobalInstance";
import { UnlockPanel } from "db://assets/Scripts/Panels/UnlockPanel";
const { ccclass, property } = _decorator; const { ccclass, property } = _decorator;
...@@ -58,6 +59,20 @@ export class MainGame extends Scene { ...@@ -58,6 +59,20 @@ export class MainGame extends Scene {
this.parkPoints.children.forEach((child, index) => { this.parkPoints.children.forEach((child, index) => {
if (index < 4) { if (index < 4) {
child.name = "empty"; child.name = "empty";
} else if (index == 4) {
child.name = "lock";
child.children[0].children[0].active = false;
if (gameStore.startInfo.shareUnlocked) {
child.children[0].children[1].active = false;
if (child.children[0].children[2]) {
child.children[0].children[2].active = true;
}
} else {
child.children[0].children[1].active = true;
if (child.children[0].children[2]) {
child.children[0].children[2].active = false;
}
}
} else { } else {
child.name = "lock"; child.name = "lock";
child.children[0].children[0].active = false; child.children[0].children[0].active = false;
...@@ -65,44 +80,58 @@ export class MainGame extends Scene { ...@@ -65,44 +80,58 @@ export class MainGame extends Scene {
} }
child.children[1]?.destroy(); child.children[1]?.destroy();
child.children[1]?.removeFromParent(); child.children[1]?.removeFromParent();
}) });
}
unlockPoint(index: number) {
const points = find("Scene/Parkings").children;
points[index].name = "empty";
points[index].children[0].children[0].active = true;
points[index].children[0].children[1].active = false;
AudioMgr.ins.playOneShot(AudioClipName.upgrade);
} }
shareUnlock() { shareUnlock() {
AudioMgr.ins.playOneShot(AudioClipName.button_ok) if (gameStore.startInfo.shareUnlocked) {
PlatformManager.instance.shareGame(() => { CarColorsGlobalInstance.instance.roleSysterm.isGaming = false
const points = find("Scene/Parkings").children showPanel(UnlockPanel, {
points[4].name = "empty" type: "green",
points[4].children[0].children[0].active = true onSuccess: () => {
points[4].children[0].children[1].active = false this.unlockPoint(4);
AudioMgr.ins.playOneShot(AudioClipName.upgrade) CarColorsGlobalInstance.instance.roleSysterm.isGaming = true;
}) }
});
} else {
showShareGuide();
this.scheduleOnce(() => {
if (gameStore.startInfo.shareUnlocked) return;
gameStore.startInfo.shareUnlocked = true;
gameStore.unlockPark("share");
this.unlockPoint(4);
}, 2.5);
}
} }
videoUnlock1() { videoUnlock1() {
AudioMgr.ins.playOneShot(AudioClipName.button_ok) CarColorsGlobalInstance.instance.roleSysterm.isGaming = false;
PlatformManager.instance.showVideoAd(() => { showPanel(UnlockPanel, {
const points = find("Scene/Parkings").children type: "credits",
points[5].name = "empty" onSuccess: () => {
points[5].children[0].children[0].active = true this.unlockPoint(5);
points[5].children[0].children[1].active = false CarColorsGlobalInstance.instance.roleSysterm.isGaming = true;
AudioMgr.ins.playOneShot(AudioClipName.upgrade) }
}, () => { });
showToast("视频播放未完成!")
})
} }
videoUnlock2() { videoUnlock2() {
AudioMgr.ins.playOneShot(AudioClipName.button_ok) CarColorsGlobalInstance.instance.roleSysterm.isGaming = false;
PlatformManager.instance.showVideoAd(() => { showPanel(UnlockPanel, {
const points = find("Scene/Parkings").children type: "credits",
points[6].name = "empty" onSuccess: () => {
points[6].children[0].children[0].active = true this.unlockPoint(6);
points[6].children[0].children[1].active = false CarColorsGlobalInstance.instance.roleSysterm.isGaming = true;
AudioMgr.ins.playOneShot(AudioClipName.upgrade) }
}, () => { });
showToast("视频播放未完成!")
})
} }
async nextLevel() { async nextLevel() {
...@@ -118,6 +147,7 @@ export class MainGame extends Scene { ...@@ -118,6 +147,7 @@ export class MainGame extends Scene {
gameStore.startInfo.level++; gameStore.startInfo.level++;
this.showPre(); this.showPre();
this.flushParkPoints();
CarColorsGlobalInstance.instance.roleSysterm.clearAll(); CarColorsGlobalInstance.instance.roleSysterm.clearAll();
CarColorsGlobalInstance.instance.carSysterm.clearAll(); CarColorsGlobalInstance.instance.carSysterm.clearAll();
......
...@@ -10,6 +10,7 @@ const { makeAutoObservable } = mobx; ...@@ -10,6 +10,7 @@ const { makeAutoObservable } = mobx;
export interface IStartInfo { export interface IStartInfo {
level: number, level: number,
startId: string, startId: string,
shareUnlocked: boolean,
} }
class GameStore { class GameStore {
...@@ -17,6 +18,7 @@ class GameStore { ...@@ -17,6 +18,7 @@ class GameStore {
startInfo: IStartInfo = { startInfo: IStartInfo = {
level: 0, level: 0,
startId: "", startId: "",
shareUnlocked: false,
} }
async start() { async start() {
...@@ -37,22 +39,32 @@ class GameStore { ...@@ -37,22 +39,32 @@ class GameStore {
this.startInfo = data; this.startInfo = data;
this.startInfo.level = 0; this.startInfo.level = 0;
this.startInfo.shareUnlocked = false;
return success; return success;
} }
async unlockPark() { async unlockPark(type: "share" | "credits" | "green") {
const { startId } = this.startInfo; const { startId, level } = this.startInfo;
const { success, data } = await sendWebNet(WebNetName.unlockPark, { const params: any = {
startId, startId,
level: 1, level,
}); type: type == "share" ? 1 : (type == "credits" ? 3 : 2),
}
if (type === "credits") {
const { success, ticket } = await creditsCost("main", "unlockPark", "deduct_credits_desc", 1000);
if (!success) return false;
params.ticketNum = ticket;
}
const { success, data } = await sendWebNet(WebNetName.unlockPark, params);
if (!success) return false; if (!success) return false;
this.startInfo = data; return success;
} }
async middleSubmit() { async middleSubmit() {
......
...@@ -17,6 +17,8 @@ export interface IHomeInfo { ...@@ -17,6 +17,8 @@ export interface IHomeInfo {
freeTimes: number; freeTimes: number;
creditsNum: number; creditsNum: number;
gameCreditsEach: number; gameCreditsEach: number;
unparkQgNum: number;
unparkCreditsNum: number;
boxConfigs: { boxConfigs: {
id: string; id: string;
targetLevel: string; targetLevel: string;
......
...@@ -8,6 +8,8 @@ ...@@ -8,6 +8,8 @@
"freeTimes": 6, "freeTimes": 6,
"creditsNum": 100, "creditsNum": 100,
"gameCreditsEach": 100, "gameCreditsEach": 100,
"unparkQgNum": 66,
"unparkCreditsNum": 88,
"boxConfigs": [ "boxConfigs": [
{ {
id: 1, id: 1,
......
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