格式化代码

This commit is contained in:
2025-05-28 18:47:51 +08:00
parent 6d44fc21b4
commit a7df8ec739
38 changed files with 2768 additions and 2840 deletions

26
.vscode/launch.json vendored
View File

@@ -1,15 +1,15 @@
{ {
// Use IntelliSense to learn about possible attributes. // Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes. // Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0", "version": "0.2.0",
"configurations": [ "configurations": [
{ {
"type": "chrome", "type": "chrome",
"request": "launch", "request": "launch",
"name": "LayaAir Debug", "name": "LayaAir Debug",
"url": "http://localhost:18090", "url": "http://localhost:18090",
"webRoot": "${workspaceFolder}/bin" "webRoot": "${workspaceFolder}/bin"
} }
] ]
} }

View File

@@ -1,21 +1,27 @@
# **项目名称** # **项目名称**
> 数独 > 数独
## **环境推荐** ## **环境推荐**
- Node.js (>= 22.x) - Node.js (>= 22.x)
- npm (>= 11.x) - npm (>= 11.x)
- LayaAir (> 3.2.x) - LayaAir (> 3.2.x)
## **打包构建** ## **打包构建**
(如有特殊配置或脚本,需备注) (如有特殊配置或脚本,需备注)
## **IDE插件** ## **IDE插件**
如有需提供IDE插件列表 如有需提供IDE插件列表
## **环境变量(宏)** ## **环境变量(宏)**
(如有,需提供宏列表) (如有,需提供宏列表)
## **其他** ## **其他**
- (接口文档)[link] - (接口文档)[link]
- (需求文档)[link] - (需求文档)[link]
- (技术设计文档)[link] - (技术设计文档)[link]

View File

