diff --git a/assets/Scene.ls b/assets/Scene.ls index 111bb48..ef581e6 100644 --- a/assets/Scene.ls +++ b/assets/Scene.ls @@ -13,7 +13,7 @@ { "_$type": "7bad1742-6eed-4d8d-81c0-501dc5bf03d6", "scriptPath": "../src/Main.ts", - "debug": true + "debug": false }, { "_$type": "cd70cd5e-b4cd-4277-ac0a-2224cfbe89ac", diff --git a/assets/atlas/comp/btn_pause.png b/assets/atlas/comp/btn_pause.png new file mode 100644 index 0000000..fe89f93 Binary files /dev/null and b/assets/atlas/comp/btn_pause.png differ diff --git a/assets/atlas/comp/btn_pause.png.meta b/assets/atlas/comp/btn_pause.png.meta new file mode 100644 index 0000000..40c9186 --- /dev/null +++ b/assets/atlas/comp/btn_pause.png.meta @@ -0,0 +1,6 @@ +{ + "uuid": "7d36066d-f01a-4a46-9eb7-109f58cdbc19", + "importer": { + "textureType": 2 + } +} \ No newline at end of file diff --git a/assets/resources/GamePause.lh b/assets/resources/GamePause.lh new file mode 100644 index 0000000..6ce074c --- /dev/null +++ b/assets/resources/GamePause.lh @@ -0,0 +1,299 @@ +{ + "_$ver": 1, + "_$id": "2c04twx2", + "_$type": "Box", + "name": "GamePause", + "width": 1080, + "height": 1920, + "_mouseState": 2, + "drawCallOptimize": true, + "left": 0, + "right": 0, + "top": 0, + "bottom": 0, + "_$comp": [ + { + "_$type": "c8bf81c2-c8fd-4f25-b120-4ad620ff7b88", + "scriptPath": "../src/views/GamePause.ts", + "label_time": { + "_$ref": "lvemgoo4" + }, + "label_diffucuty": { + "_$ref": "ztc8yofh" + }, + "btn_continue": { + "_$ref": "ugz9ejd0" + }, + "btn_restart": { + "_$ref": "lkzndo0i" + } + } + ], + "_$child": [ + { + "_$id": "vqp0nqaw", + "_$type": "Image", + "name": "Image", + "width": 1080, + "height": 1920, + "alpha": 0.6, + "left": 0, + "right": 0, + "top": 0, + "bottom": 0, + "skin": "res://a98f334e-ce04-4cd0-8fc5-bbdf9b048609", + "color": "#000000" + }, + { + "_$id": "cy0qcxu0", + "_$type": "Box", + "name": "center", + "x": 96, + "y": 507, + "width": 888, + "height": 906, + "_mouseState": 2, + "centerX": 0, + "centerY": 0, + "_$child": [ + { + "_$id": "ybaxa7q2", + "_$type": "Sprite", + "name": "Sprite", + "width": 888, + "height": 906, + "_gcmds": [ + { + "_$type": "DrawRoundRectCmd", + "x": 0, + "y": 0, + "width": 1, + "height": 1, + "lt": 20, + "rt": 20, + "lb": 20, + "rb": 20, + "percent": true, + "lineWidth": 1, + "fillColor": "#FFFFFF" + } + ] + }, + { + "_$id": "gpjobt41", + "_$type": "VBox", + "name": "buttons", + "x": 72, + "y": 478, + "width": 744, + "height": 600, + "centerX": 0, + "centerY": 325, + "space": 40, + "align": "center", + "_$child": [ + { + "_$id": "ugz9ejd0", + "_$type": "Sprite", + "name": "btn_continue", + "width": 744, + "height": 156, + "_gcmds": [ + { + "_$type": "DrawRoundRectCmd", + "x": 0, + "y": 0, + "width": 1, + "height": 1, + "lt": 20, + "rt": 20, + "lb": 20, + "rb": 20, + "percent": true, + "lineWidth": 1, + "fillColor": "rgba(29, 92, 220, 1)" + } + ] + }, + { + "_$id": "lkzndo0i", + "_$type": "Sprite", + "name": "btn_restart", + "y": 196, + "width": 744, + "height": 156, + "alpha": 0.1, + "_gcmds": [ + { + "_$type": "DrawRoundRectCmd", + "x": 0, + "y": 0, + "width": 1, + "height": 1, + "lt": 20, + "rt": 20, + "lb": 20, + "rb": 20, + "percent": true, + "lineWidth": 1, + "fillColor": "rgba(29, 92, 220, 1)" + } + ] + } + ] + }, + { + "_$id": "e5ib0aqq", + "_$type": "VBox", + "name": "labels", + "x": 72, + "y": 478, + "width": 744, + "height": 600, + "centerX": 0, + "centerY": 325, + "space": 40, + "align": "center", + "_$child": [ + { + "_$id": "8v40s793", + "_$type": "Label", + "name": "Label(1)", + "width": 744, + "height": 156, + "text": "Continue", + "fontSize": 60, + "color": "rgba(255, 255, 255, 1)", + "bold": true, + "align": "center", + "valign": "middle", + "padding": "0,0,0,0" + }, + { + "_$id": "urss0raj", + "_$type": "Label", + "name": "Label(2)", + "y": 196, + "width": 744, + "height": 156, + "text": "Restart", + "fontSize": 60, + "color": "rgba(29, 92, 220, 1)", + "bold": true, + "align": "center", + "valign": "middle", + "padding": "0,0,0,0" + } + ] + }, + { + "_$id": "hk8la5r2", + "_$type": "Label", + "name": "Label", + "x": 76, + "y": 103, + "width": 736, + "height": 100, + "centerX": 0, + "centerY": -300, + "text": "Pause", + "fontSize": 72, + "color": "rgba(45, 49, 56, 1)", + "bold": true, + "align": "center", + "valign": "middle", + "padding": "0,0,0,0" + }, + { + "_$id": "va1fgpv1", + "_$type": "HBox", + "name": "summary", + "x": 84, + "y": 250, + "width": 720, + "height": 140, + "centerX": 0, + "space": 0, + "align": "middle", + "_$child": [ + { + "_$id": "4ur3tdna", + "_$type": "Box", + "name": "Box(1)", + "y": 2.5, + "width": 360, + "height": 135, + "_$child": [ + { + "_$id": "10mi9wxu", + "_$type": "Label", + "name": "up", + "width": 360, + "height": 60, + "text": "Time", + "fontSize": 42, + "color": "rgba(123, 129, 140, 1)", + "align": "center", + "valign": "middle", + "padding": "0,0,0,0" + }, + { + "_$id": "lvemgoo4", + "_$type": "Label", + "name": "down", + "y": 70, + "width": 360, + "height": 72, + "text": "Medium", + "fontSize": 60, + "color": "rgba(45, 49, 56, 1)", + "align": "center", + "valign": "middle", + "padding": "0,0,0,0" + } + ] + }, + { + "_$id": "26zqj788", + "_$type": "Box", + "name": "Box(2)", + "x": 360, + "y": 2.5, + "width": 360, + "height": 135, + "_$child": [ + { + "_$id": "nu9nfub9", + "_$type": "Label", + "name": "up", + "width": 360, + "height": 60, + "text": "Difficuty", + "fontSize": 42, + "color": "rgba(123, 129, 140, 1)", + "align": "center", + "valign": "middle", + "padding": "0,0,0,0" + }, + { + "_$id": "ztc8yofh", + "_$type": "Label", + "name": "down", + "y": 70, + "width": 360, + "height": 72, + "text": "Medium", + "fontSize": 60, + "color": "rgba(45, 49, 56, 1)", + "align": "center", + "valign": "middle", + "padding": "0,0,0,0" + } + ] + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/assets/resources/GamePause.lh.meta b/assets/resources/GamePause.lh.meta new file mode 100644 index 0000000..21bf240 --- /dev/null +++ b/assets/resources/GamePause.lh.meta @@ -0,0 +1,3 @@ +{ + "uuid": "b6e5dbcc-bac5-45ae-98d6-48ff60f88a29" +} \ No newline at end of file diff --git a/assets/resources/Stage.lh b/assets/resources/Stage.lh index 0f749fe..20173ac 100644 --- a/assets/resources/Stage.lh +++ b/assets/resources/Stage.lh @@ -17,6 +17,9 @@ "btn_back": { "_$ref": "l1ebdt6a" }, + "btn_pause": { + "_$ref": "qfuij2yw" + }, "label_score": { "_$ref": "zgzyqyoc" }, @@ -72,19 +75,19 @@ { "_$id": "xllpjjqz", "_$type": "Box", - "name": "back", - "x": 45, + "name": "top", "y": 60, - "width": 400, + "width": 1080, "height": 64, "_mouseState": 2, - "centerX": -295, + "centerX": 0, "centerY": -868, "_$child": [ { "_$id": "l1ebdt6a", "_$type": "Button", "name": "btn_back", + "x": 45, "width": 69, "height": 48, "_mouseState": 2, @@ -94,6 +97,21 @@ "labelSize": 20, "labelAlign": "center", "labelVAlign": "middle" + }, + { + "_$id": "qfuij2yw", + "_$type": "Button", + "name": "btn_pause", + "x": 956, + "width": 75, + "height": 75, + "_mouseState": 2, + "stateNum": 1, + "skin": "res://7d36066d-f01a-4a46-9eb7-109f58cdbc19", + "label": "", + "labelSize": 20, + "labelAlign": "center", + "labelVAlign": "middle" } ] }, diff --git a/src/constants/respath.ts b/src/constants/respath.ts index d90be2c..d7dab16 100644 --- a/src/constants/respath.ts +++ b/src/constants/respath.ts @@ -13,6 +13,7 @@ export const respath = { return config.H_SCREEN ? "resources/Stage_H.lh" : "resources/Stage.lh" }, + gamepause_ui_res: "resources/GamePause.lh", gameover_ui_res: "resources/GameOver.lh", gamedone_ui_res: "resources/GameDone.lh", diff --git a/src/controllers/GameController.ts b/src/controllers/GameController.ts deleted file mode 100644 index 7796c2b..0000000 --- a/src/controllers/GameController.ts +++ /dev/null @@ -1,7 +0,0 @@ - -const { regClass, property } = Laya - -@regClass() -export class GameController extends Laya.Script { - -} diff --git a/src/controllers/GameController.ts.meta b/src/controllers/GameController.ts.meta deleted file mode 100644 index 2b0f037..0000000 --- a/src/controllers/GameController.ts.meta +++ /dev/null @@ -1,3 +0,0 @@ -{ - "uuid": "58dcdb79-495f-4e55-9403-eada57f40c67" -} \ No newline at end of file diff --git a/src/models/EventManager.ts b/src/models/EventManager.ts index b763737..96707b3 100644 --- a/src/models/EventManager.ts +++ b/src/models/EventManager.ts @@ -3,6 +3,7 @@ export const EVENT_TYPES = { NOT_UPDATE_MISTAKE: "NOT_UPDATE_MISTAKE",//更新分数 + NOT_UPDATE_PAUSE: "NOT_UPDATE_PAUSE",//更新暂停状态 } diff --git a/src/models/LevelManager.ts b/src/models/LevelManager.ts index e7d9b29..d0bc73f 100644 --- a/src/models/LevelManager.ts +++ b/src/models/LevelManager.ts @@ -153,4 +153,5 @@ export class LevelManager { } return "" } + } diff --git a/src/models/StorageManager.ts b/src/models/StorageManager.ts index 6df8527..6f21649 100644 --- a/src/models/StorageManager.ts +++ b/src/models/StorageManager.ts @@ -4,6 +4,7 @@ import { config } from "../constants/config" import { DataStage, createDataStage } from "../types/global" import { DOStage } from "./DOStage" import { DOUser } from "./DOUser" +import { LevelManager } from "./LevelManager" export class StorageManager { @@ -57,9 +58,27 @@ export class StorageManager { this.userChanged = true } - public newStage(stageID: string, type: number, name: string, difficulty: string, index: number): DOStage { + public newStage(stageID: string, type: number, name: string, difficulty: string = config.DIFFICULTY_TYPE.Easy): DOStage { this.stageID = stageID this.stageChanged = false + + var index + if (type == config.STAGE_TYPE.MAIN) {//主线关卡 + index = this.user.get_progress(difficulty) + var levelStr = LevelManager.getInstance().getLevelStr(difficulty, index) + if (!levelStr || levelStr.length <= 0) {//说明当前难度已经打通了,所以给他从头开始 + index = 0 + this.user.update_progress(difficulty, index) + } + } + else if (type == config.STAGE_TYPE.DC) { + var random = Math.random() + difficulty = config.DIFFICULTY_LIST[Math.floor(random*config.DIFFICULTY_LIST.length)] + var list = LevelManager.getInstance().getLevelList(difficulty) + random = Math.random() + index = Math.floor(random*list.length) + console.log("每日挑战随机一个关卡", difficulty, index) + } var dataStage: DataStage = createDataStage(stageID, type, name, difficulty, index) var doStage: DOStage = new DOStage(dataStage) this.stageMap.set(stageID, doStage) diff --git a/src/models/UIManager.ts b/src/models/UIManager.ts index f1f4b26..8de6e60 100644 --- a/src/models/UIManager.ts +++ b/src/models/UIManager.ts @@ -5,7 +5,6 @@ import { DailyChallenge } from "../views/DailyChallenge" import { TrophyRecord } from "../types/global" import { TrophyClaim } from "../views/TrophyClaim" import { TrophyShow } from "../views/TrophyShow" -import { config } from "../constants/config" const { regClass, property } = Laya @@ -91,6 +90,12 @@ export class UIManager extends Laya.Script { } } + public loadGamePauseUI(): void { + Laya.loader.load(respath.gamepause_ui_res).then((go)=>{ + var prefab = go.create() + this.getUIRoot().addChild(prefab) + }) + } public loadGameOverUI(): void { Laya.loader.load(respath.gameover_ui_res).then((go)=>{ var prefab = go.create() diff --git a/src/views/Block.ts b/src/views/Block.ts index 2f02855..cd46b08 100644 --- a/src/views/Block.ts +++ b/src/views/Block.ts @@ -1,4 +1,4 @@ -import { G_ShowScoreTips } from "../views/GUITips"; +import { G_ShowScoreTips } from "../views/common/GUITips"; import { DOBlock } from "../models/DOBlock"; const { regClass, property } = Laya; diff --git a/src/views/DailyChallenge.ts b/src/views/DailyChallenge.ts index b0ae586..2a6fb29 100644 --- a/src/views/DailyChallenge.ts +++ b/src/views/DailyChallenge.ts @@ -84,14 +84,8 @@ export class DailyChallenge extends Laya.Script { var doStage = StorageManager.getInstance().loadStage(stageID) console.log("play >>>>>>>>>>>>>>>>>>>>>>>", stageID, doStage) if (!doStage) { - var random = Math.random() - var value = config.DIFFICULTY_LIST[Math.floor(random*config.DIFFICULTY_LIST.length)] - var list = LevelManager.getInstance().getLevelList(value) - random = Math.random() - var index = Math.floor(random*list.length) var stageName = `${config.MONTH_ABBRS[month-1]} ${dayNow}` - console.log("随机一个关卡", value, index) - StorageManager.getInstance().newStage(stageID, config.STAGE_TYPE.DC, stageName, value, index) + StorageManager.getInstance().newStage(stageID, config.STAGE_TYPE.DC, stageName) } UIManager.getInstance().loadStageUI(stageID); this.owner.destroy() diff --git a/src/views/Difficulty.ts b/src/views/Difficulty.ts index 8812a4d..78617a9 100644 --- a/src/views/Difficulty.ts +++ b/src/views/Difficulty.ts @@ -1,5 +1,5 @@ import { config } from "../constants/config"; -import { CommonData } from "./CommonData"; +import { CommonData } from "./common/CommonData"; const { regClass, property } = Laya; diff --git a/src/views/GameDone.ts b/src/views/GameDone.ts index 8298be1..6f8002a 100644 --- a/src/views/GameDone.ts +++ b/src/views/GameDone.ts @@ -64,13 +64,7 @@ export class GameDone extends Laya.Script { d.onInit((value: string)=> { console.log("选择难度", value) StorageManager.getInstance().cleanStage() - var user = StorageManager.getInstance().getUser() - var index = user.get_progress(value) - var levelStr = LevelManager.getInstance().getLevelStr(value, index) - if (!levelStr || levelStr.length <= 0) {//说明当前难度已经打通了,所以给他从头开始 - user.update_progress(value, 0) - } - StorageManager.getInstance().newStage(config.DEFAULT_STAGE_ID, config.STAGE_TYPE.MAIN, value, value, user.get_progress(value)) + StorageManager.getInstance().newStage(config.DEFAULT_STAGE_ID, config.STAGE_TYPE.MAIN, value, value) UIManager.getInstance().loadStageUI(config.DEFAULT_STAGE_ID); this.owner.destroy() }) diff --git a/src/views/GameOver.ts b/src/views/GameOver.ts index 9d2832d..f8727be 100644 --- a/src/views/GameOver.ts +++ b/src/views/GameOver.ts @@ -40,8 +40,7 @@ export class GameOver extends Laya.Script { var type = doStage.get_stageType() var difficulty = doStage.get_difficulty() StorageManager.getInstance().cleanStage() - var user = StorageManager.getInstance().getUser() - StorageManager.getInstance().newStage(stageID, type, difficulty, difficulty, user.get_progress(difficulty)) + StorageManager.getInstance().newStage(stageID, type, difficulty, difficulty) UIManager.getInstance().loadStageUI(stageID); this.owner.destroy() }) @@ -58,13 +57,7 @@ export class GameOver extends Laya.Script { d.onInit((value: string)=> { console.log("选择难度", value) StorageManager.getInstance().cleanStage() - var user = StorageManager.getInstance().getUser() - var index = user.get_progress(value) - var levelStr = LevelManager.getInstance().getLevelStr(value, index) - if (!levelStr || levelStr.length <= 0) {//说明当前难度已经打通了,所以给他从头开始 - user.update_progress(value, 0) - } - StorageManager.getInstance().newStage(config.DEFAULT_STAGE_ID, config.STAGE_TYPE.MAIN, value, value, user.get_progress(value)) + StorageManager.getInstance().newStage(config.DEFAULT_STAGE_ID, config.STAGE_TYPE.MAIN, value, value) UIManager.getInstance().loadStageUI(config.DEFAULT_STAGE_ID); this.owner.destroy() }) diff --git a/src/views/GamePause.ts b/src/views/GamePause.ts new file mode 100644 index 0000000..10467aa --- /dev/null +++ b/src/views/GamePause.ts @@ -0,0 +1,52 @@ + + +import { UIManager } from "../models/UIManager"; +import { StorageManager } from "../models/StorageManager"; +import { Utility_ConvertSecondToString } from "../utils/utility"; +import { EVENT_TYPES, EventManager } from "../models/EventManager"; + + + +const { regClass, property } = Laya; + +@regClass() +export class GamePause extends Laya.Script { + declare owner : Laya.Box; + + @property(Laya.Label) + public label_time: Laya.Label + @property(Laya.Label) + public label_diffucuty: Laya.Label + + @property(Laya.Sprite) + public btn_continue: Laya.Sprite + @property(Laya.Sprite) + public btn_restart: Laya.Sprite + + + //组件被激活后执行,此时所有节点和组件均已创建完毕,此方法只执行一次 + onAwake(): void { + + var doStage = StorageManager.getInstance().getStage() + + this.label_time.text = Utility_ConvertSecondToString(doStage.get_duration()) + this.label_diffucuty.text = doStage.get_difficulty() + + EventManager.getInstance().DispatchEvent(EVENT_TYPES.NOT_UPDATE_PAUSE, true) + this.btn_continue.on(Laya.Event.CLICK, this, (evt: Laya.Event) => { + EventManager.getInstance().DispatchEvent(EVENT_TYPES.NOT_UPDATE_PAUSE, false) + this.owner.destroy() + }) + + this.btn_restart.on(Laya.Event.CLICK, this, (evt: Laya.Event) => { + var stageID = doStage.get_stageID() + var type = doStage.get_stageType() + var difficulty = doStage.get_difficulty() + StorageManager.getInstance().cleanStage() + StorageManager.getInstance().newStage(stageID, type, difficulty, difficulty) + UIManager.getInstance().loadStageUI(stageID); + this.owner.destroy() + }) + + } +} \ No newline at end of file diff --git a/src/views/GamePause.ts.meta b/src/views/GamePause.ts.meta new file mode 100644 index 0000000..db55e21 --- /dev/null +++ b/src/views/GamePause.ts.meta @@ -0,0 +1,3 @@ +{ + "uuid": "c8bf81c2-c8fd-4f25-b120-4ad620ff7b88" +} \ No newline at end of file diff --git a/src/views/Home.ts b/src/views/Home.ts index 0ad7471..133c2aa 100644 --- a/src/views/Home.ts +++ b/src/views/Home.ts @@ -75,14 +75,8 @@ export class Home extends Laya.Script { this.btn_continue.visible = false this.btn_more.visible = false this.btn_play.on(Laya.Event.CLICK, this, ()=>{//Play - var random = Math.random() - var value = config.DIFFICULTY_LIST[Math.floor(random*config.DIFFICULTY_LIST.length)] - var list = LevelManager.getInstance().getLevelList(value) - random = Math.random() - var index = Math.floor(random*list.length) var stageName = `${config.MONTH_ABBRS[nowMonth-1]} ${nowDay}` - console.log("随机一个关卡", value, index) - StorageManager.getInstance().newStage(stageID, config.STAGE_TYPE.DC, stageName, value, index) + StorageManager.getInstance().newStage(stageID, config.STAGE_TYPE.DC, stageName) UIManager.getInstance().loadStageUI(stageID); this.owner.destroy() }) @@ -153,13 +147,7 @@ export class Home extends Laya.Script { d.onInit((value: string)=> { console.log("选择难度", value) StorageManager.getInstance().cleanMainStage() - var user = StorageManager.getInstance().getUser() - var index = user.get_progress(value) - var levelStr = LevelManager.getInstance().getLevelStr(value, index) - if (!levelStr || levelStr.length <= 0) {//说明当前难度已经打通了,所以给他从头开始 - user.update_progress(value, 0) - } - StorageManager.getInstance().newStage(config.DEFAULT_STAGE_ID, config.STAGE_TYPE.MAIN, value, value, user.get_progress(value)) + StorageManager.getInstance().newStage(config.DEFAULT_STAGE_ID, config.STAGE_TYPE.MAIN, value, value) UIManager.getInstance().loadStageUI(config.DEFAULT_STAGE_ID); this.owner.destroy() }) diff --git a/src/views/Loading.ts b/src/views/Loading.ts deleted file mode 100644 index 0cb1ea5..0000000 --- a/src/views/Loading.ts +++ /dev/null @@ -1,7 +0,0 @@ - -const { regClass, property } = Laya - -@regClass() -export class Loading extends Laya.Script { - -} diff --git a/src/views/Loading.ts.meta b/src/views/Loading.ts.meta deleted file mode 100644 index 532ca62..0000000 --- a/src/views/Loading.ts.meta +++ /dev/null @@ -1,3 +0,0 @@ -{ - "uuid": "100c54c4-c515-4e10-8cfc-181e7067024a" -} \ No newline at end of file diff --git a/src/views/Stage.ts b/src/views/Stage.ts index e438f96..cb489dd 100644 --- a/src/views/Stage.ts +++ b/src/views/Stage.ts @@ -18,6 +18,8 @@ export class Stage extends Laya.Script { @property(Laya.Button) public btn_back: Laya.Button + @property(Laya.Button) + public btn_pause: Laya.Button @property(Laya.Label) public label_score: Laya.Label; @property(Laya.Label) @@ -71,6 +73,9 @@ export class Stage extends Laya.Script { UIManager.getInstance().closeStageUI(); } }) + this.btn_pause.on(Laya.Event.CLICK, this, ()=>{ + UIManager.getInstance().loadGamePauseUI(); + }) for (var i=0; i{ diff --git a/src/views/GUITips.ts.meta b/src/views/common/GUITips.ts.meta similarity index 100% rename from src/views/GUITips.ts.meta rename to src/views/common/GUITips.ts.meta