移动脚本目录

This commit is contained in:
2025-05-14 19:22:21 +08:00
parent 830bf2bb29
commit f229ce7fa0
12 changed files with 8 additions and 9 deletions

128
src/views/Block.ts Normal file
View File

@@ -0,0 +1,128 @@
import { G_ShowScoreTips } from "../views/GUITips";
import { DOBlock } from "../models/DOBlock";
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 label_show: Laya.Label;
private tips_labels: Array<Laya.Label> = new Array();
private animator: Laya.Animator2D
private selected: boolean = false
private newSelect: boolean = false
private data: DOBlock
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<VBox.numChildren; i++) {
var hbox = VBox.getChildAt(i);
for (var j=0; j<hbox.numChildren; j++) {
var Label = hbox.getChildAt(j) as Laya.Label
Label.text = ""
this.tips_labels.push(Label)
}
}
this.owner.on(Laya.Event.CLICK, handler, func);
this.animator = this.owner.getComponent(Laya.Animator2D)
}
public setSelected(selected: boolean): void {
this.selected = selected
if (selected)
this.newSelect = true
this.updateBlock()
}
public setButtonSkin(skin: string): void {
this.owner.skin = skin
}
public setFadeAnimation(): void {
if (this.animator) {
this.animator.play("fade_to_red")
Laya.timer.frameOnce(40, this, ()=>{
this.animator.stop()
})
}
}
public setBlock(data: DOBlock): void {
this.data = data;
this.updateBlock();
}
public getData(): DOBlock {
return this.data
}
public setShowNumber(showNumber: number): boolean {
if (this.data.get_checked() == false) {
this.data.set_show(showNumber)
var score: number = 0
if (this.newSelect) {
this.newSelect = false
if (this.data.get_checked()) {
score = 150
this.data.set_score(score)
G_ShowScoreTips(score.toString(), this.owner)
}
}
this.updateBlock()
}
return this.data.get_checked()
}
public addNoteNumber(noteNumber: number): void {
if (this.data.add_note(noteNumber)) {
this.updateBlock()
}
}
updateBlock(): void {
for (var i=0; i<this.tips_labels.length; i++)
this.tips_labels[i].text = ""
if (this.data.get_show() > 0) {
this.label_show.text = this.data.get_show().toString()
if (this.data.get_checked()) {
this.label_show.color = "#000000"
}
else {
this.label_show.color = "#ff0000"
}
}
else {
this.label_show.text = "";
var note_numbers = this.data.get_notes()
for (var i=0; i<note_numbers.length; i++) {
var value = note_numbers[i]
var label = this.tips_labels[value-1]
label.text = value.toString()
if (this.selected) {
label.color = "#ffffff"
}
else {
label.color = "#000000"
}
}
}
}
}

3
src/views/Block.ts.meta Normal file
View File

@@ -0,0 +1,3 @@
{
"uuid": "abc6b60b-980b-4853-baa5-ac8506e00c4a"
}

51
src/views/Candy.ts Normal file
View File

@@ -0,0 +1,51 @@
import { DOCandy } from "../models/DOCandy";
const { regClass, property } = Laya;
@regClass()
export class Candy extends Laya.Script {
declare owner : Laya.Button;
private label_show: Laya.Label;
private label_left: Laya.Label;
private data: DOCandy
public onInit(label_obj: Laya.Box, handler: any, func: any): void {
this.label_show = label_obj.getChildByName("label") as Laya.Label
this.label_left = label_obj.getChildByName("label_left") as Laya.Label
this.owner.on(Laya.Event.CLICK, handler, func)
}
public setCandy(data: DOCandy): void {
this.data = data
this.updateCandy()
}
public getData(): DOCandy {
return this.data
}
public setLeft(left: number): void {
this.data.set_left(left)
this.updateCandy()
}
updateCandy(): void {
if (this.data.get_show() > 0) {
this.label_show.text = this.data.get_show().toString()
}
else {
this.label_show.text = ""
}
if (this.data.get_left() > 0) {
this.label_left.text = this.data.get_left().toString();
this.owner.visible = true
}
else {
this.label_left.text = ""
this.owner.visible = false
this.label_show.text = ""
}
}
}

3
src/views/Candy.ts.meta Normal file
View File

@@ -0,0 +1,3 @@
{
"uuid": "067a5d3a-4d7c-48d7-bb01-db2682fd6c01"
}