@@ -1,4 +1,3 @@
import { config } from "./constants/config" import { config } from "./constants/config"
Laya.addBeforeInitCallback((stageConfig) => { Laya.addBeforeInitCallback((stageConfig) => {
@@ -8,8 +7,7 @@ Laya.addBeforeInitCallback((stageConfig) => {
stageConfig.designWidth = config.DESIGN_HEIGHT stageConfig.designWidth = config.DESIGN_HEIGHT
stageConfig.designHeight = config.DESIGN_WIDTH stageConfig.designHeight = config.DESIGN_WIDTH
config.H_SCREEN = true config.H_SCREEN = true
} } else {
else {
stageConfig.designWidth = config.DESIGN_WIDTH stageConfig.designWidth = config.DESIGN_WIDTH
stageConfig.designHeight = config.DESIGN_HEIGHT stageConfig.designHeight = config.DESIGN_HEIGHT
config.H_SCREEN = false config.H_SCREEN = false

View File

@@ -1,25 +1,23 @@
import { config } from "./constants/config"
import { LevelManager } from "./models/LevelManager"
import { StorageManager } from "./models/StorageManager"
const { regClass, property } = Laya
import { StorageManager } from "./models/StorageManager";
import { LevelManager } from "./models/LevelManager";
import { config } from "./constants/config";
const { regClass, property } = Laya;
@regClass() @regClass()
export class Main extends Laya.Script { export class Main extends Laya.Script {
@property(Boolean)
public debug: boolean = false
@property(Boolean) onAwake() {
public debug: boolean = false console.log("Game onAwake")
config.DEBUG = this.debug
LevelManager.getInstance().init()
StorageManager.getInstance().init()
}
onAwake() { onLateUpdate(): void {
console.log("Game onAwake") StorageManager.getInstance().saveUser()
config.DEBUG = this.debug StorageManager.getInstance().saveStage()
LevelManager.getInstance().init() }
StorageManager.getInstance().init()
}
onLateUpdate(): void {
StorageManager.getInstance().saveUser()
StorageManager.getInstance().saveStage()
}
} }

View File

@@ -1,6 +1,3 @@
export const config = { export const config = {
DESIGN_WIDTH: 1080, DESIGN_WIDTH: 1080,
@@ -10,22 +7,21 @@ export const config = {
DEBUG: false, DEBUG: false,
OPEN_GUIDE: true, OPEN_GUIDE: true,
MISTAKE_MAX: 3,//最大错误数 MISTAKE_MAX: 3, // 最大错误数
STAGE_TYPE: {//关卡类型 STAGE_TYPE: { // 关卡类型
MAIN: 1,//主线 MAIN: 1, // 主线
DC: 2,//每日挑战 DC: 2// 每日挑战
}, },
DEFAULT_STAGE_ID: "main",//主线关卡标识 DEFAULT_STAGE_ID: "main", // 主线关卡标识
DIFFICULTY_TYPE: { // 难度
DIFFICULTY_TYPE: {//难度
Easy: "Easy", Easy: "Easy",
Medium: "Medium", Medium: "Medium",
Hard: "Hard", Hard: "Hard",
Expert: "Expert", Expert: "Expert",
Extreme: "Extreme", Extreme: "Extreme"
}, },
DIFFICULTY_LIST: ["Easy", "Medium", "Hard", "Expert", "Extreme"], DIFFICULTY_LIST: ["Easy", "Medium", "Hard", "Expert", "Extreme"],
@@ -33,13 +29,10 @@ export const config = {
WHITE: "#ffffff", WHITE: "#ffffff",
GREY: "#f0f2f7", GREY: "#f0f2f7",
RED: "#ef3e67", RED: "#ef3e67",
BLUE: "#2559c0", BLUE: "#2559c0"
}, },
MONTH_ABBRS: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"], 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_FULLNAMES: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]
} }

View File

@@ -1,5 +1,4 @@
import { config } from "./config"; import { config } from "./config"
export const respath = { export const respath = {
home_ui_res: "resources/Home.lh", home_ui_res: "resources/Home.lh",
@@ -18,8 +17,7 @@ export const respath = {
gamedone_ui_res: function func(isClassic: boolean): string { gamedone_ui_res: function func(isClassic: boolean): string {
if (isClassic) { if (isClassic) {
return config.H_SCREEN ? "resources/GameDone_Normal_H.lh" : "resources/GameDone_Normal.lh" return config.H_SCREEN ? "resources/GameDone_Normal_H.lh" : "resources/GameDone_Normal.lh"
} } else {
else {
return config.H_SCREEN ? "resources/GameDone_DC_H.lh" : "resources/GameDone_DC.lh" return config.H_SCREEN ? "resources/GameDone_DC_H.lh" : "resources/GameDone_DC.lh"
} }
}, },
@@ -50,13 +48,12 @@ export const respath = {
return config.H_SCREEN ? "resources/dc/TrophyRoomCell_H.lh" : "resources/dc/TrophyRoomCell.lh" return config.H_SCREEN ? "resources/dc/TrophyRoomCell_H.lh" : "resources/dc/TrophyRoomCell.lh"
}, },
//=============================== // ===============================
home_top_dc_bg_normal: "atlas/images/bg_dc_top1.png", home_top_dc_bg_normal: "atlas/images/bg_dc_top1.png",
home_top_dc_bg_finish: "atlas/images/bg_dc_top2.png", home_top_dc_bg_finish: "atlas/images/bg_dc_top2.png",
dc_top_bg_normal: "atlas/images/img_dc_bg2.png", dc_top_bg_normal: "atlas/images/img_dc_bg2.png",
dc_top_bg_month_finish: "atlas/images/img_dc_finished.png", dc_top_bg_month_finish: "atlas/images/img_dc_finished.png",
trophy_bg_light_gold: "atlas/trophys/img_trophy_bg_light_gold.png", trophy_bg_light_gold: "atlas/trophys/img_trophy_bg_light_gold.png",
trophy_bg_light_grey: "atlas/trophys/img_trophy_bg_light_gray.png", trophy_bg_light_grey: "atlas/trophys/img_trophy_bg_light_gray.png",
@@ -71,6 +68,5 @@ export const respath = {
trophy_09: "atlas/trophys/trophy_09.png", trophy_09: "atlas/trophys/trophy_09.png",
trophy_10: "atlas/trophys/trophy_10.png", trophy_10: "atlas/trophys/trophy_10.png",
trophy_11: "atlas/trophys/trophy_11.png", trophy_11: "atlas/trophys/trophy_11.png",
trophy_12: "atlas/trophys/trophy_12.png", trophy_12: "atlas/trophys/trophy_12.png"
} }

View File

@@ -1,43 +1,38 @@
import { respath } from "../constants/respath" import { respath } from "../constants/respath"
export const MONTH_LIST = [ 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 12, begin: 2, dayCount: 31, icon_res: respath.trophy_12 }
] ]
export function G_getMonthInfo(year: number, month: number): any { export function G_getMonthInfo(year: number, month: number): any {
for (var i=0; i<MONTH_LIST.length; i++) { for (let i = 0; i < MONTH_LIST.length; i++) {
var obj = MONTH_LIST[i] const obj = MONTH_LIST[i]
if (obj.year == year && obj.month == month) { if (obj.year == year && obj.month == month) {
return obj return obj
} }
@@ -46,14 +41,11 @@ export function G_getMonthInfo(year: number, month: number): any {
} }
export class DCManager { export class DCManager {
private static instance: DCManager
private static instance: DCManager public static getInstance(): DCManager {
public static getInstance(): DCManager { if (!DCManager.instance) {
if (!DCManager.instance) { DCManager.instance = new DCManager()
DCManager.instance = new DCManager()
}
return DCManager.instance
} }
return DCManager.instance
}
} }

View File

@@ -1,81 +1,79 @@
import type { DataBlock } from "../types/global"
import { DataBlock } from "../types/global";
import { StorageManager } from "./StorageManager" import { StorageManager } from "./StorageManager"
export class DOBlock { export class DOBlock {
private data: DataBlock
private preset: boolean = false// 预设格子
private correct: number = 0
private checked: boolean = false// 是否正确
private data: DataBlock constructor(dataBlock: DataBlock, preset: boolean, correct: number) {
private preset: boolean = false//预设格子 this.data = dataBlock
private correct: number = 0; this.preset = preset
private checked: boolean = false//是否正确 this.correct = correct
this.checked = preset || (dataBlock.show == correct)
}
// ====================================持久化数据
public get_index(): number {
return this.data.index
}
constructor(dataBlock: DataBlock, preset: boolean, correct: number) { public get_show(): number {
this.data = dataBlock return this.data.show
this.preset = preset }
this.correct = correct
this.checked = preset || (dataBlock.show == correct)
}
//====================================持久化数据 public set_show(show: number): void {
public get_index(): number { this.data.show = show
return this.data.index this.checked = show == this.get_correct()
} StorageManager.getInstance().onStageChanged()
}
public get_show(): number { public get_score(): number {
return this.data.show return this.data.score
} }
public set_show(show: number): void {
this.data.show = show
this.checked = show == this.get_correct()
StorageManager.getInstance().onStageChanged()
}
public get_score(): number { public set_score(score: number): void {
return this.data.score this.data.score = score
} StorageManager.getInstance().onStageChanged()
public set_score(score: number): void { }
this.data.score = score
StorageManager.getInstance().onStageChanged()
}
public get_notes(): Array<number> { public get_notes(): Array<number> {
return this.data.notes return this.data.notes
} }
public add_note(noteNumber: number): void {
if (this.data.notes.indexOf(noteNumber) < 0) {
this.data.notes.push(noteNumber)
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().onStageChanged()
}
}
public clean_notes(): void {
if (this.data.notes.length > 0) {
this.data.notes = new Array()
StorageManager.getInstance().onStageChanged()
}
}
//====================================持久化数据
public get_preset(): boolean { public add_note(noteNumber: number): void {
return this.preset if (!this.data.notes.includes(noteNumber)) {
this.data.notes.push(noteNumber)
StorageManager.getInstance().onStageChanged()
} }
}
public get_correct(): number { public remove_note(noteNumber: number): void {
return this.correct const find = this.data.notes.indexOf(noteNumber)
if (find >= 0) {
this.data.notes.splice(find, 1)
StorageManager.getInstance().onStageChanged()
} }
}
public get_checked(): boolean { public clean_notes(): void {
return this.checked if (this.data.notes.length > 0) {
this.data.notes = []
StorageManager.getInstance().onStageChanged()
} }
}
// ====================================持久化数据
public get_preset(): boolean {
return this.preset
}
public get_correct(): number {
return this.correct
}
public get_checked(): boolean {
return this.checked
}
} }

View File

@@ -1,28 +1,21 @@
export class DOCandy { export class DOCandy {
private show: number
private left: number
private show: number constructor(show: number, left: number) {
private left: number this.show = show
this.left = left
constructor(show: number, left: number) { }
this.show = show
this.left = left
}
public get_show(): number {
return this.show
}
public get_left(): number {
return this.left
}
public set_left(left: number): void {
this.left = left
}
public get_show(): number {
return this.show
}
public get_left(): number {
return this.left
}
public set_left(left: number): void {
this.left = left
}
} }

View File

@@ -1,190 +1,197 @@
import type { DataBlock, DataStage, DataUndo } from "../types/global"
import { StorageManager } from "./StorageManager"
import { DOBlock } from "./DOBlock" import { DOBlock } from "./DOBlock"
import { DataBlock, DataUndo, DataStage } from "../types/global"
import { LevelManager } from "./LevelManager" import { LevelManager } from "./LevelManager"
import { StorageManager } from "./StorageManager"
export class DOStage { export class DOStage {
private data: DataStage
private blocks: Array<DOBlock> = []
private data: DataStage private letterToNumber: Map<string, number>
private blocks: Array<DOBlock> = new Array() private numberToLetter: Map<number, string>
private letterToNumber: Map<string, number>; constructor(dataStage: DataStage) {
private numberToLetter: Map<number, string>; this.data = dataStage
constructor(dataStage: DataStage) { this.letterToNumber = new Map()
this.data = dataStage this.letterToNumber.set("A", 1)
this.letterToNumber.set("B", 2)
this.letterToNumber.set("C", 3)
this.letterToNumber.set("D", 4)
this.letterToNumber.set("E", 5)
this.letterToNumber.set("F", 6)
this.letterToNumber.set("G", 7)
this.letterToNumber.set("H", 8)
this.letterToNumber.set("I", 9)
this.letterToNumber = new Map(); this.numberToLetter = new Map()
this.letterToNumber.set("A", 1); this.numberToLetter.set(1, "a")
this.letterToNumber.set("B", 2); this.numberToLetter.set(2, "b")
this.letterToNumber.set("C", 3); this.numberToLetter.set(3, "c")
this.letterToNumber.set("D", 4); this.numberToLetter.set(4, "d")
this.letterToNumber.set("E", 5); this.numberToLetter.set(5, "e")
this.letterToNumber.set("F", 6); this.numberToLetter.set(6, "f")
this.letterToNumber.set("G", 7); this.numberToLetter.set(7, "g")
this.letterToNumber.set("H", 8); this.numberToLetter.set(8, "h")
this.letterToNumber.set("I", 9); this.numberToLetter.set(9, "i")
this.numberToLetter = new Map(); const blockMap: Map<number, DataBlock> = new Map()
this.numberToLetter.set(1, "a"); for (var i = 0; i < this.data.blocks.length; i++) {
this.numberToLetter.set(2, "b"); var dataBlock = this.data.blocks[i]
this.numberToLetter.set(3, "c"); blockMap.set(dataBlock.index, dataBlock)
this.numberToLetter.set(4, "d"); }
this.numberToLetter.set(5, "e");
this.numberToLetter.set(6, "f");
this.numberToLetter.set(7, "g");
this.numberToLetter.set(8, "h");
this.numberToLetter.set(9, "i");
var blockMap: Map<number, DataBlock> = new Map() const levelStr = LevelManager.getInstance().getLevelStr(this.data.difficulty, this.data.index)
for (var i=0; i<this.data.blocks.length; i++) { if (!levelStr || levelStr.length != 81) {
var dataBlock = this.data.blocks[i] console.log("levelStr error", this.data.difficulty, this.data.index, levelStr)
blockMap.set(dataBlock.index, dataBlock) }
const list = new Map()
for (var i = 0; i < levelStr.length; i++) {
const letter = levelStr[i]
if (this.letterToNumber.has(letter)) { // 预设格子 使用配置文件初始化
var show = this.letterToNumber.get(letter)
var dataBlock: DataBlock = { index: i, show, score: 0, notes: [] }
var doBlock = new DOBlock(dataBlock, true, show)
this.blocks.push(doBlock)
} else {
var show = this.letterToNumber.get(letter.toUpperCase())
var dataBlock = blockMap.get(i)
if (dataBlock) { // 本地有持久化数据
var doBlock = new DOBlock(dataBlock, false, show)
this.blocks.push(doBlock)
} else {
dataBlock = { index: i, show: 0, score: 0, notes: [] }
this.data.blocks.push(dataBlock)
var doBlock = new DOBlock(dataBlock, false, show)
this.blocks.push(doBlock)
} }
var levelStr = LevelManager.getInstance().getLevelStr(this.data.difficulty, this.data.index) if (list.has(letter)) {
if (!levelStr || levelStr.length != 81) { list.set(letter, list.get(letter) + 1)
console.log("levelStr error", this.data.difficulty, this.data.index, levelStr) } else {
list.set(letter, 1)
} }
var list = new Map(); }
for (var i=0; i<levelStr.length; i++) { }
var letter = levelStr[i]; }
if (this.letterToNumber.has(letter)) {//预设格子 使用配置文件初始化
var show = this.letterToNumber.get(letter)
var dataBlock: DataBlock = {index: i, show: show, score: 0, notes: new Array()}
var doBlock = new DOBlock(dataBlock, true, show)
this.blocks.push(doBlock)
}
else {
var show = this.letterToNumber.get(letter.toUpperCase())
var dataBlock = blockMap.get(i)
if (dataBlock) {//本地有持久化数据
var doBlock = new DOBlock(dataBlock, false, show)
this.blocks.push(doBlock)
}
else {
dataBlock = {index: i, show: 0, score: 0, notes: new Array()}
this.data.blocks.push(dataBlock)
var doBlock = new DOBlock(dataBlock, false, show)
this.blocks.push(doBlock)
}
if (list.has(letter)) { public getData(): DataStage {
list.set(letter, list.get(letter)+1); return this.data
} }
else {
list.set(letter, 1);
}
}
}
}
public getData(): DataStage {
return this.data
}
//====================================持久化数据 // ====================================持久化数据
public get_stageID(): string { public get_stageID(): string {
return this.data.id return this.data.id
} }
public get_stageType(): number {
return this.data.type
}
public get_stageName(): string {
return this.data.name
}
public get_difficulty(): string {
return this.data.difficulty
}
public get_stageIndex(): number {
return this.data.index
}
public get_mistake(): number { public get_stageType(): number {
return this.data.mistake return this.data.type
} }
public set_mistake(mistake: number): void {
this.data.mistake = mistake
StorageManager.getInstance().onStageChanged()
}
public get_score(): number { public get_stageName(): string {
return this.data.score return this.data.name
} }
public set_score(score: number): void {
this.data.score = score
StorageManager.getInstance().onStageChanged()
}
public get_duration(): number { public get_difficulty(): string {
return this.data.duration return this.data.difficulty
} }
public set_duration(duration: number): void {//关卡计时
this.data.duration = duration
StorageManager.getInstance().onStageChanged()
}
public get_last_hit_time(): number { public get_stageIndex(): number {
return this.data.last_hit_time return this.data.index
} }
public set_last_hit_time(last_hit_time: number): void {
this.data.last_hit_time = last_hit_time
StorageManager.getInstance().onStageChanged()
}
public get_note_open(): boolean { public get_mistake(): number {
return this.data.note_open return this.data.mistake
} }
public set_note_open(note_open: boolean): void {
this.data.note_open = note_open
StorageManager.getInstance().onStageChanged()
}
public get_select_index(): number { public set_mistake(mistake: number): void {
return this.data.select_index this.data.mistake = mistake
} StorageManager.getInstance().onStageChanged()
public set_select_index(select_index: number): void {//当前选中 }
this.data.select_index = select_index
StorageManager.getInstance().onStageChanged()
}
public get_hint(): number { public get_score(): number {
return this.data.hint return this.data.score
} }
public set_hint(hint: number): void {//提示
this.data.hint = hint
StorageManager.getInstance().onStageChanged()
}
public get_undos(): Array<DataUndo> { public set_score(score: number): void {
return this.data.undos this.data.score = score
} StorageManager.getInstance().onStageChanged()
public add_undo(index: number, show: number=0, notes: Array<number>=new Array()): void { }
var _notes: Array<number>
if (notes) {
_notes = new Array()
for (var i=0; i<notes.length; i++)
_notes.push(notes[i])
}
var dataUndo: DataUndo = {index: index, show: show, notes: _notes}
console.log("add_undo >>>>>>>>>>>>>>>>>>>>>>>>>>>>", JSON.stringify(dataUndo))
this.data.undos.push(dataUndo)
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().onStageChanged()
}
return dataUndo
}
//====================================持久化数据
public get_blocks(): Array<DOBlock> { public get_duration(): number {
return this.blocks return this.data.duration
}
public set_duration(duration: number): void { // 关卡计时
this.data.duration = duration
StorageManager.getInstance().onStageChanged()
}
public get_last_hit_time(): number {
return this.data.last_hit_time
}
public set_last_hit_time(last_hit_time: number): void {
this.data.last_hit_time = last_hit_time
StorageManager.getInstance().onStageChanged()
}
public get_note_open(): boolean {
return this.data.note_open
}
public set_note_open(note_open: boolean): void {
this.data.note_open = note_open
StorageManager.getInstance().onStageChanged()
}
public get_select_index(): number {
return this.data.select_index
}
public set_select_index(select_index: number): void { // 当前选中
this.data.select_index = select_index
StorageManager.getInstance().onStageChanged()
}
public get_hint(): number {
return this.data.hint
}
public set_hint(hint: number): void { // 提示
this.data.hint = hint
StorageManager.getInstance().onStageChanged()
}
public get_undos(): Array<DataUndo> {
return this.data.undos
}
public add_undo(index: number, show: number = 0, notes: Array<number> = []): void {
let _notes: Array<number>
if (notes) {
_notes = []
for (let i = 0; i < notes.length; i++)
_notes.push(notes[i])
} }
const dataUndo: DataUndo = { index, show, notes: _notes }
console.log("add_undo >>>>>>>>>>>>>>>>>>>>>>>>>>>>", JSON.stringify(dataUndo))
this.data.undos.push(dataUndo)
StorageManager.getInstance().onStageChanged()
}
public pop_undo(): DataUndo {
let 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().onStageChanged()
}
return dataUndo
}
// ====================================持久化数据
public get_blocks(): Array<DOBlock> {
return this.blocks
}
} }

View File

@@ -1,171 +1,177 @@
import { DataProgress, DataUser, StageProgress, TrophyRecord } from "../types/global"; import type { DataProgress, DataUser, StageProgress, TrophyRecord } from "../types/global"
import { StorageManager } from "./StorageManager" import { StorageManager } from "./StorageManager"
export class DOUser { export class DOUser {
private data: DataUser
private mapDones: Map<string, number> = new Map()
private data: DataUser constructor(dataUser: DataUser) {
private mapDones: Map<string, number> = new Map() this.data = dataUser
for (let i = 0; i < this.data.dones.length; i++) {
const obj = this.data.dones[i]
this.mapDones.set(obj.stageID, obj.progress)
}
}
constructor(dataUser: DataUser) { public getData(): DataUser {
this.data = dataUser return this.data
for (var i=0; i<this.data.dones.length; i++) { }
var obj = this.data.dones[i]
this.mapDones.set(obj.stageID, obj.progress)
}
}
public getData(): DataUser {
return this.data
}
//====================================持久化数据 // ====================================持久化数据
public get_done(stageID: string): number { public get_done(stageID: string): number {
if (this.mapDones.has(stageID)) { if (this.mapDones.has(stageID)) {
return this.mapDones.get(stageID) return this.mapDones.get(stageID)
}
return 0
}
public get_doneCountByDate(year: number, month: number): number {
var count = 0
var key = `${year}-${month}`
this.mapDones.forEach((progres: number, stageID: string)=>{
if (stageID.startsWith(key) && progres >= 1) {
count ++
}
})
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<this.data.dones.length; i++) {
var obj = this.data.dones[i]
if (obj.stageID == stageID) {
find = obj
break
}
}
if (find) {
find.progress = progress
}
else {
find = {stageID: stageID, progress: progress}
this.data.dones.push(find)
}
this.mapDones.set(find.stageID, find.progress)
StorageManager.getInstance().onUserChanged()
} }
return 0
}
//================奖杯获得记录 public get_doneCountByDate(year: number, month: number): number {
public get_trophyRecord(year: number, month: number): TrophyRecord { let count = 0
var find: TrophyRecord const key = `${year}-${month}`
for (var i=0; i<this.data.trophy_records.length; i++) { this.mapDones.forEach((progres: number, stageID: string) => {
var obj = this.data.trophy_records[i] if (stageID.startsWith(key) && progres >= 1) {
if (obj.year == year && obj.month == month) { count++
find = obj }
break })
} return count
} }
return find
}
public get_trophyHasNew(): TrophyRecord {
var find: TrophyRecord
for (var i=0; i<this.data.trophy_records.length; i++) {
var obj = this.data.trophy_records[i]
if (obj.isNew) {
find = obj
break
}
}
return find
}
public set_trophyNew(record: TrophyRecord, isNew: boolean): void {
if (record.isNew != isNew) {
record.isNew = isNew
StorageManager.getInstance().onUserChanged()
}
}
public get_trophyHasUnread(): boolean {
var unread = false
for (var i=0; i<this.data.trophy_records.length; i++) {
var obj = this.data.trophy_records[i]
if (obj.read == false) {
unread = true
break
}
}
return unread
}
public set_trophyAllread(): void {
var changed = false
for (var i=0; i<this.data.trophy_records.length; i++) {
var obj = this.data.trophy_records[i]
if (obj.read == false) {
obj.read = true
changed = true
}
}
if (changed) {
StorageManager.getInstance().onUserChanged()
}
}
public add_trophy_record(year: number, month: number, day: number): void {
var find
for (var i=0; i<this.data.trophy_records.length; i++) {
var obj = this.data.trophy_records[i]
if (obj.year == year && obj.month == month) {
find = obj
break
}
}
if (!find) {
this.data.trophy_records.push({year: year, month: month, day: day, isNew: true, read: false})
StorageManager.getInstance().onUserChanged()
}
}
//=======关卡难度进度 public get_isAllDoneByDate(year: number, month: number): boolean {
public get_progress(difficulty: string): number { let boolean = true
var find: DataProgress const key = `${year}-${month}`
for (var i=0; i<this.data.progresses.length; i++) { this.mapDones.forEach((progres: number, stageID: string) => {
var obj = this.data.progresses[i] if (stageID.startsWith(key) && progres < 1) {
if (obj.difficulty == difficulty) { boolean = false
find = obj }
break })
} return boolean
} }
if (find) {
return find.index
}
return 0
}
public update_progress(difficulty: string, index: number): void {
var find: DataProgress
for (var i=0; i<this.data.progresses.length; i++) {
var obj = this.data.progresses[i]
if (obj.difficulty == difficulty) {
find = obj
break
}
}
if (find) {
find.index = index
}
else {
find = {difficulty: difficulty, index: index}
this.data.progresses.push(find)
}
StorageManager.getInstance().onUserChanged()
}
//====================================持久化数据 public update_stage_done(stageID: string, progress: number): void {
let find: StageProgress
for (let i = 0; i < this.data.dones.length; i++) {
const obj = this.data.dones[i]
if (obj.stageID == stageID) {
find = obj
break
}
}
if (find) {
find.progress = progress
} else {
find = { stageID, progress }
this.data.dones.push(find)
}
this.mapDones.set(find.stageID, find.progress)
StorageManager.getInstance().onUserChanged()
}
// ================奖杯获得记录
public get_trophyRecord(year: number, month: number): TrophyRecord {
let find: TrophyRecord
for (let i = 0; i < this.data.trophy_records.length; i++) {
const obj = this.data.trophy_records[i]
if (obj.year == year && obj.month == month) {
find = obj
break
}
}
return find
}
public get_trophyHasNew(): TrophyRecord {
let find: TrophyRecord
for (let i = 0; i < this.data.trophy_records.length; i++) {
const obj = this.data.trophy_records[i]
if (obj.isNew) {
find = obj
break
}
}
return find
}
public set_trophyNew(record: TrophyRecord, isNew: boolean): void {
if (record.isNew != isNew) {
record.isNew = isNew
StorageManager.getInstance().onUserChanged()
}
}
public get_trophyHasUnread(): boolean {
let unread = false
for (let i = 0; i < this.data.trophy_records.length; i++) {
const obj = this.data.trophy_records[i]
if (obj.read == false) {
unread = true
break
}
}
return unread
}
public set_trophyAllread(): void {
let changed = false
for (let i = 0; i < this.data.trophy_records.length; i++) {
const obj = this.data.trophy_records[i]
if (obj.read == false) {
obj.read = true
changed = true
}
}
if (changed) {
StorageManager.getInstance().onUserChanged()
}
}
public add_trophy_record(year: number, month: number, day: number): void {
let find
for (let i = 0; i < this.data.trophy_records.length; i++) {
const obj = this.data.trophy_records[i]
if (obj.year == year && obj.month == month) {
find = obj
break
}
}
if (!find) {
this.data.trophy_records.push({ year, month, day, isNew: true, read: false })
StorageManager.getInstance().onUserChanged()
}
}
// =======关卡难度进度
public get_progress(difficulty: string): number {
let find: DataProgress
for (let i = 0; i < this.data.progresses.length; i++) {
const obj = this.data.progresses[i]
if (obj.difficulty == difficulty) {
find = obj
break
}
}
if (find) {
return find.index
}
return 0
}
public update_progress(difficulty: string, index: number): void {
let find: DataProgress
for (let i = 0; i < this.data.progresses.length; i++) {
const obj = this.data.progresses[i]
if (obj.difficulty == difficulty) {
find = obj
break
}
}
if (find) {
find.index = index
} else {
find = { difficulty, index }
this.data.progresses.push(find)
}
StorageManager.getInstance().onUserChanged()
}
// ====================================持久化数据
} }

View File

@@ -1,53 +1,48 @@
export const EVENT_TYPES = { export const EVENT_TYPES = {
NOT_UPDATE_MISTAKE: "NOT_UPDATE_MISTAKE",//更新分数 NOT_UPDATE_MISTAKE: "NOT_UPDATE_MISTAKE", // 更新分数
NOT_UPDATE_PAUSE: "NOT_UPDATE_PAUSE",//更新暂停状态 NOT_UPDATE_PAUSE: "NOT_UPDATE_PAUSE", // 更新暂停状态
NOT_SET_TROPHY_BUTTON: "NOT_SET_TROPHY_BUTTON", NOT_SET_TROPHY_BUTTON: "NOT_SET_TROPHY_BUTTON"
} }
export class EventManager { export class EventManager {
private static instance: EventManager
private static instance: EventManager public static getInstance(): EventManager {
public static getInstance(): EventManager { if (!EventManager.instance) {
if (!EventManager.instance) { EventManager.instance = new EventManager()
EventManager.instance = new EventManager()
}
return EventManager.instance
} }
return EventManager.instance
}
private listeners: Map<string, Array<any>> = new Map() private listeners: Map<string, Array<any>> = new Map()
public RegisterEvent(eventID: string, func: any): void { public RegisterEvent(eventID: string, func: any): void {
if (this.listeners.has(eventID) == false) { if (this.listeners.has(eventID) == false) {
this.listeners.set(eventID, new Array()) this.listeners.set(eventID, [])
}
var list: Array<any> = this.listeners.get(eventID)
var find = list.indexOf(func)
if (find < 0) {
list.push(func)
}
} }
const list: Array<any> = this.listeners.get(eventID)
public UnregisterEvent(eventID: string, func: any): void { const find = list.indexOf(func)
if (this.listeners.has(eventID)) { if (find < 0) {
var list: Array<any> = this.listeners.get(eventID) list.push(func)
var find = list.indexOf(func)
if (find >= 0) {
list.splice(find, 1)
}
}
} }
}
public DispatchEvent(eventID: string, arg: any=null): void { public UnregisterEvent(eventID: string, func: any): void {
if (this.listeners.has(eventID)) { if (this.listeners.has(eventID)) {
var list: Array<any> = this.listeners.get(eventID) const list: Array<any> = this.listeners.get(eventID)
for (var i=0; i<list.length; i++) { const find = list.indexOf(func)
list[i](arg) if (find >= 0) {
} list.splice(find, 1)
} }
} }
}
public DispatchEvent(eventID: string, arg: any = null): void {
if (this.listeners.has(eventID)) {
const list: Array<any> = this.listeners.get(eventID)
for (let i = 0; i < list.length; i++) {
list[i](arg)
}
}
}
} }

View File

@@ -1,157 +1,153 @@
import { config } from "../constants/config" import { config } from "../constants/config"
const Easy = [ const Easy = [
"aBCeIGFhdEDFcAHBGIhigBdfecAgHDiFBCaeBEAGHCIdffcIdEAHbgcABfGEdiHIFHaCDGEBDGEHbiaFC", "aBCeIGFhdEDFcAHBGIhigBdfecAgHDiFBCaeBEAGHCIdffcIdEAHbgcABfGEdiHIFHaCDGEBDGEHbiaFC",
"abecfIgdhdICGhbAFEHGfeAdIcBCFAbigEHDGDhFeABICIEbHdCFGAFaGDBHcEIbCDIGehAFeHIaCFdbG", "abecfIgdhdICGhbAFEHGfeAdIcBCFAbigEHDGDhFeABICIEbHdCFGAFaGDBHcEIbCDIGehAFeHIaCFdbG",
"AbIGdeHFCHFDbCieaGgEcfaHbDIEiAdBFGcHFHGcEAIBddCBHIGFEaCdfiGBAHEbgeAHCDIfIaHefdCgB", "AbIGdeHFCHFDbCieaGgEcfaHbDIEiAdBFGcHFHGcEAIBddCBHIGFEaCdfiGBAHEbgeAHCDIfIaHefdCgB",
"ACEdBIGHFBHGFacDEIdiFheGAbCcEiBdFHaGhfBGIAecDGadcHeIfBIgCaFHbDEFdAegbcIHEBHICDfGa", "ACEdBIGHFBHGFacDEIdiFheGAbCcEiBdFHaGhfBGIAecDGadcHeIfBIgCaFHbDEFdAegbcIHEBHICDfGa",
"acEIhbgFDFIDAgEBHCBGHfCdeaIDEaBFgicHcFGHAidebIHbDecaGFeBFCIAHdGGDCebHfIAHAiGdfCBE", "acEIhbgFDFIDAgEBHCBGHfCdeaIDEaBFgicHcFGHAidebIHbDecaGFeBFCIAHdGGDCebHfIAHAiGdfCBE",
"aCfDbGHIEGHBIcEFdaedIAFhbCGDFahGiebCHbecaDIGFiGCbEFdAHBEHGIcAfDFiGedACHBCAdFHBgei", "aCfDbGHIEGHBIcEFdaedIAFhbCGDFahGiebCHbecaDIGFiGCbEFdAHBEHGIcAfDFiGedACHBCAdFHBgei",
"ACGBfIHDeHEBCdgFAIfdIHaegcBDgEAHCIBFIbhFEdaGCcAFGIbDEHgIDebHcfabHADcFEiGEfcigABHd", "ACGBfIHDeHEBCdgFAIfdIHaegcBDgEAHCIBFIbhFEdaGCcAFGIbDEHgIDebHcfabHADcFEiGEfcigABHd",
"AcGFdihBEdHEbGCAifBFIEhaGDCEgADIBfcHhibGcfDEaFDChaEigbGBHCFdEAIIEdabHCFGcAfIEGbHD", "AcGFdihBEdHEbGCAifBFIEhaGDCEgADIBfcHhibGcfDEaFDChaEigbGBHCFdEAIIEdabHCFGcAfIEGbHD",
"ACGIFbEhdbFEDGhaCIIHDCAEBGFFAIHBDceggdbecfIahHEcAIGdFBeIHFDAGBcdGFbeCHIacbAgHifdE", "ACGIFbEhdbFEDGhaCIIHDCAEBGFFAIHBDceggdbecfIahHEcAIGdFBeIHFDAGBcdGFbeCHIacbAgHifdE"
] ]
const Medium = [ const Medium = [
"achEDIBFGgeIHbFaDCFDBaCGHeIbHaceDGiFCIFGHBeadeGDIFAChbDAGbIeFCHhfEdGCIbaiBcFAhdGE", "achEDIBFGgeIHbFaDCFDBaCGHeIbHaceDGiFCIFGHBeadeGDIFAChbDAGbIeFCHhfEdGCIbaiBcFAhdGE",
"ADBeIGhFCGhCDFabiefiECHBgDACGDbaFieHEBIHGCFADhFAIedCbGdAFGbheCIbEhaciDGFIcGFDeaHb", "ADBeIGhFCGhCDFabiefiECHBgDACGDbaFieHEBIHGCFADhFAIedCbGdAFGbheCIbEhaciDGFIcGFDeaHb",
"aDBIEcHFGEGHbDFcaiIFCAGHeDbgHdEIafBCCIaHFbdGeBefGcdIHADCGFbeAIHhbedAIGcFFaIcHgBEd", "aDBIEcHFGEGHbDFcaiIFCAGHeDbgHdEIafBCCIaHFbdGeBefGcdIHADCGFbeAIHhbedAIGcFFaIcHgBEd",
"AdEGCHfibHGbefIacdCIFABdehgICgHDAbFefahbecDgIEBDIGFCAHbeICAGHDFGFCDheIbADHAFIBGec", "AdEGCHfibHGbefIacdCIFABdehgICgHDAbFefahbecDgIEBDIGFCAHbeICAGHDFGFCDheIbADHAFIBGec",
"ADeIBFgHCIHFcgabdebGCeDhaIfHfaDeIcGbgIBFacHEdECdBHGFaiFBHAIEDcGDeGHcBiFaCAIgFDEBH", "ADeIBFgHCIHFcgabdebGCeDhaIfHfaDeIcGbgIBFacHEdECdBHGFaiFBHAIEDcGDeGHcBiFaCAIgFDEBH",
"aDFIEHbcGciHaGbFDEeGBcdFHIAbeadhCgfIGHIfBEcAdFCdGAIeHBDAeHcgibFHFGbIDaECIBcEFADGh", "aDFIEHbcGciHaGbFDEeGBcdFHIAbeadhCgfIGHIfBEcAdFCdGAIeHBDAeHcgibFHFGbIDaECIBcEFADGh",
"aDgEICFBHHCFdGBAeIIEBFHacdgcAEgBIdhFDGhCFEiabBFIADHEGCGbciaDHfEEHdbcFgiAFiAHeGbcd", "aDgEICFBHHCFdGBAeIIEBFHacdgcAEgBIdhFDGhCFEiabBFIADHEGCGbciaDHfEEHdbcFgiAFiAHeGbcd",
"adHEbCIfGegBfHIDAcIcfgDaHEBDFABIGcHEHIcdfegbaBEGcAHFdIFAdIgBeCHCbihEFAGdghEACDBIF", "adHEbCIfGegBfHIDAcIcfgDaHEBDFABIGcHEHIcdfegbaBEGcAHFdIFAdIgBeCHCbihEFAGdghEACDBIF",
"aecDbHIGFDGHCFIBEAfiBEGaHCdgAFBIedHcHCEaDFGBIbDIghCFAeibahcdeFGcHdfeGAIBefGIAbCDH", "aecDbHIGFDGHCFIBEAfiBEGaHCdgAFBIedHcHCEaDFGBIbDIghCFAeibahcdeFGcHdfeGAIBefGIAbCDH"
] ]
const Hard = [ const Hard = [
"AEdfiHgCBIFGECbahdcbHGADeIFGIFCDaBeHHDCbGEIFAeabhfICdgbCIAHFDGeFGadEcHBiDHeIBgFac", "AEdfiHgCBIFGECbahdcbHGADeIFGIFCDaBeHHDCbGEIFAeabhfICdgbCIAHFDGeFGadEcHBiDHeIBgFac",
"aEFGBihCdHcIefdGBAGdbcahIfeIBAFDcegHDHEAGBCiFFgcHIEadBeFHDCGBaicidBHAFEGbAGIeFDHC", "aEFGBihCdHcIefdGBAGdbcahIfeIBAFDcegHDHEAGBCiFFgcHIEadBeFHDCGBaicidBHAFEGbAGIeFDHC",
"AEGIdchFBFICbehgAdbHDFAGeIchdEgBaFCiGbfchIadeCAIefdbGHdfBaIeChGEGHdCFibAIcaHGbDEf", "AEGIdchFBFICbehgAdbHDFAGeIchdEgBaFCiGbfchIadeCAIefdbGHdfBaIeChGEGHdCFibAIcaHGbDEf",
"afbCGDehiIGhEaFCdBECDIbHAFGhEGADbfICdbifechGAFACHIGbeDgDFBHAIcEcIaDFeGBHBHegCIdaF", "afbCGDehiIGhEaFCdBECDIbHAFGhEGADbfICdbifechGAFACHIGbeDgDFBHAIcEcIaDFeGBHBHegCIdaF",
"AFhIgCdEBcEGDBHAFIiDbfaeGCHhGIEcfbdafcdBIAHGEBaeHdGCIfEBACFdIHggHcAeiFbDdiFGHBEAC", "AFhIgCdEBcEGDBHAFIiDbfaeGCHhGIEcfbdafcdBIAHGEBaeHdGCIfEBACFdIHggHcAeiFbDdiFGHBEAC",
"agcfdHbEIHBDEIGCaFFiecBAhGDBEghcFIdaDHiAGbEfCCAFiEdGBHGCabfIdHeIDHgAEFCbEFBdHcAIg", "agcfdHbEIHBDEIGCaFFiecBAhGDBEghcFIdaDHiAGbEfCCAFiEdGBHGCabfIdHeIDHgAEFCbEFBdHcAIg",
"agibdeFchcHDGIfeBAEFbHAcDIgiDCAEBGHFHBeDFGCaIFAGICHBdEgEaCBihfdbIfeHDAGCdCHFGaIeb", "agibdeFchcHDGIfeBAEFbHAcDIgiDCAEBGHFHBeDFGCaIFAGICHBdEgEaCBihfdbIfeHDAGCdCHFGaIeb",
"AHbIEDcGFCifgHBAdeGEDAfcIHBBdGHCEFaiIFcbdaHeGHaeFIGBCDeBAcGFdIhFGHDaieBcDcIebhGFA", "AHbIEDcGFCifgHBAdeGEDAfcIHBBdGHCEFaiIFcbdaHeGHaeFIGBCDeBAcGFdIhFGHDaieBcDcIebhGFA",
"AHEbCIGfdiBGDEFHCAdfcHGaBIEBGICfdaeHhCFEAbIdGEAdihgFbcFIAgDECHbcdBAIHegfGEHFbcdAI", "AHEbCIGfdiBGDEFHCAdfcHGaBIEBGICfdaeHhCFEAbIdGEAdihgFbcFIAgDECHbcdBAIHegfGEHFbcdAI",
"AHECBgFdIBIGDAfhCECfDHIEagbIGHEDcBFAEBFAGichddCaBFHeigFEIgHadbChDcIeBGaFGabFcdiEH", "AHECBgFdIBIGDAfhCECfDHIEagbIGHEDcBFAEBFAGichddCaBFHeigFEIgHadbChDcIeBGaFGabFcdiEH"
] ]
const Expert = [ const Expert = [
"AHEIDCFGBiBFGaedchcdghbfIEADfHEIACBgbeADCGHfiGCibFHaDEeaBcHDGIFHIdFgBeAcFGCaeIBhD", "AHEIDCFGBiBFGaedchcdghbfIEADfHEIACBgbeADCGHfiGCibFHaDEeaBcHDGIFHIdFgBeAcFGCaeIBhD",
"AHEIFGcbDDgBacefhIFIcBdHGeACbdHIFAgehfgEAcIDbEaIGBDHFCIEAFGbdcHBDFchaeiGgCHDEIbAF", "AHEIFGcbDDgBacefhIFIcBdHGeACbdHIFAgehfgEAcIDbEaIGBDHFCIEAFGbdcHBDFchaeiGgCHDEIbAF",
"aIBCFDeHGcGFHaeIdbdHEIGBafCFDGahcbieBeaGDIHcFICHEBfdGAHADFEgcbIgBIdcaFEHEFCbiHGAd", "aIBCFDeHGcGFHaeIdbdHEIGBafCFDGahcbieBeaGDIHcFICHEBfdGAHADFEgcbIgBIdcaFEHEFCbiHGAd",
"AIBHEFDcGEFcaDGihbHDGBCIAefGHFiadEBCBCAeFHGIdIEDGBcHFaCAiFGebdhfbHdIaCgedgECHbfAi", "AIBHEFDcGEFcaDGihbHDGBCIAefGHFiadEBCBCAeFHGIdIEDGBcHFaCAiFGebdhfbHdIaCgedgECHbfAi",
"aiDHBEfCGCGEFIdhBABFHCaGEdiIDGEHbcAfHABifcdgeECFgDaIHBFBaDEHGiCdECbGIafHGhiacFBed", "aiDHBEfCGCGEFIdhBABFHCaGEdiIDGEHbcAfHABifcdgeECFgDaIHBFBaDEHGiCdECbGIafHGhiacFBed",
"aIgdfbhcEdBEHCiGFAFCHEGaBdIIFbCAGDEHcHABDeFigegdIHFCabBDiFEHAGcHACGIDEBFGefabcihd", "aIgdfbhcEdBEHCiGFAFCHEGaBdIIFbCAGDEHcHABDeFigegdIHFCabBDiFEHAGcHACGIDEBFGefabcihd",
"AIGdFebCHBfHiaCdGEEDcgHbIaFgcBfeAHIdiHecgDfBAfaDbIhgeccbfaDIeHGhGIECFadbdeAHBGCFI", "AIGdFebCHBfHiaCdGEEDcgHbIaFgcBfeAHIdiHecgDfBAfaDbIhgeccbfaDIeHGhGIECFadbdeAHBGCFI",
"baDEHGIFCGIHDCfABEceFAIBgdhfdchGIEABIgAbdEHcFEHbfaCDGIABeGFhciddFiCEabhGHCgIBdFEA", "baDEHGIFCGIHDCfABEceFAIBgdhfdchGIEABIgAbdEHcFEHbfaCDGIABeGFhciddFiCEabhGHCgIBdFEA",
"baicHdegFHEdIFGcABGFCaebhidfbadGCIHEICEfAhBDGdGHBIeaFCAHBEDfGCICDGHBifEaeiFGCADBh", "baicHdegFHEdIFGcABGFCaebhidfbadGCIHEICEfAhBDGdGHBIeaFCAHBEDfGCICDGHBifEaeiFGCADBh",
"BaiGFcdEHdFCHEAIGBhEgbDIcfaCidFAeBHGFBACGhEIdghEDibAcfEdBIHFgAcaGHECdFBIICfabGHDe", "BaiGFcdEHdFCHEAIGBhEgbDIcfaCidFAeBHGFBACGhEIdghEDibAcfEdBIHFgAcaGHECdFBIICfabGHDe",
"bCFIGHADeHAGdFebCIDIEaBcFGHEbHGAFDIcgdCbhieFaafiCEDHBGCEBHdGIafIHAFcbgeDfgDeiACHb", "bCFIGHADeHAGdFebCIDIEaBcFGHEbHGAFDIcgdCbhieFaafiCEDHBGCEBHdGIafIHAFcbgeDfgDeiACHb",
"BdaHFIEGCicHDgEafBEGFBACDIHfbDcEgIHAHAIFBdgceCeGihAbDFDIbEchFaggFCadbHEIaHEGIfcBD", "BdaHFIEGCicHDgEafBEGFBACDIHfbDcEgIHAHAIFBdgceCeGihAbDFDIbEchFaggFCadbHEIaHEGIfcBD",
"BDCEFiGAHIHacGBeDFGEFHADIBcEIdfHACgBhCGbDEaFIFABgicdHeaFhiEgbCdDbiaChfeGCGEdbFHIa", "BDCEFiGAHIHacGBeDFGEFHADIBcEIdfHACgBhCGbDEaFIFABgicdHeaFhiEgbCdDbiaChfeGCGEdbFHIa",
"bdEcFAHIGCAIegHFBDFGHBDICaEehfaBDIGCDCgiHeaFBIBAFcgedhaicgEbDHFGeDhAFbcIHFbDiCGEa", "bdEcFAHIGCAIegHFBDFGHBDICaEehfaBDIGCDCgiHeaFBIBAFcgedhaicgEbDHFGeDhAFbcIHFbDiCGEa",
"BEaihfcdgCFIGEDAHBgDHACBIFeFIdhaeGbcAHGcBIDEfebcdFGHAIDgeBIHFCaHCbFGAeiDIAfEdcbGH", "BEaihfcdgCFIGEDAHBgDHACBIFeFIdhaeGbcAHGcBIDEfebcdFGHAIDgeBIHFCaHCbFGAeiDIAfEdcbGH",
"BehdIcaFgCfGeAHIbdaIdfBGCheEgcIDFHAbdAFHeBGCiIHBGcaDefFCIBHdeGAHbeaGIFDCGDACfEBIH", "BehdIcaFgCfGeAHIbdaIdfBGCheEgcIDFHAbdAFHeBGCiIHBGcaDefFCIBHdeGAHbeaGIFDCGDACfEBIH",
"BfHCEGADIIdchAFGbeGaEiBdCHFFBigCADEHHEGBdIfaCDCafhEiGBeGFDIHbCacHdaFBEiGaIbegcHFd", "BfHCEGADIIdchAFGbeGaEiBdCHFFBigCADEHHEGBdIfaCDCafhEiGBeGFDIHbCacHdaFBEiGaIbegcHFd"
] ]
const Extreme = [ const Extreme = [
"BGDiEAfchahcFBDIGEEIFhgCDabFAHGibedcDEGACHbIFCbIEdfGHagDACfEHBihFBDAIcegICEbHGaFd", "BGDiEAfchahcFBDIGEEIFhgCDabFAHGibedcDEGACHbIFCbIEdfGHagDACfEHBihFBDAIcegICEbHGaFd",
"BGFAIHDCEDHicegBAfEACFDbIGHidhbCEgFAaEGIhfcDBFCbgadeHIHIedGafBCcbdhFiAEGGFAEbcHID", "BGFAIHDCEDHicegBAfEACFDbIGHidhbCEgFAaEGIhfcDBFCbgadeHIHIedGafBCcbdhFiAEGGFAEbcHID",
"BGFHIAdECaiCdBEFGHhDeFcgbaiGFBeAICHdICAGdHEFbdeHCFBGIAFhIBGDACEeBGaHcIDfcadiefhbg", "BGFHIAdECaiCdBEFGHhDeFcgbaiGFBeAICHdICAGdHEFbdeHCFBGIAFhIBGDACEeBGaHcIDfcadiefhbg",
"BhAcGEIDFIGdBaFCHefeCHiDGbaeaBFcIdGHcDGEHAFIBhifgdBEACAcIDFHbEGGbHIEcaFDdFeabGhcI", "BhAcGEIDFIGdBaFCHefeCHiDGbaeaBFcIdGHcDGEHAFIBhifgdBEACAcIDFHbEGGbHIEcaFDdFeabGhcI",
"BHeadfiCGICAgbHDEFdFgIEcHabgEHdFabICcadBHIfGEFBICGEAdHeiBFAGcHdHdCeIBGfAaGfHcDEBI", "BHeadfiCGICAgbHDEFdFgIEcHabgEHdFabICcadBHIfGEFBICGEAdHeiBFAGcHdHdCeIBGfAaGfHcDEBI",
"BHFcEdgaigIDAfbEHcCEaIGHBfDdfIGHCAeBhCBeIADGFAGedbFcihFdHBaGIceIacfDEHBGEbGHCIFdA", "BHFcEdgaigIDAfbEHcCEaIGHBfDdfIGHCAeBhCBeIADGFAGedbFcihFdHBaGIceIacfDEHBGEbGHCIFdA",
"biADChGFEEHFIagbDCcGDBFEAHIIaeFHDCGBFBHgIcdEadcGebAhIFHfBAGIECDgDICEbFahaechdFibg", "biADChGFEEHFIagbDCcGDBFEAHIIaeFHDCGBFBHgIcdEadcGebAhIFHfBAGIECDgDICEbFahaechdFibg",
"bICEGDHFAHFeaICdbGaDGbFHEcIEadfcgIHbFGHIbECAdICBhdAfGEcHiDAbgefGBFceiadhDEAGHFBIC", "bICEGDHFAHFeaICdbGaDGbFHEcIEadfcgIHbFGHIbECAdICBhdAfGEcHiDAbgefGBFceiadhDEAGHFBIC",
"bieDFaGHcgcaeHiDbFHfDGcBiAECHIBgEFdaDGBHafEciAEFIDcbghFBcaIdheGIdHCEGAFBEAGFBHCID", "bieDFaGHcgcaeHiDbFHfDGcBiAECHIBgEFdaDGBHafEciAEFIDcbghFBcaIdheGIdHCEGAFBEAGFBHCID",
"BIFCAdhGeDhAEbgFCICEgFHiBDaFBEGDAIHCADHicBEfggciHFeDabHGDBicaefiacdeFGbHEFBaGHCID", "BIFCAdhGeDhAEbgFCICEgFHiBDaFBEGDAIHCADHicBEfggciHFeDabHGDBicaefiacdeFGbHEFBaGHCID",
"bihCGEADfFAGIbDchEedCfahbigCFDEIGHbaIbEHdaFGCHGaBCfIEdGcFdHbeAIAEBGFIDcHdhIAEcGFB", "bihCGEADfFAGIbDchEedCfahbigCFDEIGHbaIbEHdaFGCHGaBCfIEdGcFdHbeAIAEBGFIDcHdhIAEcGFB",
"CaBhedgfiidHcFGAEbEFGbiahCDAEIGDbFHcFGdIhcebahBCFaEDiGDHAECIBGFbCEdGFIAHGIfaBhCDE", "CaBhedgfiidHcFGAEbEFGbiahCDAEIGDbFHcFGdIhcebahBCFaEDiGDHAECIBGFbCEdGFIAHGIfaBhCDE",
"cbFDEGiAHGIacFHdebdeHibAgFcfdIBCehGABHgAIFECdACEgHdfBIIGbFDCahEeAdHGBCIFHfceAIBDG", "cbFDEGiAHGIacFHdebdeHibAgFcfdIBCehGABHgAIFECdACEgHdfBIIGbFDCahEeAdHGBCIFHfceAIBDG",
"cbgHEaFdIaIdcbfGEHEHFigDBACbFEAIHdCGhcAEDGIBFDGIBFCehaGDCFABHIEiabGHecfdFehdcIaGB", "cbgHEaFdIaIdcbfGEHEHFigDBACbFEAIHdCGhcAEDGIBFDGIBFCehaGDCFABHIEiabGHecfdFehdcIaGB",
"CbhdAEIGfaEFgibCdhIGDHCFBEafDEBHaGICGibcfdhAehcAIeGFbddFIEbHAcGEHCagIDFBBAGfDCEHI", "CbhdAEIGfaEFgibCdhIGDHCFBEafDEBHaGICGibcfdhAehcAIeGFbddFIEbHAcGEHCagIDFBBAGfDCEHI",
"CDabGEHIFeFhIaCGDbbgIHdFcAEAcEGhbifdGIbCFdaEHdHfaEiBGciaDFCHEbghEgDbafCIFbceiGDha", "CDabGEHIFeFhIaCGDbbgIHdFcAEAcEGhbifdGIbCFdaEHdHfaEiBGciaDFCHEbghEgDbafCIFbceiGDha",
"cdgeAIBfhhbFDCgIAeAiEHbFcDGBFICGEdHAdGhBFaECIeACIdHGbfIedFHcagBGhbaEdficfCagiBHed", "cdgeAIBfhhbFDCgIAeAiEHbFcDGBFICGEdHAdGhBFaECIeACIdHGbfIedFHcagBGhbaEdficfCagiBHed",
"cDgIbFEAHehbdGaFICiafecHgDBACIGEBhfdgbdfhiCeAHFECAdbGIBIHAFedcgfGABdCIheDechIGabF", "cDgIbFEAHehbdGaFICiafecHgDBACIGEBhfdgbdfhiCeAHFECAdbGIBIHAFedcgfGABdCIheDechIGabF",
"CEBIAFHGDIhAdEgbcfgFdCbheaIFGHACIDEbeBCGFdIhADaIbHEcFgBIEFGcAdHHdGEiaFbcAcFHDBgie", "CEBIAFHGDIhAdEgbcfgFdCbheaIFGHACIDEbeBCGFdIhADaIbHEcFgBIEFGcAdHHdGEiaFbcAcFHDBgie",
"cEHGfdIABFIgCAbhedAbDeIHcGfeABFcGdHIHDFBEIACGigChdafbEbFaDHEgIcGCIAbfeDHDHeIGcBFA", "cEHGfdIABFIgCAbhedAbDeIHcGfeABFcGdHIHDFBEIACGigChdafbEbFaDHEgIcGCIAbfeDHDHeIGcBFA",
"ceIBaDGfhHaGcfiDEbBdFhGEIaCAHbFICEgDGiCdEahbFEfDGhbACIfbhEDGcIAiCeabHFdgdgaIcFBhe", "ceIBaDGfhHaGcfiDEbBdFhGEIaCAHbFICEgDGiCdEahbFEfDGhbACIfbhEDGcIAiCeabHFdgdgaIcFBhe",
"CeiBaGHDfADGfeHIBCbFHidcegAdHCeFagIBIGECHBAFDFBAgIdcHEEaFHBIDcGgidacfBEHHCBdGefaI", "CeiBaGHDfADGfeHIBCbFHidcegAdHCeFagIBIGECHBAFDFBAgIdcHEEaFHBIDcGgidacfBEHHCBdGefaI",
"cEIDAGFHbgDBEFhICAFHAIBCeGdbGFhIeadCACDBGFHIehIecDAGBFdacGEiBfHIfHAcbDEgEbgfhdCai", "cEIDAGFHbgDBEFhICAFHAIBCeGdbGFhIeadCACDBGFHIehIecDAGBFdacGEiBfHIfHAcbDEgEbgfhdCai",
"CFeabGHIDGBdHEIfcaihACDFBegEGIBadcHFbDcGFHEAIHAFEICgDBAcGihbDFEFIHdgeabcdebfCAIGH", "CFeabGHIDGBdHEIfcaihACDFBegEGIBadcHFbDcGFHEAIHAFEICgDBAcGihbDFEFIHdgeabcdebfCAIGH",
"CFEIAdbgHaHicbgDeFGDBEFhcIAeGHADCIfBIcFghbAdEBADFIEhcGFbcHGIeaDHEADCFGbidigBEaFHc", "CFEIAdbgHaHicbgDeFGDBEFhcIAeGHADCIfBIcFghbAdEBADFIEhcGFbcHGIeaDHEADCFGbidigBEaFHc",
"CGaBfHIdEHEiacDFBGDbFIgEHcaadcFBgEIHfhECDIGaBBiGHEadFcgCdEIBAHFiAbgHfCEdEFHdacBGI", "CGaBfHIdEHEiacDFBGDbFIgEHcaadcFBgEIHfhECDIGaBBiGHEadFcgCdEIBAHFiAbgHfCEdEFHdacBGI",
"CGhAIbfEDFAIEdhcBgDEBCGfHaIIDgbheACFHFcDaIbgeebAGFcIDHGCFibdEHABHDFEaGicaIeHcgDFB", "CGhAIbfEDFAIEdhcBgDEBCGfHaIIDgbheACFHFcDaIbgeebAGFcIDHGCFibdEHABHDFEaGicaIeHcgDFB",
"cHbEFDGAIAdIcgBEFHegfhIAcbDHACbDGfieIbEACFDHgGFdIheACBBCaGEHidfdEhfaIBGcFIGDbCHEa", "cHbEFDGAIAdIcgBEFHegfhIAcbDHACbDGfieIbEACFDHgGFdIheACBBCaGEHidfdEhfaIBGcFIGDbCHEa",
"cidGHEBFAFaeBDcIGHbHgAFIECdgeIHafdbcAdfecbHIGHbCDIGAEFEFaCBHgDIDCbIGaFheighFEDCAB", "cidGHEBFAFaeBDcIGHbHgAFIECdgeIHafdbcAdfecbHIGHbCDIGAEFEFaCBHgDIDCbIGaFheighFEDCAB",
"cIFDHAEbgebHgicAfdaGDEFbhCIBDacGFIEHFHIABEGDCgcehdIFABdeGBAHCIFhfciEdbgAIABFCGDhe", "cIFDHAEbgebHgicAfdaGDEFbhCIBDacGFIEHFHIABEGDCgcehdIFABdeGBAHCIFhfciEdbgAIABFCGDhe",
"CIFeBahdGHGDIcFebabaegDHIcfdhAbEcFGiIfcaHgdEbEBGDFIcAHFcbhaEgidaEIfGDBhCGdHciBAFE", "CIFeBahdGHGDIcFebabaegDHIcfdhAbEcFGiIfcaHgdEbEBGDFIcAHFcbhaEgidaEIfGDBhCGdHciBAFE",
"DAeFBIHGcFiCHGeBadhGBadCFeIabgIHDECFIEDGCFabhChFBEAdIGbcadfGIHEEdhCiBgFAGfiEAHCdb", "DAeFBIHGcFiCHGeBadhGBadCFeIabgIHDECFIEDGCFabhChFBEAdIGbcadfGIHEEdhCiBgFAGfiEAHCdb",
"dafibcGHEHIEFdgcbaBCGAHEDIfeHcDgbfaIGBAHIFECDIFdEcAHGbaGBceDIfHFehGaIBdCCdIBfHAEG", "dafibcGHEHIEFdgcbaBCGAHEDIfeHcDgbfaIGBAHIFECDIFdEcAHGbaGBceDIfHFehGaIBdCCdIBfHAEG",
"DaFIcbHgebeHGDFAiccgiEAHDFBEBcAHgFDIGHdCfibEaIFabEdGcHHIGfBeCAdFCbDIAehGAdEHGcIBF", "DaFIcbHgebeHGDFAiccgiEAHDFBEBcAHgFDIGHdCfibEaIFabEdGcHHIGfBeCAdFCbDIAehGAdEHGcIBF",
"DaibFEGHCGHECIDaBFcFbGHaIDeHiAedbFcGEgFicHBAdBCDAgFheIIEHdAGcfBFDchBIEGAabgFecDiH", "DaibFEGHCGHECIDaBFcFbGHaIDeHiAedbFcGEgFicHBAdBCDAgFheIIEHdAGcfBFDchBIEGAabgFecDiH",
"DaIbGFHeCFChaiebdGGeBdCHIFaCbGFADEHIHFAIEbGCdIDEcHgAbFBGcHDafiEEIFGbcdahahdEFiCGB", "DaIbGFHeCFChaiebdGGeBdCHIFaCbGFADEHIHFAIEbGCdIDEcHgAbFBGcHDafiEEIFGbcdahahdEFiCGB",
"dAIcebGFHgBEHFaCiDhcFdgIAbeIDBFaGeHcCeAIDHFgBfGhBcEIdABFgAHCDEIAHdeIFBcGeICGbDhaf", "dAIcebGFHgBEHFaCiDhcFdgIAbeIDBFaGeHcCeAIDHFgBfGhBcEIdABFgAHCDEIAHdeIFBcGeICGbDhaf",
"dbFECIAgHIGaFDHBCeHEcAGbDiFFDBgheiacECGIAFHBDaIHDbceFGcHEbfaGDibfdHIGCEAgaiCEDFhb", "dbFECIAgHIGaFDHBCeHEcAGbDiFFDBgheiacECGIAFHBDaIHDbceFGcHEbfaGDibfdHIGCEAgaiCEDFhb",
"DbgiCFaehcaehbdIGFHIfAEGCBDgfCeIHDABIHAbDCGFEEdbFGAhCIBEDcaiFHGaGHDfBEIcFciGhEbdA", "DbgiCFaehcaehbdIGFHIfAEGCBDgfCeIHDABIHAbDCGFEEdbFGAhCIBEDcaiFHGaGHDfBEIcFciGhEbdA",
"DEbfcgaHIFaIHDbCegcHGaiEFbDAfebhdIGcidCEGABFHgBHcFIdAEhgfibceDaeIdGafHcBBCaDEhGIF", "DEbfcgaHIFaIHDbCegcHGaiEFbDAfebhdIGcidCEGABFHgBHcFIdAEhgfibceDaeIdGafHcBBCaDEhGIF",
"dEGHAfIbCBIHcEGFDACFABDIEGhFhbagCdIEEDCfibhAGGAIeHdBCFIGfdcHaEbHCeibaGFDAbdgFechI", "dEGHAfIbCBIHcEGFDACFABDIEGhFhbagCdIEEDCfibhAGGAIeHdBCFIGfdcHaEbHCeibaGFDAbdgFechI",
"DFACBhGIEgchaIeFDbBEIFDGaChAHFbgidEcedcHAfbGIIGbdecHAFFBGECDIHAcadIHbefGHiEgFACBD", "DFACBhGIEgchaIeFDbBEIFDGaChAHFbgidEcedcHAfbGIIGbdecHAFFBGECDIHAcadIHbefGHiEgFACBD",
"dfbeahiCgECgiDbfHAAihGFCdeBGbFHCDEAihDIAgecBFcaEBIFgDHFGDCHaBIEIeADBGHFcBHcFEIaGd", "dfbeahiCgECgiDbfHAAihGFCdeBGbFHCDEAihDIAgecBFcaEBIFgDHFGDCHaBIEIeADBGHFcBHcFEIaGd",
"dfeGchaIBICAFbeHgdgBHdAIfceCHIAeBGdfAGBIFDEHcFEDHGCIBaEDgcIFBAHHIfbdAceGbACehGDFi", "dfeGchaIBICAFbeHgdgBHdAIfceCHIAeBGdfAGBIFDEHcFEDHGCIBaEDgcIFBAHHIfbdAceGbACehGDFi",
"dGaICHBFEFBIAedHcGCEhgBFIADHcEdfagBiaIbeHGCDfgDFciBEHAEAdHGCFIbbhgFdIaEcIFcbAEDGh", "dGaICHBFEFBIAedHcGCEhgBFIADHcEdfagBiaIbeHGCDfgDFciBEHAEAdHGCFIbbhgFdIaEcIFcbAEDGh",
"dGeihbaCFHFBCADgIECiaeFGBDHEDIgBHcfAbACFDiHEGGHFaEcibdaehBIFDGcFBGdcaEhIICDHgEfaB", "dGeihbaCFHFBCADgIECiaeFGBDHEDIgBHcfAbACFDiHEGGHFaEcibdaehBIFDGcFBGdcaEhIICDHgEfaB",
"dHcIFGABEIegCABFdHFbADHEIgCaGFebdCHIEDHaCIBFgciBHGFEadbaDGechiFhCIFDageBGfEBiHDca", "dHcIFGABEIegCABFdHFbADHEIgCaGFebdCHIEDHaCIBFgciBHGFEadbaDGechiFhCIFDageBGfEBiHDca",
"dHGaicbeFEacFHBIDgIbFeDghcAHeIDcAFGBFdbHgECaIGcABFIDHeaIHcEFgbDBfDGAHEiCCGEIbdAFh", "dHGaicbeFEacFHBIDgIbFeDghcAHeIDcAFGBFdbHgECaIGcABFIDHeaIHcEFgbDBfDGAHEiCCGEIbdAFh",
"DICbAEhgfFaGIHDBCEbEHFCGADIEcBGDIFAhaDFCeHibggHiAFBdECIbehGAcFdcGadIFEhBhFDebcGia", "DICbAEhgfFaGIHDBCEbEHFCGADIEcBGDIFAhaDFCeHibggHiAFBdECIbehGAcFdcGadIFEhBhFDebcGia",
"diGbCEaHFAfCIdhEBghBeAGFCdiCEbDHGFIAIgdfEaBcHFaHcIBgedgcAhBdIFEEDiGfchabbHFEaidgc", "diGbCEaHFAfCIdhEBghBeAGFCdiCEbDHGFIAIgdfEaBcHFaHcIBgedgcAhBdIFEEDiGfchabbHFEaidgc",
"diGEHFBCAHcaIBGEdfeFbCadIhgiGEDFAHBCaHFBcEDGICBDHGIfAegdcFEBAIHbehAIcGfDFaIGdhceb", "diGEHFBCAHcaIBGEdfeFbCadIhgiGEDFAHBCaHFBcEDGICBDHGIfAegdcFEBAIHbehAIcGfDFaIGdhceb",
"eaBdfIHGcIGdCHbFAEfHCAGEDBigcebdHAIFhFAiECGdBBdifAGECHabFecdIHGDiHGBFCeaCEgHIabFD", "eaBdfIHGcIGdCHbFAEfHCAGEDBigcebdHAIFhFAiECGdBBdifAGECHabFecdIHGDiHGBFCeaCEgHIabFD",
"EABFHiGcDHdICgaebfcGFBdeAHIaCDHIgBFEbFeaCDIGHiHGEFBdACfbaDECHIGgEHiBfcdadICGahFeB", "EABFHiGcDHdICgaebfcGFBdeAHIaCDHIgBFEbFeaCDIGHiHGEFBdACfbaDECHIGgEHiBfcdadICGahFeB",
"eacIBFhdgGHBecDaFIDIfgAhCBECFGHDEiabIdHaGBECFabeCFIGHDfCiBHGdeAHgdFEabIcBEADiCFGh", "eacIBFhdgGHBecDaFIDIfgAhCBECFGHDEiabIdHaGBECFabeCFIGHDfCiBHGdeAHgdFEabIcBEADiCFGh",
"EadCFbIhGbGCiahdeffhiGedcABGDbEiFHCACEadhgbFIIfHBcAeGddCfabegiHaBEHGIFDChIGFDcaBE", "EadCFbIhGbGCiahdeffhiGedcABGDbEiFHCACEadhgbFIIfHBcAeGddCfabegiHaBEHGIFDChIGFDcaBE"
] ]
export class LevelManager { export class LevelManager {
private static instance: LevelManager
public static getInstance(): LevelManager {
if (!LevelManager.instance) {
LevelManager.instance = new LevelManager()
}
return LevelManager.instance
}
private static instance: LevelManager private levelMap: Map<string, Array<string>> = new Map()
public static getInstance(): LevelManager {
if (!LevelManager.instance) { public init(): void {
LevelManager.instance = new LevelManager() this.levelMap.set(config.DIFFICULTY_TYPE.Easy, Easy)
this.levelMap.set(config.DIFFICULTY_TYPE.Medium, Medium)
this.levelMap.set(config.DIFFICULTY_TYPE.Hard, Hard)
this.levelMap.set(config.DIFFICULTY_TYPE.Expert, Expert)
this.levelMap.set(config.DIFFICULTY_TYPE.Extreme, Extreme)
// 检查关卡配置
this.levelMap.forEach((list, key) => {
for (let i = 0; i < list.length; i++) {
if (list[i].length != 81) {
console.error("关卡配置有误>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>", key, i)
} }
return LevelManager.instance }
})
}
public getLevelList(difficulty: string): Array<string> {
const list = this.levelMap.get(difficulty)
return list
}
public getLevelStr(difficulty: string, index: number): string {
const list = this.levelMap.get(difficulty)
if (list) {
return list[index]
} }
return ""
private levelMap: Map<string, Array<string>> = new Map() }
public init(): void {
this.levelMap.set(config.DIFFICULTY_TYPE.Easy, Easy)
this.levelMap.set(config.DIFFICULTY_TYPE.Medium, Medium)
this.levelMap.set(config.DIFFICULTY_TYPE.Hard, Hard)
this.levelMap.set(config.DIFFICULTY_TYPE.Expert, Expert)
this.levelMap.set(config.DIFFICULTY_TYPE.Extreme, Extreme)
//检查关卡配置
this.levelMap.forEach((list, key)=>{
for (var i=0; i<list.length; i++) {
if (list[i].length != 81) {
console.error("关卡配置有误>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>", key, i)
}
}
})
}
public getLevelList(difficulty: string): Array<string> {
var list = this.levelMap.get(difficulty)
return list
}
public getLevelStr(difficulty: string, index: number): string {
var list = this.levelMap.get(difficulty)
if (list) {
return list[index]
}
return ""
}
} }

View File

@@ -1,14 +1,11 @@
import type { DataStage } from "../types/global"
import { config } from "../constants/config" import { config } from "../constants/config"
import { DataStage, createDataStage } from "../types/global" import { createDataStage } from "../types/global"
import { DOStage } from "./DOStage" import { DOStage } from "./DOStage"
import { DOUser } from "./DOUser" import { DOUser } from "./DOUser"
import { LevelManager } from "./LevelManager" import { LevelManager } from "./LevelManager"
export class StorageManager { export class StorageManager {
private static instance: StorageManager private static instance: StorageManager
public static getInstance(): StorageManager { public static getInstance(): StorageManager {
if (!StorageManager.instance) { if (!StorageManager.instance) {
@@ -17,23 +14,21 @@ export class StorageManager {
return StorageManager.instance return StorageManager.instance
} }
private user: DOUser; private user: DOUser
private userChanged = false private userChanged = false
private stageID: string = ""; private stageID: string = ""
private stageChanged = false private stageChanged = false
private stageMap: Map<string, DOStage> = new Map(); private stageMap: Map<string, DOStage> = new Map()
public init(): void { public init(): void {
if (!this.user) { if (!this.user) {
var jsonStr = Laya.LocalStorage.getItem("user") const jsonStr = Laya.LocalStorage.getItem("user")
if (jsonStr) { if (jsonStr) {
this.user = new DOUser(JSON.parse(jsonStr)) this.user = new DOUser(JSON.parse(jsonStr))
} } else {
else { this.user = new DOUser({ dones: [], trophy_records: [], progresses: [] })
this.user = new DOUser({dones: new Array(), trophy_records: new Array(), progresses: new Array()}) }
}
} }
this.userChanged = false this.userChanged = false
@@ -41,19 +36,20 @@ export class StorageManager {
this.stageChanged = false this.stageChanged = false
} }
public getUser(): DOUser { public getUser(): DOUser {
return this.user return this.user
} }
public saveUser(): void { public saveUser(): void {
if (this.userChanged) { if (this.userChanged) {
this.userChanged = false this.userChanged = false
if (this.user) { if (this.user) {
var jsonStr = JSON.stringify(this.user.getData()) const jsonStr = JSON.stringify(this.user.getData())
Laya.LocalStorage.setItem("user", jsonStr) Laya.LocalStorage.setItem("user", jsonStr)
} }
} }
} }
public onUserChanged(): void { public onUserChanged(): void {
this.userChanged = true this.userChanged = true
} }
@@ -62,51 +58,48 @@ export class StorageManager {
this.stageID = stageID this.stageID = stageID
this.stageChanged = true this.stageChanged = true
var index let index
if (type == config.STAGE_TYPE.MAIN) {//主线关卡 if (type == config.STAGE_TYPE.MAIN) { // 主线关卡
index = this.user.get_progress(difficulty) index = this.user.get_progress(difficulty)
var levelStr = LevelManager.getInstance().getLevelStr(difficulty, index) const levelStr = LevelManager.getInstance().getLevelStr(difficulty, index)
if (!levelStr || levelStr.length <= 0) {//说明当前难度已经打通了,所以给他从头开始 if (!levelStr || levelStr.length <= 0) { // 说明当前难度已经打通了,所以给他从头开始
index = 0 index = 0
this.user.update_progress(difficulty, index) this.user.update_progress(difficulty, index)
} }
} } else if (type == config.STAGE_TYPE.DC) { // 每天调整如果已经创建过关卡那么就用之前的关卡配置
else if (type == config.STAGE_TYPE.DC) {//每天调整如果已经创建过关卡那么就用之前的关卡配置 const value = this.getStage(stageID)
var value = this.getStage(stageID)
if (value) { if (value) {
difficulty = value.get_difficulty() difficulty = value.get_difficulty()
index = value.get_stageIndex() index = value.get_stageIndex()
} } else {
else { let random = Math.random()
var random = Math.random() difficulty = config.DIFFICULTY_LIST[Math.floor(random * config.DIFFICULTY_LIST.length)]
difficulty = config.DIFFICULTY_LIST[Math.floor(random*config.DIFFICULTY_LIST.length)] const list = LevelManager.getInstance().getLevelList(difficulty)
var list = LevelManager.getInstance().getLevelList(difficulty)
random = Math.random() random = Math.random()
index = Math.floor(random*list.length) index = Math.floor(random * list.length)
console.log("每日挑战随机一个关卡", difficulty, index) console.log("每日挑战随机一个关卡", difficulty, index)
} }
} }
this.user.update_stage_done(this.stageID, 0)//重置关卡进度 this.user.update_stage_done(this.stageID, 0)// 重置关卡进度
var dataStage: DataStage = createDataStage(stageID, type, name, difficulty, index) const dataStage: DataStage = createDataStage(stageID, type, name, difficulty, index)
var doStage: DOStage = new DOStage(dataStage) const doStage: DOStage = new DOStage(dataStage)
this.stageMap.set(stageID, doStage) this.stageMap.set(stageID, doStage)
return doStage return doStage
} }
public getStage(stageID: string): DOStage {//获取指定关卡数据对象,注意判空 public getStage(stageID: string): DOStage { // 获取指定关卡数据对象,注意判空
if (this.stageMap.has(stageID)) { if (this.stageMap.has(stageID)) {
var doStage: DOStage = this.stageMap.get(stageID) var doStage: DOStage = this.stageMap.get(stageID)
return doStage
} else {
const jsonStr = Laya.LocalStorage.getItem(stageID)
if (jsonStr) {
const dataStage: DataStage = JSON.parse(jsonStr)
var doStage: DOStage = new DOStage(dataStage)
this.stageMap.set(stageID, doStage)
return doStage return doStage
} }
else {
var jsonStr = Laya.LocalStorage.getItem(stageID)
if (jsonStr) {
var dataStage: DataStage = JSON.parse(jsonStr)
var doStage: DOStage = new DOStage(dataStage)
this.stageMap.set(stageID, doStage)
return doStage
}
} }
return null return null
} }
@@ -118,8 +111,8 @@ export class StorageManager {
Laya.LocalStorage.removeItem(stageID) Laya.LocalStorage.removeItem(stageID)
} }
public loadStage(stageID: string): DOStage {//载入关卡 public loadStage(stageID: string): DOStage { // 载入关卡
var doStage = this.getStage(stageID) const doStage = this.getStage(stageID)
if (doStage) { if (doStage) {
this.stageID = stageID this.stageID = stageID
this.stageChanged = false this.stageChanged = false
@@ -129,24 +122,23 @@ export class StorageManager {
return null return null
} }
public saveStage(): void { public saveStage(): void {
if (this.stageChanged) { if (this.stageChanged) {
this.stageChanged = false this.stageChanged = false
if (this.stageMap.has(this.stageID)) { if (this.stageMap.has(this.stageID)) {
var doStage = this.stageMap.get(this.stageID) const doStage = this.stageMap.get(this.stageID)
var jsonStr = JSON.stringify(doStage.getData()) const jsonStr = JSON.stringify(doStage.getData())
Laya.LocalStorage.setItem(this.stageID, jsonStr) Laya.LocalStorage.setItem(this.stageID, jsonStr)
} }
} }
} }
public onStageChanged(): void { public onStageChanged(): void {
this.stageChanged = true this.stageChanged = true
} }
public cleanAll(): void { public cleanAll(): void {
this.user = new DOUser({dones: new Array(), trophy_records: new Array(), progresses: new Array()}) this.user = new DOUser({ dones: [], trophy_records: [], progresses: [] })
this.userChanged = false this.userChanged = false
this.stageID = "" this.stageID = ""
@@ -155,5 +147,4 @@ export class StorageManager {
Laya.LocalStorage.clear() Laya.LocalStorage.clear()
} }
} }

View File

@@ -1,18 +1,17 @@
import { respath } from "../constants/respath" import type { TrophyRecord } from "../types/global"
import { StorageManager } from "./StorageManager" import type { DOStage } from "./DOStage"
import { Stage } from "../views/Stage"
import { DailyChallenge } from "../views/dc/DailyChallenge"
import { TrophyRecord } from "../types/global"
import { TrophyClaim } from "../views/dc/TrophyClaim"
import { TrophyShow } from "../views/dc/TrophyShow"
import { config } from "../constants/config" import { config } from "../constants/config"
import { respath } from "../constants/respath"
import { DailyChallenge } from "../views/dc/DailyChallenge"
import { TrophyClaim } from "../views/dc/TrophyClaim"
import { TrophyRoom } from "../views/dc/TrophyRoom" import { TrophyRoom } from "../views/dc/TrophyRoom"
import { DOStage } from "./DOStage" import { TrophyShow } from "../views/dc/TrophyShow"
import { GamePause } from "../views/GamePause"
import { GameOver } from "../views/GameOver"
import { GameDone } from "../views/GameDone" import { GameDone } from "../views/GameDone"
import { GameOver } from "../views/GameOver"
import { GamePause } from "../views/GamePause"
import { Stage } from "../views/Stage"
import { TopBar } from "../views/TopBar" import { TopBar } from "../views/TopBar"
import { StorageManager } from "./StorageManager"
const { regClass, property } = Laya const { regClass, property } = Laya
@@ -36,8 +35,7 @@ export class UIManager extends Laya.Script {
if (config.H_SCREEN) { if (config.H_SCREEN) {
this.UIRoot.width = config.DESIGN_HEIGHT this.UIRoot.width = config.DESIGN_HEIGHT
this.UIRoot.height = config.DESIGN_WIDTH this.UIRoot.height = config.DESIGN_WIDTH
} } else {
else {
this.UIRoot.width = config.DESIGN_WIDTH this.UIRoot.width = config.DESIGN_WIDTH
this.UIRoot.height = config.DESIGN_HEIGHT this.UIRoot.height = config.DESIGN_HEIGHT
} }
@@ -45,35 +43,33 @@ export class UIManager extends Laya.Script {
return this.UIRoot return this.UIRoot
} }
private topbar : TopBar private topbar: TopBar
private stage: Stage private stage: Stage
private dc_ui: DailyChallenge private dc_ui: DailyChallenge
private trophyRoom: TrophyRoom private trophyRoom: TrophyRoom
onStart(): void { onStart(): void {
if (config.H_SCREEN) { if (config.H_SCREEN) {
this.loadTopBarUI() this.loadTopBarUI()
} } else {
else {
this.loadHomeUI() this.loadHomeUI()
} }
} }
public loadHomeUI(): void { public loadHomeUI(): void {
Laya.loader.load(respath.home_ui_res).then((go)=>{ Laya.loader.load(respath.home_ui_res).then((go) => {
var prefab = go.create() const prefab = go.create()
this.getUIRoot().addChild(prefab) this.getUIRoot().addChild(prefab)
}) })
} }
public loadTopBarUI(): void { public loadTopBarUI(): void {
Laya.loader.load(respath.topbar_ui_res).then((go)=>{ Laya.loader.load(respath.topbar_ui_res).then((go) => {
var prefab = go.create() const prefab = go.create()
this.topbar = this.getUIRoot().addChild(prefab).getComponent(TopBar) this.topbar = this.getUIRoot().addChild(prefab).getComponent(TopBar)
}) })
} }
public setTopbarTo(isClassic: boolean): void { public setTopbarTo(isClassic: boolean): void {
if (this.topbar) { if (this.topbar) {
this.topbar.onClickTab(isClassic) this.topbar.onClickTab(isClassic)
@@ -81,12 +77,13 @@ export class UIManager extends Laya.Script {
} }
public loadDCUI(): void { 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() const prefab = go.create()
this.dc_ui = this.getUIRoot().addChild(prefab).getComponent(DailyChallenge) this.dc_ui = this.getUIRoot().addChild(prefab).getComponent(DailyChallenge)
this.dc_ui.loadWithMonth() this.dc_ui.loadWithMonth()
}) })
} }
public closeDCUI(): void { public closeDCUI(): void {
if (this.dc_ui) { if (this.dc_ui) {
this.dc_ui.owner.destroy() this.dc_ui.owner.destroy()
@@ -95,19 +92,20 @@ export class UIManager extends Laya.Script {
} }
public loadTrophyClaimUI(record: TrophyRecord): void { 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() const prefab = go.create()
var obj = this.getUIRoot().addChild(prefab).getComponent(TrophyClaim) const obj = this.getUIRoot().addChild(prefab).getComponent(TrophyClaim)
obj.onSetShow(record) obj.onSetShow(record)
}) })
} }
public loadTrophyUI(): void { 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() const prefab = go.create()
this.trophyRoom = this.getUIRoot().addChild(prefab).getComponent(TrophyRoom) this.trophyRoom = this.getUIRoot().addChild(prefab).getComponent(TrophyRoom)
}) })
} }
public closeTrophyUI(): void { public closeTrophyUI(): void {
if (this.trophyRoom) { if (this.trophyRoom) {
this.trophyRoom.owner.destroy() this.trophyRoom.owner.destroy()
@@ -116,25 +114,25 @@ export class UIManager extends Laya.Script {
} }
public loadTrophyShowUI(record: TrophyRecord): void { 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() const prefab = go.create()
var obj = this.getUIRoot().addChild(prefab).getComponent(TrophyShow) const obj = this.getUIRoot().addChild(prefab).getComponent(TrophyShow)
obj.onSetShow(record) obj.onSetShow(record)
}) })
} }
public loadStageUI(stageID: string): void { public loadStageUI(stageID: string): void {
if (this.stage) { if (this.stage) {
this.stage.onLoadStage(StorageManager.getInstance().loadStage(stageID)) this.stage.onLoadStage(StorageManager.getInstance().loadStage(stageID))
} } else {
else { Laya.loader.load(respath.stage_ui_res()).then((go) => {
Laya.loader.load(respath.stage_ui_res()).then((go)=>{ const prefab = go.create()
var prefab = go.create()
this.stage = this.getUIRoot().addChild(prefab).getComponent(Stage) this.stage = this.getUIRoot().addChild(prefab).getComponent(Stage)
this.stage.onLoadStage(StorageManager.getInstance().loadStage(stageID)) this.stage.onLoadStage(StorageManager.getInstance().loadStage(stageID))
}) })
} }
} }
public closeStageUI(): void { public closeStageUI(): void {
if (this.stage) { if (this.stage) {
this.stage.owner.destroy() this.stage.owner.destroy()
@@ -143,25 +141,26 @@ export class UIManager extends Laya.Script {
} }
public loadGamePauseUI(doStage: DOStage): void { public loadGamePauseUI(doStage: DOStage): void {
Laya.loader.load(respath.gamepause_ui_res()).then((go)=>{ Laya.loader.load(respath.gamepause_ui_res()).then((go) => {
var prefab = go.create() const prefab = go.create()
var ui = this.getUIRoot().addChild(prefab).getComponent(GamePause) const ui = this.getUIRoot().addChild(prefab).getComponent(GamePause)
ui.onSetStageInfo(doStage)
})
}
public loadGameOverUI(doStage: DOStage): void {
Laya.loader.load(respath.gameover_ui_res()).then((go)=>{
var prefab = go.create()
var ui = this.getUIRoot().addChild(prefab).getComponent(GameOver)
ui.onSetStageInfo(doStage)
})
}
public loadGameDoneUI(isClassic: boolean, doStage: DOStage): void {
Laya.loader.load(respath.gamedone_ui_res(isClassic)).then((go)=>{
var prefab = go.create()
var ui = this.getUIRoot().addChild(prefab).getComponent(GameDone)
ui.onSetStageInfo(doStage) ui.onSetStageInfo(doStage)
}) })
} }
public loadGameOverUI(doStage: DOStage): void {
Laya.loader.load(respath.gameover_ui_res()).then((go) => {
const prefab = go.create()
const ui = this.getUIRoot().addChild(prefab).getComponent(GameOver)
ui.onSetStageInfo(doStage)
})
}
public loadGameDoneUI(isClassic: boolean, doStage: DOStage): void {
Laya.loader.load(respath.gamedone_ui_res(isClassic)).then((go) => {
const prefab = go.create()
const ui = this.getUIRoot().addChild(prefab).getComponent(GameDone)
ui.onSetStageInfo(doStage)
})
}
} }

View File

@@ -1,69 +1,66 @@
// 格子持久化数据结构
//格子持久化数据结构
export interface DataBlock { export interface DataBlock {
index: number, index: number
show: number, show: number
score: number score: number
notes: Array<number>, notes: Array<number>
} }
//撤回数据结构 // 撤回数据结构
export interface DataUndo { export interface DataUndo {
index: number, index: number
show: number, show: number
notes?: Array<number>, notes?: Array<number>
} }
//关卡数据 // 关卡数据
export interface DataStage { export interface DataStage {
id: string,//关卡ID dc关卡格式为年-月-日 id: string// 关卡ID dc关卡格式为年-月-日
type: number, type: number
name: string, name: string
difficulty: string, difficulty: string
index: number, index: number
mistake?: number, mistake?: number
score?: number, score?: number
duration?: number, duration?: number
last_hit_time?: number,//上一次填对计时 last_hit_time?: number// 上一次填对计时
note_open?: boolean, note_open?: boolean
hint?: number, hint?: number
select_index?: number, select_index?: number
blocks?: Array<DataBlock>, blocks?: Array<DataBlock>
undos?: Array<DataUndo>, undos?: Array<DataUndo>
} }
export function createDataStage(id: string, type: number, name: string, difficulty: string, index: number): DataStage { export function createDataStage(id: string, type: number, name: string, difficulty: string, index: number): DataStage {
var data: DataStage = {id: id, type: type, name: name, difficulty: difficulty, index: index} const data: DataStage = { id, type, name, difficulty, index }
data.mistake = 0 data.mistake = 0
data.score = 0 data.score = 0
data.duration = 0 data.duration = 0
data.last_hit_time = 0 data.last_hit_time = 0
data.note_open = false data.note_open = false
data.hint = 2 data.hint = 2
data.select_index = 0 data.select_index = 0
data.blocks = new Array() data.blocks = []
data.undos = new Array() data.undos = []
return data return data
} }
export interface StageProgress { // 关卡完成进度
export interface StageProgress {//关卡完成进度 stageID: string// 关卡ID dc关卡格式为年-月-日
stageID: string,//关卡ID dc关卡格式为年-月-日 progress: number
progress: number,
} }
export interface TrophyRecord { export interface TrophyRecord {
year: number, year: number
month: number, month: number
day: number, day: number
isNew: boolean, isNew: boolean
read: boolean, read: boolean
} }
export interface DataProgress {//关卡难度进度 export interface DataProgress { // 关卡难度进度
difficulty: string, difficulty: string
index: number, index: number
} }
export interface DataUser { export interface DataUser {
dones: Array<StageProgress>,//关卡完成进度 dones: Array<StageProgress>// 关卡完成进度
trophy_records: Array<TrophyRecord>,//奖杯获得记录 trophy_records: Array<TrophyRecord>// 奖杯获得记录
progresses: Array<DataProgress>,//主线各个难度进度 progresses: Array<DataProgress>// 主线各个难度进度
} }

