From 468f40351dfc41962e231a8407c4d4a0e6018123 Mon Sep 17 00:00:00 2001 From: yangwen Date: Mon, 26 May 2025 19:57:17 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=A8=AA=E5=B1=8F=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- assets/Scene.ls | 4 +- assets/atlas/comp/icon_check.png | Bin 0 -> 630 bytes assets/atlas/comp/icon_check.png.meta | 6 + assets/resources/CommonTips.lh | 326 + assets/resources/CommonTips.lh.meta | 3 + assets/resources/Difficulty.lh | 27 +- assets/resources/GameDone.lh.meta | 2 +- .../resources/{GameDone.lh => GameDone_DC.lh} | 101 +- assets/resources/GameDone_DC.lh.meta | 3 + assets/resources/GameDone_DC_H.lh | 528 + assets/resources/GameDone_DC_H.lh.meta | 3 + assets/resources/GameDone_H.lh.meta | 3 - .../{GameDone_H.lh => GameDone_Normal.lh} | 125 +- assets/resources/GameDone_Normal.lh.meta | 3 + assets/resources/GameDone_Normal_H.lh | 527 + assets/resources/GameDone_Normal_H.lh.meta | 3 + assets/resources/GameOver.lh | 9 +- assets/resources/GameOver_H.lh | 332 + assets/resources/GameOver_H.lh.meta | 3 + assets/resources/GamePause.lh | 19 +- assets/resources/GamePause_H.lh | 308 + assets/resources/GamePause_H.lh.meta | 3 + assets/resources/Home.lh | 24 +- assets/resources/ScoreAdd.lh | 10 +- assets/resources/Stage_H.lh | 94 +- assets/resources/Stage_H_DC.lh | 41452 ---------------- assets/resources/Stage_H_DC.lh.meta | 3 - assets/resources/TopBar.lh | 111 +- assets/resources/TopBar.lh.meta | 2 +- assets/resources/TrophyRoom.lh | 107 - assets/resources/{ => dc}/DailyChallenge.lh | 241 +- .../resources/{ => dc}/DailyChallenge.lh.meta | 0 assets/resources/dc/DailyChallenge_H.lh | 7699 +++ assets/resources/dc/DailyChallenge_H.lh.meta | 3 + assets/resources/{ => dc}/TrophyClaim.lh | 7 +- assets/resources/{ => dc}/TrophyClaim.lh.meta | 0 assets/resources/dc/TrophyClaim_H.lh | 172 + assets/resources/dc/TrophyClaim_H.lh.meta | 3 + assets/resources/dc/TrophyRoom.lh | 169 + assets/resources/{ => dc}/TrophyRoom.lh.meta | 0 assets/resources/{ => dc}/TrophyRoomCell.lh | 12 +- .../resources/{ => dc}/TrophyRoomCell.lh.meta | 0 assets/resources/dc/TrophyRoomCell_H.lh | 468 + assets/resources/dc/TrophyRoomCell_H.lh.meta | 3 + assets/resources/{ => dc}/TrophyRoomYear.lh | 1 + .../resources/{ => dc}/TrophyRoomYear.lh.meta | 0 assets/resources/dc/TrophyRoomYear_H.lh | 72 + assets/resources/dc/TrophyRoomYear_H.lh.meta | 3 + assets/resources/dc/TrophyRoom_H.lh | 160 + assets/resources/dc/TrophyRoom_H.lh.meta | 3 + assets/resources/{ => dc}/TrophyShow.lh | 3 +- assets/resources/{ => dc}/TrophyShow.lh.meta | 0 assets/resources/dc/TrophyShow_H.lh | 147 + assets/resources/dc/TrophyShow_H.lh.meta | 3 + settings/PlayerSettings.json | 4 +- src/constants/respath.ts | 44 +- src/models/StorageManager.ts | 34 +- src/models/UIManager.ts | 54 +- src/views/Block.ts | 13 +- src/views/CommonTips.ts | 59 + src/views/CommonTips.ts.meta | 3 + src/views/GameDone.ts | 79 +- src/views/GameOver.ts | 44 +- src/views/GamePause.ts | 10 +- src/views/Home.ts | 24 +- src/views/Stage.ts | 36 +- src/views/TopBar.ts | 103 +- src/views/common/GUITips.ts | 2 +- src/views/dc/CalendarUnit.ts | 10 +- src/views/dc/DailyChallenge.ts | 16 +- src/views/dc/TrophyRoom.ts | 18 +- 71 files changed, 11796 insertions(+), 42067 deletions(-) create mode 100644 assets/atlas/comp/icon_check.png create mode 100644 assets/atlas/comp/icon_check.png.meta create mode 100644 assets/resources/CommonTips.lh create mode 100644 assets/resources/CommonTips.lh.meta rename assets/resources/{GameDone.lh => GameDone_DC.lh} (86%) create mode 100644 assets/resources/GameDone_DC.lh.meta create mode 100644 assets/resources/GameDone_DC_H.lh create mode 100644 assets/resources/GameDone_DC_H.lh.meta delete mode 100644 assets/resources/GameDone_H.lh.meta rename assets/resources/{GameDone_H.lh => GameDone_Normal.lh} (84%) create mode 100644 assets/resources/GameDone_Normal.lh.meta create mode 100644 assets/resources/GameDone_Normal_H.lh create mode 100644 assets/resources/GameDone_Normal_H.lh.meta create mode 100644 assets/resources/GameOver_H.lh create mode 100644 assets/resources/GameOver_H.lh.meta create mode 100644 assets/resources/GamePause_H.lh create mode 100644 assets/resources/GamePause_H.lh.meta delete mode 100644 assets/resources/Stage_H_DC.lh delete mode 100644 assets/resources/Stage_H_DC.lh.meta delete mode 100644 assets/resources/TrophyRoom.lh rename assets/resources/{ => dc}/DailyChallenge.lh (96%) rename assets/resources/{ => dc}/DailyChallenge.lh.meta (100%) create mode 100644 assets/resources/dc/DailyChallenge_H.lh create mode 100644 assets/resources/dc/DailyChallenge_H.lh.meta rename assets/resources/{ => dc}/TrophyClaim.lh (93%) rename assets/resources/{ => dc}/TrophyClaim.lh.meta (100%) create mode 100644 assets/resources/dc/TrophyClaim_H.lh create mode 100644 assets/resources/dc/TrophyClaim_H.lh.meta create mode 100644 assets/resources/dc/TrophyRoom.lh rename assets/resources/{ => dc}/TrophyRoom.lh.meta (100%) rename assets/resources/{ => dc}/TrophyRoomCell.lh (92%) rename assets/resources/{ => dc}/TrophyRoomCell.lh.meta (100%) create mode 100644 assets/resources/dc/TrophyRoomCell_H.lh create mode 100644 assets/resources/dc/TrophyRoomCell_H.lh.meta rename assets/resources/{ => dc}/TrophyRoomYear.lh (95%) rename assets/resources/{ => dc}/TrophyRoomYear.lh.meta (100%) create mode 100644 assets/resources/dc/TrophyRoomYear_H.lh create mode 100644 assets/resources/dc/TrophyRoomYear_H.lh.meta create mode 100644 assets/resources/dc/TrophyRoom_H.lh create mode 100644 assets/resources/dc/TrophyRoom_H.lh.meta rename assets/resources/{ => dc}/TrophyShow.lh (96%) rename assets/resources/{ => dc}/TrophyShow.lh.meta (100%) create mode 100644 assets/resources/dc/TrophyShow_H.lh create mode 100644 assets/resources/dc/TrophyShow_H.lh.meta create mode 100644 src/views/CommonTips.ts create mode 100644 src/views/CommonTips.ts.meta diff --git a/assets/Scene.ls b/assets/Scene.ls index a61ba7e..ef581e6 100644 --- a/assets/Scene.ls +++ b/assets/Scene.ls @@ -7,8 +7,8 @@ "top": 0, "bottom": 0, "name": "Scene2D", - "width": 1920, - "height": 1080, + "width": 1080, + "height": 1920, "_$comp": [ { "_$type": "7bad1742-6eed-4d8d-81c0-501dc5bf03d6", diff --git a/assets/atlas/comp/icon_check.png b/assets/atlas/comp/icon_check.png new file mode 100644 index 0000000000000000000000000000000000000000..c74b55e2e2d5b2b67e2fc41bdab7c43762332441 GIT binary patch literal 630 zcmV-+0*U>JP)|00009a7bBm001F4 z001F40Y#QEU;qFB0drDELIAGL9O(c600d`2O+f$vv5yPhiQRlu<%TXhH_S7BKB zXGlr{n1uvWjt51UFOY0G5QRRVit(Tr!>?SOA}?teF(4QxAv%FNEAb#756PBG<`~h) zK_ZMQAqb}V0Lka7$xPI|QJDM5V&bqKGL=-b#?|}^!NYiU>M$PSN)jJb(zvm%5yFQb zg*gn6Ht#1@5{j_H)KRYVl0s1+-6P%|vetC?}nOuCLPH#_V|!Xq}L33q{Eove+%ypG{r^T>>>>", stageID) return null } - public cleanStage(): void {//清空当前关卡数据对象,注意判空 - this.user.update_stage_done(this.stageID, 0) - if (this.stageMap.has(this.stageID)) { - this.stageMap.delete(this.stageID) - } - Laya.LocalStorage.removeItem(this.stageID) - this.stageID = "" - this.stageChanged = false - } - public cleanMainStage(): void {//清空主线关卡数据 - this.stageID = config.DEFAULT_STAGE_ID - this.cleanStage() - } + + public saveStage(): void { if (this.stageChanged) { this.stageChanged = false diff --git a/src/models/UIManager.ts b/src/models/UIManager.ts index dcb1883..b64cc16 100644 --- a/src/models/UIManager.ts +++ b/src/models/UIManager.ts @@ -6,6 +6,11 @@ import { TrophyRecord } from "../types/global" import { TrophyClaim } from "../views/dc/TrophyClaim" import { TrophyShow } from "../views/dc/TrophyShow" import { config } from "../constants/config" +import { TrophyRoom } from "../views/dc/TrophyRoom" +import { DOStage } from "./DOStage" +import { GamePause } from "../views/GamePause" +import { GameOver } from "../views/GameOver" +import { GameDone } from "../views/GameDone" const { regClass, property } = Laya @@ -33,6 +38,8 @@ export class UIManager extends Laya.Script { } private stage: Stage + private dc_ui: DailyChallenge + private trophyRoom: TrophyRoom public getUIRoot(): Laya.Node { @@ -54,15 +61,21 @@ export class UIManager extends Laya.Script { } public loadDCUI(): void { - Laya.loader.load(respath.dc_ui_res).then((go)=>{ + Laya.loader.load(respath.dc_ui_res()).then((go)=>{ var prefab = go.create() - var dc = this.getUIRoot().addChild(prefab).getComponent(DailyChallenge) - dc.loadWithMonth() + this.dc_ui = this.getUIRoot().addChild(prefab).getComponent(DailyChallenge) + this.dc_ui.loadWithMonth() }) } + public closeDCUI(): void { + if (this.dc_ui) { + this.dc_ui.owner.destroy() + this.dc_ui = null + } + } public loadTrophyClaimUI(record: TrophyRecord): void { - Laya.loader.load(respath.trophy_claim_ui_res).then((go)=>{ + Laya.loader.load(respath.trophy_claim_ui_res()).then((go)=>{ var prefab = go.create() var obj = this.getUIRoot().addChild(prefab).getComponent(TrophyClaim) obj.onSetShow(record) @@ -70,14 +83,20 @@ export class UIManager extends Laya.Script { } public loadTrophyUI(): void { - Laya.loader.load(respath.trophy_ui_res).then((go)=>{ + Laya.loader.load(respath.trophy_ui_res()).then((go)=>{ var prefab = go.create() - this.getUIRoot().addChild(prefab) + this.trophyRoom = this.getUIRoot().addChild(prefab).getComponent(TrophyRoom) }) } + public closeTrophyUI(): void { + if (this.trophyRoom) { + this.trophyRoom.owner.destroy() + this.trophyRoom = null + } + } public loadTrophyShowUI(record: TrophyRecord): void { - Laya.loader.load(respath.trophy_show_ui_res).then((go)=>{ + Laya.loader.load(respath.trophy_show_ui_res()).then((go)=>{ var prefab = go.create() var obj = this.getUIRoot().addChild(prefab).getComponent(TrophyShow) obj.onSetShow(record) @@ -103,22 +122,25 @@ export class UIManager extends Laya.Script { } } - public loadGamePauseUI(): void { - Laya.loader.load(respath.gamepause_ui_res).then((go)=>{ + public loadGamePauseUI(doStage: DOStage): void { + Laya.loader.load(respath.gamepause_ui_res()).then((go)=>{ var prefab = go.create() - this.getUIRoot().addChild(prefab) + var ui = this.getUIRoot().addChild(prefab).getComponent(GamePause) + ui.onSetStageInfo(doStage) }) } - public loadGameOverUI(): void { - Laya.loader.load(respath.gameover_ui_res).then((go)=>{ + public loadGameOverUI(doStage: DOStage): void { + Laya.loader.load(respath.gameover_ui_res()).then((go)=>{ var prefab = go.create() - this.getUIRoot().addChild(prefab) + var ui = this.getUIRoot().addChild(prefab).getComponent(GameOver) + ui.onSetStageInfo(doStage) }) } - public loadGameDoneUI(): void { - Laya.loader.load(respath.gamedone_ui_res).then((go)=>{ + public loadGameDoneUI(isClassic: boolean, doStage: DOStage): void { + Laya.loader.load(respath.gamedone_ui_res(isClassic)).then((go)=>{ var prefab = go.create() - this.getUIRoot().addChild(prefab) + var ui = this.getUIRoot().addChild(prefab).getComponent(GameDone) + ui.onSetStageInfo(doStage) }) } diff --git a/src/views/Block.ts b/src/views/Block.ts index cd46b08..4fabe7c 100644 --- a/src/views/Block.ts +++ b/src/views/Block.ts @@ -1,5 +1,6 @@ import { G_ShowScoreTips } from "../views/common/GUITips"; import { DOBlock } from "../models/DOBlock"; +import { config } from "../constants/config"; const { regClass, property } = Laya; @@ -59,12 +60,15 @@ export class Block extends Laya.Script { } public setBlockColor(color: string, alpha: number=1, animated: boolean=false, completedColor: string = "", completedAlpha: number=1): void { + var blockSize = 116 + if (config.H_SCREEN) + blockSize = 96 this.owner.graphics.clear() - this.owner.graphics.drawRect(0, 0, 116, 116, color) + this.owner.graphics.drawRect(0, 0, blockSize, blockSize, color) if (animated) { Laya.Tween.to(this.owner, {alpha:alpha}, 500, Laya.Ease.elasticOut, Laya.Handler.create(this, () => { this.owner.graphics.clear() - this.owner.graphics.drawRect(0, 0, 116, 116, completedColor) + this.owner.graphics.drawRect(0, 0, blockSize, blockSize, completedColor) this.owner.alpha = completedAlpha })) } @@ -92,11 +96,14 @@ export class Block extends Laya.Script { } public setTipsBgColor(visible: boolean, noteNumber: number=0, color: string="", alpha: number=1): void { + var blockSize = 38 + if (config.H_SCREEN) + blockSize = 30 if (visible) { var obj = this.tips_bgs[noteNumber-1] obj.visible = true obj.graphics.clear() - obj.graphics.drawRect(0, 0, 38, 38, color) + obj.graphics.drawRect(0, 0, blockSize, blockSize, color) obj.alpha = alpha } else { diff --git a/src/views/CommonTips.ts b/src/views/CommonTips.ts new file mode 100644 index 0000000..2bdc9bf --- /dev/null +++ b/src/views/CommonTips.ts @@ -0,0 +1,59 @@ +import { respath } from "../constants/respath"; +import { UIManager } from "../models/UIManager"; + +const { regClass, property } = Laya; + + +export function G_ShowCommonTips(title: string, content: string, showToggle: boolean, func: any): void { + Laya.loader.load(respath.common_tips_ui_res).then((go)=>{ + var prefab = go.create() + var obj = UIManager.getInstance().getUIRoot().addChild(prefab).getComponent(CommonTips) + obj.showCommonTips(title, content, showToggle, func) + }) +} + +@regClass() +export class CommonTips extends Laya.Script { + declare owner : Laya.Box; + + @property(Laya.Label) + public label_title: Laya.Label + @property(Laya.Label) + public label_content: Laya.Label + + @property(Laya.Box) + public btn_ok: Laya.Box + @property(Laya.Box) + public btn_cancel: Laya.Box + + @property(Laya.Box) + public toggle: Laya.Box + @property(Laya.Image) + public check: Laya.Image + private isChecked = false + + public showCommonTips(title: string, content: string, showToggle: boolean, func: any): void { + this.label_title.text = title + this.label_content.text = content + this.toggle.visible = showToggle + this.check.visible = false + this.toggle.on(Laya.Event.CLICK, this, ()=>{ + this.isChecked = !this.isChecked + this.check.visible = this.isChecked + }) + + this.btn_ok.on(Laya.Event.CLICK, this, ()=>{ + if (func) { + func(true, this.isChecked) + } + this.owner.destroy() + }) + this.btn_cancel.on(Laya.Event.CLICK, this, ()=>{ + if (func) { + func(false, this.isChecked) + } + this.owner.destroy() + }) + + } +} \ No newline at end of file diff --git a/src/views/CommonTips.ts.meta b/src/views/CommonTips.ts.meta new file mode 100644 index 0000000..5134d6c --- /dev/null +++ b/src/views/CommonTips.ts.meta @@ -0,0 +1,3 @@ +{ + "uuid": "b0dfcf08-5aef-4078-8149-1fbd00d8038f" +} \ No newline at end of file diff --git a/src/views/GameDone.ts b/src/views/GameDone.ts index 6f8002a..de8eb07 100644 --- a/src/views/GameDone.ts +++ b/src/views/GameDone.ts @@ -3,8 +3,8 @@ import { StorageManager } from "../models/StorageManager"; import { Utility_ConvertSecondToString } from "../utils/utility"; import { respath } from "../constants/respath"; import { Difficulty } from "./Difficulty"; -import { LevelManager } from "../models/LevelManager"; import { config } from "../constants/config"; +import { DOStage } from "../models/DOStage"; const { regClass, property } = Laya; @@ -12,13 +12,6 @@ const { regClass, property } = Laya; export class GameDone extends Laya.Script { declare owner : Laya.Box; - @property(Laya.Box) - public obj_top: Laya.Box - @property(Laya.Box) - public obj_stars: Laya.Box - @property(Laya.Image) - public obj_star: Laya.Image - @property(Laya.Label) public label_diffucuty: Laya.Label @property(Laya.Label) @@ -35,52 +28,56 @@ export class GameDone extends Laya.Script { onStart(): void { - var doStage = StorageManager.getInstance().getStage() - var type = doStage.get_stageType() - if (type == config.STAGE_TYPE.MAIN) { - this.obj_top.y = 356 - this.obj_stars.visible = true - this.obj_star.visible = false - this.btn_new.visible = true - this.btn_home.visible = true - this.btn_continue.visible = false - } - else { - this.obj_top.y = 456 - this.obj_stars.visible = false - this.obj_star.visible = true - this.btn_new.visible = false - this.btn_home.visible = false - this.btn_continue.visible = true - } + + } + + public onSetStageInfo(doStage: DOStage): void { this.label_diffucuty.text = doStage.get_difficulty() this.label_time.text = Utility_ConvertSecondToString(doStage.get_duration()) this.label_score.text = doStage.get_score().toString() this.btn_new.on(Laya.Event.CLICK, this, (evt: Laya.Event) => { - Laya.loader.load(respath.difficulty_ui_res).then((go)=>{ - var prefab = go.create() - var d = UIManager.getInstance().getUIRoot().addChild(prefab).getComponent(Difficulty) - d.onInit((value: string)=> { - console.log("选择难度", value) - StorageManager.getInstance().cleanStage() - StorageManager.getInstance().newStage(config.DEFAULT_STAGE_ID, config.STAGE_TYPE.MAIN, value, value) + if (config.H_SCREEN) { + var user = StorageManager.getInstance().getUser() + user.update_progress(doStage.get_difficulty(), doStage.get_stageIndex()+1)//主线关卡更新难度进度 + StorageManager.getInstance().newStage(config.DEFAULT_STAGE_ID, config.STAGE_TYPE.MAIN, doStage.get_difficulty(), doStage.get_difficulty()) UIManager.getInstance().loadStageUI(config.DEFAULT_STAGE_ID); this.owner.destroy() + } + else { + Laya.loader.load(respath.difficulty_ui_res).then((go)=>{ + var prefab = go.create() + var d = UIManager.getInstance().getUIRoot().addChild(prefab).getComponent(Difficulty) + d.onInit((value: string)=> { + console.log("选择难度", value) + StorageManager.getInstance().newStage(config.DEFAULT_STAGE_ID, config.STAGE_TYPE.MAIN, value, value) + UIManager.getInstance().loadStageUI(config.DEFAULT_STAGE_ID); + this.owner.destroy() + }) }) - }) + } }) - this.btn_home.on(Laya.Event.CLICK, this, (evt: Laya.Event) => { - UIManager.getInstance().loadHomeUI() - UIManager.getInstance().closeStageUI(); - this.owner.destroy() - }) - - this.btn_continue.on(Laya.Event.CLICK, this, (evt: Laya.Event) => { + this.btn_continue.on(Laya.Event.CLICK, this, (evt: Laya.Event) => {//这个按钮只有从DC来的会显示 UIManager.getInstance().loadDCUI() UIManager.getInstance().closeStageUI(); this.owner.destroy() }) + + this.btn_home.on(Laya.Event.CLICK, this, (evt: Laya.Event) => { + if (config.H_SCREEN) { + UIManager.getInstance().closeDCUI() + var user = StorageManager.getInstance().getUser() + user.update_progress(doStage.get_difficulty(), doStage.get_stageIndex()+1)//主线关卡更新难度进度 + StorageManager.getInstance().newStage(config.DEFAULT_STAGE_ID, config.STAGE_TYPE.MAIN, doStage.get_difficulty(), doStage.get_difficulty()) + UIManager.getInstance().loadStageUI(config.DEFAULT_STAGE_ID); + } + else { + UIManager.getInstance().loadHomeUI() + UIManager.getInstance().closeStageUI(); + } + this.owner.destroy() + }) + } } \ No newline at end of file diff --git a/src/views/GameOver.ts b/src/views/GameOver.ts index f8727be..80d34b5 100644 --- a/src/views/GameOver.ts +++ b/src/views/GameOver.ts @@ -2,9 +2,9 @@ import { respath } from "../constants/respath"; import { config } from "../constants/config"; import { UIManager } from "../models/UIManager"; import { StorageManager } from "../models/StorageManager"; -import { LevelManager } from "../models/LevelManager"; import { EventManager, EVENT_TYPES } from "../models/EventManager"; import { Difficulty } from "./Difficulty"; +import { DOStage } from "../models/DOStage"; const { regClass, property } = Laya; @@ -23,45 +23,49 @@ export class GameOver extends Laya.Script { public btn_newOrClose: Laya.Sprite @property(Laya.Label) public label_newOrClose: Laya.Label + - //组件被激活后执行,此时所有节点和组件均已创建完毕,此方法只执行一次 - onAwake(): void { + public onSetStageInfo(doStage: DOStage): void { this.btn_second.on(Laya.Event.CLICK, this, (evt: Laya.Event) => { - var doStage = StorageManager.getInstance().getStage() doStage.set_mistake(doStage.get_mistake()-1) EventManager.getInstance().DispatchEvent(EVENT_TYPES.NOT_UPDATE_MISTAKE) this.owner.destroy() }) this.btn_restart.on(Laya.Event.CLICK, this, (evt: Laya.Event) => { - var doStage = StorageManager.getInstance().getStage() 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() }) - var doStage = StorageManager.getInstance().getStage() var type = doStage.get_stageType() - if (type == config.STAGE_TYPE.MAIN) { this.label_newOrClose.text = "New Game" this.btn_newOrClose.on(Laya.Event.CLICK, this, (evt: Laya.Event) => { - Laya.loader.load(respath.difficulty_ui_res).then((go)=>{ - var prefab = go.create() - var d = UIManager.getInstance().getUIRoot().addChild(prefab).getComponent(Difficulty) - d.onInit((value: string)=> { - console.log("选择难度", value) - StorageManager.getInstance().cleanStage() - StorageManager.getInstance().newStage(config.DEFAULT_STAGE_ID, config.STAGE_TYPE.MAIN, value, value) - UIManager.getInstance().loadStageUI(config.DEFAULT_STAGE_ID); - this.owner.destroy() - }) - }) + if (config.H_SCREEN) { + var user = StorageManager.getInstance().getUser() + user.update_progress(doStage.get_difficulty(), doStage.get_stageIndex()+1)//主线关卡更新难度进度 + var difficulty = doStage.get_difficulty() + StorageManager.getInstance().newStage(config.DEFAULT_STAGE_ID, config.STAGE_TYPE.MAIN, difficulty, difficulty) + UIManager.getInstance().loadStageUI(config.DEFAULT_STAGE_ID); + this.owner.destroy() + } + else { + Laya.loader.load(respath.difficulty_ui_res).then((go)=>{ + var prefab = go.create() + var d = UIManager.getInstance().getUIRoot().addChild(prefab).getComponent(Difficulty) + d.onInit((value: string)=> { + console.log("选择难度", value) + StorageManager.getInstance().newStage(config.DEFAULT_STAGE_ID, config.STAGE_TYPE.MAIN, value, value) + UIManager.getInstance().loadStageUI(config.DEFAULT_STAGE_ID); + this.owner.destroy() + }) + }) + } }) } else { @@ -72,6 +76,6 @@ export class GameOver extends Laya.Script { this.owner.destroy() }) } - } + } } \ No newline at end of file diff --git a/src/views/GamePause.ts b/src/views/GamePause.ts index 10467aa..0daf179 100644 --- a/src/views/GamePause.ts +++ b/src/views/GamePause.ts @@ -4,6 +4,7 @@ import { UIManager } from "../models/UIManager"; import { StorageManager } from "../models/StorageManager"; import { Utility_ConvertSecondToString } from "../utils/utility"; import { EVENT_TYPES, EventManager } from "../models/EventManager"; +import { DOStage } from "../models/DOStage"; @@ -26,8 +27,10 @@ export class GamePause extends Laya.Script { //组件被激活后执行,此时所有节点和组件均已创建完毕,此方法只执行一次 onAwake(): void { - - var doStage = StorageManager.getInstance().getStage() + + } + + public onSetStageInfo(doStage: DOStage): void { this.label_time.text = Utility_ConvertSecondToString(doStage.get_duration()) this.label_diffucuty.text = doStage.get_difficulty() @@ -42,11 +45,10 @@ export class GamePause extends Laya.Script { 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/Home.ts b/src/views/Home.ts index 133c2aa..59d7a16 100644 --- a/src/views/Home.ts +++ b/src/views/Home.ts @@ -115,13 +115,24 @@ export class Home extends Laya.Script { this.btn_go.visible = false } else { - var doStage = StorageManager.getInstance().loadStage(config.DEFAULT_STAGE_ID) + var doStage = StorageManager.getInstance().getStage(config.DEFAULT_STAGE_ID) if (doStage) { - console.log("当前主线关卡进行中") - var label_time = this.btn_go.getChildByName("time").getChildByName("label_time") as Laya.Label - var duration = doStage.get_duration() - var timeStr = Utility_ConvertSecondToString(duration) - label_time.text = `${timeStr} - ${doStage.get_difficulty()}` + console.log("当前主线关卡进行中 mistake=", doStage.get_mistake()) + if (doStage.get_mistake() >= config.MISTAKE_MAX) { + this.btn_new_blue.visible = true + this.btn_new_white.visible = false + this.btn_go.visible = false + } + else { + this.btn_new_blue.visible = false + this.btn_new_white.visible = true + this.btn_go.visible = true + + var label_time = this.btn_go.getChildByName("time").getChildByName("label_time") as Laya.Label + var duration = doStage.get_duration() + var timeStr = Utility_ConvertSecondToString(duration) + label_time.text = `${timeStr} - ${doStage.get_difficulty()}` + } } else { console.log("当前主线关卡未开始") @@ -146,7 +157,6 @@ export class Home extends Laya.Script { var d = UIManager.getInstance().getUIRoot().addChild(prefab).getComponent(Difficulty) d.onInit((value: string)=> { console.log("选择难度", value) - StorageManager.getInstance().cleanMainStage() 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/Stage.ts b/src/views/Stage.ts index 1f439a4..bfb4c81 100644 --- a/src/views/Stage.ts +++ b/src/views/Stage.ts @@ -16,8 +16,11 @@ const { regClass, property } = Laya; export class Stage extends Laya.Script { declare owner : Laya.Box; - @property(Laya.Button) - public btn_back: Laya.Button + @property(Laya.Box) + public btn_back: Laya.Box + @property(Laya.Box) + public btn_new: Laya.Box + @property(Laya.Button) public btn_pause: Laya.Button @property(Laya.Label) @@ -63,6 +66,7 @@ export class Stage extends Laya.Script { private static _instance: Stage onAwake(): void { Stage._instance = this + this.btn_back.on(Laya.Event.CLICK, this, ()=>{ if (this.data.get_stageType() == config.STAGE_TYPE.MAIN) { UIManager.getInstance().loadHomeUI(); @@ -73,8 +77,19 @@ export class Stage extends Laya.Script { UIManager.getInstance().closeStageUI(); } }) + + if (this.btn_new) { + this.btn_new.on(Laya.Event.CLICK, this, ()=>{ + var user = StorageManager.getInstance().getUser() + user.update_progress(this.data.get_difficulty(), this.data.get_stageIndex()+1)//主线关卡更新难度进度 + StorageManager.getInstance().newStage(config.DEFAULT_STAGE_ID, config.STAGE_TYPE.MAIN, this.data.get_difficulty(), this.data.get_difficulty()) + UIManager.getInstance().loadStageUI(config.DEFAULT_STAGE_ID) + }) + } + + this.btn_pause.on(Laya.Event.CLICK, this, ()=>{ - UIManager.getInstance().loadGamePauseUI(); + UIManager.getInstance().loadGamePauseUI(this.data); }) for (var i=0; i{ if (this.paused) { return @@ -348,7 +371,7 @@ export class Stage extends Laya.Script { var show = this.selectedBlock.getData().get_show() var notes = this.selectedBlock.getData().get_notes() if (this.selectedBlock.getData().get_checked() == false) { - if (this.data.get_note_open()) { + if (this.data.get_note_open() && hint == false) { var relateds = this.findRelatedBlocks(this.selectedBlock) var find = false for (var i=0; i= 1) {//完成每日挑战关卡检查是否或者当月奖杯 @@ -424,8 +448,8 @@ export class Stage extends Laya.Script { user.add_trophy_record(nowYear, nowMonth, now.getDate()) } } + UIManager.getInstance().loadGameDoneUI(false, this.data) } - UIManager.getInstance().loadGameDoneUI() } } else {//失败 @@ -434,7 +458,7 @@ export class Stage extends Laya.Script { if (this.data.get_mistake() >= config.MISTAKE_MAX) { console.log("关卡失败") this.paused = true - UIManager.getInstance().loadGameOverUI() + UIManager.getInstance().loadGameOverUI(this.data) } } } diff --git a/src/views/TopBar.ts b/src/views/TopBar.ts index 9b28d1f..357d8aa 100644 --- a/src/views/TopBar.ts +++ b/src/views/TopBar.ts @@ -2,6 +2,7 @@ import { config } from "../constants/config"; import { StorageManager } from "../models/StorageManager"; import { UIManager } from "../models/UIManager"; import { CommonData } from "./common/CommonData"; +import { G_ShowCommonTips } from "./CommonTips"; const { regClass, property } = Laya; @@ -25,26 +26,56 @@ export class TopBar extends Laya.Script { private isClassic: boolean = true + @property(Laya.Label) + public obj_label: Laya.Label @property(Laya.Box) public obj_items: Laya.Box private items: Map = new Map() - onStart(): void { + onStart(): void { + + //如果是第一次以横屏启动游戏需要创建经典关卡 + var difficulty = Laya.LocalStorage.getItem("difficulty")//读取用户上次选择的难度 + if (!difficulty || difficulty.length<=0) { + difficulty = config.DIFFICULTY_TYPE.Easy + Laya.LocalStorage.setItem("difficulty", difficulty) + } + var doStage = StorageManager.getInstance().getStage(config.DEFAULT_STAGE_ID) + if (!doStage) { + StorageManager.getInstance().newStage(config.DEFAULT_STAGE_ID, config.STAGE_TYPE.MAIN, difficulty, difficulty) + } + else { + var user = StorageManager.getInstance().getUser() + if (user.get_done(config.DEFAULT_STAGE_ID) >= 1) { + console.log("当前主线关卡完成") + user.update_progress(doStage.get_difficulty(), doStage.get_stageIndex()+1)//主线关卡更新难度进度 + StorageManager.getInstance().newStage(config.DEFAULT_STAGE_ID, config.STAGE_TYPE.MAIN, difficulty, difficulty) + } + else if (doStage.get_mistake() >= config.MISTAKE_MAX) {//上次失败了则重新开始 + StorageManager.getInstance().newStage(config.DEFAULT_STAGE_ID, config.STAGE_TYPE.MAIN, difficulty, difficulty) + } + } + this.btn_classic.on(Laya.Event.CLICK, this, ()=>{ if (this.isClassic == false) { this.isClassic = true - this.setLeftTab() + this.onClickTab() } }) this.btn_dc.on(Laya.Event.CLICK, this, ()=>{ if (this.isClassic) { this.isClassic = false - this.setLeftTab() + this.onClickTab() } }) - this.setLeftTab() + this.onClickTab() + var showToggle = Laya.LocalStorage.getItem("showToggle") + if (!showToggle || showToggle.length <= 0) { + Laya.LocalStorage.setItem("showToggle", "true") + } + for (var i=0; i{ + if (ok) { + if (toggleValue) { + Laya.LocalStorage.setItem("showToggle", "false") + } + this.onClickDifficulty(common.strValue) + } + }) + } + else { + this.onClickDifficulty(common.strValue) + } } }) } - - //如果是第一次以横屏启动游戏需要创建经典关卡 - var difficulty = Laya.LocalStorage.getItem("difficulty")//读取用户上次选择的难度 - if (!difficulty || difficulty.length<=0) { - difficulty = config.DIFFICULTY_TYPE.Easy - Laya.LocalStorage.setItem("difficulty", difficulty) - } - var doStage = StorageManager.getInstance().loadStage(config.DEFAULT_STAGE_ID) - if (!doStage) { - StorageManager.getInstance().newStage(config.DEFAULT_STAGE_ID, config.STAGE_TYPE.MAIN, difficulty, difficulty) - } - - this.setDifficulty(difficulty) + this.updateDifficulty(difficulty) } - setLeftTab(): void { + onClickTab(): void { + if (this.isClassic) { + UIManager.getInstance().closeTrophyUI() + UIManager.getInstance().closeDCUI() + UIManager.getInstance().loadStageUI(config.DEFAULT_STAGE_ID) + } + else { + UIManager.getInstance().closeStageUI() + UIManager.getInstance().loadDCUI() + } + this.updateLeftTab() + } + updateLeftTab(): void { this.sprite_classic.alpha = this.isClassic ? 1 : 0.1 this.label_classic.color = this.isClassic ? "#ffffff" : "#0e2a53" this.sprite_dc.alpha = this.isClassic ? 0.1 : 1 this.label_dc.color = this.isClassic ? "#0e2a53" : "#ffffff" - if (this.isClassic) { - UIManager.getInstance().loadStageUI(config.DEFAULT_STAGE_ID) - } + this.obj_label.visible = this.isClassic + this.obj_items.visible = this.isClassic } - setDifficulty(difficulty: string): void { + onClickDifficulty(difficulty: string): void { + Laya.LocalStorage.setItem("difficulty", difficulty)//记录横屏模式用户选择的难度 + StorageManager.getInstance().newStage(config.DEFAULT_STAGE_ID, config.STAGE_TYPE.MAIN, difficulty, difficulty) + UIManager.getInstance().loadStageUI(config.DEFAULT_STAGE_ID) + + this.updateDifficulty(difficulty) + } + + updateDifficulty(difficulty: string): void { this.items.forEach((label: Laya.Label, key: string)=>{ label.color = "#0e2a53" }) diff --git a/src/views/common/GUITips.ts b/src/views/common/GUITips.ts index af661b4..18255f8 100644 --- a/src/views/common/GUITips.ts +++ b/src/views/common/GUITips.ts @@ -7,4 +7,4 @@ export function G_ShowScoreTips(text: string, parent: any): void { var Label = obj.getChildByName("offset").getChildByName("Label") as Laya.Label Label.text = text }) -} \ No newline at end of file +} diff --git a/src/views/dc/CalendarUnit.ts b/src/views/dc/CalendarUnit.ts index 7d1d1e8..4d495c2 100644 --- a/src/views/dc/CalendarUnit.ts +++ b/src/views/dc/CalendarUnit.ts @@ -1,3 +1,5 @@ +import { config } from "../../constants/config"; + const { regClass, property } = Laya; @regClass() @@ -89,6 +91,10 @@ export class CalendarUnit extends Laya.Script { this.obj_star.visible = this.progress >= 1 + var blockSize = 48 + if (config.H_SCREEN) + blockSize = 33 + if (this.selected) { this.label_show.color = "#ffffff" this.obj_selected.visible = true @@ -96,7 +102,7 @@ export class CalendarUnit extends Laya.Script { this.obj_pie.visible = true this.obj_mask.visible = true this.sprite_pie.graphics.clear() - this.sprite_pie.graphics.drawPie(48, 48, 48, 0, 360*this.progress, "#ffffff") + this.sprite_pie.graphics.drawPie(blockSize, blockSize, blockSize, 0, 360*this.progress, "#ffffff") this.sprite_mask.graphics.clear() this.sprite_mask.graphics.drawCircle(0.5, 0.5, 0.5, "#1d5cdc") } @@ -112,7 +118,7 @@ export class CalendarUnit extends Laya.Script { this.obj_pie.visible = true this.obj_mask.visible = true this.sprite_pie.graphics.clear() - this.sprite_pie.graphics.drawPie(48, 48, 48, 0, 360*this.progress, "#2d3138") + this.sprite_pie.graphics.drawPie(blockSize, blockSize, blockSize, 0, 360*this.progress, "#2d3138") this.sprite_mask.graphics.clear() this.sprite_mask.graphics.drawCircle(0.5, 0.5, 0.5, "#ffffff") } diff --git a/src/views/dc/DailyChallenge.ts b/src/views/dc/DailyChallenge.ts index 650be92..bb2b005 100644 --- a/src/views/dc/DailyChallenge.ts +++ b/src/views/dc/DailyChallenge.ts @@ -60,10 +60,12 @@ export class DailyChallenge extends Laya.Script { private indexMax: number onAwake(): void { - this.btn_back.on(Laya.Event.CLICK, this, ()=>{ - UIManager.getInstance().loadHomeUI() - this.owner.destroy() - }) + if (this.btn_back) { + this.btn_back.on(Laya.Event.CLICK, this, ()=>{ + UIManager.getInstance().loadHomeUI() + UIManager.getInstance().closeDCUI() + }) + } var user = StorageManager.getInstance().getUser() this.btn_trophy_red.visible = user.get_trophyHasUnread() @@ -80,7 +82,7 @@ export class DailyChallenge extends Laya.Script { var month = now.getMonth() + 1 var dayNow = this.selectedUnit.day var stageID = `${year}-${month}-${dayNow}` - var doStage = StorageManager.getInstance().loadStage(stageID) + var doStage = StorageManager.getInstance().getStage(stageID) console.log("play >>>>>>>>>>>>>>>>>>>>>>>", stageID, doStage) if (!doStage) { var stageName = `${config.MONTH_ABBRS[month-1]} ${dayNow}` @@ -217,7 +219,7 @@ export class DailyChallenge extends Laya.Script { if (progress >= 1) { this.btn_play.visible = false this.obj_summary.visible = true - var doStage = StorageManager.getInstance().loadStage(stageID) + var doStage = StorageManager.getInstance().getStage(stageID) this.label_diffucuty.text = doStage.get_difficulty() this.label_score.text = doStage.get_score().toString() this.label_time.text = Utility_ConvertSecondToString(doStage.get_duration()) @@ -225,7 +227,7 @@ export class DailyChallenge extends Laya.Script { else { this.btn_play.visible = true this.obj_summary.visible = false - var doStage = StorageManager.getInstance().loadStage(stageID) + var doStage = StorageManager.getInstance().getStage(stageID) if (doStage) { this.label_play.text = "Continue" } diff --git a/src/views/dc/TrophyRoom.ts b/src/views/dc/TrophyRoom.ts index dff11ed..7b095fc 100644 --- a/src/views/dc/TrophyRoom.ts +++ b/src/views/dc/TrophyRoom.ts @@ -2,8 +2,10 @@ +import { config } from "../../constants/config"; import { respath } from "../../constants/respath"; import { MONTH_LIST } from "../../models/DCManager"; +import { UIManager } from "../../models/UIManager"; import { TrophyUnit } from "./TrophyUnit"; const { regClass, property } = Laya; @@ -12,8 +14,8 @@ const { regClass, property } = Laya; export class TrophyRoom extends Laya.Script { declare owner : Laya.Box; - @property(Laya.Button) - public btn_back: Laya.Button; + @property(Laya.Box) + public btn_back: Laya.Box; @property(Laya.Box) public obj_items: Laya.Box; @@ -21,8 +23,12 @@ export class TrophyRoom extends Laya.Script { //第一次执行update之前执行,只会执行一次 onStart(): void { + var trophyCountOfCell = 3 + if (config.H_SCREEN) + trophyCountOfCell = 5 + this.btn_back.on(Laya.Event.CLICK, this, ()=>{ - this.owner.destroy() + UIManager.getInstance().closeTrophyUI() }) var infos: Array = new Array() @@ -52,7 +58,7 @@ export class TrophyRoom extends Laya.Script { list.push(obj) } console.log(">>>>>>>>>>>>years=", years) - Laya.loader.load(respath.trophy_year_ui_res).then((go)=>{ + Laya.loader.load(respath.trophy_year_ui_res()).then((go)=>{ for (var i=1; i{ + Laya.loader.load(respath.trophy_cell_ui_res()).then((go)=>{ var itemsHeight = 0 for (var i=0; i