格式化代码 var to let or const
This commit is contained in:
@@ -104,10 +104,10 @@ export class Stage extends Laya.Script {
|
||||
this.btn_pause.on(Laya.Event.CLICK, this, () => {
|
||||
UIManager.getInstance().loadGamePauseUI(this.data)
|
||||
})
|
||||
for (var i = 0; i < this.obj_blocks.numChildren; i++) {
|
||||
var hbox = this.obj_blocks.getChildAt(i)
|
||||
var l_hbox = this.obj_block_labels.getChildAt(i)
|
||||
for (var j = 0; j < hbox.numChildren; j++) {
|
||||
for (let i = 0; i < this.obj_blocks.numChildren; i++) {
|
||||
const hbox = this.obj_blocks.getChildAt(i)
|
||||
const l_hbox = this.obj_block_labels.getChildAt(i)
|
||||
for (let j = 0; j < hbox.numChildren; j++) {
|
||||
const block = hbox.getChildAt(j).getComponent(Block)
|
||||
this.blocks.push(block)
|
||||
let XGroup = 0
|
||||
@@ -124,10 +124,10 @@ export class Stage extends Laya.Script {
|
||||
block.onInit(j, i, XGroup, YGroup, l_vbox, this, this.onClickBlock)
|
||||
}
|
||||
}
|
||||
for (var i = 0; i < this.obj_candys.numChildren; i++) {
|
||||
hbox = this.obj_candys.getChildAt(i)
|
||||
l_hbox = this.obj_candy_labels.getChildAt(i)
|
||||
for (var j = 0; j < hbox.numChildren; j++) {
|
||||
for (let i = 0; i < this.obj_candys.numChildren; i++) {
|
||||
const hbox = this.obj_candys.getChildAt(i)
|
||||
const l_hbox = this.obj_candy_labels.getChildAt(i)
|
||||
for (let j = 0; j < hbox.numChildren; j++) {
|
||||
const candy = hbox.getChildAt(j).getComponent(Candy)
|
||||
this.candys.push(candy)
|
||||
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)
|
||||
}
|
||||
|
||||
public static EventUpdateMistake(arg: any): void {
|
||||
public static EventUpdateMistake(): void {
|
||||
if (Stage._instance) {
|
||||
Stage._instance.onUpdateMistake()
|
||||
}
|
||||
@@ -258,33 +258,33 @@ export class Stage extends Laya.Script {
|
||||
|
||||
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].setTipsBgColor(false)
|
||||
}
|
||||
// 相关格子置灰
|
||||
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)
|
||||
|
||||
// 选中空白格子
|
||||
if (block.getData().get_show() <= 0) {
|
||||
block.setBlockColor(config.BLOCK_COLOR.BLUE)
|
||||
} else {
|
||||
var sames = this.findSameNumberBlocks(block)// 相同数字的格子
|
||||
for (var i = 0; i < sames.length; i++) {
|
||||
sames[i].setBlockColor(config.BLOCK_COLOR.BLUE, 0.4)
|
||||
const sameNumbers = this.findSameNumberBlocks(block)// 相同数字的格子
|
||||
for (let i = 0; i < sameNumbers.length; i++) {
|
||||
sameNumbers[i].setBlockColor(config.BLOCK_COLOR.BLUE, 0.4)
|
||||
}
|
||||
var sames = this.findSameNoteBlocks(block)// 相同数字的铅笔格子
|
||||
for (var i = 0; i < sames.length; i++) {
|
||||
sames[i].setTipsBgColor(true, block.getData().get_show(), config.BLOCK_COLOR.BLUE, 0.4)
|
||||
const sameNotes = this.findSameNoteBlocks(block)// 相同数字的铅笔格子
|
||||
for (let i = 0; i < sameNotes.length; i++) {
|
||||
sameNotes[i].setTipsBgColor(true, block.getData().get_show(), config.BLOCK_COLOR.BLUE, 0.4)
|
||||
}
|
||||
// 正确
|
||||
if (block.getData().get_checked()) {
|
||||
block.setBlockColor(config.BLOCK_COLOR.BLUE)
|
||||
} else { // 错误
|
||||
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_index() !== block.getData().get_index()) {
|
||||
// relateds[i].setBlockColor(config.BLOCK_COLOR.WHITE)
|
||||
@@ -293,7 +293,7 @@ export class Stage extends Laya.Script {
|
||||
}
|
||||
}
|
||||
} 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_index() !== block.getData().get_index()) {
|
||||
relateds[i].setBlockColor(config.BLOCK_COLOR.RED, 0.4)
|
||||
@@ -319,7 +319,7 @@ export class Stage extends Laya.Script {
|
||||
this.onApplyBlock(block)
|
||||
}
|
||||
|
||||
onClickUndo(evt: Laya.Event): void {
|
||||
onClickUndo(): void {
|
||||
const undo = this.data.pop_undo()
|
||||
if (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) { // 未完成且有数字或者笔记才可以使用橡皮
|
||||
const show = this.selectedBlock.getData().get_show()
|
||||
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()
|
||||
if (hint > 0) {
|
||||
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.data.set_hint(hint - 1)
|
||||
this.onUpdateHintStatus()
|
||||
} else {
|
||||
const list: Array<Block> = []
|
||||
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)
|
||||
list.push(block)
|
||||
}
|
||||
@@ -386,9 +386,9 @@ export class Stage extends Laya.Script {
|
||||
let index = Math.round(random * list.length)
|
||||
if (index >= list.length)
|
||||
index = list.length - 1
|
||||
var block = list[index]
|
||||
const block = list[index]
|
||||
this.onApplyBlock(block)
|
||||
var correct = block.getData().get_correct()
|
||||
const correct = block.getData().get_correct()
|
||||
this.onApplyCandy(correct, true)
|
||||
this.data.set_hint(hint - 1)
|
||||
this.onUpdateHintStatus()
|
||||
@@ -415,7 +415,7 @@ export class Stage extends Laya.Script {
|
||||
if (this.data.get_note_open() && hint === false) {
|
||||
const relateds = this.findRelatedBlocks(this.selectedBlock)
|
||||
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) {
|
||||
find = true
|
||||
break
|
||||
@@ -426,7 +426,7 @@ export class Stage extends Laya.Script {
|
||||
this.selectedBlock.addNoteNumber(showNumber)
|
||||
this.onSetBlock(this.selectedBlock)
|
||||
} else {
|
||||
for (var i = 0; i < relateds.length; i++) {
|
||||
for (let i = 0; i < relateds.length; i++) {
|
||||
const obj = relateds[i]
|
||||
if (obj.getData().get_show() === showNumber && obj.getData().get_index() !== this.selectedBlock.getData().get_index()) {
|
||||
obj.setFadeAnimation()
|
||||
@@ -453,7 +453,7 @@ export class Stage extends Laya.Script {
|
||||
let all = 0
|
||||
let finished = 0
|
||||
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) {
|
||||
all++
|
||||
if (blocks[i].get_checked()) {
|
||||
@@ -519,16 +519,16 @@ export class Stage extends Laya.Script {
|
||||
|
||||
onUpdateCandys(): void {
|
||||
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)
|
||||
for (var i = 0; i < this.blocks.length; i++) {
|
||||
for (let i = 0; i < this.blocks.length; i++) {
|
||||
const block = this.blocks[i]
|
||||
if (block.getData().get_checked() === false) {
|
||||
const correct = block.getData().get_correct()
|
||||
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 show = i + 1
|
||||
const left = list.get(show)
|
||||
|
||||
Reference in New Issue
Block a user