View File

@@ -1,39 +1,33 @@
import { config } from "../constants/config" import { config } from "../constants/config"
export function Utility_ConvertSecondToString(second: number) { export function Utility_ConvertSecondToString(second: number) {
var last = second let last = second
var hour = Math.floor(last/3600) const hour = Math.floor(last / 3600)
last = last - hour * 3600 last = last - hour * 3600
var minite = Math.floor(last/60) const minite = Math.floor(last / 60)
last = last - minite * 60 last = last - minite * 60
var second = Math.floor(last) var second = Math.floor(last)
function format(value: number) { function format(value: number) {
return value>=10?value.toString():("0"+value) return value >= 10 ? value.toString() : (`0${value}`)
} }
return `${format(hour)}:${format(minite)}:${format(second)}` return `${format(hour)}:${format(minite)}:${format(second)}`
} }
//计算积分 // 计算积分
export function Utility_CalculateScore(difficulty: string, second: number): number { export function Utility_CalculateScore(difficulty: string, second: number): number {
var score = 0 let score = 0
var currentTime = Math.min(120, second) const currentTime = Math.min(120, second)
if (difficulty == config.DIFFICULTY_TYPE.Easy) { if (difficulty == config.DIFFICULTY_TYPE.Easy) {
score = 270 - currentTime score = 270 - currentTime
} } else if (difficulty == config.DIFFICULTY_TYPE.Medium) {
else if (difficulty == config.DIFFICULTY_TYPE.Medium) { score = 420 - currentTime * 2
score = 420 - currentTime * 2 } else if (difficulty == config.DIFFICULTY_TYPE.Hard) {
} score = 760 - currentTime * 3
else if (difficulty == config.DIFFICULTY_TYPE.Hard) { } else if (difficulty == config.DIFFICULTY_TYPE.Expert) {
score = 760 - currentTime * 3 score = 1120 - currentTime * 3
} } else if (difficulty == config.DIFFICULTY_TYPE.Extreme) {
else if (difficulty == config.DIFFICULTY_TYPE.Expert) { score = 1320 - currentTime * 4
score = 1120 - currentTime * 3 }
} // console.log("计算积分 >>>>>", difficulty, second, score)
else if (difficulty == config.DIFFICULTY_TYPE.Extreme) { return score
score = 1320 - currentTime * 4
}
// console.log("计算积分 >>>>>", difficulty, second, score)
return score
} }

