完善撤回逻辑
This commit is contained in:
@@ -52,6 +52,7 @@ export class Stage extends Laya.Script {
|
||||
private data: DOStage;
|
||||
private selectedBlock: Block;
|
||||
|
||||
|
||||
//组件被激活后执行,此时所有节点和组件均已创建完毕,此方法只执行一次
|
||||
onAwake(): void {
|
||||
this.btn_back.on(Laya.Event.CLICK, this, ()=>{
|
||||
@@ -209,32 +210,28 @@ export class Stage extends Laya.Script {
|
||||
this.onApplyBlock(block)
|
||||
}
|
||||
|
||||
|
||||
onApplyUndo(undo: DataUndo): void {
|
||||
|
||||
}
|
||||
onClickUndo(evt: Laya.Event): void {
|
||||
var undo = this.data.pop_undo()
|
||||
if (undo) {
|
||||
// console.log("onClickUndo>>>>", JSON.stringify(undo))
|
||||
// this.selectedBlock = this.blocks[undo.index]
|
||||
// this.onApplyBlock(this.selectedBlock)
|
||||
// if (undo.type == config.UNDO_TYPE.NORMAL) {
|
||||
// var block = this.blocks[undo.index]
|
||||
|
||||
// this.selectedBlock.setShowNumber(undo.value)
|
||||
// this.onSetBlock(this.selectedBlock)
|
||||
// }
|
||||
// else if (undo.type == config.UNDO_TYPE.NOTE) {
|
||||
|
||||
// }
|
||||
console.log("onClickUndo>>>>", JSON.stringify(undo))
|
||||
this.selectedBlock = this.blocks[undo.index]
|
||||
this.onApplyBlock(this.selectedBlock)
|
||||
if (undo.notes && undo.notes.length > 0) {
|
||||
this.selectedBlock.setNotes(undo.notes)
|
||||
}
|
||||
else {
|
||||
this.selectedBlock.setShowNumber(undo.show)
|
||||
}
|
||||
this.onSetBlock(this.selectedBlock)
|
||||
}
|
||||
}
|
||||
|
||||
onClickErase(evt: Laya.Event): void {
|
||||
if (this.selectedBlock.getData().get_checked() == false) {//未完成切有数字或者笔记才可以使用橡皮
|
||||
if (this.selectedBlock.getData().get_show() > 0 || this.selectedBlock.getData().get_notes().length > 0) {
|
||||
this.data.add_undo(config.UNDO_TYPE.NORMAL, this.selectedBlock.getData().get_index(), 0)
|
||||
if (this.selectedBlock.getData().get_checked() == false) {//未完成且有数字或者笔记才可以使用橡皮
|
||||
var show = this.selectedBlock.getData().get_show()
|
||||
var notes = this.selectedBlock.getData().get_notes()
|
||||
if (show > 0 || notes.length > 0) {
|
||||
this.data.add_undo(this.selectedBlock.getData().get_index(), show, notes)
|
||||
this.selectedBlock.setShowNumber(0)
|
||||
this.onUpdateScore()
|
||||
this.onSetBlock(this.selectedBlock)
|
||||
@@ -288,6 +285,7 @@ export class Stage extends Laya.Script {
|
||||
this.data.set_hint(9)
|
||||
this.onUpdateHintStatus()
|
||||
}
|
||||
|
||||
}
|
||||
onUpdateHintStatus(): void {
|
||||
var hint = this.data.get_hint()
|
||||
@@ -297,6 +295,8 @@ export class Stage extends Laya.Script {
|
||||
}
|
||||
|
||||
public onApplyCandy(showNumber: number): void {
|
||||
var show = this.selectedBlock.getData().get_show()
|
||||
var notes = this.selectedBlock.getData().get_notes()
|
||||
if (this.selectedBlock.getData().get_checked() == false) {
|
||||
if (this.data.get_note_open()) {
|
||||
var relateds = this.findRelatedBlocks(this.selectedBlock)
|
||||
@@ -308,25 +308,26 @@ export class Stage extends Laya.Script {
|
||||
}
|
||||
}
|
||||
if (find == false) {
|
||||
this.data.add_undo(this.selectedBlock.getData().get_index(), show, notes)
|
||||
this.selectedBlock.addNoteNumber(showNumber)
|
||||
this.onSetBlock(this.selectedBlock)
|
||||
}
|
||||
else {
|
||||
for (var i=0; i<relateds.length; i++) {
|
||||
var obj = relateds[i]
|
||||
if (obj.getData().get_show() == showNumber) {
|
||||
if (obj.getData().get_show() == showNumber && obj.getData().get_index() != this.selectedBlock.getData().get_index()) {
|
||||
obj.setFadeAnimation()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
this.data.add_undo(this.selectedBlock.getData().get_index(), show, notes)
|
||||
if (this.selectedBlock.getData().get_show() == showNumber) {
|
||||
this.data.add_undo(config.UNDO_TYPE.NORMAL, this.selectedBlock.getData().get_index(), 0)
|
||||
this.selectedBlock.setShowNumber(0);
|
||||
this.onSetBlock(this.selectedBlock)
|
||||
}
|
||||
else {
|
||||
this.data.add_undo(config.UNDO_TYPE.NORMAL, this.selectedBlock.getData().get_index(), showNumber)
|
||||
var b = this.selectedBlock.setShowNumber(showNumber)
|
||||
this.onUpdateScore()
|
||||
this.onSetBlock(this.selectedBlock, true)
|
||||
|
||||
Reference in New Issue
Block a user