格式化代码 var to let or const
This commit is contained in:
@@ -36,8 +36,8 @@ export class DOStage {
|
|||||||
this.numberToLetter.set(9, "i")
|
this.numberToLetter.set(9, "i")
|
||||||
|
|
||||||
const blockMap: Map<number, DataBlock> = new Map()
|
const blockMap: Map<number, DataBlock> = new Map()
|
||||||
for (var i = 0; i < this.data.blocks.length; i++) {
|
for (let i = 0; i < this.data.blocks.length; i++) {
|
||||||
var dataBlock = this.data.blocks[i]
|
const dataBlock = this.data.blocks[i]
|
||||||
blockMap.set(dataBlock.index, dataBlock)
|
blockMap.set(dataBlock.index, dataBlock)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -46,23 +46,24 @@ export class DOStage {
|
|||||||
console.log("levelStr error", this.data.difficulty, this.data.index, levelStr)
|
console.log("levelStr error", this.data.difficulty, this.data.index, levelStr)
|
||||||
}
|
}
|
||||||
const list = new Map()
|
const list = new Map()
|
||||||
for (var i = 0; i < levelStr.length; i++) {
|
for (let i = 0; i < levelStr.length; i++) {
|
||||||
const letter = levelStr[i]
|
const letter = levelStr[i]
|
||||||
if (this.letterToNumber.has(letter)) { // 预设格子 使用配置文件初始化
|
if (this.letterToNumber.has(letter)) { // 预设格子 使用配置文件初始化
|
||||||
var show = this.letterToNumber.get(letter)
|
const show = this.letterToNumber.get(letter)
|
||||||
var dataBlock: DataBlock = { index: i, show, score: 0, notes: [] }
|
const dataBlock: DataBlock = { index: i, show, score: 0, notes: [] }
|
||||||
var doBlock = new DOBlock(dataBlock, true, show)
|
const doBlock = new DOBlock(dataBlock, true, show)
|
||||||
this.blocks.push(doBlock)
|
this.blocks.push(doBlock)
|
||||||
} else {
|
} else {
|
||||||
var show = this.letterToNumber.get(letter.toUpperCase())
|
const show = this.letterToNumber.get(letter.toUpperCase())
|
||||||
var dataBlock = blockMap.get(i)
|
if (blockMap.has(i)) { // 本地有持久化数据
|
||||||
if (dataBlock) { // 本地有持久化数据
|
const dataBlock = blockMap.get(i)
|
||||||
var doBlock = new DOBlock(dataBlock, false, show)
|
const doBlock = new DOBlock(dataBlock, false, show)
|
||||||
this.blocks.push(doBlock)
|
this.blocks.push(doBlock)
|
||||||
} else {
|
} else {
|
||||||
dataBlock = { index: i, show: 0, score: 0, notes: [] }
|
const notes: Array<number> = []
|
||||||
|
const dataBlock = { index: i, show: 0, score: 0, notes }
|
||||||
this.data.blocks.push(dataBlock)
|
this.data.blocks.push(dataBlock)
|
||||||
var doBlock = new DOBlock(dataBlock, false, show)
|
const doBlock = new DOBlock(dataBlock, false, show)
|
||||||
this.blocks.push(doBlock)
|
this.blocks.push(doBlock)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -90,13 +90,13 @@ export class StorageManager {
|
|||||||
|
|
||||||
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)
|
const doStage: DOStage = this.stageMap.get(stageID)
|
||||||
return doStage
|
return doStage
|
||||||
} else {
|
} else {
|
||||||
const jsonStr = Laya.LocalStorage.getItem(stageID)
|
const jsonStr = Laya.LocalStorage.getItem(stageID)
|
||||||
if (jsonStr) {
|
if (jsonStr) {
|
||||||
const dataStage: DataStage = JSON.parse(jsonStr)
|
const dataStage: DataStage = JSON.parse(jsonStr)
|
||||||
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
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import { Stage } from "../views/Stage"
|
|||||||
import { TopBar } from "../views/TopBar"
|
import { TopBar } from "../views/TopBar"
|
||||||
import { StorageManager } from "./StorageManager"
|
import { StorageManager } from "./StorageManager"
|
||||||
|
|
||||||
const { regClass, property } = Laya
|
const { regClass } = Laya
|
||||||
|
|
||||||
@regClass()
|
@regClass()
|
||||||
export class UIManager extends Laya.Script {
|
export class UIManager extends Laya.Script {
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
import { config } from "../constants/config"
|
import { config } from "../constants/config"
|
||||||
|
|
||||||
export function Utility_ConvertSecondToString(second: number) {
|
export function Utility_ConvertSecondToString(seconds: number) {
|
||||||
let last = second
|
let last = seconds
|
||||||
const hour = Math.floor(last / 3600)
|
const hour = Math.floor(last / 3600)
|
||||||
last = last - hour * 3600
|
last = last - hour * 3600
|
||||||
const minite = Math.floor(last / 60)
|
const minite = Math.floor(last / 60)
|
||||||
last = last - minite * 60
|
last = last - minite * 60
|
||||||
var second = Math.floor(last)
|
const 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}`)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,9 +35,9 @@ export class Block extends Laya.Script {
|
|||||||
this.YGroup = YGroup
|
this.YGroup = YGroup
|
||||||
|
|
||||||
let VBox = this.owner.getChildByName("VBox")
|
let VBox = this.owner.getChildByName("VBox")
|
||||||
for (var i = 0; i < VBox.numChildren; i++) {
|
for (let i = 0; i < VBox.numChildren; i++) {
|
||||||
var hbox = VBox.getChildAt(i)
|
const hbox = VBox.getChildAt(i)
|
||||||
for (var j = 0; j < hbox.numChildren; j++) {
|
for (let j = 0; j < hbox.numChildren; j++) {
|
||||||
const sp = hbox.getChildAt(j) as Laya.Sprite
|
const sp = hbox.getChildAt(j) as Laya.Sprite
|
||||||
this.tips_bgs.push(sp)
|
this.tips_bgs.push(sp)
|
||||||
}
|
}
|
||||||
@@ -45,9 +45,9 @@ export class Block extends Laya.Script {
|
|||||||
this.label_show = label_obj.getChildByName("label_show") as Laya.Label
|
this.label_show = label_obj.getChildByName("label_show") as Laya.Label
|
||||||
// this.label_show.text = XGroup + "" + YGroup
|
// this.label_show.text = XGroup + "" + YGroup
|
||||||
VBox = label_obj.getChildByName("VBox")
|
VBox = label_obj.getChildByName("VBox")
|
||||||
for (var i = 0; i < VBox.numChildren; i++) {
|
for (let i = 0; i < VBox.numChildren; i++) {
|
||||||
var hbox = VBox.getChildAt(i)
|
const hbox = VBox.getChildAt(i)
|
||||||
for (var j = 0; j < hbox.numChildren; j++) {
|
for (let j = 0; j < hbox.numChildren; j++) {
|
||||||
const Label = hbox.getChildAt(j) as Laya.Label
|
const Label = hbox.getChildAt(j) as Laya.Label
|
||||||
Label.text = ""
|
Label.text = ""
|
||||||
this.tips_labels.push(Label)
|
this.tips_labels.push(Label)
|
||||||
@@ -101,14 +101,14 @@ export class Block extends Laya.Script {
|
|||||||
if (config.H_SCREEN)
|
if (config.H_SCREEN)
|
||||||
blockSize = 30
|
blockSize = 30
|
||||||
if (visible) {
|
if (visible) {
|
||||||
var obj = this.tips_bgs[noteNumber - 1]
|
const obj = this.tips_bgs[noteNumber - 1]
|
||||||
obj.visible = true
|
obj.visible = true
|
||||||
obj.graphics.clear()
|
obj.graphics.clear()
|
||||||
obj.graphics.drawRect(0, 0, blockSize, blockSize, color)
|
obj.graphics.drawRect(0, 0, blockSize, blockSize, color)
|
||||||
obj.alpha = alpha
|
obj.alpha = alpha
|
||||||
} else {
|
} else {
|
||||||
for (let i = 0; i < this.tips_bgs.length; i++) {
|
for (let i = 0; i < this.tips_bgs.length; i++) {
|
||||||
var obj = this.tips_bgs[i]
|
const obj = this.tips_bgs[i]
|
||||||
obj.visible = false
|
obj.visible = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -164,7 +164,7 @@ export class Block extends Laya.Script {
|
|||||||
// 设置文字颜色
|
// 设置文字颜色
|
||||||
if (this.selected) {
|
if (this.selected) {
|
||||||
this.label_show.color = "#ffffff"
|
this.label_show.color = "#ffffff"
|
||||||
for (var i = 0; i < this.tips_labels.length; i++) {
|
for (let i = 0; i < this.tips_labels.length; i++) {
|
||||||
this.tips_labels[i].color = "#ffffff"
|
this.tips_labels[i].color = "#ffffff"
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -177,12 +177,12 @@ export class Block extends Laya.Script {
|
|||||||
} else {
|
} else {
|
||||||
this.label_show.color = "#cb3256"
|
this.label_show.color = "#cb3256"
|
||||||
}
|
}
|
||||||
for (var i = 0; i < this.tips_labels.length; i++) {
|
for (let i = 0; i < this.tips_labels.length; i++) {
|
||||||
this.tips_labels[i].color = "#2d3138"
|
this.tips_labels[i].color = "#2d3138"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (var i = 0; i < this.tips_labels.length; i++) {
|
for (let i = 0; i < this.tips_labels.length; i++) {
|
||||||
this.tips_labels[i].text = ""
|
this.tips_labels[i].text = ""
|
||||||
}
|
}
|
||||||
if (this.data.get_show() > 0) {
|
if (this.data.get_show() > 0) {
|
||||||
@@ -190,7 +190,7 @@ export class Block extends Laya.Script {
|
|||||||
} else {
|
} else {
|
||||||
this.label_show.text = ""
|
this.label_show.text = ""
|
||||||
const note_numbers = this.data.get_notes()
|
const note_numbers = this.data.get_notes()
|
||||||
for (var i = 0; i < note_numbers.length; i++) {
|
for (let i = 0; i < note_numbers.length; i++) {
|
||||||
const value = note_numbers[i]
|
const value = note_numbers[i]
|
||||||
const label = this.tips_labels[value - 1]
|
const label = this.tips_labels[value - 1]
|
||||||
label.text = value.toString()
|
label.text = value.toString()
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
const { regClass, property } = Laya
|
const { regClass } = Laya
|
||||||
|
|
||||||
@regClass()
|
@regClass()
|
||||||
export class Candy extends Laya.Script {
|
export class Candy extends Laya.Script {
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ export class GameDone extends Laya.Script {
|
|||||||
this.label_time.text = Utility_ConvertSecondToString(doStage.get_duration())
|
this.label_time.text = Utility_ConvertSecondToString(doStage.get_duration())
|
||||||
this.label_score.text = doStage.get_score().toString()
|
this.label_score.text = doStage.get_score().toString()
|
||||||
|
|
||||||
this.btn_new.on(Laya.Event.CLICK, this, (evt: Laya.Event) => {
|
this.btn_new.on(Laya.Event.CLICK, this, () => {
|
||||||
if (config.H_SCREEN) {
|
if (config.H_SCREEN) {
|
||||||
const 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)// 主线关卡更新难度进度
|
||||||
@@ -60,13 +60,13 @@ export class GameDone extends Laya.Script {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
this.btn_continue.on(Laya.Event.CLICK, this, (evt: Laya.Event) => { // 这个按钮只有从DC来的会显示
|
this.btn_continue.on(Laya.Event.CLICK, this, () => { // 这个按钮只有从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, () => {
|
||||||
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) {
|
||||||
|
|||||||
@@ -25,13 +25,13 @@ export class GameOver extends Laya.Script {
|
|||||||
public label_newOrClose: Laya.Label
|
public label_newOrClose: Laya.Label
|
||||||
|
|
||||||
public onSetStageInfo(doStage: DOStage): void {
|
public onSetStageInfo(doStage: DOStage): void {
|
||||||
this.btn_second.on(Laya.Event.CLICK, this, (evt: Laya.Event) => {
|
this.btn_second.on(Laya.Event.CLICK, this, () => {
|
||||||
doStage.set_mistake(doStage.get_mistake() - 1)
|
doStage.set_mistake(doStage.get_mistake() - 1)
|
||||||
EventManager.getInstance().DispatchEvent(EVENT_TYPES.NOT_UPDATE_MISTAKE)
|
EventManager.getInstance().DispatchEvent(EVENT_TYPES.NOT_UPDATE_MISTAKE)
|
||||||
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, () => {
|
||||||
const stageID = doStage.get_stageID()
|
const stageID = doStage.get_stageID()
|
||||||
const type = doStage.get_stageType()
|
const type = doStage.get_stageType()
|
||||||
const difficulty = doStage.get_difficulty()
|
const difficulty = doStage.get_difficulty()
|
||||||
@@ -43,7 +43,7 @@ export class GameOver extends Laya.Script {
|
|||||||
const type = doStage.get_stageType()
|
const type = doStage.get_stageType()
|
||||||
if (type === config.STAGE_TYPE.MAIN) {
|
if (type === config.STAGE_TYPE.MAIN) {
|
||||||
this.label_newOrClose.text = "New Game"
|
this.label_newOrClose.text = "New Game"
|
||||||
this.btn_newOrClose.on(Laya.Event.CLICK, this, (evt: Laya.Event) => {
|
this.btn_newOrClose.on(Laya.Event.CLICK, this, () => {
|
||||||
if (config.H_SCREEN) {
|
if (config.H_SCREEN) {
|
||||||
const 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)// 主线关卡更新难度进度
|
||||||
@@ -66,7 +66,7 @@ export class GameOver extends Laya.Script {
|
|||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
this.label_newOrClose.text = "Close"
|
this.label_newOrClose.text = "Close"
|
||||||
this.btn_newOrClose.on(Laya.Event.CLICK, this, (evt: Laya.Event) => {
|
this.btn_newOrClose.on(Laya.Event.CLICK, this, () => {
|
||||||
UIManager.getInstance().loadDCUI()
|
UIManager.getInstance().loadDCUI()
|
||||||
UIManager.getInstance().closeStageUI()
|
UIManager.getInstance().closeStageUI()
|
||||||
this.owner.destroy()
|
this.owner.destroy()
|
||||||
|
|||||||
@@ -32,12 +32,12 @@ export class GamePause extends Laya.Script {
|
|||||||
this.label_diffucuty.text = doStage.get_difficulty()
|
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, () => {
|
||||||
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, () => {
|
||||||
const stageID = doStage.get_stageID()
|
const stageID = doStage.get_stageID()
|
||||||
const type = doStage.get_stageType()
|
const type = doStage.get_stageType()
|
||||||
const difficulty = doStage.get_difficulty()
|
const difficulty = doStage.get_difficulty()
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ export class Home extends Laya.Script {
|
|||||||
|
|
||||||
// 组件被激活后执行,此时所有节点和组件均已创建完毕,此方法只执行一次
|
// 组件被激活后执行,此时所有节点和组件均已创建完毕,此方法只执行一次
|
||||||
onAwake(): void {
|
onAwake(): void {
|
||||||
var user = StorageManager.getInstance().getUser()
|
const user = StorageManager.getInstance().getUser()
|
||||||
const now = new Date()
|
const now = new Date()
|
||||||
const nowYear = now.getFullYear()
|
const nowYear = now.getFullYear()
|
||||||
const nowMonth = now.getMonth() + 1
|
const nowMonth = now.getMonth() + 1
|
||||||
@@ -104,11 +104,11 @@ export class Home extends Laya.Script {
|
|||||||
|
|
||||||
this.btn_new_blue.on(Laya.Event.CLICK, this, this.onClickNew)
|
this.btn_new_blue.on(Laya.Event.CLICK, this, this.onClickNew)
|
||||||
this.btn_new_white.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) => {
|
this.btn_go.on(Laya.Event.CLICK, this, () => {
|
||||||
UIManager.getInstance().loadStageUI(config.DEFAULT_STAGE_ID)
|
UIManager.getInstance().loadStageUI(config.DEFAULT_STAGE_ID)
|
||||||
this.owner.destroy()
|
this.owner.destroy()
|
||||||
})
|
})
|
||||||
var user = StorageManager.getInstance().getUser()
|
|
||||||
if (user.get_done(config.DEFAULT_STAGE_ID) >= 1) {
|
if (user.get_done(config.DEFAULT_STAGE_ID) >= 1) {
|
||||||
console.log("当前主线关卡完成")
|
console.log("当前主线关卡完成")
|
||||||
this.btn_new_blue.visible = true
|
this.btn_new_blue.visible = true
|
||||||
@@ -149,7 +149,7 @@ export class Home extends Laya.Script {
|
|||||||
// ======
|
// ======
|
||||||
}
|
}
|
||||||
|
|
||||||
public onClickNew(evt: Laya.Event): void {
|
public onClickNew(_evt: Laya.Event): void {
|
||||||
Laya.loader.load(respath.difficulty_ui_res).then((go) => {
|
Laya.loader.load(respath.difficulty_ui_res).then((go) => {
|
||||||
const prefab = go.create()
|
const prefab = go.create()
|
||||||
const d = UIManager.getInstance().getUIRoot().addChild(prefab).getComponent(Difficulty)
|
const d = UIManager.getInstance().getUIRoot().addChild(prefab).getComponent(Difficulty)
|
||||||
|
|||||||
@@ -104,10 +104,10 @@ export class Stage extends Laya.Script {
|
|||||||
this.btn_pause.on(Laya.Event.CLICK, this, () => {
|
this.btn_pause.on(Laya.Event.CLICK, this, () => {
|
||||||
UIManager.getInstance().loadGamePauseUI(this.data)
|
UIManager.getInstance().loadGamePauseUI(this.data)
|
||||||
})
|
})
|
||||||
for (var i = 0; i < this.obj_blocks.numChildren; i++) {
|
for (let i = 0; i < this.obj_blocks.numChildren; i++) {
|
||||||
var hbox = this.obj_blocks.getChildAt(i)
|
const hbox = this.obj_blocks.getChildAt(i)
|
||||||
var l_hbox = this.obj_block_labels.getChildAt(i)
|
const l_hbox = this.obj_block_labels.getChildAt(i)
|
||||||
for (var j = 0; j < hbox.numChildren; j++) {
|
for (let j = 0; j < hbox.numChildren; j++) {
|
||||||
const block = hbox.getChildAt(j).getComponent(Block)
|
const block = hbox.getChildAt(j).getComponent(Block)
|
||||||
this.blocks.push(block)
|
this.blocks.push(block)
|
||||||
let XGroup = 0
|
let XGroup = 0
|
||||||
@@ -124,10 +124,10 @@ export class Stage extends Laya.Script {
|
|||||||
block.onInit(j, i, XGroup, YGroup, l_vbox, this, this.onClickBlock)
|
block.onInit(j, i, XGroup, YGroup, l_vbox, this, this.onClickBlock)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (var i = 0; i < this.obj_candys.numChildren; i++) {
|
for (let i = 0; i < this.obj_candys.numChildren; i++) {
|
||||||
hbox = this.obj_candys.getChildAt(i)
|
const hbox = this.obj_candys.getChildAt(i)
|
||||||
l_hbox = this.obj_candy_labels.getChildAt(i)
|
const l_hbox = this.obj_candy_labels.getChildAt(i)
|
||||||
for (var j = 0; j < hbox.numChildren; j++) {
|
for (let j = 0; j < hbox.numChildren; j++) {
|
||||||
const candy = hbox.getChildAt(j).getComponent(Candy)
|
const candy = hbox.getChildAt(j).getComponent(Candy)
|
||||||
this.candys.push(candy)
|
this.candys.push(candy)
|
||||||
const box = l_hbox.getChildAt(j) as Laya.Box
|
const box = l_hbox.getChildAt(j) as Laya.Box
|
||||||
@@ -155,7 +155,7 @@ export class Stage extends Laya.Script {
|
|||||||
EventManager.getInstance().UnregisterEvent(EVENT_TYPES.NOT_UPDATE_PAUSE, Stage.EventUpdatePause)
|
EventManager.getInstance().UnregisterEvent(EVENT_TYPES.NOT_UPDATE_PAUSE, Stage.EventUpdatePause)
|
||||||
}
|
}
|
||||||
|
|
||||||
public static EventUpdateMistake(arg: any): void {
|
public static EventUpdateMistake(): void {
|
||||||
if (Stage._instance) {
|
if (Stage._instance) {
|
||||||
Stage._instance.onUpdateMistake()
|
Stage._instance.onUpdateMistake()
|
||||||
}
|
}
|
||||||
@@ -258,33 +258,33 @@ export class Stage extends Laya.Script {
|
|||||||
|
|
||||||
onSetBlock(block: Block, animated: boolean = false): void {
|
onSetBlock(block: Block, animated: boolean = false): void {
|
||||||
// 全部格子还原
|
// 全部格子还原
|
||||||
for (var i = 0; i < this.blocks.length; i++) {
|
for (let i = 0; i < this.blocks.length; i++) {
|
||||||
this.blocks[i].setBlockColor(config.BLOCK_COLOR.WHITE)
|
this.blocks[i].setBlockColor(config.BLOCK_COLOR.WHITE)
|
||||||
this.blocks[i].setTipsBgColor(false)
|
this.blocks[i].setTipsBgColor(false)
|
||||||
}
|
}
|
||||||
// 相关格子置灰
|
// 相关格子置灰
|
||||||
const relateds = this.findRelatedBlocks(block)
|
const relateds = this.findRelatedBlocks(block)
|
||||||
for (var i = 0; i < relateds.length; i++)
|
for (let i = 0; i < relateds.length; i++)
|
||||||
relateds[i].setBlockColor(config.BLOCK_COLOR.GREY)
|
relateds[i].setBlockColor(config.BLOCK_COLOR.GREY)
|
||||||
|
|
||||||
// 选中空白格子
|
// 选中空白格子
|
||||||
if (block.getData().get_show() <= 0) {
|
if (block.getData().get_show() <= 0) {
|
||||||
block.setBlockColor(config.BLOCK_COLOR.BLUE)
|
block.setBlockColor(config.BLOCK_COLOR.BLUE)
|
||||||
} else {
|
} else {
|
||||||
var sames = this.findSameNumberBlocks(block)// 相同数字的格子
|
const sameNumbers = this.findSameNumberBlocks(block)// 相同数字的格子
|
||||||
for (var i = 0; i < sames.length; i++) {
|
for (let i = 0; i < sameNumbers.length; i++) {
|
||||||
sames[i].setBlockColor(config.BLOCK_COLOR.BLUE, 0.4)
|
sameNumbers[i].setBlockColor(config.BLOCK_COLOR.BLUE, 0.4)
|
||||||
}
|
}
|
||||||
var sames = this.findSameNoteBlocks(block)// 相同数字的铅笔格子
|
const sameNotes = this.findSameNoteBlocks(block)// 相同数字的铅笔格子
|
||||||
for (var i = 0; i < sames.length; i++) {
|
for (let i = 0; i < sameNotes.length; i++) {
|
||||||
sames[i].setTipsBgColor(true, block.getData().get_show(), config.BLOCK_COLOR.BLUE, 0.4)
|
sameNotes[i].setTipsBgColor(true, block.getData().get_show(), config.BLOCK_COLOR.BLUE, 0.4)
|
||||||
}
|
}
|
||||||
// 正确
|
// 正确
|
||||||
if (block.getData().get_checked()) {
|
if (block.getData().get_checked()) {
|
||||||
block.setBlockColor(config.BLOCK_COLOR.BLUE)
|
block.setBlockColor(config.BLOCK_COLOR.BLUE)
|
||||||
} else { // 错误
|
} else { // 错误
|
||||||
if (animated) { // 填数状态播放闪动效果
|
if (animated) { // 填数状态播放闪动效果
|
||||||
for (var i = 0; i < relateds.length; i++) { // 相关且数字相同
|
for (let i = 0; i < relateds.length; i++) { // 相关且数字相同
|
||||||
if (relateds[i].getData().get_show() === block.getData().get_show()) { // 播放变红动效
|
if (relateds[i].getData().get_show() === block.getData().get_show()) { // 播放变红动效
|
||||||
if (relateds[i].getData().get_index() !== block.getData().get_index()) {
|
if (relateds[i].getData().get_index() !== block.getData().get_index()) {
|
||||||
// relateds[i].setBlockColor(config.BLOCK_COLOR.WHITE)
|
// relateds[i].setBlockColor(config.BLOCK_COLOR.WHITE)
|
||||||
@@ -293,7 +293,7 @@ export class Stage extends Laya.Script {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (var i = 0; i < relateds.length; i++) { // 相关且数字相同
|
for (let i = 0; i < relateds.length; i++) { // 相关且数字相同
|
||||||
if (relateds[i].getData().get_show() === block.getData().get_show()) { // 直接变红
|
if (relateds[i].getData().get_show() === block.getData().get_show()) { // 直接变红
|
||||||
if (relateds[i].getData().get_index() !== block.getData().get_index()) {
|
if (relateds[i].getData().get_index() !== block.getData().get_index()) {
|
||||||
relateds[i].setBlockColor(config.BLOCK_COLOR.RED, 0.4)
|
relateds[i].setBlockColor(config.BLOCK_COLOR.RED, 0.4)
|
||||||
@@ -319,7 +319,7 @@ export class Stage extends Laya.Script {
|
|||||||
this.onApplyBlock(block)
|
this.onApplyBlock(block)
|
||||||
}
|
}
|
||||||
|
|
||||||
onClickUndo(evt: Laya.Event): void {
|
onClickUndo(): void {
|
||||||
const undo = this.data.pop_undo()
|
const undo = this.data.pop_undo()
|
||||||
if (undo) {
|
if (undo) {
|
||||||
console.log("onClickUndo>>>>", JSON.stringify(undo))
|
console.log("onClickUndo>>>>", JSON.stringify(undo))
|
||||||
@@ -341,7 +341,7 @@ export class Stage extends Laya.Script {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onClickErase(evt: Laya.Event): void {
|
onClickErase(): void {
|
||||||
if (this.selectedBlock.getData().get_checked() === false) { // 未完成且有数字或者笔记才可以使用橡皮
|
if (this.selectedBlock.getData().get_checked() === false) { // 未完成且有数字或者笔记才可以使用橡皮
|
||||||
const show = this.selectedBlock.getData().get_show()
|
const show = this.selectedBlock.getData().get_show()
|
||||||
const notes = this.selectedBlock.getData().get_notes()
|
const notes = this.selectedBlock.getData().get_notes()
|
||||||
@@ -366,18 +366,18 @@ export class Stage extends Laya.Script {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onClickHint(evt: Laya.Event): void {
|
onClickHint(): void {
|
||||||
const hint = this.data.get_hint()
|
const hint = this.data.get_hint()
|
||||||
if (hint > 0) {
|
if (hint > 0) {
|
||||||
if (this.selectedBlock.getData().get_checked() === false) { // 当前选中的格子没有完成
|
if (this.selectedBlock.getData().get_checked() === false) { // 当前选中的格子没有完成
|
||||||
var correct = this.selectedBlock.getData().get_correct()
|
const correct = this.selectedBlock.getData().get_correct()
|
||||||
this.onApplyCandy(correct, true)
|
this.onApplyCandy(correct, true)
|
||||||
this.data.set_hint(hint - 1)
|
this.data.set_hint(hint - 1)
|
||||||
this.onUpdateHintStatus()
|
this.onUpdateHintStatus()
|
||||||
} else {
|
} else {
|
||||||
const list: Array<Block> = []
|
const list: Array<Block> = []
|
||||||
for (let i = 0; i < this.blocks.length; i++) {
|
for (let i = 0; i < this.blocks.length; i++) {
|
||||||
var block = this.blocks[i]
|
const block = this.blocks[i]
|
||||||
if (block.getData().get_checked() === false)
|
if (block.getData().get_checked() === false)
|
||||||
list.push(block)
|
list.push(block)
|
||||||
}
|
}
|
||||||
@@ -386,9 +386,9 @@ export class Stage extends Laya.Script {
|
|||||||
let index = Math.round(random * list.length)
|
let index = Math.round(random * list.length)
|
||||||
if (index >= list.length)
|
if (index >= list.length)
|
||||||
index = list.length - 1
|
index = list.length - 1
|
||||||
var block = list[index]
|
const block = list[index]
|
||||||
this.onApplyBlock(block)
|
this.onApplyBlock(block)
|
||||||
var correct = block.getData().get_correct()
|
const correct = block.getData().get_correct()
|
||||||
this.onApplyCandy(correct, true)
|
this.onApplyCandy(correct, true)
|
||||||
this.data.set_hint(hint - 1)
|
this.data.set_hint(hint - 1)
|
||||||
this.onUpdateHintStatus()
|
this.onUpdateHintStatus()
|
||||||
@@ -415,7 +415,7 @@ export class Stage extends Laya.Script {
|
|||||||
if (this.data.get_note_open() && hint === false) {
|
if (this.data.get_note_open() && hint === false) {
|
||||||
const relateds = this.findRelatedBlocks(this.selectedBlock)
|
const relateds = this.findRelatedBlocks(this.selectedBlock)
|
||||||
let find = false
|
let find = false
|
||||||
for (var i = 0; i < relateds.length; i++) {
|
for (let i = 0; i < relateds.length; i++) {
|
||||||
if (relateds[i].getData().get_show() === showNumber) {
|
if (relateds[i].getData().get_show() === showNumber) {
|
||||||
find = true
|
find = true
|
||||||
break
|
break
|
||||||
@@ -426,7 +426,7 @@ export class Stage extends Laya.Script {
|
|||||||
this.selectedBlock.addNoteNumber(showNumber)
|
this.selectedBlock.addNoteNumber(showNumber)
|
||||||
this.onSetBlock(this.selectedBlock)
|
this.onSetBlock(this.selectedBlock)
|
||||||
} else {
|
} else {
|
||||||
for (var i = 0; i < relateds.length; i++) {
|
for (let i = 0; i < relateds.length; i++) {
|
||||||
const obj = relateds[i]
|
const obj = relateds[i]
|
||||||
if (obj.getData().get_show() === showNumber && obj.getData().get_index() !== this.selectedBlock.getData().get_index()) {
|
if (obj.getData().get_show() === showNumber && obj.getData().get_index() !== this.selectedBlock.getData().get_index()) {
|
||||||
obj.setFadeAnimation()
|
obj.setFadeAnimation()
|
||||||
@@ -453,7 +453,7 @@ export class Stage extends Laya.Script {
|
|||||||
let all = 0
|
let all = 0
|
||||||
let finished = 0
|
let finished = 0
|
||||||
const blocks = this.data.get_blocks()
|
const blocks = this.data.get_blocks()
|
||||||
for (var i = 0; i < blocks.length; i++) {
|
for (let i = 0; i < blocks.length; i++) {
|
||||||
if (blocks[i].get_preset() === false) {
|
if (blocks[i].get_preset() === false) {
|
||||||
all++
|
all++
|
||||||
if (blocks[i].get_checked()) {
|
if (blocks[i].get_checked()) {
|
||||||
@@ -519,16 +519,16 @@ export class Stage extends Laya.Script {
|
|||||||
|
|
||||||
onUpdateCandys(): void {
|
onUpdateCandys(): void {
|
||||||
const list: Map<number, number> = new Map()
|
const list: Map<number, number> = new Map()
|
||||||
for (var i = 1; i <= 9; i++)
|
for (let i = 1; i <= 9; i++)
|
||||||
list.set(i, 0)
|
list.set(i, 0)
|
||||||
for (var i = 0; i < this.blocks.length; i++) {
|
for (let i = 0; i < this.blocks.length; i++) {
|
||||||
const block = this.blocks[i]
|
const block = this.blocks[i]
|
||||||
if (block.getData().get_checked() === false) {
|
if (block.getData().get_checked() === false) {
|
||||||
const correct = block.getData().get_correct()
|
const correct = block.getData().get_correct()
|
||||||
list.set(correct, list.get(correct) + 1)
|
list.set(correct, list.get(correct) + 1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (var i = 0; i < this.candys.length; i++) {
|
for (let i = 0; i < this.candys.length; i++) {
|
||||||
const candy = this.candys[i]
|
const candy = this.candys[i]
|
||||||
const show = i + 1
|
const show = i + 1
|
||||||
const left = list.get(show)
|
const left = list.get(show)
|
||||||
|
|||||||
@@ -140,7 +140,7 @@ export class TopBar extends Laya.Script {
|
|||||||
}
|
}
|
||||||
|
|
||||||
updateDifficulty(difficulty: string): void {
|
updateDifficulty(difficulty: string): void {
|
||||||
this.items.forEach((label: Laya.Label, key: string) => {
|
this.items.forEach((label: Laya.Label) => {
|
||||||
label.color = "#0e2a53"
|
label.color = "#0e2a53"
|
||||||
})
|
})
|
||||||
const label = this.items.get(difficulty)
|
const label = this.items.get(difficulty)
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ export class CalendarUnit extends Laya.Script {
|
|||||||
} else {
|
} else {
|
||||||
this.label_show.text = this.day.toString()
|
this.label_show.text = this.day.toString()
|
||||||
this.label_show.color = "#d3d5db"
|
this.label_show.color = "#d3d5db"
|
||||||
this.owner.on(Laya.Event.CLICK, this, (evt: Laya.Event) => {
|
this.owner.on(Laya.Event.CLICK, this, () => {
|
||||||
|
|
||||||
})
|
})
|
||||||
this.obj_selected.visible = false
|
this.obj_selected.visible = false
|
||||||
|
|||||||
@@ -97,7 +97,7 @@ export class DailyChallenge extends Laya.Script {
|
|||||||
UIManager.getInstance().loadTrophyUI()
|
UIManager.getInstance().loadTrophyUI()
|
||||||
})
|
})
|
||||||
|
|
||||||
this.btn_play.on(Laya.Event.CLICK, this, (evt: Laya.Event) => {
|
this.btn_play.on(Laya.Event.CLICK, this, () => {
|
||||||
// console.log(">>>>>>>>>>>>>>>>>>>>>>>", this.selectedUnit.day)
|
// console.log(">>>>>>>>>>>>>>>>>>>>>>>", this.selectedUnit.day)
|
||||||
const now = new Date()
|
const now = new Date()
|
||||||
const year = now.getFullYear()
|
const year = now.getFullYear()
|
||||||
@@ -114,7 +114,7 @@ export class DailyChallenge extends Laya.Script {
|
|||||||
this.owner.destroy()
|
this.owner.destroy()
|
||||||
})
|
})
|
||||||
|
|
||||||
for (var i = 0; i < this.obj_items.numChildren; i++) {
|
for (let i = 0; i < this.obj_items.numChildren; i++) {
|
||||||
const hbox = this.obj_items.getChildAt(i)
|
const hbox = this.obj_items.getChildAt(i)
|
||||||
const l_hbox = this.obj_labels.getChildAt(i)
|
const l_hbox = this.obj_labels.getChildAt(i)
|
||||||
for (let j = 0; j < hbox.numChildren; j++) {
|
for (let j = 0; j < hbox.numChildren; j++) {
|
||||||
@@ -129,7 +129,7 @@ export class DailyChallenge extends Laya.Script {
|
|||||||
const now = new Date()
|
const now = new Date()
|
||||||
const nowYear = now.getFullYear()
|
const nowYear = now.getFullYear()
|
||||||
const nowMonth = now.getMonth() + 1
|
const nowMonth = now.getMonth() + 1
|
||||||
for (var i = 0; i < MONTH_LIST.length; i++) {
|
for (let i = 0; i < MONTH_LIST.length; i++) {
|
||||||
const obj = MONTH_LIST[i]
|
const obj = MONTH_LIST[i]
|
||||||
if (nowYear === obj.year && nowMonth === obj.month) {
|
if (nowYear === obj.year && nowMonth === obj.month) {
|
||||||
this.indexMax = i
|
this.indexMax = i
|
||||||
@@ -261,14 +261,14 @@ export class DailyChallenge extends Laya.Script {
|
|||||||
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)
|
const 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)
|
const doStage = StorageManager.getInstance().getStage(stageID)
|
||||||
if (doStage) {
|
if (doStage) {
|
||||||
this.label_play.text = "Continue"
|
this.label_play.text = "Continue"
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -31,8 +31,8 @@ export class TrophyRoom extends Laya.Script {
|
|||||||
const now = new Date()
|
const now = new Date()
|
||||||
const nowYear = now.getFullYear()
|
const nowYear = now.getFullYear()
|
||||||
const nowMonth = now.getMonth() + 1
|
const nowMonth = now.getMonth() + 1
|
||||||
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]
|
||||||
infos.push(obj)
|
infos.push(obj)
|
||||||
if (obj.year === nowYear && obj.month === nowMonth) {
|
if (obj.year === nowYear && obj.month === nowMonth) {
|
||||||
break
|
break
|
||||||
@@ -42,8 +42,8 @@ export class TrophyRoom extends Laya.Script {
|
|||||||
|
|
||||||
const years: Array<number> = []
|
const years: Array<number> = []
|
||||||
const monthMap: Map<number, Array<any>> = new Map()
|
const monthMap: Map<number, Array<any>> = new Map()
|
||||||
for (var i = 0; i < infos.length; i++) {
|
for (let i = 0; i < infos.length; i++) {
|
||||||
obj = infos[i]
|
const obj = infos[i]
|
||||||
const find = years.indexOf(obj.year)
|
const find = years.indexOf(obj.year)
|
||||||
if (find < 0) {
|
if (find < 0) {
|
||||||
years.push(obj.year)
|
years.push(obj.year)
|
||||||
|
|||||||
Reference in New Issue
Block a user