View File

@@ -1,205 +1,200 @@
import { G_ShowScoreTips } from "../views/common/GUITips"; import type { DOBlock } from "../models/DOBlock"
import { DOBlock } from "../models/DOBlock"; import { config } from "../constants/config"
import { config } from "../constants/config"; import { G_ShowScoreTips } from "../views/common/GUITips"
const { regClass, property } = Laya; const { regClass, property } = Laya
@regClass() @regClass()
export class Block extends Laya.Script { export class Block extends Laya.Script {
declare owner : Laya.Sprite; declare owner: Laya.Sprite
@property(Number) @property(Number)
public XIndex: number = 0; public XIndex: number = 0
@property(Number)
public YIndex: number = 0;
@property(Number)
public XGroup: number = 0;
@property(Number)
public YGroup: number = 0;
private tips_bgs: Array<Laya.Sprite> = new Array(); @property(Number)
private label_show: Laya.Label; public YIndex: number = 0
private tips_labels: Array<Laya.Label> = new Array();
private selected: boolean = false @property(Number)
public XGroup: number = 0
private data: DOBlock @property(Number)
public YGroup: number = 0
private tips_bgs: Array<Laya.Sprite> = []
private label_show: Laya.Label
private tips_labels: Array<Laya.Label> = []
public onInit(XIndex: number, YIndex: number, XGroup: number, YGroup: number, label_obj: Laya.Box, handler: any, func: any): void { private selected: boolean = false
this.XIndex = XIndex;
this.YIndex = YIndex;
this.XGroup = XGroup;
this.YGroup = YGroup;
var VBox = this.owner.getChildByName("VBox") private data: DOBlock
for (var i=0; i<VBox.numChildren; i++) {
var hbox = VBox.getChildAt(i) public onInit(XIndex: number, YIndex: number, XGroup: number, YGroup: number, label_obj: Laya.Box, handler: any, func: any): void {
for (var j=0; j<hbox.numChildren; j++) { this.XIndex = XIndex
var sp = hbox.getChildAt(j) as Laya.Sprite this.YIndex = YIndex
this.tips_bgs.push(sp) this.XGroup = XGroup
} this.YGroup = YGroup
}
this.label_show = label_obj.getChildByName("label_show") as Laya.Label let VBox = this.owner.getChildByName("VBox")
// this.label_show.text = XGroup + "" + YGroup for (var i = 0; i < VBox.numChildren; i++) {
VBox = label_obj.getChildByName("VBox") var hbox = VBox.getChildAt(i)
for (var i=0; i<VBox.numChildren; i++) { for (var j = 0; j < hbox.numChildren; j++) {
var hbox = VBox.getChildAt(i); const sp = hbox.getChildAt(j) as Laya.Sprite
for (var j=0; j<hbox.numChildren; j++) { this.tips_bgs.push(sp)
var Label = hbox.getChildAt(j) as Laya.Label }
Label.text = ""
this.tips_labels.push(Label)
}
}
this.owner.on(Laya.Event.CLICK, handler, func);
} }
this.label_show = label_obj.getChildByName("label_show") as Laya.Label
public setSelected(selected: boolean): void { // this.label_show.text = XGroup + "" + YGroup
this.selected = selected VBox = label_obj.getChildByName("VBox")
this.updateBlock() for (var i = 0; i < VBox.numChildren; i++) {
var hbox = VBox.getChildAt(i)
for (var j = 0; j < hbox.numChildren; j++) {
const Label = hbox.getChildAt(j) as Laya.Label
Label.text = ""
this.tips_labels.push(Label)
}
} }
this.owner.on(Laya.Event.CLICK, handler, func)
}
public setBlockColor(color: string, alpha: number=1, animated: boolean=false, completedColor: string = "", completedAlpha: number=1): void { public setSelected(selected: boolean): void {
var blockSize = 116 this.selected = selected
if (config.H_SCREEN) this.updateBlock()
blockSize = 96 }
public setBlockColor(color: string, alpha: number = 1, animated: boolean = false, completedColor: string = "", completedAlpha: number = 1): void {
let blockSize = 116
if (config.H_SCREEN)
blockSize = 96
this.owner.graphics.clear()
this.owner.graphics.drawRect(0, 0, blockSize, blockSize, color)
if (animated) {
this.owner.alpha = 0
Laya.Tween.to(this.owner, { alpha }, 100, Laya.Ease.linearIn)
Laya.Tween.to(this.owner, { alpha: 0 }, 150, Laya.Ease.linearIn, null, 100)
Laya.Tween.to(this.owner, { alpha }, 100, Laya.Ease.linearIn, Laya.Handler.create(this, () => {
this.owner.graphics.clear() this.owner.graphics.clear()
this.owner.graphics.drawRect(0, 0, blockSize, blockSize, color) this.owner.graphics.drawRect(0, 0, blockSize, blockSize, completedColor)
if (animated) { this.owner.alpha = completedAlpha
this.owner.alpha = 0 }), 250)
Laya.Tween.to(this.owner, {alpha:alpha}, 100, Laya.Ease.linearIn) } else {
Laya.Tween.to(this.owner, {alpha:0}, 150, Laya.Ease.linearIn, null, 100) this.owner.alpha = alpha
Laya.Tween.to(this.owner, {alpha:alpha}, 100, Laya.Ease.linearIn, Laya.Handler.create(this, () => {
this.owner.graphics.clear()
this.owner.graphics.drawRect(0, 0, blockSize, blockSize, completedColor)
this.owner.alpha = completedAlpha
}), 250)
}
else {
this.owner.alpha = alpha
}
} }
}
public setFadeAnimation(): void { public setFadeAnimation(): void {
Laya.timer.once(200, this, ()=>{ Laya.timer.once(200, this, () => {
this.label_show.color = "#ff0000" this.label_show.color = "#ff0000"
Laya.timer.once(100, this, ()=>{ Laya.timer.once(100, this, () => {
this.label_show.color = "#2d3138" this.label_show.color = "#2d3138"
Laya.timer.once(200, this, ()=>{ Laya.timer.once(200, this, () => {
this.label_show.color = "#ff0000" this.label_show.color = "#ff0000"
Laya.timer.once(100, this, ()=>{ Laya.timer.once(100, this, () => {
this.updateBlock() this.updateBlock()
}) })
})
})
}) })
})
})
}
public setTipsBgColor(visible: boolean, noteNumber: number = 0, color: string = "", alpha: number = 1): void {
let 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, blockSize, blockSize, color)
obj.alpha = alpha
} else {
for (let i = 0; i < this.tips_bgs.length; i++) {
var obj = this.tips_bgs[i]
obj.visible = false
}
}
}
public setBlock(data: DOBlock): void {
this.data = data
this.updateBlock()
}
public getData(): DOBlock {
return this.data
}
public setShowNumber(showNumber: number, score: number): boolean {
this.data.set_show(showNumber)
if (this.data.get_checked()) {
this.data.set_score(score)
if (score > 0)
G_ShowScoreTips(score.toString(), this.label_show.parent)
} else {
if (this.data.get_score() != 0)
this.data.set_score(0)
}
this.data.clean_notes()
this.updateBlock()
return this.data.get_checked()
}
public addNoteNumber(noteNumber: number): void {
this.data.set_show(0)
const note_numbers = this.data.get_notes()
const find = note_numbers.indexOf(noteNumber)
if (find >= 0) {
this.data.remove_note(noteNumber)
} else {
this.data.add_note(noteNumber)
}
this.updateBlock()
}
public setNotes(notes: Array<number>): void {
this.data.set_show(0)
this.data.clean_notes()
for (let i = 0; i < notes.length; i++) {
this.data.add_note(notes[i])
}
this.updateBlock()
}
updateBlock(): void {
// 设置文字颜色
if (this.selected) {
this.label_show.color = "#ffffff"
for (var i = 0; i < this.tips_labels.length; i++) {
this.tips_labels[i].color = "#ffffff"
}
} else {
if (this.data.get_show() == this.data.get_correct()) {
if (this.data.get_preset()) {
this.label_show.color = "#2d3138"
} else {
this.label_show.color = "#2559c0"
}
} else {
this.label_show.color = "#cb3256"
}
for (var i = 0; i < this.tips_labels.length; i++) {
this.tips_labels[i].color = "#2d3138"
}
} }
public setTipsBgColor(visible: boolean, noteNumber: number=0, color: string="", alpha: number=1): void { for (var i = 0; i < this.tips_labels.length; i++) {
var blockSize = 38 this.tips_labels[i].text = ""
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, blockSize, blockSize, color)
obj.alpha = alpha
}
else {
for (var i=0; i<this.tips_bgs.length; i++) {
var obj = this.tips_bgs[i]
obj.visible = false
}
}
} }
if (this.data.get_show() > 0) {
public setBlock(data: DOBlock): void { this.label_show.text = this.data.get_show().toString()
this.data = data; } else {
this.updateBlock(); this.label_show.text = ""
const note_numbers = this.data.get_notes()
for (var i = 0; i < note_numbers.length; i++) {
const value = note_numbers[i]
const label = this.tips_labels[value - 1]
label.text = value.toString()
}
} }
public getData(): DOBlock { }
return this.data
}
public setShowNumber(showNumber: number, score: number): boolean {
this.data.set_show(showNumber)
if (this.data.get_checked()) {
this.data.set_score(score)
if (score > 0)
G_ShowScoreTips(score.toString(), this.label_show.parent)
}
else {
if (this.data.get_score() != 0)
this.data.set_score(0)
}
this.data.clean_notes()
this.updateBlock()
return this.data.get_checked()
}
public addNoteNumber(noteNumber: number): void {
this.data.set_show(0)
var note_numbers = this.data.get_notes()
var find = note_numbers.indexOf(noteNumber)
if (find >= 0) {
this.data.remove_note(noteNumber)
}
else {
this.data.add_note(noteNumber)
}
this.updateBlock()
}
public setNotes(notes: Array<number>): void {
this.data.set_show(0)
this.data.clean_notes()
for (var i=0; i<notes.length; i++) {
this.data.add_note(notes[i])
}
this.updateBlock()
}
updateBlock(): void {
//设置文字颜色
if (this.selected) {
this.label_show.color = "#ffffff"
for (var i=0; i<this.tips_labels.length; i++) {
this.tips_labels[i].color = "#ffffff"
}
}
else {
if (this.data.get_show() == this.data.get_correct()) {
if (this.data.get_preset()) {
this.label_show.color = "#2d3138"
}
else {
this.label_show.color = "#2559c0"
}
}
else {
this.label_show.color = "#cb3256"
}
for (var i=0; i<this.tips_labels.length; i++) {
this.tips_labels[i].color = "#2d3138"
}
}
for (var i=0; i<this.tips_labels.length; i++) {
this.tips_labels[i].text = ""
}
if (this.data.get_show() > 0) {
this.label_show.text = this.data.get_show().toString()
}
else {
this.label_show.text = "";
var note_numbers = this.data.get_notes()
for (var i=0; i<note_numbers.length; i++) {
var value = note_numbers[i]
var label = this.tips_labels[value-1]
label.text = value.toString()
}
}
}
} }

