From 2bf07ab8f6612ee235f479ac153208131d3b950d Mon Sep 17 00:00:00 2001 From: yangwen Date: Thu, 22 May 2025 14:54:48 +0800 Subject: [PATCH] add trophy logic --- assets/resources/DailyChallenge.lh | 28 +++- assets/resources/TrophyClaim.lh | 169 ++++++++++++++++++++++++ assets/resources/TrophyClaim.lh.meta | 3 + assets/resources/TrophyRoom.lh | 4 +- assets/resources/TrophyRoomCell.lh | 95 ++++++------- assets/resources/TrophyRoomCell.lh.meta | 2 +- assets/resources/TrophyRoomYear.lh | 14 +- assets/resources/TrophyRoomYear.lh.meta | 2 +- src/Main.ts | 1 + src/constants/config.ts | 17 +-- src/constants/respath.ts | 2 + src/models/DCManager.ts | 59 +++++++++ src/models/DCManager.ts.meta | 3 + src/models/DOBlock.ts | 10 +- src/models/DOStage.ts | 16 +-- src/models/DOUser.ts | 87 +++++++++++- src/models/StorageManager.ts | 23 +++- src/models/UIManager.ts | 19 +++ src/types/global.ts | 14 +- src/views/DailyChallenge.ts | 32 ++++- src/views/Home.ts | 16 +-- src/views/Stage.ts | 22 ++- src/views/TrophyClaim.ts | 36 +++++ src/views/TrophyClaim.ts.meta | 3 + src/views/TrophyRoom.ts | 7 +- src/views/TrophyShow.ts | 22 ++- src/views/TrophyUnit.ts | 8 +- 27 files changed, 587 insertions(+), 127 deletions(-) create mode 100644 assets/resources/TrophyClaim.lh create mode 100644 assets/resources/TrophyClaim.lh.meta create mode 100644 src/models/DCManager.ts create mode 100644 src/models/DCManager.ts.meta create mode 100644 src/views/TrophyClaim.ts create mode 100644 src/views/TrophyClaim.ts.meta diff --git a/assets/resources/DailyChallenge.lh b/assets/resources/DailyChallenge.lh index c9f8b66..b0443da 100644 --- a/assets/resources/DailyChallenge.lh +++ b/assets/resources/DailyChallenge.lh @@ -20,6 +20,9 @@ "btn_trophy": { "_$ref": "ft6m7zwa" }, + "btn_trophy_red": { + "_$ref": "zx15vggp" + }, "icon_trophy": { "_$ref": "e7a1ntdg" }, @@ -146,7 +149,30 @@ "height": 75, "skin": "res://4458c7de-47ff-496e-a28f-be808c0823b3", "useSourceSize": true, - "color": "#ffffff" + "color": "#ffffff", + "_$child": [ + { + "_$id": "zx15vggp", + "_$type": "Sprite", + "name": "Sprite", + "x": 64, + "y": -4, + "width": 24, + "height": 24, + "_gcmds": [ + { + "_$type": "DrawCircleCmd", + "x": 0.5, + "y": 0.5, + "radius": 0.5, + "percent": true, + "lineWidth": 4, + "lineColor": "rgba(255, 255, 255, 1)", + "fillColor": "rgba(229, 34, 28, 1)" + } + ] + } + ] }, { "_$id": "e7a1ntdg", diff --git a/assets/resources/TrophyClaim.lh b/assets/resources/TrophyClaim.lh new file mode 100644 index 0000000..cf3a211 --- /dev/null +++ b/assets/resources/TrophyClaim.lh @@ -0,0 +1,169 @@ +{ + "_$ver": 1, + "_$id": "6l8gfnd1", + "_$type": "Box", + "name": "TrophyClaim", + "width": 1080, + "height": 1920, + "left": 0, + "right": 0, + "top": 0, + "bottom": 0, + "_$comp": [ + { + "_$type": "0550b681-b602-49fe-900f-e30866ce922c", + "scriptPath": "../src/views/TrophyClaim.ts", + "icon": { + "_$ref": "ta6ji66s" + }, + "label_date": { + "_$ref": "a0u7wsik" + }, + "btn_close": { + "_$ref": "qgwt28k7" + } + } + ], + "_$child": [ + { + "_$id": "l3kqo0ly", + "_$type": "Image", + "name": "Image", + "width": 1080, + "height": 1920, + "alpha": 0.8, + "left": 0, + "right": 0, + "top": 0, + "bottom": 0, + "skin": "res://a98f334e-ce04-4cd0-8fc5-bbdf9b048609", + "color": "#000000" + }, + { + "_$id": "21y8h6ei", + "_$type": "Box", + "name": "center", + "y": 264, + "width": 1080, + "height": 1080, + "centerX": 0, + "centerY": -156, + "_$child": [ + { + "_$id": "vngawy58", + "_$type": "Image", + "name": "img_light_yellow", + "width": 1080, + "height": 1080, + "centerX": 0, + "centerY": 0, + "skin": "res://0403c03d-0fbb-4930-8cf7-c4bf0f4d45b9", + "useSourceSize": true, + "color": "#ffffff" + }, + { + "_$id": "ta6ji66s", + "_$type": "Image", + "name": "trophy", + "x": 123, + "y": 123, + "width": 834, + "height": 834, + "centerX": 0, + "centerY": 0, + "skin": "res://7d235ac1-6755-4409-ab86-23aaf41e1537", + "color": "#ffffff" + }, + { + "_$id": "qgwt28k7", + "_$type": "Box", + "name": "btn_close", + "x": 180, + "y": 1140, + "width": 720, + "height": 156, + "bottom": -216, + "centerX": 0, + "_$child": [ + { + "_$id": "y8abda90", + "_$type": "Sprite", + "name": "Sprite", + "width": 720, + "height": 156, + "mouseThrough": true, + "_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": "6v9udrtu", + "_$type": "Label", + "name": "label", + "x": -90, + "y": 28, + "width": 900, + "height": 100, + "centerX": 0, + "centerY": 0, + "text": "Claim", + "fontSize": 60, + "color": "rgba(29, 92, 220, 1)", + "align": "center", + "valign": "middle", + "padding": "0,0,0,0" + } + ] + }, + { + "_$id": "0eaixmbm", + "_$type": "Label", + "name": "titlle", + "x": 90, + "y": -10, + "width": 900, + "height": 100, + "top": -10, + "centerX": 0, + "text": "Conratulations!", + "fontSize": 84, + "color": "#FFFFFF", + "align": "center", + "valign": "middle", + "padding": "0,0,0,0" + }, + { + "_$id": "a0u7wsik", + "_$type": "Label", + "name": "label_date", + "x": 90, + "y": 1010, + "width": 900, + "height": 60, + "alpha": 0.8, + "bottom": 10, + "centerX": 0, + "text": "Sep 11, 2024", + "fontSize": 60, + "color": "#FFFFFF", + "align": "center", + "valign": "middle", + "padding": "0,0,0,0" + } + ] + } + ] +} \ No newline at end of file diff --git a/assets/resources/TrophyClaim.lh.meta b/assets/resources/TrophyClaim.lh.meta new file mode 100644 index 0000000..8b09306 --- /dev/null +++ b/assets/resources/TrophyClaim.lh.meta @@ -0,0 +1,3 @@ +{ + "uuid": "b12ed6b6-072b-4dd9-ab6f-c544692a6422" +} \ No newline at end of file diff --git a/assets/resources/TrophyRoom.lh b/assets/resources/TrophyRoom.lh index fef0680..0652dda 100644 --- a/assets/resources/TrophyRoom.lh +++ b/assets/resources/TrophyRoom.lh @@ -104,8 +104,8 @@ "align": "center", "_$child": [ { - "_$id": "0cxaz0lv", - "_$prefab": "381b129b-cb47-4a77-805d-6d4637bc67b8", + "_$id": "g7t27k1h", + "_$prefab": "ef797791-e197-4854-bf49-347fe92999f4", "name": "TrophyRoomYear", "active": true, "x": 0, diff --git a/assets/resources/TrophyRoomCell.lh b/assets/resources/TrophyRoomCell.lh index 681caec..5d8ae6b 100644 --- a/assets/resources/TrophyRoomCell.lh +++ b/assets/resources/TrophyRoomCell.lh @@ -1,6 +1,6 @@ { "_$ver": 1, - "_$id": "qayij6fq", + "_$id": "42qxmdwy", "_$type": "VBox", "name": "TrophyRoomCell", "y": 120, @@ -10,16 +10,16 @@ "align": "center", "_$child": [ { - "_$id": "edutm8p9", + "_$id": "od2un0s9", "_$type": "HBox", "name": "HBox", "width": 984, "height": 288, - "space": 48, + "space": 0, "align": "middle", "_$child": [ { - "_$id": "npywocl2", + "_$id": "t4qzx693", "_$type": "Box", "name": "Box(1)", "width": 328, @@ -29,22 +29,22 @@ "_$type": "79064920-30a6-4b11-a82e-bbdd4112c4e1", "scriptPath": "../src/views/TrophyUnit.ts", "bg_light": { - "_$ref": "7a93ikng" + "_$ref": "rnanoiet" }, "icon": { - "_$ref": "232cncr7" + "_$ref": "cnlfb8yz" }, "label_count": { - "_$ref": "jafwv0lk" + "_$ref": "2bldvkij" }, "label_month": { - "_$ref": "5ifvmsv6" + "_$ref": "5wwqja5x" } } ], "_$child": [ { - "_$id": "7a93ikng", + "_$id": "rnanoiet", "_$type": "Image", "name": "bg_light", "x": 20, @@ -55,7 +55,7 @@ "color": "#ffffff" }, { - "_$id": "232cncr7", + "_$id": "cnlfb8yz", "_$type": "Image", "name": "icon", "x": 20, @@ -63,15 +63,14 @@ "height": 288, "centerX": 0, "skin": "res://7d235ac1-6755-4409-ab86-23aaf41e1537", - "useSourceSize": true, "color": "#ffffff" }, { - "_$id": "jafwv0lk", + "_$id": "2bldvkij", "_$type": "Label", "name": "label_count", "x": 128, - "y": 233, + "y": 234, "width": 72, "height": 20, "centerX": 0, @@ -84,7 +83,7 @@ "padding": "0,0,0,0" }, { - "_$id": "5ifvmsv6", + "_$id": "5wwqja5x", "_$type": "Label", "name": "month", "x": 114, @@ -103,56 +102,59 @@ ] }, { - "_$id": "h293u30o", + "_$id": "u3azxf82", "_$type": "Box", "name": "Box(2)", - "x": 376, - "width": 288, + "x": 328, + "width": 328, "height": 288, "_$comp": [ { "_$type": "79064920-30a6-4b11-a82e-bbdd4112c4e1", "scriptPath": "../src/views/TrophyUnit.ts", "bg_light": { - "_$ref": "tsk96lzw" + "_$ref": "tnjynmgf" }, "icon": { - "_$ref": "vnxa59lv" + "_$ref": "0qe74n99" }, "label_count": { - "_$ref": "3matj08s" + "_$ref": "9dsn53bb" }, "label_month": { - "_$ref": "z4msejq5" + "_$ref": "zse8y0wo" } } ], "_$child": [ { - "_$id": "tsk96lzw", + "_$id": "tnjynmgf", "_$type": "Image", "name": "bg_light", + "x": 20, "width": 288, "height": 288, + "centerX": 0, "skin": "res://d0c3b007-6036-460a-b23d-09d6f2492886", "color": "#ffffff" }, { - "_$id": "vnxa59lv", + "_$id": "0qe74n99", "_$type": "Image", "name": "icon", + "x": 20, "width": 288, "height": 288, + "centerX": 0, "skin": "res://7d235ac1-6755-4409-ab86-23aaf41e1537", - "useSourceSize": true, "color": "#ffffff" }, { - "_$id": "3matj08s", + "_$id": "9dsn53bb", "_$type": "Label", "name": "label_count", - "x": 108, - "y": 233, + "x": 128, + "y": 234, "width": 72, "height": 20, "centerX": 0, @@ -165,10 +167,10 @@ "padding": "0,0,0,0" }, { - "_$id": "z4msejq5", + "_$id": "zse8y0wo", "_$type": "Label", "name": "month", - "x": 94, + "x": 114, "y": 334, "width": 100, "height": 60, @@ -184,56 +186,59 @@ ] }, { - "_$id": "g7w60s1c", + "_$id": "wle8hrmr", "_$type": "Box", "name": "Box(3)", - "x": 712, - "width": 288, + "x": 656, + "width": 328, "height": 288, "_$comp": [ { "_$type": "79064920-30a6-4b11-a82e-bbdd4112c4e1", "scriptPath": "../src/views/TrophyUnit.ts", "bg_light": { - "_$ref": "ka2embmi" + "_$ref": "o57stpd9" }, "icon": { - "_$ref": "d1fdbz6w" + "_$ref": "en1ghf80" }, "label_count": { - "_$ref": "6rod3nlm" + "_$ref": "1znenn3j" }, "label_month": { - "_$ref": "tmao7m9v" + "_$ref": "row347fk" } } ], "_$child": [ { - "_$id": "ka2embmi", + "_$id": "o57stpd9", "_$type": "Image", "name": "bg_light", + "x": 20, "width": 288, "height": 288, + "centerX": 0, "skin": "res://d0c3b007-6036-460a-b23d-09d6f2492886", "color": "#ffffff" }, { - "_$id": "d1fdbz6w", + "_$id": "en1ghf80", "_$type": "Image", "name": "icon", + "x": 20, "width": 288, "height": 288, + "centerX": 0, "skin": "res://7d235ac1-6755-4409-ab86-23aaf41e1537", - "useSourceSize": true, "color": "#ffffff" }, { - "_$id": "6rod3nlm", + "_$id": "1znenn3j", "_$type": "Label", "name": "label_count", - "x": 108, - "y": 233, + "x": 128, + "y": 234, "width": 72, "height": 20, "centerX": 0, @@ -246,10 +251,10 @@ "padding": "0,0,0,0" }, { - "_$id": "tmao7m9v", + "_$id": "row347fk", "_$type": "Label", "name": "month", - "x": 94, + "x": 114, "y": 334, "width": 100, "height": 60, @@ -267,7 +272,7 @@ ] }, { - "_$id": "btspwass", + "_$id": "so760lhs", "_$type": "Sprite", "name": "Sprite", "x": 12, diff --git a/assets/resources/TrophyRoomCell.lh.meta b/assets/resources/TrophyRoomCell.lh.meta index 4623be2..cd31b24 100644 --- a/assets/resources/TrophyRoomCell.lh.meta +++ b/assets/resources/TrophyRoomCell.lh.meta @@ -1,3 +1,3 @@ { - "uuid": "c4bc91b4-43cc-4655-b508-946a63b6534f" + "uuid": "770e3b0c-7e51-4656-9a08-46992057f0a2" } \ No newline at end of file diff --git a/assets/resources/TrophyRoomYear.lh b/assets/resources/TrophyRoomYear.lh index 78ca308..6dfe16e 100644 --- a/assets/resources/TrophyRoomYear.lh +++ b/assets/resources/TrophyRoomYear.lh @@ -1,6 +1,6 @@ { "_$ver": 1, - "_$id": "4d6d3tpb", + "_$id": "0cxaz0lv", "_$type": "VBox", "name": "TrophyRoomYear", "width": 984, @@ -9,14 +9,14 @@ "align": "center", "_$child": [ { - "_$id": "ijq66j2p", + "_$id": "kq3dv2lv", "_$type": "Box", "name": "year", "width": 984, "height": 120, "_$child": [ { - "_$id": "5y2etcc5", + "_$id": "4v0nfps1", "_$type": "Sprite", "name": "Sprite", "y": 24, @@ -40,10 +40,10 @@ ] }, { - "_$id": "fkmnbowd", + "_$id": "i7ttmqwh", "_$type": "Label", "name": "Label", - "y": 48, + "y": 24, "width": 984, "height": 72, "centerX": 0, @@ -58,8 +58,8 @@ ] }, { - "_$id": "6j7wol13", - "_$prefab": "c4bc91b4-43cc-4655-b508-946a63b6534f", + "_$id": "qn7hlno1", + "_$prefab": "770e3b0c-7e51-4656-9a08-46992057f0a2", "name": "TrophyRoomCell", "active": true, "x": 0, diff --git a/assets/resources/TrophyRoomYear.lh.meta b/assets/resources/TrophyRoomYear.lh.meta index 08622d8..df5fbcb 100644 --- a/assets/resources/TrophyRoomYear.lh.meta +++ b/assets/resources/TrophyRoomYear.lh.meta @@ -1,3 +1,3 @@ { - "uuid": "381b129b-cb47-4a77-805d-6d4637bc67b8" + "uuid": "ef797791-e197-4854-bf49-347fe92999f4" } \ No newline at end of file diff --git a/src/Main.ts b/src/Main.ts index d9ad5a8..8d151cb 100644 --- a/src/Main.ts +++ b/src/Main.ts @@ -19,6 +19,7 @@ export class Main extends Laya.Script { } onLateUpdate(): void { + StorageManager.getInstance().saveUser() StorageManager.getInstance().saveStage() } } \ No newline at end of file diff --git a/src/constants/config.ts b/src/constants/config.ts index ce6c634..eab8522 100644 --- a/src/constants/config.ts +++ b/src/constants/config.ts @@ -1,4 +1,3 @@ -import { respath } from "./respath"; @@ -38,21 +37,7 @@ export const config = { MONTH_ABBRS: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"], MONTH_FULLNAMES: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"], - MONTH_LIST: [ - {year: 2024, month: 12, begin: 0, dayCount: 31, icon_res: respath.trophy_12}, - {year: 2025, month: 1, begin: 3, dayCount: 31, icon_res: respath.trophy_01}, - {year: 2025, month: 2, begin: 6, dayCount: 30, icon_res: respath.trophy_02}, - {year: 2025, month: 3, begin: 6, dayCount: 31, icon_res: respath.trophy_03}, - {year: 2025, month: 4, begin: 2, dayCount: 30, icon_res: respath.trophy_04}, - {year: 2025, month: 5, begin: 4, dayCount: 31, icon_res: respath.trophy_05}, - {year: 2025, month: 6, begin: 0, dayCount: 30, icon_res: respath.trophy_06}, - {year: 2025, month: 7, begin: 2, dayCount: 31, icon_res: respath.trophy_07}, - {year: 2025, month: 8, begin: 5, dayCount: 31, icon_res: respath.trophy_08}, - {year: 2025, month: 9, begin: 1, dayCount: 30, icon_res: respath.trophy_09}, - {year: 2025, month: 10, begin: 3, dayCount: 31, icon_res: respath.trophy_10}, - {year: 2025, month: 11, begin: 6, dayCount: 30, icon_res: respath.trophy_11}, - {year: 2025, month: 12, begin: 1, dayCount: 31, icon_res: respath.trophy_12}, - ] } + diff --git a/src/constants/respath.ts b/src/constants/respath.ts index 773a4e9..dc224a9 100644 --- a/src/constants/respath.ts +++ b/src/constants/respath.ts @@ -3,6 +3,8 @@ export const respath = { home_ui_res: "resources/Home.lh", dc_ui_res: "resources/DailyChallenge.lh", + trophy_claim_ui_res: "resources/TrophyClaim.lh", + trophy_show_ui_res: "resources/TrophyShow.lh", trophy_ui_res: "resources/TrophyRoom.lh", trophy_year_ui_res: "resources/TrophyRoomYear.lh", trophy_cell_ui_res: "resources/TrophyRoomCell.lh", diff --git a/src/models/DCManager.ts b/src/models/DCManager.ts new file mode 100644 index 0000000..34b17ef --- /dev/null +++ b/src/models/DCManager.ts @@ -0,0 +1,59 @@ + + + +import { respath } from "../constants/respath" + + +export const MONTH_LIST = [ + {year: 2024, month: 12, begin: 0, dayCount: 31, icon_res: respath.trophy_12}, + + {year: 2025, month: 1, begin: 3, dayCount: 31, icon_res: respath.trophy_01}, + {year: 2025, month: 2, begin: 6, dayCount: 30, icon_res: respath.trophy_02}, + {year: 2025, month: 3, begin: 6, dayCount: 31, icon_res: respath.trophy_03}, + {year: 2025, month: 4, begin: 2, dayCount: 30, icon_res: respath.trophy_04}, + {year: 2025, month: 5, begin: 4, dayCount: 31, icon_res: respath.trophy_05}, + {year: 2025, month: 6, begin: 0, dayCount: 30, icon_res: respath.trophy_06}, + {year: 2025, month: 7, begin: 2, dayCount: 31, icon_res: respath.trophy_07}, + {year: 2025, month: 8, begin: 5, dayCount: 31, icon_res: respath.trophy_08}, + {year: 2025, month: 9, begin: 1, dayCount: 30, icon_res: respath.trophy_09}, + {year: 2025, month: 10, begin: 3, dayCount: 31, icon_res: respath.trophy_10}, + {year: 2025, month: 11, begin: 6, dayCount: 30, icon_res: respath.trophy_11}, + {year: 2025, month: 12, begin: 1, dayCount: 31, icon_res: respath.trophy_12}, + + {year: 2026, month: 1, begin: 4, dayCount: 31, icon_res: respath.trophy_01}, + {year: 2026, month: 2, begin: 0, dayCount: 30, icon_res: respath.trophy_02}, + {year: 2026, month: 3, begin: 0, dayCount: 31, icon_res: respath.trophy_03}, + {year: 2026, month: 4, begin: 3, dayCount: 30, icon_res: respath.trophy_04}, + {year: 2026, month: 5, begin: 5, dayCount: 31, icon_res: respath.trophy_05}, + {year: 2026, month: 6, begin: 1, dayCount: 30, icon_res: respath.trophy_06}, + {year: 2026, month: 7, begin: 3, dayCount: 31, icon_res: respath.trophy_07}, + {year: 2026, month: 8, begin: 6, dayCount: 31, icon_res: respath.trophy_08}, + {year: 2026, month: 9, begin: 2, dayCount: 30, icon_res: respath.trophy_09}, + {year: 2026, month: 10, begin: 4, dayCount: 31, icon_res: respath.trophy_10}, + {year: 2026, month: 11, begin: 0, dayCount: 30, icon_res: respath.trophy_11}, + {year: 2026, month: 12, begin: 2, dayCount: 31, icon_res: respath.trophy_12}, +] + + +export function G_getMonthInfo(year: number, month: number): any { + for (var i=0; i { @@ -48,20 +48,20 @@ export class DOBlock { public add_note(noteNumber: number): void { if (this.data.notes.indexOf(noteNumber) < 0) { this.data.notes.push(noteNumber) - StorageManager.getInstance().onChanged() + StorageManager.getInstance().onStageChanged() } } public remove_note(noteNumber: number): void { var find = this.data.notes.indexOf(noteNumber) if (find >= 0) { this.data.notes.splice(find, 1) - StorageManager.getInstance().onChanged() + StorageManager.getInstance().onStageChanged() } } public clean_notes(): void { if (this.data.notes.length > 0) { this.data.notes = new Array() - StorageManager.getInstance().onChanged() + StorageManager.getInstance().onStageChanged() } } //====================================持久化数据 diff --git a/src/models/DOStage.ts b/src/models/DOStage.ts index c0a09ef..b5af835 100644 --- a/src/models/DOStage.ts +++ b/src/models/DOStage.ts @@ -107,7 +107,7 @@ export class DOStage { } public set_mistake(mistake: number): void { this.data.mistake = mistake - StorageManager.getInstance().onChanged() + StorageManager.getInstance().onStageChanged() } public get_score(): number { @@ -115,7 +115,7 @@ export class DOStage { } public set_score(score: number): void { this.data.score = score - StorageManager.getInstance().onChanged() + StorageManager.getInstance().onStageChanged() } public get_duration(): number { @@ -123,7 +123,7 @@ export class DOStage { } public set_duration(duration: number): void {//关卡计时 this.data.duration = duration - StorageManager.getInstance().onChanged() + StorageManager.getInstance().onStageChanged() } public get_note_open(): boolean { @@ -131,7 +131,7 @@ export class DOStage { } public set_note_open(note_open: boolean): void { this.data.note_open = note_open - StorageManager.getInstance().onChanged() + StorageManager.getInstance().onStageChanged() } public get_select_index(): number { @@ -139,7 +139,7 @@ export class DOStage { } public set_select_index(select_index: number): void {//当前选中 this.data.select_index = select_index - StorageManager.getInstance().onChanged() + StorageManager.getInstance().onStageChanged() } public get_hint(): number { @@ -147,7 +147,7 @@ export class DOStage { } public set_hint(hint: number): void {//提示 this.data.hint = hint - StorageManager.getInstance().onChanged() + StorageManager.getInstance().onStageChanged() } public get_undos(): Array { @@ -163,14 +163,14 @@ export class DOStage { var dataUndo: DataUndo = {index: index, show: show, notes: _notes} console.log("add_undo >>>>>>>>>>>>>>>>>>>>>>>>>>>>", JSON.stringify(dataUndo)) this.data.undos.push(dataUndo) - StorageManager.getInstance().onChanged() + StorageManager.getInstance().onStageChanged() } public pop_undo(): DataUndo { var dataUndo: DataUndo if (this.data.undos.length > 0) { dataUndo = this.data.undos[this.data.undos.length-1] this.data.undos.splice(this.data.undos.length-1, 1) - StorageManager.getInstance().onChanged() + StorageManager.getInstance().onStageChanged() } return dataUndo } diff --git a/src/models/DOUser.ts b/src/models/DOUser.ts index 3ff0344..cdee901 100644 --- a/src/models/DOUser.ts +++ b/src/models/DOUser.ts @@ -1,4 +1,4 @@ -import { DataProgress, DataUser, StageProgress } from "../types/global"; +import { DataProgress, DataUser, StageProgress, TrophyRecord } from "../types/global"; import { StorageManager } from "./StorageManager" @@ -25,7 +25,7 @@ export class DOUser { } return 0 } - public get_doneCountBydate(year: number, month: number): number { + public get_doneCountByDate(year: number, month: number): number { var count = 0 var key = `${year}-${month}` this.mapDones.forEach((progres: number, stageID: string)=>{ @@ -35,6 +35,16 @@ export class DOUser { }) return count } + public get_isAllDoneByDate(year: number, month: number): boolean { + var boolean = true + var key = `${year}-${month}` + this.mapDones.forEach((progres: number, stageID: string)=>{ + if (stageID.startsWith(key) && progres < 1) { + boolean = false + } + }) + return boolean + } public update_stage_done(stageID: string, progress: number): void { var find: StageProgress for (var i=0; i{ + var prefab = go.create() + var obj = this.getUIRoot().addChild(prefab).getComponent(TrophyClaim) + obj.onSetShow(record) + }) + } + public loadTrophyUI(): void { Laya.loader.load(respath.trophy_ui_res).then((go)=>{ var prefab = go.create() @@ -52,6 +63,14 @@ export class UIManager extends Laya.Script { }) } + public loadTrophyShowUI(record: TrophyRecord): void { + 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) + }) + } + public loadStageUI(stageID: string): void { if (this.stage) { this.stage.onLoadStage(StorageManager.getInstance().loadStage(stageID)) diff --git a/src/types/global.ts b/src/types/global.ts index 37084d2..67656e5 100644 --- a/src/types/global.ts +++ b/src/types/global.ts @@ -17,7 +17,7 @@ export interface DataUndo { //关卡数据 export interface DataStage { - id: string, + id: string,//关卡ID dc关卡格式为:年-月-日 type: number, name: string, difficulty: string, @@ -46,14 +46,22 @@ export function createDataStage(id: string, type: number, name: string, difficul export interface StageProgress {//关卡完成进度 - stageID: string, + stageID: string,//关卡ID dc关卡格式为:年-月-日 progress: number, } -export interface DataProgress { +export interface TrophyRecord { + year: number, + month: number, + day: number, + isNew: boolean, + read: boolean, +} +export interface DataProgress {//关卡难度进度 difficulty: string, index: number, } export interface DataUser { dones: Array,//关卡完成进度 + trophy_records: Array,//奖杯获得记录 progresses: Array,//主线各个难度进度 } diff --git a/src/views/DailyChallenge.ts b/src/views/DailyChallenge.ts index 847a3c4..bacc388 100644 --- a/src/views/DailyChallenge.ts +++ b/src/views/DailyChallenge.ts @@ -5,6 +5,7 @@ import { CalendarUnit } from "./CalendarUnit"; import { LevelManager } from "../models/LevelManager"; import { UIManager } from "../models/UIManager"; import { respath } from "../constants/respath"; +import { MONTH_LIST } from "../models/DCManager"; const { regClass, property } = Laya; @@ -16,6 +17,8 @@ export class DailyChallenge extends Laya.Script { public btn_back: Laya.Button @property(Laya.Image) public btn_trophy: Laya.Image + @property(Laya.Sprite) + public btn_trophy_red: Laya.Sprite @property(Laya.Image) public icon_trophy: Laya.Image @property(Laya.Box) @@ -62,9 +65,15 @@ export class DailyChallenge extends Laya.Script { UIManager.getInstance().loadHomeUI() this.owner.destroy() }) + + var user = StorageManager.getInstance().getUser() + this.btn_trophy_red.visible = user.get_trophyHasUnread() this.btn_trophy.on(Laya.Event.CLICK, this, ()=>{ + user.set_trophyAllread() + this.btn_trophy_red.visible = false UIManager.getInstance().loadTrophyUI() }) + this.btn_play.on(Laya.Event.CLICK, this, (evt: Laya.Event)=>{ // console.log(">>>>>>>>>>>>>>>>>>>>>>>", this.selectedUnit.day) var now = new Date() @@ -99,12 +108,12 @@ export class DailyChallenge extends Laya.Script { } } - this.indexMax = config.MONTH_LIST.length - 1 + this.indexMax = MONTH_LIST.length - 1 var now = new Date() var nowYear = now.getFullYear() var nowMonth = now.getMonth() + 1 - for (var i=0; i 0 this.btn_right.visible = this.currentIndex < this.indexMax - var info = config.MONTH_LIST[index] + var info = MONTH_LIST[index] var user = StorageManager.getInstance().getUser() var now = new Date() var nowYear = now.getFullYear() @@ -152,7 +161,7 @@ export class DailyChallenge extends Laya.Script { this.icon_trophy.skin = info.icon_res //设置背景 - var starCount = user.get_doneCountBydate(info.year, info.month) + var starCount = user.get_doneCountByDate(info.year, info.month) if (starCount >= info.dayCount) { this.bg_dc.skin = respath.dc_top_bg_month_finish } @@ -249,4 +258,13 @@ export class DailyChallenge extends Laya.Script { var unit = evt.target.getComponent(CalendarUnit) this.onApplyUnit(unit) } + + onStart(): void { + var user = StorageManager.getInstance().getUser() + var find = user.get_trophyHasNew() + if (find) { + UIManager.getInstance().loadTrophyClaimUI(find) + user.set_trophyNew(find, false) + } + } } \ No newline at end of file diff --git a/src/views/Home.ts b/src/views/Home.ts index 1932692..0ad7471 100644 --- a/src/views/Home.ts +++ b/src/views/Home.ts @@ -6,6 +6,7 @@ import { Difficulty } from "./Difficulty"; import { LevelManager } from "../models/LevelManager"; import { config } from "../constants/config"; import { Utility_ConvertSecondToString } from "../utils/utility"; +import { G_getMonthInfo } from "../models/DCManager"; const { regClass, property } = Laya @@ -44,17 +45,11 @@ export class Home extends Laya.Script { var now = new Date() var nowYear = now.getFullYear() var nowMonth = now.getMonth() + 1 - var find - for (var i=0; i= find.dayCount) { + if (user.get_doneCountByDate(nowYear, nowMonth) >= find.dayCount) { this.bg_dc.skin = respath.home_top_dc_bg_finish this.label_dc_title.color = "#ffffff" this.label_dc_date.color = "#ffffff" @@ -70,8 +65,7 @@ export class Home extends Laya.Script { this.label_dc_title.color = "#2d3138" this.label_dc_date.color = "#2d3138" } - - var nowDay = new Date().getDate() + var stageID = `${nowYear}-${nowMonth}-${nowDay}` this.label_dc_date.text = `${config.MONTH_ABBRS[nowMonth-1]} ${nowDay}` diff --git a/src/views/Stage.ts b/src/views/Stage.ts index b361403..c85d844 100644 --- a/src/views/Stage.ts +++ b/src/views/Stage.ts @@ -7,6 +7,7 @@ import { config } from "../constants/config"; import { StorageManager } from "../models/StorageManager"; import { Utility_ConvertSecondToString } from "../utils/utility"; import { EVENT_TYPES, EventManager } from "../models/EventManager"; +import { G_getMonthInfo } from "../models/DCManager"; const { regClass, property } = Laya; @@ -377,14 +378,31 @@ export class Stage extends Laya.Script { } } } - user.update_stage_done(this.data.get_stageID(), finished/all)//更新关卡完成进度 + var progress = finished/all + user.update_stage_done(this.data.get_stageID(), progress)//更新关卡完成进度 if (this.getIsComplete()) { - console.log("完成关卡") + console.log("完成关卡", finished, all, progress) this.paused = true this.data.set_score(score) if (this.data.get_stageType() == config.STAGE_TYPE.MAIN) {//主线关卡更新难度进度 user.update_progress(this.data.get_difficulty(), this.data.get_stageIndex()+1) } + else if (this.data.get_stageType() == config.STAGE_TYPE.DC) {//dc + if (progress >= 1) {//完成每日挑战关卡检查是否或者当月奖杯 + var now = new Date() + var nowYear = now.getFullYear() + var nowMonth = now.getMonth() + 1 + var doneCount = user.get_doneCountByDate(nowYear, nowMonth) + var dayCount = 0 + var info = G_getMonthInfo(nowYear, nowMonth) + if (info) + dayCount = info.dayCount + console.log("dc完成信息>>>>>>>>>>>>>>>", nowYear, nowMonth, doneCount, dayCount) + if (doneCount >= dayCount) {//当月每日挑战全部完成 + user.add_trophy_record(nowYear, nowMonth, now.getDate()) + } + } + } UIManager.getInstance().loadGameDoneUI() } } diff --git a/src/views/TrophyClaim.ts b/src/views/TrophyClaim.ts new file mode 100644 index 0000000..a8a1c35 --- /dev/null +++ b/src/views/TrophyClaim.ts @@ -0,0 +1,36 @@ +import { config } from "../constants/config"; +import { MONTH_LIST } from "../models/DCManager"; +import { TrophyRecord } from "../types/global"; + +const { regClass, property } = Laya; + +@regClass() +export class TrophyClaim extends Laya.Script { + declare owner : Laya.Box; + + @property(Laya.Image) + public icon: Laya.Image + + @property(Laya.Label) + public label_date: Laya.Label + + @property(Laya.Box) + public btn_close: Laya.Box + + public onSetShow(record: TrophyRecord): void { + for (var i=0; i{ + this.owner.destroy() + }) + } + +} \ No newline at end of file diff --git a/src/views/TrophyClaim.ts.meta b/src/views/TrophyClaim.ts.meta new file mode 100644 index 0000000..c1577f5 --- /dev/null +++ b/src/views/TrophyClaim.ts.meta @@ -0,0 +1,3 @@ +{ + "uuid": "0550b681-b602-49fe-900f-e30866ce922c" +} \ No newline at end of file diff --git a/src/views/TrophyRoom.ts b/src/views/TrophyRoom.ts index 8ae303b..2e22fb4 100644 --- a/src/views/TrophyRoom.ts +++ b/src/views/TrophyRoom.ts @@ -1,8 +1,9 @@ -import { config } from "../constants/config"; + import { respath } from "../constants/respath"; +import { MONTH_LIST } from "../models/DCManager"; import { TrophyUnit } from "./TrophyUnit"; const { regClass, property } = Laya; @@ -28,8 +29,8 @@ export class TrophyRoom extends Laya.Script { var now = new Date() var nowYear = now.getFullYear() var nowMonth = now.getMonth() + 1 - for (var i=0; i{ + this.owner.destroy() + }) } } \ No newline at end of file diff --git a/src/views/TrophyUnit.ts b/src/views/TrophyUnit.ts index da290c8..9d1b0c7 100644 --- a/src/views/TrophyUnit.ts +++ b/src/views/TrophyUnit.ts @@ -1,6 +1,7 @@ import { config } from "../constants/config"; import { respath } from "../constants/respath"; import { StorageManager } from "../models/StorageManager"; +import { UIManager } from "../models/UIManager"; const { regClass, property } = Laya; @@ -19,7 +20,7 @@ export class TrophyUnit extends Laya.Script { public onInit(info: any): void { var user = StorageManager.getInstance().getUser() - var starCount = user.get_doneCountBydate(info.year, info.month) + var starCount = user.get_doneCountByDate(info.year, info.month) this.icon.skin = info.icon_res this.label_count.text = `${starCount}/${info.dayCount}` this.label_month.text = config.MONTH_ABBRS[info.month-1] @@ -35,7 +36,10 @@ export class TrophyUnit extends Laya.Script { } this.icon.on(Laya.Event.CLICK, this, ()=>{ - + var find = user.get_trophyRecord(info.year, info.month) + if (find) { + UIManager.getInstance().loadTrophyShowUI(find) + } }) } } \ No newline at end of file