From 699a2100620437d6704978480fbddb570698fed2 Mon Sep 17 00:00:00 2001 From: yangwen Date: Thu, 29 May 2025 20:08:37 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8A=A8=E6=80=81=E9=85=8D=E7=BD=AEdc=E6=97=A5?= =?UTF-8?q?=E5=8E=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Main.ts | 2 + src/models/DCManager.ts | 97 ++++++++++++++++++++++++++++++----------- 2 files changed, 74 insertions(+), 25 deletions(-) diff --git a/src/Main.ts b/src/Main.ts index 1812402..c3d307c 100644 --- a/src/Main.ts +++ b/src/Main.ts @@ -1,5 +1,6 @@ import { config } from "./constants/config" import { respath } from "./constants/respath" +import { DCManager } from "./models/DCManager" import { LevelManager } from "./models/LevelManager" import { StorageManager } from "./models/StorageManager" @@ -13,6 +14,7 @@ export class Main extends Laya.Script { onAwake() { console.log("Game onAwake") config.DEBUG = this.debug + DCManager.getInstance().init() LevelManager.getInstance().init() StorageManager.getInstance().init() diff --git a/src/models/DCManager.ts b/src/models/DCManager.ts index 9ff205a..1fa25bc 100644 --- a/src/models/DCManager.ts +++ b/src/models/DCManager.ts @@ -1,33 +1,33 @@ import { respath } from "../constants/respath" export const MONTH_LIST = [ - { year: 2024, month: 12, begin: 0, dayCount: 31, icon_res: respath.trophy_12 }, + { 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: 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 } + // { 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 { @@ -48,4 +48,51 @@ export class DCManager { } return DCManager.instance } + + public init(): void { + const trophys: Array = [] + trophys.push(respath.trophy_01) + trophys.push(respath.trophy_02) + trophys.push(respath.trophy_03) + trophys.push(respath.trophy_04) + trophys.push(respath.trophy_05) + trophys.push(respath.trophy_06) + trophys.push(respath.trophy_07) + trophys.push(respath.trophy_08) + trophys.push(respath.trophy_09) + trophys.push(respath.trophy_10) + trophys.push(respath.trophy_11) + trophys.push(respath.trophy_12) + + const now = new Date() + const nowYear = now.getFullYear() + const nowMonth = now.getMonth() + 1 + let year = nowYear + let month = nowMonth + if (nowMonth === 12) { + year++ + month = 1 + } + for (let i = 2025; i <= year; i++) { + let b = false + for (let j = 1; j <= 12; j++) { + const date1 = new Date(`${i}/${j}/1`) + let date2 = new Date(`${i}/${j + 1}/1`) + if (j === 12) { + date2 = new Date(`${i + 1}/1/1`) + } + const seconds = date2.getTime() - date1.getTime() + const dayCount = Math.round(seconds / 1000 / 86400) + const begin = date1.getDay() + MONTH_LIST.push({ year: i, month: j, begin, dayCount, icon_res: trophys[j - 1] }) + if (i === year && j === month) { + b = true + break + } + } + if (b) { + break + } + } + } }