View File

@@ -1,62 +1,57 @@
const { regClass, property } = Laya
const { regClass, property } = Laya;
@regClass() @regClass()
export class Candy extends Laya.Script { export class Candy extends Laya.Script {
declare owner : Laya.Box; declare owner: Laya.Box
private show_sprite: Laya.Sprite private show_sprite: Laya.Sprite
private label_show: Laya.Label; private label_show: Laya.Label
private label_left: Laya.Label; private label_left: Laya.Label
private show: number private show: number
private left: number private left: number
public onInit(label_obj: Laya.Box, handler: any, func: any): void { public onInit(label_obj: Laya.Box, handler: any, func: any): void {
this.owner.on(Laya.Event.CLICK, handler, func) this.owner.on(Laya.Event.CLICK, handler, func)
this.show_sprite = this.owner.getChildByName("Sprite") as Laya.Sprite this.show_sprite = this.owner.getChildByName("Sprite") as Laya.Sprite
this.label_show = label_obj.getChildByName("label") as Laya.Label this.label_show = label_obj.getChildByName("label") as Laya.Label
this.label_left = label_obj.getChildByName("label_left") as Laya.Label this.label_left = label_obj.getChildByName("label_left") as Laya.Label
}
public setNoteStatus(note_open: boolean) {
if (note_open) {
this.show_sprite.visible = false
this.label_show.color = "#7b818c"
} else {
this.show_sprite.visible = true
this.label_show.color = "#2559c0"
}
}
public setCandy(show: number, left: number): void {
this.show = show
this.left = left
this.updateCandy()
}
public get_show(): number {
return this.show
}
updateCandy(): void {
if (this.show > 0) {
this.label_show.text = this.show.toString()
} else {
this.label_show.text = ""
} }
public setNoteStatus(note_open: boolean) { if (this.left > 0) {
if (note_open) { this.label_left.text = this.left.toString()
this.show_sprite.visible = false this.owner.visible = true
this.label_show.color = "#7b818c" } else {
} this.label_left.text = ""
else { this.owner.visible = false
this.show_sprite.visible = true this.label_show.text = ""
this.label_show.color = "#2559c0"
}
}
public setCandy(show: number, left: number): void {
this.show = show
this.left = left
this.updateCandy()
}
public get_show(): number {
return this.show
}
updateCandy(): void {
if (this.show > 0) {
this.label_show.text = this.show.toString()
}
else {
this.label_show.text = ""
}
if (this.left > 0) {
this.label_left.text = this.left.toString();
this.owner.visible = true
}
else {
this.label_left.text = ""
this.owner.visible = false
this.label_show.text = ""
}
} }
}
} }

View File

@@ -1,59 +1,61 @@
import { respath } from "../constants/respath"; import { respath } from "../constants/respath"
import { UIManager } from "../models/UIManager"; import { UIManager } from "../models/UIManager"
const { regClass, property } = Laya;
const { regClass, property } = Laya
export function G_ShowCommonTips(title: string, content: string, showToggle: boolean, func: any): void { export function G_ShowCommonTips(title: string, content: string, showToggle: boolean, func: any): void {
Laya.loader.load(respath.common_tips_ui_res).then((go)=>{ Laya.loader.load(respath.common_tips_ui_res).then((go) => {
var prefab = go.create() const prefab = go.create()
var obj = UIManager.getInstance().getUIRoot().addChild(prefab).getComponent(CommonTips) const obj = UIManager.getInstance().getUIRoot().addChild(prefab).getComponent(CommonTips)
obj.showCommonTips(title, content, showToggle, func) obj.showCommonTips(title, content, showToggle, func)
}) })
} }
@regClass() @regClass()
export class CommonTips extends Laya.Script { export class CommonTips extends Laya.Script {
declare owner : Laya.Box; declare owner: Laya.Box
@property(Laya.Label) @property(Laya.Label)
public label_title: Laya.Label public label_title: Laya.Label
@property(Laya.Label)
public label_content: Laya.Label
@property(Laya.Box) @property(Laya.Label)
public btn_ok: Laya.Box public label_content: Laya.Label
@property(Laya.Box)
public btn_cancel: Laya.Box
@property(Laya.Box) @property(Laya.Box)
public toggle: Laya.Box public btn_ok: Laya.Box
@property(Laya.Image)
public check: Laya.Image
private isChecked = false
public showCommonTips(title: string, content: string, showToggle: boolean, func: any): void { @property(Laya.Box)
this.label_title.text = title public btn_cancel: Laya.Box
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, ()=>{ @property(Laya.Box)
if (func) { public toggle: Laya.Box
func(true, this.isChecked)
}
this.owner.destroy()
})
this.btn_cancel.on(Laya.Event.CLICK, this, ()=>{
if (func) {
func(false, this.isChecked)
}
this.owner.destroy()
})
} @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()
})
}
} }

View File

@@ -1,48 +1,46 @@
import { config } from "../constants/config"; import { config } from "../constants/config"
import { CommonData } from "./common/CommonData"; import { CommonData } from "./common/CommonData"
const { regClass, property } = Laya; const { regClass, property } = Laya
@regClass() @regClass()
export class Difficulty extends Laya.Script { export class Difficulty extends Laya.Script {
declare owner : Laya.Box; declare owner: Laya.Box
@property(Laya.Box)
public obj_items: Laya.Box
@property(Laya.Box) // 组件被激活后执行,此时所有节点和组件均已创建完毕,此方法只执行一次
public obj_items: Laya.Box; onAwake(): void {
const offset = this.owner.getChildByName("offset") as Laya.Box
const bg = offset.getChildByName("bg") as Laya.Sprite
bg.graphics.clear()
bg.graphics.drawRoundRect(0, 0, offset.width, offset.height, 20, 20, 0, 0, "#f5f7fb")
Laya.Tween.to(offset, { y: 705 }, 500)
//组件被激活后执行,此时所有节点和组件均已创建完毕,此方法只执行一次 const mask = this.owner.getChildByName("mask")
onAwake(): void { mask.on(Laya.Event.CLICK, this, () => {
var offset = this.owner.getChildByName("offset") as Laya.Box Laya.Tween.to(offset, { y: 2400 }, 500, null, Laya.Handler.create(this, () => {
var bg = offset.getChildByName("bg") as Laya.Sprite this.owner.destroy()
bg.graphics.clear() }))
bg.graphics.drawRoundRect(0, 0, offset.width, offset.height, 20, 20, 0, 0, "#f5f7fb") })
}
Laya.Tween.to(offset, {y: 705}, 500) public onInit(callback: any): void {
for (let i = 0; i < config.DIFFICULTY_LIST.length; i++) {
var mask = this.owner.getChildByName("mask") const obj = this.obj_items.getChildAt(i)
mask.on(Laya.Event.CLICK, this, ()=>{ const Label = obj.getChildByName("Label") as Laya.Label
Laya.Tween.to(offset, {y: 2400}, 500, null, Laya.Handler.create(this, () => { Label.text = config.DIFFICULTY_LIST[i]
this.owner.destroy() const data = obj.getComponent(CommonData)
})) data.strValue = config.DIFFICULTY_LIST[i]
}) obj.on(Laya.Event.CLICK, this, (evt: Laya.Event) => {
} const data = evt.target.getComponent(CommonData)
if (callback) {
public onInit(callback: any): void { callback(data.strValue)
for (var i=0; i<config.DIFFICULTY_LIST.length; i++) {
var obj = this.obj_items.getChildAt(i)
var Label = obj.getChildByName("Label") as Laya.Label
Label.text = config.DIFFICULTY_LIST[i]
var data = obj.getComponent(CommonData)
data.strValue = config.DIFFICULTY_LIST[i]
obj.on(Laya.Event.CLICK, this, (evt: Laya.Event)=>{
var data = evt.target.getComponent(CommonData)
if (callback) {
callback(data.strValue)
}
this.owner.destroy()
})
} }
this.owner.destroy()
})
} }
}
} }

View File

