提示当前格子
This commit is contained in:
@@ -220,23 +220,30 @@ export class Stage extends Laya.Script {
|
||||
}
|
||||
|
||||
onClickHint(evt: Laya.Event): void {
|
||||
var list: Array<Block> = new Array()
|
||||
for (var i=0; i<this.blocks.length; i++) {
|
||||
var block = this.blocks[i]
|
||||
if (block.getData().get_checked() == false)
|
||||
list.push(block)
|
||||
}
|
||||
if (list.length > 0) {
|
||||
var random = Math.random()
|
||||
var index = Math.round(random*list.length)
|
||||
if (index >= list.length)
|
||||
index = list.length -1
|
||||
var block = list[index]
|
||||
this.selectedBlock = block
|
||||
var correct = block.getData().get_correct()
|
||||
if (this.selectedBlock && this.selectedBlock.getData().get_checked() == false) {//当前选中的格子没有完成
|
||||
var correct = this.selectedBlock.getData().get_correct()
|
||||
var candy = this.candys[correct-1]
|
||||
this.onApplyCandy(candy)
|
||||
}
|
||||
else {
|
||||
var list: Array<Block> = new Array()
|
||||
for (var i=0; i<this.blocks.length; i++) {
|
||||
var block = this.blocks[i]
|
||||
if (block.getData().get_checked() == false)
|
||||
list.push(block)
|
||||
}
|
||||
if (list.length > 0) {
|
||||
var random = Math.random()
|
||||
var index = Math.round(random*list.length)
|
||||
if (index >= list.length)
|
||||
index = list.length -1
|
||||
var block = list[index]
|
||||
this.selectedBlock = block
|
||||
var correct = block.getData().get_correct()
|
||||
var candy = this.candys[correct-1]
|
||||
this.onApplyCandy(candy)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public onApplyCandy(candy: Candy): void {
|
||||
|
||||
Reference in New Issue
Block a user