添加道具功能

This commit is contained in:
2025-05-12 21:18:27 +08:00
parent 45d7df0184
commit 2ca60b215b
40 changed files with 3148 additions and 240 deletions

6
NOTE.txt Normal file
View File

@@ -0,0 +1,6 @@
玩法功能问题
无限撤回
提示说明
中英文翻译

File diff suppressed because it is too large Load Diff

Binary file not shown.

View File

@@ -0,0 +1,3 @@
{
"uuid": "ffc1d580-9237-4231-a78d-f39d72640d50"
}

View File

@@ -0,0 +1,53 @@
{
"_$type": "Animator",
"enabled": true,
"path": "",
"cullingMode": 2,
"controllerLayers": [
{
"name": "Base Layer",
"states": [
{
"x": 84,
"y": 176,
"id": "-1",
"name": "进入",
"nexts": [],
"soloTransitions": [
{
"id": "0",
"exitByTime": true,
"exitTime": 1
}
]
},
{
"y": 305,
"id": "-2",
"name": "任何状态",
"x": 70,
"soloTransitions": []
},
{
"x": 291,
"y": 262,
"_isLooping": 0,
"id": "0",
"name": "fade_to_red",
"speed": 1,
"clipEnd": 1,
"loop": 0,
"clip": {
"_$uuid": "ffc1d580-9237-4231-a78d-f39d72640d50"
},
"soloTransitions": []
}
],
"playOnWake": false,
"blendingMode": 0,
"defaultWeight": 1
}
],
"layerW": 150,
"animatorParams": []
}

View File