@@ -1,88 +1,87 @@
import { UIManager } from "../models/UIManager"; import type { DOStage } from "../models/DOStage"
import { StorageManager } from "../models/StorageManager"; import { config } from "../constants/config"
import { Utility_ConvertSecondToString } from "../utils/utility"; import { respath } from "../constants/respath"
import { respath } from "../constants/respath"; import { StorageManager } from "../models/StorageManager"
import { Difficulty } from "./Difficulty"; import { UIManager } from "../models/UIManager"
import { config } from "../constants/config"; import { Utility_ConvertSecondToString } from "../utils/utility"
import { DOStage } from "../models/DOStage"; import { Difficulty } from "./Difficulty"
const { regClass, property } = Laya; const { regClass, property } = Laya
@regClass() @regClass()
export class GameDone extends Laya.Script { export class GameDone extends Laya.Script {
declare owner : Laya.Box; declare owner: Laya.Box
@property(Laya.Label) @property(Laya.Label)
public label_diffucuty: Laya.Label public label_diffucuty: Laya.Label
@property(Laya.Label)
public label_time: Laya.Label
@property(Laya.Label)
public label_score: Laya.Label
@property(Laya.Box) @property(Laya.Label)
public btn_new: Laya.Box public label_time: Laya.Label
@property(Laya.Box)
public btn_home: Laya.Box
@property(Laya.Box)
public btn_continue: Laya.Box
@property(Laya.Label)
public label_score: Laya.Label
onStart(): void { @property(Laya.Box)
public btn_new: Laya.Box
} @property(Laya.Box)
public btn_home: Laya.Box
public onSetStageInfo(doStage: DOStage): void { @property(Laya.Box)
this.label_diffucuty.text = doStage.get_difficulty() public btn_continue: Laya.Box
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) => { onStart(): void {
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()) public onSetStageInfo(doStage: DOStage): void {
UIManager.getInstance().loadStageUI(config.DEFAULT_STAGE_ID); 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) => {
if (config.H_SCREEN) {
const 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) => {
const prefab = go.create()
const 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.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_continue.on(Laya.Event.CLICK, this, (evt: Laya.Event) => {//这个按钮只有从DC来的会显示 this.btn_continue.on(Laya.Event.CLICK, this, (evt: Laya.Event) => { // 这个按钮只有从DC来的会显示
UIManager.getInstance().loadDCUI() UIManager.getInstance().loadDCUI()
UIManager.getInstance().closeStageUI(); UIManager.getInstance().closeStageUI()
this.owner.destroy() this.owner.destroy()
}) })
this.btn_home.on(Laya.Event.CLICK, this, (evt: Laya.Event) => { this.btn_home.on(Laya.Event.CLICK, this, (evt: Laya.Event) => {
if (config.H_SCREEN) { if (config.H_SCREEN) {
UIManager.getInstance().closeDCUI() UIManager.getInstance().closeDCUI()
if (doStage.get_stageType() == config.STAGE_TYPE.MAIN) { if (doStage.get_stageType() == config.STAGE_TYPE.MAIN) {
var user = StorageManager.getInstance().getUser() const user = StorageManager.getInstance().getUser()
user.update_progress(doStage.get_difficulty(), doStage.get_stageIndex()+1)//主线关卡更新难度进度 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()) StorageManager.getInstance().newStage(config.DEFAULT_STAGE_ID, config.STAGE_TYPE.MAIN, doStage.get_difficulty(), doStage.get_difficulty())
UIManager.getInstance().loadStageUI(config.DEFAULT_STAGE_ID); UIManager.getInstance().loadStageUI(config.DEFAULT_STAGE_ID)
} } else if (doStage.get_stageType() == config.STAGE_TYPE.DC) {
else if (doStage.get_stageType() == config.STAGE_TYPE.DC) { UIManager.getInstance().setTopbarTo(true)
UIManager.getInstance().setTopbarTo(true)
}
} }
else { } else {
UIManager.getInstance().loadHomeUI() UIManager.getInstance().loadHomeUI()
UIManager.getInstance().closeStageUI(); UIManager.getInstance().closeStageUI()
} }
this.owner.destroy() this.owner.destroy()
}) })
}
}
} }

View File

@@ -1,81 +1,76 @@
import { respath } from "../constants/respath"; import type { DOStage } from "../models/DOStage"
import { config } from "../constants/config"; import { config } from "../constants/config"
import { UIManager } from "../models/UIManager"; import { respath } from "../constants/respath"
import { StorageManager } from "../models/StorageManager"; import { EVENT_TYPES, EventManager } from "../models/EventManager"
import { EventManager, EVENT_TYPES } from "../models/EventManager"; import { StorageManager } from "../models/StorageManager"
import { Difficulty } from "./Difficulty"; import { UIManager } from "../models/UIManager"
import { DOStage } from "../models/DOStage"; import { Difficulty } from "./Difficulty"
const { regClass, property } = Laya; const { regClass, property } = Laya
@regClass() @regClass()
export class GameOver extends Laya.Script { export class GameOver extends Laya.Script {
declare owner : Laya.Box; declare owner: Laya.Box
@property(Laya.Sprite)
public btn_second: Laya.Sprite
@property(Laya.Sprite) @property(Laya.Sprite)
public btn_second: Laya.Sprite public btn_restart: Laya.Sprite
@property(Laya.Sprite) @property(Laya.Sprite)
public btn_restart: Laya.Sprite public btn_newOrClose: Laya.Sprite
@property(Laya.Sprite) @property(Laya.Label)
public btn_newOrClose: Laya.Sprite public label_newOrClose: Laya.Label
@property(Laya.Label)
public label_newOrClose: Laya.Label
public onSetStageInfo(doStage: DOStage): void {
this.btn_second.on(Laya.Event.CLICK, this, (evt: Laya.Event) => {
doStage.set_mistake(doStage.get_mistake() - 1)
EventManager.getInstance().DispatchEvent(EVENT_TYPES.NOT_UPDATE_MISTAKE)
this.owner.destroy()
})
public onSetStageInfo(doStage: DOStage): void { this.btn_restart.on(Laya.Event.CLICK, this, (evt: Laya.Event) => {
const stageID = doStage.get_stageID()
const type = doStage.get_stageType()
const difficulty = doStage.get_difficulty()
StorageManager.getInstance().newStage(stageID, type, difficulty, difficulty)
UIManager.getInstance().loadStageUI(stageID)
this.owner.destroy()
})
this.btn_second.on(Laya.Event.CLICK, this, (evt: Laya.Event) => { const type = doStage.get_stageType()
doStage.set_mistake(doStage.get_mistake()-1) if (type == config.STAGE_TYPE.MAIN) {
EventManager.getInstance().DispatchEvent(EVENT_TYPES.NOT_UPDATE_MISTAKE) this.label_newOrClose.text = "New Game"
this.owner.destroy() this.btn_newOrClose.on(Laya.Event.CLICK, this, (evt: Laya.Event) => {
if (config.H_SCREEN) {
const user = StorageManager.getInstance().getUser()
user.update_progress(doStage.get_difficulty(), doStage.get_stageIndex() + 1)// 主线关卡更新难度进度
const 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) => {
const prefab = go.create()
const 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 {
this.btn_restart.on(Laya.Event.CLICK, this, (evt: Laya.Event) => { this.label_newOrClose.text = "Close"
var stageID = doStage.get_stageID() this.btn_newOrClose.on(Laya.Event.CLICK, this, (evt: Laya.Event) => {
var type = doStage.get_stageType() UIManager.getInstance().loadDCUI()
var difficulty = doStage.get_difficulty() UIManager.getInstance().closeStageUI()
StorageManager.getInstance().newStage(stageID, type, difficulty, difficulty)
UIManager.getInstance().loadStageUI(stageID);
this.owner.destroy() this.owner.destroy()
}) })
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) => {
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 {
this.label_newOrClose.text = "Close"
this.btn_newOrClose.on(Laya.Event.CLICK, this, (evt: Laya.Event) => {
UIManager.getInstance().loadDCUI()
UIManager.getInstance().closeStageUI();
this.owner.destroy()
})
}
} }
}
} }

View File

@@ -1,54 +1,49 @@
import type { DOStage } from "../models/DOStage"
import { EVENT_TYPES, EventManager } from "../models/EventManager"
import { StorageManager } from "../models/StorageManager"
import { UIManager } from "../models/UIManager"
import { Utility_ConvertSecondToString } from "../utils/utility"
const { regClass, property } = Laya
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";
const { regClass, property } = Laya;
@regClass() @regClass()
export class GamePause extends Laya.Script { export class GamePause extends Laya.Script {
declare owner : Laya.Box; declare owner: Laya.Box
@property(Laya.Label) @property(Laya.Label)
public label_time: Laya.Label public label_time: Laya.Label
@property(Laya.Label)
public label_diffucuty: Laya.Label
@property(Laya.Sprite) @property(Laya.Label)
public btn_continue: Laya.Sprite public label_diffucuty: Laya.Label
@property(Laya.Sprite)
public btn_restart: Laya.Sprite
@property(Laya.Sprite)
public btn_continue: Laya.Sprite
//组件被激活后执行,此时所有节点和组件均已创建完毕,此方法只执行一次 @property(Laya.Sprite)
onAwake(): void { public btn_restart: Laya.Sprite
} // 组件被激活后执行,此时所有节点和组件均已创建完毕,此方法只执行一次
onAwake(): void {
public onSetStageInfo(doStage: DOStage): void { }
this.label_time.text = Utility_ConvertSecondToString(doStage.get_duration()) public onSetStageInfo(doStage: DOStage): void {
this.label_diffucuty.text = doStage.get_difficulty() 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) EventManager.getInstance().DispatchEvent(EVENT_TYPES.NOT_UPDATE_PAUSE, true)
this.btn_continue.on(Laya.Event.CLICK, this, (evt: Laya.Event) => { this.btn_continue.on(Laya.Event.CLICK, this, (evt: Laya.Event) => {
EventManager.getInstance().DispatchEvent(EVENT_TYPES.NOT_UPDATE_PAUSE, false) EventManager.getInstance().DispatchEvent(EVENT_TYPES.NOT_UPDATE_PAUSE, false)
this.owner.destroy() this.owner.destroy()
}) })
this.btn_restart.on(Laya.Event.CLICK, this, (evt: Laya.Event) => { this.btn_restart.on(Laya.Event.CLICK, this, (evt: Laya.Event) => {
var stageID = doStage.get_stageID() const stageID = doStage.get_stageID()
var type = doStage.get_stageType() const type = doStage.get_stageType()
var difficulty = doStage.get_difficulty() const difficulty = doStage.get_difficulty()
StorageManager.getInstance().newStage(stageID, type, difficulty, difficulty) StorageManager.getInstance().newStage(stageID, type, difficulty, difficulty)
UIManager.getInstance().loadStageUI(stageID); UIManager.getInstance().loadStageUI(stageID)
this.owner.destroy() this.owner.destroy()
}) })
}
}
} }

View File

@@ -1,168 +1,164 @@
import { config } from "../constants/config"
import { UIManager } from "../models/UIManager"; import { respath } from "../constants/respath"
import { StorageManager } from "../models/StorageManager"; import { G_getMonthInfo } from "../models/DCManager"
import { respath } from "../constants/respath"; import { StorageManager } from "../models/StorageManager"
import { Difficulty } from "./Difficulty"; import { UIManager } from "../models/UIManager"
import { LevelManager } from "../models/LevelManager"; import { Utility_ConvertSecondToString } from "../utils/utility"
import { config } from "../constants/config"; import { Difficulty } from "./Difficulty"
import { Utility_ConvertSecondToString } from "../utils/utility";
import { G_getMonthInfo } from "../models/DCManager";
const { regClass, property } = Laya const { regClass, property } = Laya
@regClass() @regClass()
export class Home extends Laya.Script { export class Home extends Laya.Script {
declare owner : Laya.Box; declare owner: Laya.Box
@property(Laya.Image) @property(Laya.Image)
public bg_dc: Laya.Image; public bg_dc: Laya.Image
@property(Laya.Image)
public icon_dc: Laya.Image;
@property(Laya.Label)
public label_dc_title: Laya.Label;
@property(Laya.Label)
public label_dc_date: Laya.Label;
@property(Laya.Sprite)
public btn_play: Laya.Sprite;
@property(Laya.Sprite)
public btn_continue: Laya.Sprite;
@property(Laya.Sprite)
public btn_more: Laya.Sprite;
@property(Laya.Box) @property(Laya.Image)
public btn_new_blue: Laya.Box; public icon_dc: Laya.Image
@property(Laya.Box)
public btn_go: Laya.Box;
@property(Laya.Box)
public btn_new_white: Laya.Box;
@property(Laya.Box) @property(Laya.Label)
public btn_clean: Laya.Box; public label_dc_title: Laya.Label
//组件被激活后执行,此时所有节点和组件均已创建完毕,此方法只执行一次 @property(Laya.Label)
onAwake(): void { public label_dc_date: Laya.Label
var user = StorageManager.getInstance().getUser()
var now = new Date() @property(Laya.Sprite)
var nowYear = now.getFullYear() public btn_play: Laya.Sprite
var nowMonth = now.getMonth() + 1
var nowDay = now.getDate() @property(Laya.Sprite)
var find = G_getMonthInfo(nowYear, nowMonth) public btn_continue: Laya.Sprite
if (find) {
this.icon_dc.skin = find.icon_res @property(Laya.Sprite)
if (user.get_doneCountByDate(nowYear, nowMonth) >= find.dayCount) { public btn_more: Laya.Sprite
this.bg_dc.skin = respath.home_top_dc_bg_finish
this.label_dc_title.color = "#ffffff" @property(Laya.Box)
this.label_dc_date.color = "#ffffff" public btn_new_blue: Laya.Box
}
else { @property(Laya.Box)
this.bg_dc.skin = respath.home_top_dc_bg_normal public btn_go: Laya.Box
this.label_dc_title.color = "#2d3138"
this.label_dc_date.color = "#2d3138" @property(Laya.Box)
} public btn_new_white: Laya.Box
}
else { @property(Laya.Box)
public btn_clean: Laya.Box
// 组件被激活后执行,此时所有节点和组件均已创建完毕,此方法只执行一次
onAwake(): void {
var user = StorageManager.getInstance().getUser()
const now = new Date()
const nowYear = now.getFullYear()
const nowMonth = now.getMonth() + 1
const nowDay = now.getDate()
const find = G_getMonthInfo(nowYear, nowMonth)
if (find) {
this.icon_dc.skin = find.icon_res
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"
} else {
this.bg_dc.skin = respath.home_top_dc_bg_normal this.bg_dc.skin = respath.home_top_dc_bg_normal
this.label_dc_title.color = "#2d3138" this.label_dc_title.color = "#2d3138"
this.label_dc_date.color = "#2d3138" this.label_dc_date.color = "#2d3138"
} }
} else {
this.bg_dc.skin = respath.home_top_dc_bg_normal
this.label_dc_title.color = "#2d3138"
this.label_dc_date.color = "#2d3138"
}
var stageID = `${nowYear}-${nowMonth}-${nowDay}` const stageID = `${nowYear}-${nowMonth}-${nowDay}`
this.label_dc_date.text = `${config.MONTH_ABBRS[nowMonth-1]} ${nowDay}` this.label_dc_date.text = `${config.MONTH_ABBRS[nowMonth - 1]} ${nowDay}`
var progress = user.get_done(stageID) const progress = user.get_done(stageID)
if (progress <= 0) { if (progress <= 0) {
this.btn_play.visible = true this.btn_play.visible = true
this.btn_continue.visible = false this.btn_continue.visible = false
this.btn_more.visible = false this.btn_more.visible = false
this.btn_play.on(Laya.Event.CLICK, this, ()=>{//Play this.btn_play.on(Laya.Event.CLICK, this, () => { // Play
var stageName = `${config.MONTH_ABBRS[nowMonth-1]} ${nowDay}` const stageName = `${config.MONTH_ABBRS[nowMonth - 1]} ${nowDay}`
StorageManager.getInstance().newStage(stageID, config.STAGE_TYPE.DC, stageName) StorageManager.getInstance().newStage(stageID, config.STAGE_TYPE.DC, stageName)
UIManager.getInstance().loadStageUI(stageID); UIManager.getInstance().loadStageUI(stageID)
this.owner.destroy()
})
}
else if (progress >= 1) {
this.btn_play.visible = false
this.btn_continue.visible = false
this.btn_more.visible = true
this.btn_more.on(Laya.Event.CLICK, this, ()=>{//更多
UIManager.getInstance().loadDCUI();
this.owner.destroy()
})
}
else {
this.btn_play.visible = false
this.btn_continue.visible = true
this.btn_more.visible = false
this.btn_continue.on(Laya.Event.CLICK, this, ()=>{//继续
UIManager.getInstance().loadStageUI(stageID);
this.owner.destroy()
})
}
this.btn_new_blue.on(Laya.Event.CLICK, this, this.onClickNew)
this.btn_new_white.on(Laya.Event.CLICK, this, this.onClickNew)
this.btn_go.on(Laya.Event.CLICK, this, (evt: Laya.Event)=>{
UIManager.getInstance().loadStageUI(config.DEFAULT_STAGE_ID);
this.owner.destroy() this.owner.destroy()
}) })
var user = StorageManager.getInstance().getUser() } else if (progress >= 1) {
if (user.get_done(config.DEFAULT_STAGE_ID) >= 1) { this.btn_play.visible = false
console.log("当前主线关卡完成") this.btn_continue.visible = false
this.btn_more.visible = true
this.btn_more.on(Laya.Event.CLICK, this, () => { // 更多
UIManager.getInstance().loadDCUI()
this.owner.destroy()
})
} else {
this.btn_play.visible = false
this.btn_continue.visible = true
this.btn_more.visible = false
this.btn_continue.on(Laya.Event.CLICK, this, () => { // 继续
UIManager.getInstance().loadStageUI(stageID)
this.owner.destroy()
})
}
this.btn_new_blue.on(Laya.Event.CLICK, this, this.onClickNew)
this.btn_new_white.on(Laya.Event.CLICK, this, this.onClickNew)
this.btn_go.on(Laya.Event.CLICK, this, (evt: Laya.Event) => {
UIManager.getInstance().loadStageUI(config.DEFAULT_STAGE_ID)
this.owner.destroy()
})
var user = StorageManager.getInstance().getUser()
if (user.get_done(config.DEFAULT_STAGE_ID) >= 1) {
console.log("当前主线关卡完成")
this.btn_new_blue.visible = true
this.btn_new_white.visible = false
this.btn_go.visible = false
} else {
const doStage = StorageManager.getInstance().getStage(config.DEFAULT_STAGE_ID)
if (doStage) {
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
const label_time = this.btn_go.getChildByName("time").getChildByName("label_time") as Laya.Label
const duration = doStage.get_duration()
const timeStr = Utility_ConvertSecondToString(duration)
label_time.text = `${timeStr} - ${doStage.get_difficulty()}`
}
} else {
console.log("当前主线关卡未开始")
this.btn_new_blue.visible = true this.btn_new_blue.visible = true
this.btn_new_white.visible = false this.btn_new_white.visible = false
this.btn_go.visible = false this.btn_go.visible = false
} }
else {
var doStage = StorageManager.getInstance().getStage(config.DEFAULT_STAGE_ID)
if (doStage) {
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("当前主线关卡未开始")
this.btn_new_blue.visible = true
this.btn_new_white.visible = false
this.btn_go.visible = false
}
}
//测试逻辑
this.btn_clean.on(Laya.Event.CLICK, this, (evt: Laya.Event) => {
console.log("btn_clean=", evt);
StorageManager.getInstance().cleanAll()
})
this.btn_clean.visible = config.DEBUG
//======
} }
public onClickNew(evt: Laya.Event): void { // 测试逻辑
Laya.loader.load(respath.difficulty_ui_res).then((go)=>{ this.btn_clean.on(Laya.Event.CLICK, this, (evt: Laya.Event) => {
var prefab = go.create() console.log("btn_clean=", evt)
var d = UIManager.getInstance().getUIRoot().addChild(prefab).getComponent(Difficulty) StorageManager.getInstance().cleanAll()
d.onInit((value: string)=> { })
console.log("选择难度", value) this.btn_clean.visible = config.DEBUG
StorageManager.getInstance().newStage(config.DEFAULT_STAGE_ID, config.STAGE_TYPE.MAIN, value, value) // ======
UIManager.getInstance().loadStageUI(config.DEFAULT_STAGE_ID); }
this.owner.destroy()
}) public onClickNew(evt: Laya.Event): void {
Laya.loader.load(respath.difficulty_ui_res).then((go) => {
const prefab = go.create()
const 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()
}) })
} })
}
} }

View File

@@ -1,44 +1,39 @@
import { config } from "../constants/config"; import { AutoDestroy } from "./common/AutoDestroy"
import { AutoDestroy } from "./common/AutoDestroy";
const { regClass, property } = Laya; const { regClass, property } = Laya
@regClass() @regClass()
export class ScoreAdd extends Laya.Script { export class ScoreAdd extends Laya.Script {
declare owner : Laya.Box; declare owner: Laya.Box
@property(Laya.Label) @property(Laya.Label)
public label: Laya.Label public label: Laya.Label
onAwake(): void { onAwake(): void {
this.label.scaleX = 0 this.label.scaleX = 0
this.label.skewY = 0 this.label.skewY = 0
var d = this.owner.getComponent(AutoDestroy) const d = this.owner.getComponent(AutoDestroy)
d.lifeTime = 2 d.lifeTime = 2
} }
onStart(): void { onStart(): void {
let wait = 0
var wait = 0 let duration = 300
Laya.Tween.to(this.label, { scaleX: 1, scaleY: 1 }, duration, Laya.Ease.strongIn, null, wait)
wait += duration
var duration = 300 duration = 300
Laya.Tween.to(this.label, {scaleX: 1, scaleY: 1}, duration, Laya.Ease.strongIn, null, wait) Laya.Tween.to(this.label, { y: -102 }, duration, Laya.Ease.strongIn, null, wait)
wait += duration wait += duration
duration = 300
Laya.Tween.to(this.label, {y:-102}, duration, Laya.Ease.strongIn, null, wait)
wait += duration
duration = 300
Laya.Tween.to(this.label, {alpha:0}, duration, Laya.Ease.strongIn, null, wait)
wait += duration
}
public onSetText(text: string): void {
this.label.text = text
}
duration = 300
Laya.Tween.to(this.label, { alpha: 0 }, duration, Laya.Ease.strongIn, null, wait)
wait += duration
}
public onSetText(text: string): void {
this.label.text = text
}
} }

File diff suppressed because it is too large Load Diff

View File

