import { G_ShowScoreTips } from "../views/GUITips"; const { regClass, property } = Laya; @regClass() export class Block extends Laya.Script { declare owner : Laya.Button; @property(Number) public XIndex: number = 0; @property(Number) public YIndex: number = 0; @property(Number) public XGroup: number = 0; @property(Number) public YGroup: number = 0; private selected: boolean = false private newSelect: boolean = false private preset: boolean = false//预设格子 private checked: boolean = false//正确格子 private showNumber: number = 0; private correctNumber: number = 0; private score: number = 0 private note_numbers: Array = new Array() private label_show: Laya.Label; private tips_labels: Array = new Array(); private animator: Laya.Animator2D public onInit(XIndex: number, YIndex: number, XGroup: number, YGroup: number, label_obj: Laya.Box, handler: any, func: any): void { this.XIndex = XIndex; this.YIndex = YIndex; this.XGroup = XGroup; this.YGroup = YGroup; this.label_show = label_obj.getChildByName("label_show") as Laya.Label var VBox = label_obj.getChildByName("VBox") for (var i=0; i{ this.animator.stop() }) } } public setBlock(preset: boolean, showNumber: number, correctNumber: number): void { this.preset = preset; this.checked = preset; this.showNumber = showNumber; this.correctNumber = correctNumber; this.score = 0 this.updateBlock(); } public getIsPreset(): boolean { return this.preset; } public getIsChecked(): boolean { return this.checked; } public getShowNumber(): number { return this.showNumber; } public setShowNumber(showNumber: number): boolean { if (this.checked == false) { if (showNumber == this.correctNumber) this.checked = true; this.showNumber = showNumber; if (this.checked || showNumber == 0) {//正确或者擦除 this.note_numbers = new Array() } this.score = 0 if (this.newSelect) { this.newSelect = false if (this.checked) { this.score = 150 G_ShowScoreTips(this.score.toString(), this.owner) } } this.updateBlock(); } return this.checked } public getCorrectNumber(): number { return this.correctNumber; } public getScore(): number { return this.score } public addNoteNumber(noteNumber: number): void { if (this.note_numbers.indexOf(noteNumber) < 0) { this.note_numbers.push(noteNumber) this.updateBlock(); } } updateBlock(): void { for (var i=0; i 0) { this.label_show.text = this.showNumber.toString(); if (this.checked) { this.label_show.color = "#000000" } else { this.label_show.color = "#ff0000" } } else { this.label_show.text = ""; for (var i=0; i