@@ -0,0 +1,3 @@
{
"uuid": "d1fce7b7-1bf7-4f74-9c5a-bd9051e10b95"
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

View File

@@ -0,0 +1,6 @@
{
"uuid": "7c87f6c5-6334-4f12-b61a-22c3af858d8f",
"importer": {
"textureType": 2
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

View File

@@ -0,0 +1,6 @@
{
"uuid": "15fb8b20-2b34-48fb-8259-499ebf380309",
"importer": {
"textureType": 2
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

View File

@@ -0,0 +1,6 @@
{
"uuid": "a5777c44-0002-4629-b646-c0e8098c7f80",
"importer": {
"textureType": 2
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

View File

@@ -0,0 +1,6 @@
{
"uuid": "e2b45239-87db-4cee-9dd7-a2d1762abc24",
"importer": {
"textureType": 2
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 388 B

View File

@@ -1,6 +0,0 @@
{
"uuid": "735153fb-4c79-4186-a0ce-084a936e804c",
"importer": {
"textureType": 2
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 391 B

View File

@@ -1,6 +0,0 @@
{
"uuid": "9108533f-196d-4022-847a-ddfcb8a27833",
"importer": {
"textureType": 2
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 390 B

View File

@@ -1,6 +0,0 @@
{
"uuid": "340fd635-b217-4696-9990-01f2cdae0be4",
"importer": {
"textureType": 2
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

View File

@@ -0,0 +1,6 @@
{
"uuid": "4870f053-9781-471b-a405-ea95b5318a98",
"importer": {
"textureType": 2
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

View File

@@ -0,0 +1,6 @@
{
"uuid": "45de1954-6e2a-45bf-a9a3-aa9a684be816",
"importer": {
"textureType": 2
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

View File

@@ -0,0 +1,6 @@
{
"uuid": "18ec8458-52a2-405b-886a-f6441ed4f785",
"importer": {
"textureType": 2
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

View File

@@ -0,0 +1,6 @@
{
"uuid": "3d714bdf-39fd-48aa-b29d-5c179abc1981",
"importer": {
"textureType": 2
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

View File

@@ -0,0 +1,6 @@
{
"uuid": "8cacbf45-5b2c-4ec0-ad94-5ca671b74d72",
"importer": {
"textureType": 2
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 392 B

View File

@@ -1,6 +0,0 @@
{
"uuid": "6391adfb-3d90-48e7-97cd-42c34c88255b",
"importer": {
"textureType": 2
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 391 B

View File

@@ -1,6 +0,0 @@
{
"uuid": "fa5d5577-1a74-4232-a8c3-e7926980227b",
"importer": {
"textureType": 2
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 347 B

View File

@@ -0,0 +1,6 @@
{
"uuid": "c46eab14-87ac-4178-a786-afe811fc0848",
"importer": {
"textureType": 2
}
}

View File

@@ -1,7 +1,8 @@
{
"resolution": {
"designWidth": 1080,
"designHeight": 1920
"designHeight": 1920,
"scaleMode": "fixedauto"
},
"modules": {
"laya.ui": true,

View File

@@ -4,9 +4,6 @@ const { regClass, property } = Laya;
export class Block extends Laya.Script {
declare owner : Laya.Button;
private label_show: Laya.Label;
private tips_labels: Array<Laya.Label> = new Array();
@property(Number)
public XIndex: number = 0;
@property(Number)
@@ -16,12 +13,23 @@ export class Block extends Laya.Script {
@property(Number)
public YGroup: number = 0;
private selected: boolean = false
private preset: boolean = false//预设格子
private checked: boolean = false//正确格子
private showNumber: number = 0;
private correctNumber: number = 0;
private note_numbers: Array<number> = new Array()
private label_show: Laya.Label;
private tips_labels: Array<Laya.Label> = 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;
public onInit(label_obj: Laya.Box, XIndex: number, YIndex: number, XGroup: number, YGroup: number, handler: any, func: any): void {
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++) {
@@ -32,16 +40,27 @@ export class Block extends Laya.Script {
this.tips_labels.push(Label)
}
}
this.XIndex = XIndex;
this.YIndex = YIndex;
this.XGroup = XGroup;
this.YGroup = YGroup;
this.owner.on(Laya.Event.CLICK, handler, func);
this.animator = this.owner.getComponent(Laya.Animator2D)
}
public setSelected(selected: boolean): void {
this.selected = selected
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(preset: boolean, showNumber: number, correctNumber: number): void {
this.preset = preset;
@@ -63,18 +82,32 @@ export class Block extends Laya.Script {
return this.showNumber;
}
public getCorrectNumber(): number {
return this.correctNumber;
}
public setShowNumber(showNumber: number): boolean {
console.log("setShowNumber >>>>>", showNumber, this.correctNumber, this.XIndex, this.YIndex)
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.updateBlock();
}
return this.checked
}
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<this.tips_labels.length; i++)
this.tips_labels[i].text = ""
if (this.showNumber > 0) {
this.label_show.text = this.showNumber.toString();
if (this.checked) {
@@ -86,6 +119,17 @@ export class Block extends Laya.Script {
}
else {
this.label_show.text = "";
for (var i=0; i<this.note_numbers.length; i++) {
var value = this.note_numbers[i]
var label = this.tips_labels[value-1]
label.text = value.toString()
if (this.selected) {
label.color = "#ffffff"
}
else {
label.color = "#000000"
}
}
}
}

View File

@@ -10,11 +10,13 @@ export class Candy extends Laya.Script {
private showNumber: number = 0;
private left: number = 0;
public onInit(label_obj: Laya.Box, showNumber: number, handler: any, func: any): void {
public onInit(showNumber: number, label_obj: Laya.Box, handler: any, func: any): void {
this.showNumber = showNumber
this.label_show = label_obj.getChildByName("label") as Laya.Label
this.label_left = label_obj.getChildByName("label_left") as Laya.Label
this.showNumber = showNumber
this.owner.on(Laya.Event.CLICK, handler, func)
this.updateCandy()
}

View File

@@ -23,6 +23,19 @@ export class Stage extends Laya.Script {
public obj_candy_labels: Laya.Box;
private candys: Array<Candy> = new Array();
@property(Laya.Box)
public btn_undo: Laya.Box;
@property(Laya.Box)
public btn_erase: Laya.Box;
@property(Laya.Box)
public btn_note: Laya.Box;
@property(Laya.Box)
public btn_hint: Laya.Box;
private is_note_open: boolean = false
private btn_note_normal: Laya.Box
private btn_note_checked: Laya.Box
@property(Laya.Box)
public obj_block_colors: Laya.Box;
@property(Laya.Image)
@@ -82,16 +95,26 @@ export class Stage extends Laya.Script {
if (j==6 || j==7 || j==8)
YGroup = 2
var l_vbox = l_hbox.getChildAt(j) as Laya.Box
block.onInit(l_vbox, i, j, XGroup, YGroup, this, this.onClickBlock)
block.onInit(i, j, XGroup, YGroup, l_vbox, this, this.onClickBlock)
}
}
for (var i=0; i<this.obj_candys.numChildren; i++) {
var candy = this.obj_candys.getChildAt(i).getComponent(Candy);
this.candys.push(candy);
var box = this.obj_candy_labels.getChildAt(i) as Laya.Box
candy.onInit(box, i+1, this, this.onClickCandy)
candy.onInit(i+1, box, this, this.onClickCandy)
}
this.btn_undo.on(Laya.Event.CLICK, this, this.onClickUndo)
this.btn_erase.on(Laya.Event.CLICK, this, this.onClickErase)
this.btn_note.on(Laya.Event.CLICK, this, this.onClickNote)
this.btn_hint.on(Laya.Event.CLICK, this, this.onClickHint)
this.btn_note_normal = this.btn_note.getChildByName("normal") as Laya.Box
this.btn_note_checked = this.btn_note.getChildByName("checked") as Laya.Box
this.btn_note_normal.visible = this.is_note_open == false
this.btn_note_checked.visible = this.is_note_open
this.obj_block_colors.visible = false
}
@@ -134,7 +157,7 @@ export class Stage extends Laya.Script {
}
}
_onClickBlock(block: Block): void {
onSetBlock(block: Block): void {
//全部格子还原
for (var i=0; i<this.blocks.length; i++) {
this.blocks[i].setButtonSkin(this.img_block_normal.skin)
@@ -166,30 +189,105 @@ export class Stage extends Laya.Script {
}
}
}
public onClickBlock(evt: Laya.Event): void {
onClickBlock(evt: Laya.Event): void {
if (this.selectedBlock)
this.selectedBlock.setSelected(false)
var block = evt.target.getComponent(Block);
block.setSelected(true)
this.onSetBlock(block)
this.selectedBlock = block
this._onClickBlock(block)
}
public onClickCandy(evt: Laya.Event): void {
onClickUndo(evt: Laya.Event): void {
}
onClickErase(evt: Laya.Event): void {
if (this.selectedBlock && this.selectedBlock.getIsChecked() == false) {
var candy = evt.target.getComponent(Candy);
var b = this.selectedBlock.setShowNumber(candy.getShowNumber());
this._onClickBlock(this.selectedBlock)
if (b) {
var left = candy.getLeft();
candy.setLeft(left-1);
if (this.getIsComplete()) {
console.log("完成关卡")
this.selectedBlock.setShowNumber(0)
this.onSetBlock(this.selectedBlock)
}
}
onClickNote(evt: Laya.Event): void {
this.is_note_open = !this.is_note_open
this.btn_note_normal.visible = this.is_note_open == false
this.btn_note_checked.visible = this.is_note_open
}
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.getIsChecked() == 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]
block.setShowNumber(block.getCorrectNumber())
this.selectedBlock = block
this.onSetBlock(block)
}
}
public onApplyCandy(candy: Candy): void {
if (this.selectedBlock && this.selectedBlock.getIsChecked() == false) {
var showNumber = candy.getShowNumber()
if (this.is_note_open) {
var relateds = this.findRelatedBlocks(this.selectedBlock)
var find = false
for (var i=0; i<relateds.length; i++) {
if (relateds[i].getShowNumber() == showNumber) {
find = true
break
}
}
if (find == false) {
this.selectedBlock.addNoteNumber(showNumber)
}
else {
for (var i=0; i<relateds.length; i++) {
var obj = relateds[i]
if (obj.getShowNumber() == showNumber) {
obj.setFadeAnimation()
}
}
}
}
else {
var b = this.selectedBlock.setShowNumber(showNumber);
this.onSetBlock(this.selectedBlock)
if (b) {
var left = candy.getLeft();
candy.setLeft(left-1);
if (this.getIsComplete()) {
console.log("完成关卡")
}
}
else {
}
}
}
}
public onClickCandy(evt: Laya.Event): void {
var candy = evt.target.getComponent(Candy);
this.onApplyCandy(candy)
}
onKeyUp(evt: Laya.Event): void {
var n = Number(evt.key)
if (n && n > 0) {
var candy = this.candys[n-1]
this.onApplyCandy(candy)
}
}
findRelatedBlocks(obj: Block): Array<Block> {
var list: Array<Block> = new Array()
for (var i=0; i<this.blocks.length; i++) {