@@ -1,150 +1,149 @@
import { config } from "../constants/config"; import { config } from "../constants/config"
import { StorageManager } from "../models/StorageManager"; import { StorageManager } from "../models/StorageManager"
import { UIManager } from "../models/UIManager"; import { UIManager } from "../models/UIManager"
import { CommonData } from "./common/CommonData"; import { CommonData } from "./common/CommonData"
import { G_ShowCommonTips } from "./CommonTips"; import { G_ShowCommonTips } from "./CommonTips"
const { regClass, property } = Laya; const { regClass, property } = Laya
@regClass() @regClass()
export class TopBar extends Laya.Script { export class TopBar extends Laya.Script {
declare owner : Laya.Box; declare owner: Laya.Box
@property(Laya.Box) @property(Laya.Box)
public btn_classic: Laya.Box public btn_classic: Laya.Box
@property(Laya.Sprite)
public sprite_classic: Laya.Sprite
@property(Laya.Label)
public label_classic: Laya.Label
@property(Laya.Box) @property(Laya.Sprite)
public btn_dc: Laya.Box public sprite_classic: Laya.Sprite
@property(Laya.Sprite)
public sprite_dc: Laya.Sprite
@property(Laya.Label)
public label_dc: Laya.Label
private isClassic: boolean = true @property(Laya.Label)
public label_classic: Laya.Label
@property(Laya.Label) @property(Laya.Box)
public obj_label: Laya.Label public btn_dc: Laya.Box
@property(Laya.Box)
public obj_items: Laya.Box
private items: Map<string, Laya.Label> = new Map()
onStart(): void { @property(Laya.Sprite)
public sprite_dc: Laya.Sprite
//如果是第一次以横屏启动游戏需要创建经典关卡 @property(Laya.Label)
var difficulty = Laya.LocalStorage.getItem("difficulty")//读取用户上次选择的难度 public label_dc: Laya.Label
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, ()=>{ private isClassic: boolean = true
if (this.isClassic == false) {
this.onClickTab(true)
}
})
this.btn_dc.on(Laya.Event.CLICK, this, ()=>{
if (this.isClassic) {
this.onClickTab(false)
}
})
this.onClickTab(this.isClassic)
@property(Laya.Label)
public obj_label: Laya.Label
var showToggle = Laya.LocalStorage.getItem("showToggle") @property(Laya.Box)
if (!showToggle || showToggle.length <= 0) { public obj_items: Laya.Box
Laya.LocalStorage.setItem("showToggle", "true")
}
for (var i=0; i<this.obj_items.numChildren; i++) { private items: Map<string, Laya.Label> = new Map()
var obj = this.obj_items.getChildAt(i)
var value = config.DIFFICULTY_LIST[i]
var label = obj.getChildByName("Label") as Laya.Label
label.text = value
this.items.set(value, label)
var common = obj.getComponent(CommonData)
common.strValue = value
obj.on(Laya.Event.CLICK, this, (evt: Laya.Event)=>{
var common = evt.target.getComponent(CommonData)
var difficulty = Laya.LocalStorage.getItem("difficulty")
if (common.strValue != difficulty) {
if (Laya.LocalStorage.getItem("showToggle")=="true") {
var title = "Start New Game"
var content = "Current game progress will be lost"
G_ShowCommonTips(title, content, true, (ok: boolean, toggleValue: boolean)=>{
if (ok) {
if (toggleValue) {
Laya.LocalStorage.setItem("showToggle", "false")
}
this.onClickDifficulty(common.strValue)
}
})
}
else {
this.onClickDifficulty(common.strValue)
}
}
})
}
this.updateDifficulty(difficulty)
onStart(): void {
// 如果是第一次以横屏启动游戏需要创建经典关卡
let difficulty = Laya.LocalStorage.getItem("difficulty")// 读取用户上次选择的难度
if (!difficulty || difficulty.length <= 0) {
difficulty = config.DIFFICULTY_TYPE.Easy
Laya.LocalStorage.setItem("difficulty", difficulty)
} }
const doStage = StorageManager.getInstance().getStage(config.DEFAULT_STAGE_ID)
onClickTab(isClassic: boolean): void { if (!doStage) {
this.isClassic = isClassic StorageManager.getInstance().newStage(config.DEFAULT_STAGE_ID, config.STAGE_TYPE.MAIN, difficulty, difficulty)
if (isClassic) { } else {
UIManager.getInstance().closeTrophyUI() const user = StorageManager.getInstance().getUser()
UIManager.getInstance().closeDCUI() if (user.get_done(config.DEFAULT_STAGE_ID) >= 1) {
UIManager.getInstance().loadStageUI(config.DEFAULT_STAGE_ID) console.log("当前主线关卡完成")
} user.update_progress(doStage.get_difficulty(), doStage.get_stageIndex() + 1)// 主线关卡更新难度进度
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"
this.obj_label.visible = this.isClassic
this.obj_items.visible = this.isClassic
}
onClickDifficulty(difficulty: string): void {
Laya.LocalStorage.setItem("difficulty", difficulty)//记录横屏模式用户选择的难度
StorageManager.getInstance().newStage(config.DEFAULT_STAGE_ID, config.STAGE_TYPE.MAIN, difficulty, difficulty) StorageManager.getInstance().newStage(config.DEFAULT_STAGE_ID, config.STAGE_TYPE.MAIN, difficulty, difficulty)
UIManager.getInstance().loadStageUI(config.DEFAULT_STAGE_ID) } else if (doStage.get_mistake() >= config.MISTAKE_MAX) { // 上次失败了则重新开始
StorageManager.getInstance().newStage(config.DEFAULT_STAGE_ID, config.STAGE_TYPE.MAIN, difficulty, difficulty)
this.updateDifficulty(difficulty) }
} }
updateDifficulty(difficulty: string): void { this.btn_classic.on(Laya.Event.CLICK, this, () => {
this.items.forEach((label: Laya.Label, key: string)=>{ if (this.isClassic == false) {
label.color = "#0e2a53" this.onClickTab(true)
}) }
var label = this.items.get(difficulty) })
label.color = "#1d5cdc" this.btn_dc.on(Laya.Event.CLICK, this, () => {
if (this.isClassic) {
this.onClickTab(false)
}
})
this.onClickTab(this.isClassic)
const showToggle = Laya.LocalStorage.getItem("showToggle")
if (!showToggle || showToggle.length <= 0) {
Laya.LocalStorage.setItem("showToggle", "true")
} }
for (let i = 0; i < this.obj_items.numChildren; i++) {
const obj = this.obj_items.getChildAt(i)
const value = config.DIFFICULTY_LIST[i]
const label = obj.getChildByName("Label") as Laya.Label
label.text = value
this.items.set(value, label)
const common = obj.getComponent(CommonData)
common.strValue = value
obj.on(Laya.Event.CLICK, this, (evt: Laya.Event) => {
const common = evt.target.getComponent(CommonData)
const difficulty = Laya.LocalStorage.getItem("difficulty")
if (common.strValue != difficulty) {
if (Laya.LocalStorage.getItem("showToggle") == "true") {
const title = "Start New Game"
const content = "Current game progress will be lost"
G_ShowCommonTips(title, content, true, (ok: boolean, toggleValue: boolean) => {
if (ok) {
if (toggleValue) {
Laya.LocalStorage.setItem("showToggle", "false")
}
this.onClickDifficulty(common.strValue)
}
})
} else {
this.onClickDifficulty(common.strValue)
}
}
})
}
this.updateDifficulty(difficulty)
}
onClickTab(isClassic: boolean): void {
this.isClassic = isClassic
if (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"
this.obj_label.visible = this.isClassic
this.obj_items.visible = this.isClassic
}
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"
})
const label = this.items.get(difficulty)
label.color = "#1d5cdc"
}
} }

View File

@@ -1,19 +1,19 @@
const { regClass, property } = Laya; const { regClass, property } = Laya
@regClass() @regClass()
export class AutoDestroy extends Laya.Script { export class AutoDestroy extends Laya.Script {
declare owner : Laya.Box; declare owner: Laya.Box
@property(Number) @property(Number)
public lifeTime: number = 1; public lifeTime: number = 1
//组件被激活后执行,此时所有节点和组件均已创建完毕,此方法只执行一次 // 组件被激活后执行,此时所有节点和组件均已创建完毕,此方法只执行一次
onStart(): void { onStart(): void {
if (this.lifeTime < 1) { if (this.lifeTime < 1) {
this.lifeTime = 1 this.lifeTime = 1
}
Laya.timer.once(this.lifeTime*1000, this, ()=>{
this.owner.destroy()
})
} }
Laya.timer.once(this.lifeTime * 1000, this, () => {
this.owner.destroy()
})
}
} }

View File

@@ -1,13 +1,12 @@
const { regClass, property } = Laya; const { regClass, property } = Laya
@regClass() @regClass()
export class CommonData extends Laya.Script { export class CommonData extends Laya.Script {
declare owner : Laya.Box; declare owner: Laya.Box
@property(Number) @property(Number)
public intValue: number = 0; public intValue: number = 0
@property(String)
public strValue: string = "";
@property(String)
public strValue: string = ""
} }

View File

@@ -2,9 +2,9 @@ import { respath } from "../../constants/respath"
import { ScoreAdd } from "../ScoreAdd" import { ScoreAdd } from "../ScoreAdd"
export function G_ShowScoreTips(text: string, parent: any): void { export function G_ShowScoreTips(text: string, parent: any): void {
Laya.loader.load(respath.score_add_ui_res()).then((go)=>{ Laya.loader.load(respath.score_add_ui_res()).then((go) => {
var prefab = go.create() const prefab = go.create()
var score = parent.addChild(prefab).getComponent(ScoreAdd) const score = parent.addChild(prefab).getComponent(ScoreAdd)
score.onSetText(text) score.onSetText(text)
}) })
} }

View File

@@ -1,131 +1,131 @@
import { config } from "../../constants/config"; import { config } from "../../constants/config"
const { regClass, property } = Laya; const { regClass, property } = Laya
@regClass() @regClass()
export class CalendarUnit extends Laya.Script { export class CalendarUnit extends Laya.Script {
declare owner : Laya.Box; declare owner: Laya.Box
@property(Number) @property(Number)
public year: number = 0; public year: number = 0
@property(Number)
public month: number = 0;
@property(Number)
public day: number = 0;
@property(Boolean)
public open: boolean = false;
@property(Number)
public progress: number = 0;
private selected: boolean = false @property(Number)
public month: number = 0
@property(Laya.Sprite) @property(Number)
public obj_selected: Laya.Sprite; public day: number = 0
@property(Laya.Box) @property(Boolean)
public obj_pie: Laya.Box; public open: boolean = false
@property(Laya.Sprite)
public sprite_pie: Laya.Sprite;
@property(Laya.Sprite) @property(Number)
public obj_mask: Laya.Sprite; public progress: number = 0
@property(Laya.Sprite)
public sprite_mask: Laya.Sprite;
@property(Laya.Image) private selected: boolean = false
public obj_star: Laya.Image;
@property(Laya.Label) @property(Laya.Sprite)
public label_show: Laya.Label; public obj_selected: Laya.Sprite
@property(Laya.Box)
public obj_pie: Laya.Box
//组件被激活后执行,此时所有节点和组件均已创建完毕,此方法只执行一次 @property(Laya.Sprite)
onAwake(): void { public sprite_pie: Laya.Sprite
@property(Laya.Sprite)
public obj_mask: Laya.Sprite
@property(Laya.Sprite)
public sprite_mask: Laya.Sprite
@property(Laya.Image)
public obj_star: Laya.Image
@property(Laya.Label)
public label_show: Laya.Label
// 组件被激活后执行,此时所有节点和组件均已创建完毕,此方法只执行一次
onAwake(): void {
}
public onInit(label_obj: Laya.Label): void {
this.label_show = label_obj
}
public setCalendarUnit(year: number, month: number, day: number, open: boolean, progress: number, handler: any, func: any): void {
this.selected = false
this.year = year
this.month = month
this.day = day
this.open = open
this.progress = progress
if (open) {
if (progress >= 1) {
this.label_show.text = ""
} else {
this.label_show.text = this.day.toString()
}
this.label_show.color = "#2d3138"
this.owner.on(Laya.Event.CLICK, handler, func)
this.updateUnit()
} else {
this.label_show.text = this.day.toString()
this.label_show.color = "#d3d5db"
this.owner.on(Laya.Event.CLICK, this, (evt: Laya.Event) => {
})
this.obj_selected.visible = false
this.obj_pie.visible = false
this.obj_mask.visible = false
this.obj_star.visible = false
}
}
public setSelected(selected: boolean): void {
this.selected = selected
this.updateUnit()
}
updateUnit(): void {
if (this.open == false) {
return
} }
public onInit(label_obj: Laya.Label): void { this.obj_star.visible = this.progress >= 1
this.label_show = label_obj
} let blockSize = 48
if (config.H_SCREEN)
public setCalendarUnit(year: number, month: number, day: number, open: boolean, progress: number, handler: any, func: any): void { blockSize = 33
this.selected = false
this.year = year if (this.selected) {
this.month = month this.label_show.color = "#ffffff"
this.day = day this.obj_selected.visible = true
this.open = open if (this.progress > 0) {
this.progress = progress this.obj_pie.visible = true
if (open) { this.obj_mask.visible = true
if (progress >= 1) { this.sprite_pie.graphics.clear()
this.label_show.text = "" this.sprite_pie.graphics.drawPie(blockSize, blockSize, blockSize, 0, 360 * this.progress, "#ffffff")
} this.sprite_mask.graphics.clear()
else { this.sprite_mask.graphics.drawCircle(0.5, 0.5, 0.5, "#1d5cdc")
this.label_show.text = this.day.toString() } else {
} this.obj_pie.visible = false
this.label_show.color = "#2d3138" this.obj_mask.visible = false
this.owner.on(Laya.Event.CLICK, handler, func) }
this.updateUnit() } else {
} this.label_show.color = "#2d3138"
else { this.obj_selected.visible = false
this.label_show.text = this.day.toString() if (this.progress > 0 && this.progress < 1) {
this.label_show.color = "#d3d5db" this.obj_pie.visible = true
this.owner.on(Laya.Event.CLICK, this, (evt: Laya.Event)=>{ this.obj_mask.visible = true
this.sprite_pie.graphics.clear()
}) this.sprite_pie.graphics.drawPie(blockSize, blockSize, blockSize, 0, 360 * this.progress, "#2d3138")
this.obj_selected.visible = false this.sprite_mask.graphics.clear()
this.obj_pie.visible = false this.sprite_mask.graphics.drawCircle(0.5, 0.5, 0.5, "#ffffff")
this.obj_mask.visible = false } else {
this.obj_star.visible = false this.obj_pie.visible = false
} this.obj_mask.visible = false
} }
public setSelected(selected: boolean): void {
this.selected = selected
this.updateUnit()
}
updateUnit(): void {
if (this.open == false) {
return
}
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
if (this.progress > 0) {
this.obj_pie.visible = true
this.obj_mask.visible = true
this.sprite_pie.graphics.clear()
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")
}
else {
this.obj_pie.visible = false
this.obj_mask.visible = false
}
}
else {
this.label_show.color = "#2d3138"
this.obj_selected.visible = false
if (this.progress > 0 && this.progress < 1) {
this.obj_pie.visible = true
this.obj_mask.visible = true
this.sprite_pie.graphics.clear()
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")
}
else {
this.obj_pie.visible = false
this.obj_mask.visible = false
}
}
} }
}
} }

View File

@@ -1,282 +1,293 @@
import { config } from "../../constants/config"; import { config } from "../../constants/config"
import { Utility_ConvertSecondToString } from "../../utils/utility"; import { respath } from "../../constants/respath"
import { StorageManager } from "../../models/StorageManager"; import { MONTH_LIST } from "../../models/DCManager"
import { CalendarUnit } from "./CalendarUnit"; import { EVENT_TYPES, EventManager } from "../../models/EventManager"
import { UIManager } from "../../models/UIManager"; import { StorageManager } from "../../models/StorageManager"
import { respath } from "../../constants/respath"; import { UIManager } from "../../models/UIManager"
import { MONTH_LIST } from "../../models/DCManager"; import { Utility_ConvertSecondToString } from "../../utils/utility"
import { EVENT_TYPES, EventManager } from "../../models/EventManager"; import { CalendarUnit } from "./CalendarUnit"
const { regClass, property } = Laya
const { regClass, property } = Laya;
@regClass() @regClass()
export class DailyChallenge extends Laya.Script { export class DailyChallenge extends Laya.Script {
declare owner : Laya.Box; declare owner: Laya.Box
@property(Laya.Button) @property(Laya.Button)
public btn_back: Laya.Button 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 trophy_light: Laya.Image
@property(Laya.Image)
public trophy_icon: Laya.Image
@property(Laya.Box)
public btn_left: Laya.Box
@property(Laya.Box)
public btn_right: Laya.Box
@property(Laya.Image) @property(Laya.Image)
public bg_dc: Laya.Image; public btn_trophy: Laya.Image
@property(Laya.Label)
public label_year: Laya.Label;
@property(Laya.Label)
public label_month: Laya.Label;
@property(Laya.Label)
public label_star: Laya.Label;
@property(Laya.Box) @property(Laya.Sprite)
public btn_play: Laya.Box public btn_trophy_red: Laya.Sprite
@property(Laya.Label)
public label_play: Laya.Label
@property(Laya.Box)
public obj_summary: Laya.Box
@property(Laya.Label)
public label_date: Laya.Label;
@property(Laya.Label)
public label_diffucuty: Laya.Label
@property(Laya.Label)
public label_score: Laya.Label
@property(Laya.Label)
public label_time: Laya.Label
@property(Laya.Box) @property(Laya.Image)
public obj_items: Laya.Box; public trophy_light: Laya.Image
@property(Laya.Box)
public obj_labels: Laya.Box;
private units: Array<CalendarUnit> = new Array();
private selectedUnit: CalendarUnit; @property(Laya.Image)
private currentIndex: number public trophy_icon: Laya.Image
private indexMax: number
private static _instance: DailyChallenge @property(Laya.Box)
onAwake(): void { public btn_left: Laya.Box
DailyChallenge._instance = this
if (this.btn_back) { @property(Laya.Box)
this.btn_back.on(Laya.Event.CLICK, this, ()=>{ public btn_right: Laya.Box
UIManager.getInstance().loadHomeUI()
UIManager.getInstance().closeDCUI()
})
}
var user = StorageManager.getInstance().getUser() @property(Laya.Image)
this.btn_trophy_red.visible = user.get_trophyHasUnread() public bg_dc: Laya.Image
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)=>{ @property(Laya.Label)
// console.log(">>>>>>>>>>>>>>>>>>>>>>>", this.selectedUnit.day) public label_year: Laya.Label
var now = new Date()
var year = now.getFullYear()
var month = now.getMonth() + 1
var dayNow = this.selectedUnit.day
var stageID = `${year}-${month}-${dayNow}`
var doStage = StorageManager.getInstance().getStage(stageID)
console.log("play >>>>>>>>>>>>>>>>>>>>>>>", stageID, doStage)
if (!doStage || doStage.get_mistake() >= config.MISTAKE_MAX) {
var stageName = `${config.MONTH_ABBRS[month-1]} ${dayNow}`
StorageManager.getInstance().newStage(stageID, config.STAGE_TYPE.DC, stageName)
}
UIManager.getInstance().loadStageUI(stageID);
this.owner.destroy()
})
for (var i=0; i<this.obj_items.numChildren; i++) { @property(Laya.Label)
var hbox = this.obj_items.getChildAt(i) public label_month: Laya.Label
var l_hbox = this.obj_labels.getChildAt(i)
for (var j=0; j<hbox.numChildren; j++) {
var unit = hbox.getChildAt(j).getComponent(CalendarUnit)
var l_obj = l_hbox.getChildAt(j) as Laya.Label
this.units.push(unit)
unit.onInit(l_obj)
}
}
this.indexMax = MONTH_LIST.length - 1 @property(Laya.Label)
var now = new Date() public label_star: Laya.Label
var nowYear = now.getFullYear()
var nowMonth = now.getMonth() + 1
for (var i=0; i<MONTH_LIST.length; i++) {
var obj = MONTH_LIST[i]
if (nowYear == obj.year && nowMonth == obj.month) {
this.indexMax = i;
break
}
}
this.btn_left.on(Laya.Event.CLICK, this, ()=>{
if (this.currentIndex > 0) {
this.currentIndex --
this.loadWithIndex(this.currentIndex)
}
})
this.btn_right.on(Laya.Event.CLICK, this, ()=>{
if (this.currentIndex < this.indexMax) {
this.currentIndex ++
this.loadWithIndex(this.currentIndex)
}
})
EventManager.getInstance().RegisterEvent(EVENT_TYPES.NOT_SET_TROPHY_BUTTON, DailyChallenge.EventUpdateTrophyButton) @property(Laya.Box)
public btn_play: Laya.Box
@property(Laya.Label)
public label_play: Laya.Label
@property(Laya.Box)
public obj_summary: Laya.Box
@property(Laya.Label)
public label_date: Laya.Label
@property(Laya.Label)
public label_diffucuty: Laya.Label
@property(Laya.Label)
public label_score: Laya.Label
@property(Laya.Label)
public label_time: Laya.Label
@property(Laya.Box)
public obj_items: Laya.Box
@property(Laya.Box)
public obj_labels: Laya.Box
private units: Array<CalendarUnit> = []
private selectedUnit: CalendarUnit
private currentIndex: number
private indexMax: number
private static _instance: DailyChallenge
onAwake(): void {
DailyChallenge._instance = this
if (this.btn_back) {
this.btn_back.on(Laya.Event.CLICK, this, () => {
UIManager.getInstance().loadHomeUI()
UIManager.getInstance().closeDCUI()
})
} }
onDestroy(): void { const user = StorageManager.getInstance().getUser()
EventManager.getInstance().UnregisterEvent(EVENT_TYPES.NOT_SET_TROPHY_BUTTON, DailyChallenge.EventUpdateTrophyButton) 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)
const now = new Date()
const year = now.getFullYear()
const month = now.getMonth() + 1
const dayNow = this.selectedUnit.day
const stageID = `${year}-${month}-${dayNow}`
const doStage = StorageManager.getInstance().getStage(stageID)
console.log("play >>>>>>>>>>>>>>>>>>>>>>>", stageID, doStage)
if (!doStage || doStage.get_mistake() >= config.MISTAKE_MAX) {
const stageName = `${config.MONTH_ABBRS[month - 1]} ${dayNow}`
StorageManager.getInstance().newStage(stageID, config.STAGE_TYPE.DC, stageName)
}
UIManager.getInstance().loadStageUI(stageID)
this.owner.destroy()
})
for (var i = 0; i < this.obj_items.numChildren; i++) {
const hbox = this.obj_items.getChildAt(i)
const l_hbox = this.obj_labels.getChildAt(i)
for (let j = 0; j < hbox.numChildren; j++) {
const unit = hbox.getChildAt(j).getComponent(CalendarUnit)
const l_obj = l_hbox.getChildAt(j) as Laya.Label
this.units.push(unit)
unit.onInit(l_obj)
}
} }
public static EventUpdateTrophyButton(arg: any): void { this.indexMax = MONTH_LIST.length - 1
if (DailyChallenge._instance) { const now = new Date()
DailyChallenge._instance.btn_trophy.visible = arg const nowYear = now.getFullYear()
} const nowMonth = now.getMonth() + 1
for (var i = 0; i < MONTH_LIST.length; i++) {
const obj = MONTH_LIST[i]
if (nowYear == obj.year && nowMonth == obj.month) {
this.indexMax = i
break
}
} }
this.btn_left.on(Laya.Event.CLICK, this, () => {
loadWithMonth(): void { if (this.currentIndex > 0) {
var now = new Date() this.currentIndex--
var nowYear = now.getFullYear()
var nowMonth = now.getMonth() + 1
this.currentIndex = 0
for (var i=0; i<MONTH_LIST.length; i++) {
var obj = MONTH_LIST[i]
if (nowYear == obj.year && nowMonth == obj.month) {
this.currentIndex = i;
break
}
}
console.log("DailyChallenge loadWithMonth >>>>>>>>>>>>>>>", nowYear, nowMonth, this.currentIndex)
this.loadWithIndex(this.currentIndex) this.loadWithIndex(this.currentIndex)
}
})
this.btn_right.on(Laya.Event.CLICK, this, () => {
if (this.currentIndex < this.indexMax) {
this.currentIndex++
this.loadWithIndex(this.currentIndex)
}
})
EventManager.getInstance().RegisterEvent(EVENT_TYPES.NOT_SET_TROPHY_BUTTON, DailyChallenge.EventUpdateTrophyButton)
}
onDestroy(): void {
EventManager.getInstance().UnregisterEvent(EVENT_TYPES.NOT_SET_TROPHY_BUTTON, DailyChallenge.EventUpdateTrophyButton)
}
public static EventUpdateTrophyButton(arg: any): void {
if (DailyChallenge._instance) {
DailyChallenge._instance.btn_trophy.visible = arg
} }
}
public loadWithIndex(index: number): void { loadWithMonth(): void {
this.btn_left.visible = this.currentIndex > 0 const now = new Date()
this.btn_right.visible = this.currentIndex < this.indexMax const nowYear = now.getFullYear()
var info = MONTH_LIST[index] const nowMonth = now.getMonth() + 1
var user = StorageManager.getInstance().getUser() this.currentIndex = 0
var now = new Date() for (let i = 0; i < MONTH_LIST.length; i++) {
var nowYear = now.getFullYear() const obj = MONTH_LIST[i]
var nowMonth = now.getMonth() + 1 if (nowYear == obj.year && nowMonth == obj.month) {
var nowDay = new Date().getDate() this.currentIndex = i
break
}
}
console.log("DailyChallenge loadWithMonth >>>>>>>>>>>>>>>", nowYear, nowMonth, this.currentIndex)
this.loadWithIndex(this.currentIndex)
}
this.trophy_icon.skin = info.icon_res public loadWithIndex(index: number): void {
//设置背景 this.btn_left.visible = this.currentIndex > 0
var starCount = user.get_doneCountByDate(info.year, info.month) this.btn_right.visible = this.currentIndex < this.indexMax
if (starCount >= info.dayCount) { const info = MONTH_LIST[index]
this.bg_dc.skin = respath.dc_top_bg_month_finish const user = StorageManager.getInstance().getUser()
this.trophy_light.visible = true const now = new Date()
} const nowYear = now.getFullYear()
else { const nowMonth = now.getMonth() + 1
this.bg_dc.skin = respath.dc_top_bg_normal const nowDay = new Date().getDate()
this.trophy_light.visible = false
}
this.label_year.text = info.year.toString()
this.label_month.text = config.MONTH_FULLNAMES[info.month-1]
this.label_star.text = `${starCount}/${info.dayCount}`
this.selectedUnit = null this.trophy_icon.skin = info.icon_res
var day = 1 // 设置背景
for (var i=0; i<this.units.length; i++) { const starCount = user.get_doneCountByDate(info.year, info.month)
var unit = this.units[i] if (starCount >= info.dayCount) {
if (i >= info.begin && i < info.begin+info.dayCount) { this.bg_dc.skin = respath.dc_top_bg_month_finish
unit.owner.visible = true this.trophy_light.visible = true
unit.label_show.visible = true } else {
var open = true this.bg_dc.skin = respath.dc_top_bg_normal
if (info.year > nowYear) { this.trophy_light.visible = false
open = false }
} this.label_year.text = info.year.toString()
else if (info.year == nowYear) { this.label_month.text = config.MONTH_FULLNAMES[info.month - 1]
if (info.month > nowMonth) { this.label_star.text = `${starCount}/${info.dayCount}`
open = false
} this.selectedUnit = null
else if (info.month == nowMonth) { let day = 1
if (day > nowDay) { for (let i = 0; i < this.units.length; i++) {
open = false const unit = this.units[i]
} if (i >= info.begin && i < info.begin + info.dayCount) {
} unit.owner.visible = true
} unit.label_show.visible = true
var stageID = `${info.year}-${info.month}-${day}` let open = true
var progress = user.get_done(stageID) if (info.year > nowYear) {
if (open && progress < 1) {//检查失败的关卡,如果失败了就重置 open = false
var doStage = StorageManager.getInstance().getStage(stageID) } else if (info.year == nowYear) {
if (doStage) {//有关卡数据 if (info.month > nowMonth) {
if (doStage.get_mistake() >= config.MISTAKE_MAX) { open = false
progress = 0 } else if (info.month == nowMonth) {
user.update_stage_done(stageID, 0) if (day > nowDay) {
StorageManager.getInstance().cleanStage(stageID) open = false
}
}
}
unit.setCalendarUnit(info.year, info.month, day, open, progress, this, this.onClickUnit)
if (info.year == nowYear && info.month == nowMonth && day == nowDay) {
this.selectedUnit = unit
}
day ++
} }
else { }
unit.owner.visible = false }
unit.label_show.visible = false const stageID = `${info.year}-${info.month}-${day}`
let progress = user.get_done(stageID)
if (open && progress < 1) { // 检查失败的关卡,如果失败了就重置
const doStage = StorageManager.getInstance().getStage(stageID)
if (doStage) { // 有关卡数据
if (doStage.get_mistake() >= config.MISTAKE_MAX) {
progress = 0
user.update_stage_done(stageID, 0)
StorageManager.getInstance().cleanStage(stageID)
} }
}
} }
if (!this.selectedUnit) unit.setCalendarUnit(info.year, info.month, day, open, progress, this, this.onClickUnit)
this.selectedUnit = this.units[info.begin+info.dayCount-1] if (info.year == nowYear && info.month == nowMonth && day == nowDay) {
this.onApplyUnit(this.selectedUnit) this.selectedUnit = unit
}
day++
} else {
unit.owner.visible = false
unit.label_show.visible = false
}
} }
if (!this.selectedUnit)
this.selectedUnit = this.units[info.begin + info.dayCount - 1]
this.onApplyUnit(this.selectedUnit)
}
public onApplyUnit(unit: CalendarUnit): void { public onApplyUnit(unit: CalendarUnit): void {
this.selectedUnit.setSelected(false) this.selectedUnit.setSelected(false)
this.selectedUnit = unit this.selectedUnit = unit
this.selectedUnit.setSelected(true) this.selectedUnit.setSelected(true)
var stageID = `${unit.year}-${unit.month}-${unit.day}` const stageID = `${unit.year}-${unit.month}-${unit.day}`
this.label_date.text = `${config.MONTH_ABBRS[unit.month-1]} ${unit.day},${unit.year}` this.label_date.text = `${config.MONTH_ABBRS[unit.month - 1]} ${unit.day},${unit.year}`
var user = StorageManager.getInstance().getUser() const user = StorageManager.getInstance().getUser()
var progress = user.get_done(stageID) const progress = user.get_done(stageID)
// console.log("onApplyUnit >>>>>", stageID, progress) // console.log("onApplyUnit >>>>>", stageID, progress)
if (progress >= 1) { if (progress >= 1) {
this.btn_play.visible = false this.btn_play.visible = false
this.obj_summary.visible = true this.obj_summary.visible = true
var doStage = StorageManager.getInstance().getStage(stageID) var doStage = StorageManager.getInstance().getStage(stageID)
this.label_diffucuty.text = doStage.get_difficulty() this.label_diffucuty.text = doStage.get_difficulty()
this.label_score.text = doStage.get_score().toString() this.label_score.text = doStage.get_score().toString()
this.label_time.text = Utility_ConvertSecondToString(doStage.get_duration()) this.label_time.text = Utility_ConvertSecondToString(doStage.get_duration())
} } else {
else { this.btn_play.visible = true
this.btn_play.visible = true this.obj_summary.visible = false
this.obj_summary.visible = false var doStage = StorageManager.getInstance().getStage(stageID)
var doStage = StorageManager.getInstance().getStage(stageID) if (doStage) {
if (doStage) { this.label_play.text = "Continue"
this.label_play.text = "Continue" } else {
} this.label_play.text = "Play"
else { }
this.label_play.text = "Play"
}
}
}
public onClickUnit(evt: Laya.Event): void {
var unit = evt.target.getComponent(CalendarUnit)
this.onApplyUnit(unit)
} }
}
onStart(): void { public onClickUnit(evt: Laya.Event): void {
var user = StorageManager.getInstance().getUser() const unit = evt.target.getComponent(CalendarUnit)
var find = user.get_trophyHasNew() this.onApplyUnit(unit)
if (find) { }
UIManager.getInstance().loadTrophyClaimUI(find)
user.set_trophyNew(find, false) onStart(): void {
} const user = StorageManager.getInstance().getUser()
const find = user.get_trophyHasNew()
if (find) {
UIManager.getInstance().loadTrophyClaimUI(find)
user.set_trophyNew(find, false)
} }
}
} }

View File

@@ -1,36 +1,35 @@
import { config } from "../../constants/config"; import type { TrophyRecord } from "../../types/global"
import { MONTH_LIST } from "../../models/DCManager"; import { config } from "../../constants/config"
import { TrophyRecord } from "../../types/global"; import { MONTH_LIST } from "../../models/DCManager"
const { regClass, property } = Laya; const { regClass, property } = Laya
@regClass() @regClass()
export class TrophyClaim extends Laya.Script { export class TrophyClaim extends Laya.Script {
declare owner : Laya.Box; declare owner: Laya.Box
@property(Laya.Image) @property(Laya.Image)
public icon: Laya.Image public icon: Laya.Image
@property(Laya.Label) @property(Laya.Label)
public label_date: Laya.Label public label_date: Laya.Label
@property(Laya.Box) @property(Laya.Box)
public btn_close: Laya.Box public btn_close: Laya.Box
public onSetShow(record: TrophyRecord): void { public onSetShow(record: TrophyRecord): void {
for (var i=0; i<MONTH_LIST.length; i++) { for (let i = 0; i < MONTH_LIST.length; i++) {
var obj = MONTH_LIST[i] const obj = MONTH_LIST[i]
if (obj.year == record.year && obj.month == record.month) { if (obj.year == record.year && obj.month == record.month) {
this.icon.skin = obj.icon_res this.icon.skin = obj.icon_res
break break
} }
}
this.label_date.text = `${config.MONTH_ABBRS[record.month-1]} ${record.day},${record.year}`
this.btn_close.on(Laya.Event.CLICK, this, ()=>{
this.owner.destroy()
})
} }
this.label_date.text = `${config.MONTH_ABBRS[record.month - 1]} ${record.day},${record.year}`
this.btn_close.on(Laya.Event.CLICK, this, () => {
this.owner.destroy()
})
}
} }

View File

@@ -1,116 +1,109 @@
import { config } from "../../constants/config"
import { respath } from "../../constants/respath"
import { MONTH_LIST } from "../../models/DCManager"
import { EVENT_TYPES, EventManager } from "../../models/EventManager"
import { UIManager } from "../../models/UIManager"
import { TrophyUnit } from "./TrophyUnit"
const { regClass, property } = Laya
import { config } from "../../constants/config";
import { respath } from "../../constants/respath";
import { MONTH_LIST } from "../../models/DCManager";
import { EVENT_TYPES, EventManager } from "../../models/EventManager";
import { UIManager } from "../../models/UIManager";
import { TrophyUnit } from "./TrophyUnit";
const { regClass, property } = Laya;
@regClass() @regClass()
export class TrophyRoom extends Laya.Script { export class TrophyRoom extends Laya.Script {
declare owner : Laya.Box; declare owner: Laya.Box
@property(Laya.Box) @property(Laya.Box)
public btn_back: Laya.Box; public btn_back: Laya.Box
@property(Laya.Box) @property(Laya.Box)
public obj_items: Laya.Box; public obj_items: Laya.Box
//第一次执行update之前执行只会执行一次 // 第一次执行update之前执行只会执行一次
onStart(): void { onStart(): void {
let trophyCountOfCell = 3
if (config.H_SCREEN)
trophyCountOfCell = 5
var trophyCountOfCell = 3 this.btn_back.on(Laya.Event.CLICK, this, () => {
if (config.H_SCREEN) UIManager.getInstance().closeTrophyUI()
trophyCountOfCell = 5 })
this.btn_back.on(Laya.Event.CLICK, this, ()=>{ const infos: Array<any> = []
UIManager.getInstance().closeTrophyUI() const now = new Date()
}) const nowYear = now.getFullYear()
const nowMonth = now.getMonth() + 1
var infos: Array<any> = new Array() for (var i = 0; i < MONTH_LIST.length; i++) {
var now = new Date() var obj = MONTH_LIST[i]
var nowYear = now.getFullYear() infos.push(obj)
var nowMonth = now.getMonth() + 1 if (obj.year == nowYear && obj.month == nowMonth) {
for (var i=0; i<MONTH_LIST.length; i++) { break
var obj = MONTH_LIST[i] }
infos.push(obj)
if (obj.year == nowYear && obj.month == nowMonth) {
break
}
}
infos.reverse()
var years: Array<number> = new Array()
var monthMap: Map<number, Array<any>> = new Map()
for (var i=0; i<infos.length; i++) {
obj = infos[i]
if (years.indexOf(obj.year) < 0) {
years.push(obj.year)
}
if (monthMap.has(obj.year)== false) {
monthMap.set(obj.year, new Array())
}
var list = monthMap.get(obj.year)
list.push(obj)
}
console.log(">>>>>>>>>>>>years=", years)
Laya.loader.load(respath.trophy_year_ui_res()).then((go)=>{
for (var i=1; i<years.length; i++) {
var obj_year = this.obj_items.getChildAt(i)
if (!obj_year) {
var prefab = go.create()
this.obj_items.addChild(prefab)
}
}
Laya.loader.load(respath.trophy_cell_ui_res()).then((go)=>{
var itemsHeight = 0
for (var i=0; i<years.length; i++) {
var list = monthMap.get(years[i])
var cellCount = Math.ceil(list.length/trophyCountOfCell)
var yearHeight = 120 + cellCount * 444
itemsHeight += yearHeight
var obj_year = this.obj_items.getChildAt(i) as Laya.Box
obj_year.height = yearHeight
var label = obj_year.getChildByName("year").getChildByName("Label") as Laya.Label
label.text = years[i].toString()
var index = -1
for (var j=1; j<cellCount+1; j++) {
var obj_cell = obj_year.getChildAt(j)
if (!obj_cell) {
var prefab = go.create()
obj_cell = obj_year.addChild(prefab)
}
var hbox = obj_cell.getChildByName("HBox")
for (var k=0; k<hbox.numChildren; k++) {
var unit = hbox.getChildAt(k).getComponent(TrophyUnit)
index ++
if (index < list.length) {
unit.owner.visible = true
unit.onInit(list[index])
}
else {
unit.owner.visible = false
}
}
}
}
this.obj_items.height = itemsHeight
})
})
EventManager.getInstance().DispatchEvent(EVENT_TYPES.NOT_SET_TROPHY_BUTTON, false)
} }
infos.reverse()
onDestroy(): void { const years: Array<number> = []
EventManager.getInstance().DispatchEvent(EVENT_TYPES.NOT_SET_TROPHY_BUTTON, true) const monthMap: Map<number, Array<any>> = new Map()
for (var i = 0; i < infos.length; i++) {
obj = infos[i]
if (!years.includes(obj.year)) {
years.push(obj.year)
}
if (monthMap.has(obj.year) == false) {
monthMap.set(obj.year, [])
}
const list = monthMap.get(obj.year)
list.push(obj)
} }
console.log(">>>>>>>>>>>>years=", years)
Laya.loader.load(respath.trophy_year_ui_res()).then((go) => {
for (let i = 1; i < years.length; i++) {
const obj_year = this.obj_items.getChildAt(i)
if (!obj_year) {
const prefab = go.create()
this.obj_items.addChild(prefab)
}
}
Laya.loader.load(respath.trophy_cell_ui_res()).then((go) => {
let itemsHeight = 0
for (let i = 0; i < years.length; i++) {
const list = monthMap.get(years[i])
const cellCount = Math.ceil(list.length / trophyCountOfCell)
const yearHeight = 120 + cellCount * 444
itemsHeight += yearHeight
const obj_year = this.obj_items.getChildAt(i) as Laya.Box
obj_year.height = yearHeight
const label = obj_year.getChildByName("year").getChildByName("Label") as Laya.Label
label.text = years[i].toString()
let index = -1
for (let j = 1; j < cellCount + 1; j++) {
let obj_cell = obj_year.getChildAt(j)
if (!obj_cell) {
const prefab = go.create()
obj_cell = obj_year.addChild(prefab)
}
const hbox = obj_cell.getChildByName("HBox")
for (let k = 0; k < hbox.numChildren; k++) {
const unit = hbox.getChildAt(k).getComponent(TrophyUnit)
index++
if (index < list.length) {
unit.owner.visible = true
unit.onInit(list[index])
} else {
unit.owner.visible = false
}
}
}
}
this.obj_items.height = itemsHeight
})
})
EventManager.getInstance().DispatchEvent(EVENT_TYPES.NOT_SET_TROPHY_BUTTON, false)
}
onDestroy(): void {
EventManager.getInstance().DispatchEvent(EVENT_TYPES.NOT_SET_TROPHY_BUTTON, true)
}
} }

View File

@@ -1,37 +1,35 @@
import type { TrophyRecord } from "../../types/global"
import { config } from "../../constants/config"
import { MONTH_LIST } from "../../models/DCManager"
import { config } from "../../constants/config"; const { regClass, property } = Laya
import { MONTH_LIST } from "../../models/DCManager";
import { TrophyRecord } from "../../types/global";
const { regClass, property } = Laya;
@regClass() @regClass()
export class TrophyShow extends Laya.Script { export class TrophyShow extends Laya.Script {
declare owner : Laya.Box; declare owner: Laya.Box
@property(Laya.Image) @property(Laya.Image)
public icon: Laya.Image public icon: Laya.Image
@property(Laya.Label) @property(Laya.Label)
public label_date: Laya.Label public label_date: Laya.Label
@property(Laya.Box) @property(Laya.Box)
public btn_close: Laya.Box public btn_close: Laya.Box
public onSetShow(record: TrophyRecord): void { public onSetShow(record: TrophyRecord): void {
for (var i=0; i<MONTH_LIST.length; i++) { for (let i = 0; i < MONTH_LIST.length; i++) {
var obj = MONTH_LIST[i] const obj = MONTH_LIST[i]
if (obj.year == record.year && obj.month == record.month) { if (obj.year == record.year && obj.month == record.month) {
this.icon.skin = obj.icon_res this.icon.skin = obj.icon_res
break break
} }
}
this.label_date.text = `${config.MONTH_ABBRS[record.month-1]} ${record.day},${record.year}`
this.btn_close.on(Laya.Event.CLICK, this, ()=>{
this.owner.destroy()
})
} }
this.label_date.text = `${config.MONTH_ABBRS[record.month - 1]} ${record.day},${record.year}`
this.btn_close.on(Laya.Event.CLICK, this, () => {
this.owner.destroy()
})
}
} }

View File

@@ -1,45 +1,47 @@
import { config } from "../../constants/config"; import { config } from "../../constants/config"
import { respath } from "../../constants/respath"; import { respath } from "../../constants/respath"
import { StorageManager } from "../../models/StorageManager"; import { StorageManager } from "../../models/StorageManager"
import { UIManager } from "../../models/UIManager"; import { UIManager } from "../../models/UIManager"
const { regClass, property } = Laya; const { regClass, property } = Laya
@regClass() @regClass()
export class TrophyUnit extends Laya.Script { export class TrophyUnit extends Laya.Script {
declare owner : Laya.Box; declare owner: Laya.Box
@property(Laya.Image) @property(Laya.Image)
public bg_light: Laya.Image; public bg_light: Laya.Image
@property(Laya.Image)
public icon: Laya.Image;
@property(Laya.Label)
public label_count: Laya.Label;
@property(Laya.Label)
public label_month: Laya.Label;
public onInit(info: any): void { @property(Laya.Image)
var user = StorageManager.getInstance().getUser() public icon: Laya.Image
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]
if (starCount >= info.dayCount) {
this.bg_light.skin = respath.trophy_bg_light_gold
this.icon.gray = false
this.label_month.color = "#2d3138"
}
else {
this.bg_light.skin = respath.trophy_bg_light_grey
this.icon.gray = true
this.label_month.color = "#a7abb3"
}
this.icon.on(Laya.Event.CLICK, this, ()=>{ @property(Laya.Label)
var find = user.get_trophyRecord(info.year, info.month) public label_count: Laya.Label
if (find) {
UIManager.getInstance().loadTrophyShowUI(find) @property(Laya.Label)
} public label_month: Laya.Label
})
public onInit(info: any): void {
const user = StorageManager.getInstance().getUser()
const 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]
if (starCount >= info.dayCount) {
this.bg_light.skin = respath.trophy_bg_light_gold
this.icon.gray = false
this.label_month.color = "#2d3138"
} else {
this.bg_light.skin = respath.trophy_bg_light_grey
this.icon.gray = true
this.label_month.color = "#a7abb3"
} }
this.icon.on(Laya.Event.CLICK, this, () => {
const find = user.get_trophyRecord(info.year, info.month)
if (find) {
UIManager.getInstance().loadTrophyShowUI(find)
}
})
}
} }

View File

@@ -1,20 +1,20 @@
{ {
"compilerOptions": { "compilerOptions": {
"module": "es6",
"target": "es6", "target": "es6",
"strict": true,
"strictNullChecks": false,
"noEmitHelpers": true,
"sourceMap": false,
"experimentalDecorators": true, "experimentalDecorators": true,
"skipLibCheck": true, "module": "es6",
"moduleResolution": "node", "moduleResolution": "node",
"allowSyntheticDefaultImports": true,
"paths": { "paths": {
"~/packages/*": [ "~/packages/*": [
"./library/packages/*" "./library/packages/*"
] ]
} },
"strict": true,
"strictNullChecks": false,
"noEmitHelpers": true,
"sourceMap": false,
"allowSyntheticDefaultImports": true,
"skipLibCheck": true
}, },
"include": [ "include": [
"./assets", "./assets",