调整核心玩法细节表现

This commit is contained in:
2025-05-15 21:36:03 +08:00
parent 860c069b99
commit b06c8d4414
17 changed files with 25009 additions and 6156 deletions

Binary file not shown.

View File

@@ -1,3 +0,0 @@
{
"uuid": "55f943ef-58d2-4b30-8498-271c4213cce4"
}

View File

@@ -69,7 +69,7 @@
"skin": "res://2e8c9585-e650-4494-a329-807fd2d2a532", "skin": "res://2e8c9585-e650-4494-a329-807fd2d2a532",
"sizeGrid": "24,40,24,40,0", "sizeGrid": "24,40,24,40,0",
"label": "新游戏", "label": "新游戏",
"labelFont": "res://55f943ef-58d2-4b30-8498-271c4213cce4", "labelFont": "",
"labelSize": 60, "labelSize": 60,
"labelBold": true, "labelBold": true,
"labelColors": "#1d5cdc,#1d5cdc,#1d5cdc", "labelColors": "#1d5cdc,#1d5cdc,#1d5cdc",
@@ -87,7 +87,7 @@
"centerX": 0, "centerX": 0,
"centerY": -115, "centerY": -115,
"text": "Well done", "text": "Well done",
"font": "res://55f943ef-58d2-4b30-8498-271c4213cce4", "font": "",
"fontSize": 80, "fontSize": 80,
"color": "rgba(0, 0, 0, 1)", "color": "rgba(0, 0, 0, 1)",
"bold": true, "bold": true,
@@ -103,7 +103,7 @@
"width": 736, "width": 736,
"height": 200, "height": 200,
"text": "[color=#7b818c]你击败了[color=#f1bf44]80%[/color]的玩家[/color]", "text": "[color=#7b818c]你击败了[color=#f1bf44]80%[/color]的玩家[/color]",
"font": "res://55f943ef-58d2-4b30-8498-271c4213cce4", "font": "",
"fontSize": 60, "fontSize": 60,
"color": "#FFFFFF", "color": "#FFFFFF",
"ubb": true, "ubb": true,

View File

@@ -42,7 +42,7 @@
"skin": "res://2e8c9585-e650-4494-a329-807fd2d2a532", "skin": "res://2e8c9585-e650-4494-a329-807fd2d2a532",
"sizeGrid": "24,40,24,40,0", "sizeGrid": "24,40,24,40,0",
"label": "重新开始", "label": "重新开始",
"labelFont": "res://55f943ef-58d2-4b30-8498-271c4213cce4", "labelFont": "",
"labelSize": 60, "labelSize": 60,
"labelBold": true, "labelBold": true,
"labelColors": "#1d5cdc,#1d5cdc,#1d5cdc", "labelColors": "#1d5cdc,#1d5cdc,#1d5cdc",
@@ -64,7 +64,7 @@
"skin": "res://2e8c9585-e650-4494-a329-807fd2d2a532", "skin": "res://2e8c9585-e650-4494-a329-807fd2d2a532",
"sizeGrid": "24,40,24,40,0", "sizeGrid": "24,40,24,40,0",
"label": "新游戏", "label": "新游戏",
"labelFont": "res://55f943ef-58d2-4b30-8498-271c4213cce4", "labelFont": "",
"labelSize": 60, "labelSize": 60,
"labelBold": true, "labelBold": true,
"labelColors": "#1d5cdc,#1d5cdc,#1d5cdc", "labelColors": "#1d5cdc,#1d5cdc,#1d5cdc",
@@ -82,7 +82,7 @@
"centerX": 0, "centerX": 0,
"centerY": -400, "centerY": -400,
"text": "游戏结束", "text": "游戏结束",
"font": "res://55f943ef-58d2-4b30-8498-271c4213cce4", "font": "",
"fontSize": 80, "fontSize": 80,
"color": "rgba(0, 0, 0, 1)", "color": "rgba(0, 0, 0, 1)",
"bold": true, "bold": true,
@@ -101,7 +101,7 @@
"centerX": 0, "centerX": 0,
"centerY": -143, "centerY": -143,
"text": "你犯了3个错误所以你输掉了游戏", "text": "你犯了3个错误所以你输掉了游戏",
"font": "res://55f943ef-58d2-4b30-8498-271c4213cce4", "font": "",
"fontSize": 60, "fontSize": 60,
"color": "rgba(123, 129, 140, 1)", "color": "rgba(123, 129, 140, 1)",
"align": "center", "align": "center",

View File

@@ -50,7 +50,7 @@
"centerY": -173, "centerY": -173,
"skin": "res://7eeb7e11-21ca-41ca-b7c2-dd2afa0c3ba7", "skin": "res://7eeb7e11-21ca-41ca-b7c2-dd2afa0c3ba7",
"label": "继续", "label": "继续",
"labelFont": "res://55f943ef-58d2-4b30-8498-271c4213cce4", "labelFont": "",
"labelSize": 60, "labelSize": 60,
"labelColors": "#ffffff,#32cc6b,#ff0000", "labelColors": "#ffffff,#32cc6b,#ff0000",
"labelAlign": "center", "labelAlign": "center",
@@ -71,7 +71,7 @@
"skin": "res://a75b43fb-bcf6-47d1-a1ef-e5261122a4e2", "skin": "res://a75b43fb-bcf6-47d1-a1ef-e5261122a4e2",
"sizeGrid": "24,40,24,40,0", "sizeGrid": "24,40,24,40,0",
"label": "新游戏", "label": "新游戏",
"labelFont": "res://55f943ef-58d2-4b30-8498-271c4213cce4", "labelFont": "",
"labelSize": 60, "labelSize": 60,
"labelBold": true, "labelBold": true,
"labelColors": "#ffffff,#ffffff,#ffffff", "labelColors": "#ffffff,#ffffff,#ffffff",
@@ -91,7 +91,7 @@
"centerX": 0, "centerX": 0,
"skin": "res://7eeb7e11-21ca-41ca-b7c2-dd2afa0c3ba7", "skin": "res://7eeb7e11-21ca-41ca-b7c2-dd2afa0c3ba7",
"label": "清理", "label": "清理",
"labelFont": "res://55f943ef-58d2-4b30-8498-271c4213cce4", "labelFont": "",
"labelSize": 60, "labelSize": 60,
"labelColors": "#ffffff,#32cc6b,#ff0000", "labelColors": "#ffffff,#32cc6b,#ff0000",
"labelAlign": "center", "labelAlign": "center",

View File

@@ -1,73 +1,56 @@
{ {
"_$ver": 1, "_$ver": 1,
"_$id": "ze5gx82a", "_$id": "pl8y75ht",
"_$type": "Box", "_$type": "Box",
"name": "ScoreAdd", "name": "ScoreAdd",
"x": -17, "x": 465,
"y": 28, "y": 930,
"width": 150, "width": 150,
"height": 60, "height": 60,
"centerX": 0, "centerX": 0,
"centerY": 0, "centerY": 0,
"_$comp": [ "_$comp": [
{
"_$type": "Animator2D",
"controller": {
"_$uuid": "96c849ea-9704-40bc-8bb5-c00a4f341d30",
"_$type": "AnimationController2D"
},
"controllerLayers": [
{
"_$type": "AnimatorControllerLayer2D",
"name": "Base Layer",
"states": [
{
"_$type": "AnimatorState2D",
"name": "score_up",
"clipStart": 0,
"clip": {
"_$uuid": "3ff6c374-5ecd-4de1-b271-a3280f87f9d9",
"_$type": "AnimationClip2D"
},
"soloTransitions": []
}
],
"defaultStateName": "score_up"
}
]
},
{ {
"_$type": "bdb0e671-99fa-47a5-9101-7ec008b1d25d", "_$type": "bdb0e671-99fa-47a5-9101-7ec008b1d25d",
"scriptPath": "../src/views/AutoDestroy.ts", "scriptPath": "../src/views/AutoDestroy.ts",
"lifeTime": 1 "lifeTime": 2
},
{
"_$type": "c910a064-d127-442e-a884-b5289c488647",
"scriptPath": "../src/views/ScoreAdd.ts"
} }
], ],
"_$child": [ "_$child": [
{ {
"_$id": "mqksqekt", "_$id": "chd952dx",
"_$type": "Box", "_$type": "Box",
"name": "offset", "name": "offset",
"y": -150, "y": -60,
"width": 150, "width": 150,
"height": 60, "height": 60,
"_$child": [ "_$child": [
{ {
"_$id": "muzcdy3q", "_$id": "7popbrt7",
"_$type": "Label", "_$type": "Label",
"name": "Label", "name": "Label",
"x": 0, "x": 75,
"y": 0, "y": 30,
"width": 150, "width": 150,
"height": 60, "height": 60,
"anchorX": 0.5,
"anchorY": 0.5,
"scaleX": 1, "scaleX": 1,
"scaleY": 1, "scaleY": 1,
"text": "+150", "text": "+150",
"font": "res://55f943ef-58d2-4b30-8498-271c4213cce4",
"fontSize": 60, "fontSize": 60,
"color": "rgba(29, 92, 220, 1)", "color": "rgba(29, 92, 220, 1)",
"bold": true,
"align": "center", "align": "center",
"valign": "middle", "valign": "middle",
"padding": "0,0,0,0" "borderColor": null,
"padding": "0,0,0,0",
"stroke": 16,
"strokeColor": "rgba(255, 255, 255, 1)"
} }
] ]
} }

View File

@@ -1,3 +1,3 @@
{ {
"uuid": "324b6a80-ccee-46d2-bbbd-5a7bf92067b3" "uuid": "a07d56a7-b6d8-40b9-97c2-6c2b0e294ff1"
} }

File diff suppressed because it is too large Load Diff

View File

@@ -1,9 +1,13 @@
export const config = { export const config = {
BREAK_POINT: 1, // 竖版和横版的分界宽度
DEBUG: false, DEBUG: false,
OPEN_GUIDE: true, OPEN_GUIDE: true,
BREAK_POINT: 1, // 竖版和横版的分界宽度
MISTAKE_MAX: 3,//最大错误数
DIFFICULTY_TYPE: {//难度 DIFFICULTY_TYPE: {//难度
Easy: 1, Easy: 1,
@@ -13,6 +17,11 @@ export const config = {
Extreme: 5, Extreme: 5,
}, },
BLOCK_COLOR: {
WHITE: "#ffffff",
GREY: "#f0f2f7",
RED: "#ef3e67",
BLUE: "#2559c0",
}
} }

View File

@@ -30,8 +30,6 @@ export class DOBlock {
this.data.show = show this.data.show = show
if (show == this.get_correct()) if (show == this.get_correct())
this.checked = true this.checked = true
if (this.get_checked() || show == 0)
this.clean_notes()//正确或者擦除
StorageManager.getInstance().onChanged() StorageManager.getInstance().onChanged()
} }
@@ -46,14 +44,18 @@ export class DOBlock {
public get_notes(): Array<number> { public get_notes(): Array<number> {
return this.data.notes return this.data.notes
} }
public add_note(noteNumber: number): boolean { public add_note(noteNumber: number): void {
var b = false
if (this.data.notes.indexOf(noteNumber) < 0) { if (this.data.notes.indexOf(noteNumber) < 0) {
this.data.notes.push(noteNumber) this.data.notes.push(noteNumber)
StorageManager.getInstance().onChanged() StorageManager.getInstance().onChanged()
b = true
} }
return b }
public remove_note(noteNumber: number): void {
var find = this.data.notes.indexOf(noteNumber)
if (find >= 0) {
this.data.notes.splice(find, 1)
StorageManager.getInstance().onChanged()
}
} }
public clean_notes(): void { public clean_notes(): void {
if (this.data.notes.length > 0) { if (this.data.notes.length > 0) {

View File

@@ -5,7 +5,7 @@ const { regClass, property } = Laya;
@regClass() @regClass()
export class Block extends Laya.Script { export class Block extends Laya.Script {
declare owner : Laya.Button; declare owner : Laya.Sprite;
@property(Number) @property(Number)
public XIndex: number = 0; public XIndex: number = 0;
@@ -16,23 +16,32 @@ export class Block extends Laya.Script {
@property(Number) @property(Number)
public YGroup: number = 0; public YGroup: number = 0;
private tips_bgs: Array<Laya.Sprite> = new Array();
private label_show: Laya.Label; private label_show: Laya.Label;
private tips_labels: Array<Laya.Label> = new Array(); private tips_labels: Array<Laya.Label> = new Array();
private animator: Laya.Animator2D
private selected: boolean = false private selected: boolean = false
private newSelect: boolean = false private newSelect: boolean = false
private data: DOBlock private data: DOBlock
public onInit(XIndex: number, YIndex: number, XGroup: number, YGroup: number, label_obj: Laya.Box, handler: any, func: any): void { public onInit(XIndex: number, YIndex: number, XGroup: number, YGroup: number, label_obj: Laya.Box, handler: any, func: any): void {
this.XIndex = XIndex; this.XIndex = XIndex;
this.YIndex = YIndex; this.YIndex = YIndex;
this.XGroup = XGroup; this.XGroup = XGroup;
this.YGroup = YGroup; this.YGroup = YGroup;
var VBox = this.owner.getChildByName("VBox")
for (var i=0; i<VBox.numChildren; i++) {
var hbox = VBox.getChildAt(i)
for (var j=0; j<hbox.numChildren; j++) {
var sp = hbox.getChildAt(j) as Laya.Sprite
this.tips_bgs.push(sp)
}
}
this.label_show = label_obj.getChildByName("label_show") as Laya.Label this.label_show = label_obj.getChildByName("label_show") as Laya.Label
var VBox = label_obj.getChildByName("VBox") VBox = label_obj.getChildByName("VBox")
for (var i=0; i<VBox.numChildren; i++) { for (var i=0; i<VBox.numChildren; i++) {
var hbox = VBox.getChildAt(i); var hbox = VBox.getChildAt(i);
for (var j=0; j<hbox.numChildren; j++) { for (var j=0; j<hbox.numChildren; j++) {
@@ -42,7 +51,6 @@ export class Block extends Laya.Script {
} }
} }
this.owner.on(Laya.Event.CLICK, handler, func); this.owner.on(Laya.Event.CLICK, handler, func);
this.animator = this.owner.getComponent(Laya.Animator2D)
} }
public setSelected(selected: boolean): void { public setSelected(selected: boolean): void {
@@ -52,16 +60,52 @@ export class Block extends Laya.Script {
this.updateBlock() this.updateBlock()
} }
public setButtonSkin(skin: string): void { public setBlockColor(color: string, alpha: number=1, animated: boolean=false, completedColor: string = "", completedAlpha: number=1): void {
this.owner.skin = skin this.owner.graphics.clear()
this.owner.graphics.drawRect(0, 0, 116, 116, color)
if (animated) {
Laya.Tween.to(this.owner, {alpha:alpha}, 500, Laya.Ease.elasticOut, Laya.Handler.create(this, () => {
this.owner.graphics.clear()
this.owner.graphics.drawRect(0, 0, 116, 116, completedColor)
this.owner.alpha = completedAlpha
}))
}
else {
this.owner.alpha = alpha
}
} }
public setFadeAnimation(): void { public setFadeAnimation(): void {
if (this.animator) { var color = this.label_show.color
this.animator.play("fade_to_red") var flag = true
Laya.timer.frameOnce(40, this, ()=>{ Laya.timer.loop(200, this, ()=>{
this.animator.stop() flag = !flag
}) if (flag) {
this.label_show.color = color
}
else {
this.label_show.color = "#ff0000"
}
})
Laya.Tween.to(this.label_show, {color:"#ff0000"}, 1000, Laya.Ease.strongIn, Laya.Handler.create(this, () => {
this.label_show.color = color
Laya.timer.clearAll(this)
}))
}
public setTipsBgColor(visible: boolean, noteNumber: number=0, color: string="", alpha: number=1): void {
if (visible) {
var obj = this.tips_bgs[noteNumber-1]
obj.visible = true
obj.graphics.clear()
obj.graphics.drawRect(0, 0, 38, 38, color)
obj.alpha = alpha
}
else {
for (var i=0; i<this.tips_bgs.length; i++) {
var obj = this.tips_bgs[i]
obj.visible = false
}
} }
} }
@@ -82,31 +126,59 @@ export class Block extends Laya.Script {
if (this.data.get_checked()) { if (this.data.get_checked()) {
score = 150 score = 150
this.data.set_score(score) this.data.set_score(score)
G_ShowScoreTips(score.toString(), this.owner) G_ShowScoreTips(score.toString(), this.label_show)
} }
} }
this.data.clean_notes()
this.updateBlock() this.updateBlock()
} }
return this.data.get_checked() return this.data.get_checked()
} }
public addNoteNumber(noteNumber: number): void { public addNoteNumber(noteNumber: number): void {
if (this.data.add_note(noteNumber)) { this.data.set_show(0)
this.updateBlock() var note_numbers = this.data.get_notes()
var find = note_numbers.indexOf(noteNumber)
if (find >= 0) {
this.data.remove_note(noteNumber)
} }
else {
this.data.add_note(noteNumber)
}
this.updateBlock()
} }
updateBlock(): void { updateBlock(): void {
for (var i=0; i<this.tips_labels.length; i++) //设置文字颜色
this.tips_labels[i].text = "" if (this.selected) {
if (this.data.get_show() > 0) { this.label_show.color = "#ffffff"
this.label_show.text = this.data.get_show().toString() for (var i=0; i<this.tips_labels.length; i++) {
if (this.data.get_checked()) { this.tips_labels[i].color = "#ffffff"
this.label_show.color = "#000000" }
}
else {
if (this.data.get_show() == this.data.get_correct()) {
if (this.data.get_preset()) {
this.label_show.color = "#2d3138"
}
else {
this.label_show.color = "#2559c0"
}
} }
else { else {
this.label_show.color = "#ff0000" this.label_show.color = "#cb3256"
} }
for (var i=0; i<this.tips_labels.length; i++) {
this.tips_labels[i].color = "#2d3138"
}
}
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()
} }
else { else {
this.label_show.text = ""; this.label_show.text = "";
@@ -115,12 +187,6 @@ export class Block extends Laya.Script {
var value = note_numbers[i] var value = note_numbers[i]
var label = this.tips_labels[value-1] var label = this.tips_labels[value-1]
label.text = value.toString() label.text = value.toString()
if (this.selected) {
label.color = "#ffffff"
}
else {
label.color = "#000000"
}
} }
} }
} }

View File

@@ -4,17 +4,31 @@ const { regClass, property } = Laya;
@regClass() @regClass()
export class Candy extends Laya.Script { export class Candy extends Laya.Script {
declare owner : Laya.Button; declare owner : Laya.Box;
private show_sprite: Laya.Sprite
private label_show: Laya.Label; private label_show: Laya.Label;
private label_left: Laya.Label; private label_left: Laya.Label;
private data: DOCandy private data: DOCandy
public onInit(label_obj: Laya.Box, handler: any, func: any): void { public onInit(label_obj: Laya.Box, handler: any, func: any): void {
this.owner.on(Laya.Event.CLICK, handler, func)
this.show_sprite = this.owner.getChildByName("Sprite") as Laya.Sprite
this.label_show = label_obj.getChildByName("label") as Laya.Label this.label_show = label_obj.getChildByName("label") as Laya.Label
this.label_left = label_obj.getChildByName("label_left") as Laya.Label this.label_left = label_obj.getChildByName("label_left") as Laya.Label
this.owner.on(Laya.Event.CLICK, handler, func)
}
public setNoteStatus(note_open: boolean) {
if (note_open) {
this.show_sprite.visible = false
this.label_show.color = "#7b818c"
}
else {
this.show_sprite.visible = true
this.label_show.color = "#2559c0"
}
} }
public setCandy(data: DOCandy): void { public setCandy(data: DOCandy): void {

View File

@@ -3,7 +3,8 @@ import { respath } from "../constants/respath";
export function G_ShowScoreTips(text: string, parent: any): void { export function G_ShowScoreTips(text: string, parent: any): void {
Laya.loader.load(respath.score_add_ui_res).then((go)=>{ Laya.loader.load(respath.score_add_ui_res).then((go)=>{
var prefab = go.create() var prefab = go.create()
var label = parent.addChild(prefab).getChildByName("offset").getChildByName("Label") as Laya.Label var obj = parent.addChild(prefab)
label.text = text var Label = obj.getChildByName("offset").getChildByName("Label") as Laya.Label
Label.text = text
}) })
} }

View File

@@ -1,4 +1,6 @@
import { UIManager } from "../models/UIManager"; import { UIManager } from "../models/UIManager";
import { StorageManager } from "../models/StorageManager";
const { regClass, property } = Laya const { regClass, property } = Laya
@@ -22,6 +24,7 @@ export class Home extends Laya.Script {
this.btn_clean.on(Laya.Event.CLICK, this, (evt: Laya.Event) => { this.btn_clean.on(Laya.Event.CLICK, this, (evt: Laya.Event) => {
console.log("btn_clean=", evt); console.log("btn_clean=", evt);
StorageManager.getInstance().cleanStage()
Laya.LocalStorage.clear() Laya.LocalStorage.clear()
}) })
} }

14
src/views/ScoreAdd.ts Normal file
View File

@@ -0,0 +1,14 @@
const { regClass, property } = Laya;
@regClass()
export class ScoreAdd extends Laya.Script {
declare owner : Laya.Box;
//组件被激活后执行,此时所有节点和组件均已创建完毕,此方法只执行一次
onAwake(): void {
var offset = this.owner.getChildByName("offset")
Laya.Tween.to(offset, {y:-200}, 1000, Laya.Ease.strongIn, null, 500)
var Label = offset.getChildByName("Label")
Laya.Tween.to(Label, {scaleX:1.5, scaleY:1.5}, 500)
}
}

View File

@@ -0,0 +1,3 @@
{
"uuid": "c910a064-d127-442e-a884-b5289c488647"
}

View File

@@ -3,6 +3,7 @@ import { UIManager } from "../models/UIManager";
import { Block } from "./Block"; import { Block } from "./Block";
import { Candy } from "./Candy"; import { Candy } from "./Candy";
import { DOStage } from "../models/DOStage"; import { DOStage } from "../models/DOStage";
import { config } from "../constants/config";
const { regClass, property } = Laya; const { regClass, property } = Laya;
@@ -16,7 +17,6 @@ export class Stage extends Laya.Script {
public label_score: Laya.Label; public label_score: Laya.Label;
@property(Laya.Label) @property(Laya.Label)
public label_mistake: Laya.Label; public label_mistake: Laya.Label;
private mistake_all = 3
@property(Laya.Label) @property(Laya.Label)
public label_diff: Laya.Label; public label_diff: Laya.Label;
@property(Laya.Label) @property(Laya.Label)
@@ -48,21 +48,6 @@ export class Stage extends Laya.Script {
private selectedBlock: Block; private selectedBlock: Block;
private data: DOStage; private data: DOStage;
@property(Laya.Box)
public obj_block_colors: Laya.Box;
@property(Laya.Image)
public img_block_normal: Laya.Image;
@property(Laya.Image)
public img_block_grey: Laya.Image;
@property(Laya.Image)
public img_block_correct: Laya.Image;
@property(Laya.Image)
public img_block_weak_correct: Laya.Image;
@property(Laya.Image)
public img_block_wrong: Laya.Image;
@property(Laya.Image)
public img_block_weak_wrong: Laya.Image;
//组件被激活后执行,此时所有节点和组件均已创建完毕,此方法只执行一次 //组件被激活后执行,此时所有节点和组件均已创建完毕,此方法只执行一次
onAwake(): void { onAwake(): void {
this.btn_back.on(Laya.Event.CLICK, this, ()=>{ this.btn_back.on(Laya.Event.CLICK, this, ()=>{
@@ -104,8 +89,6 @@ export class Stage extends Laya.Script {
this.btn_hint.on(Laya.Event.CLICK, this, this.onClickHint) this.btn_hint.on(Laya.Event.CLICK, this, this.onClickHint)
this.selectedBlock = null; this.selectedBlock = null;
this.obj_block_colors.visible = false
} }
public onLoadStage(doStage: DOStage): void { public onLoadStage(doStage: DOStage): void {
@@ -131,8 +114,9 @@ export class Stage extends Laya.Script {
for (var i=0; i<blocks.length; i++) { for (var i=0; i<blocks.length; i++) {
var doBlock = blocks[i] var doBlock = blocks[i]
var block = this.blocks[i] var block = this.blocks[i]
block.setButtonSkin(this.img_block_normal.skin) block.setBlockColor(config.BLOCK_COLOR.WHITE)
block.setBlock(doBlock) block.setBlock(doBlock)
block.setTipsBgColor(false)
} }
var candys = doStage.get_candys() var candys = doStage.get_candys()
for (var i=0; i<candys.length; i++) { for (var i=0; i<candys.length; i++) {
@@ -150,42 +134,62 @@ export class Stage extends Laya.Script {
for (var i=0; i<blocks.length; i++) { for (var i=0; i<blocks.length; i++) {
score += blocks[i].get_score() score += blocks[i].get_score()
} }
this.label_score.text = `分数: ${score}` this.label_score.text = `Score: ${score}`
} }
onUpdateMistake(): void { onUpdateMistake(): void {
this.label_mistake.text = `${this.data.get_mistake()}/${this.mistake_all}` this.label_mistake.text = `mistake:${this.data.get_mistake()}/${config.MISTAKE_MAX}`
} }
onSetBlock(block: Block): void { onSetBlock(block: Block, animated: boolean = false): void {
//全部格子还原 //全部格子还原
for (var i=0; i<this.blocks.length; i++) { for (var i=0; i<this.blocks.length; i++) {
this.blocks[i].setButtonSkin(this.img_block_normal.skin) this.blocks[i].setBlockColor(config.BLOCK_COLOR.WHITE)
this.blocks[i].setTipsBgColor(false)
} }
//相关格子置灰 //相关格子置灰
var relateds = this.findRelatedBlocks(block) var relateds = this.findRelatedBlocks(block)
for (var i=0; i<relateds.length; i++) for (var i=0; i<relateds.length; i++)
relateds[i].setButtonSkin(this.img_block_grey.skin) relateds[i].setBlockColor(config.BLOCK_COLOR.GREY)
//空白格子 //选中空白格子
if (block.getData().get_show() <= 0) { if (block.getData().get_show() <= 0) {
block.setButtonSkin(this.img_block_correct.skin) block.setBlockColor(config.BLOCK_COLOR.BLUE)
} }
else { else {
//相同数字的格子 var sames = this.findSameNumberBlocks(block)//相同数字的格子
var sames = this.findSameNumberBlocks(block) for (var i=0; i<sames.length; i++) {
for (var i=0; i<sames.length; i++) sames[i].setBlockColor(config.BLOCK_COLOR.BLUE, 0.4)
sames[i].setButtonSkin(this.img_block_weak_correct.skin)
if (block.getData().get_checked()) {//正确的格子
block.setButtonSkin(this.img_block_correct.skin)
} }
else {//错误的格子 var sames = this.findSameNoteBlocks(block)//相同数字的铅笔格子
for (var i=0; i<relateds.length; i++) { for (var i=0; i<sames.length; i++) {
if (relateds[i].getData().get_show() == block.getData().get_show()) sames[i].setTipsBgColor(true, block.getData().get_show(), config.BLOCK_COLOR.BLUE, 0.4)
relateds[i].setButtonSkin(this.img_block_weak_wrong.skin) }
//正确
if (block.getData().get_checked()) {
block.setBlockColor(config.BLOCK_COLOR.BLUE)
}
else {//错误
if (animated) {//填数状态播放闪动效果
for (var i=0; i<relateds.length; i++) {//相关且数字相同
if (relateds[i].getData().get_show() == block.getData().get_show()) {//播放变红动效
if (relateds[i].getData().get_index() != block.getData().get_index()) {
relateds[i].setBlockColor(config.BLOCK_COLOR.WHITE)
relateds[i].setBlockColor(config.BLOCK_COLOR.RED, 0.4, true, config.BLOCK_COLOR.GREY, 1)
}
}
}
} }
block.setButtonSkin(this.img_block_wrong.skin) else {
for (var i=0; i<relateds.length; i++) {//相关且数字相同
if (relateds[i].getData().get_show() == block.getData().get_show()) {//直接变红
if (relateds[i].getData().get_index() != block.getData().get_index()) {
relateds[i].setBlockColor(config.BLOCK_COLOR.RED, 0.4)
}
}
}
}
block.setBlockColor(config.BLOCK_COLOR.RED)
} }
} }
} }
@@ -217,6 +221,9 @@ export class Stage extends Laya.Script {
} }
this.btn_note_normal.visible = this.data.get_note_open() == false this.btn_note_normal.visible = this.data.get_note_open() == false
this.btn_note_checked.visible = this.data.get_note_open() this.btn_note_checked.visible = this.data.get_note_open()
for (var i=0; i<this.candys.length; i++) {
this.candys[i].setNoteStatus(this.data.get_note_open())
}
} }
onClickHint(evt: Laya.Event): void { onClickHint(evt: Laya.Event): void {
@@ -271,23 +278,29 @@ export class Stage extends Laya.Script {
} }
} }
else { else {
var b = this.selectedBlock.setShowNumber(showNumber); if (this.selectedBlock.getData().get_show() == showNumber) {
this.onUpdateScore() this.selectedBlock.setShowNumber(0);
this.onSetBlock(this.selectedBlock) this.onSetBlock(this.selectedBlock)
if (b) {
var left = candy.getData().get_left();
candy.setLeft(left-1);
if (this.getIsComplete()) {
console.log("完成关卡")
UIManager.getInstance().loadGameDone()
}
} }
else {//失败 else {
this.data.set_mistake(this.data.get_mistake()+1) var b = this.selectedBlock.setShowNumber(showNumber);
this.onUpdateMistake() this.onUpdateScore()
if (this.data.get_mistake() >= this.mistake_all) { this.onSetBlock(this.selectedBlock, true)
//关卡失败 if (b) {
UIManager.getInstance().loadGameOver() var left = candy.getData().get_left();
candy.setLeft(left-1);
if (this.getIsComplete()) {
console.log("完成关卡")
UIManager.getInstance().loadGameDone()
}
}
else {//失败
this.data.set_mistake(this.data.get_mistake()+1)
this.onUpdateMistake()
if (this.data.get_mistake() >= config.MISTAKE_MAX) {
console.log("关卡失败")
// UIManager.getInstance().loadGameOver()
}
} }
} }
} }
@@ -331,6 +344,17 @@ export class Stage extends Laya.Script {
return list return list
} }
findSameNoteBlocks(obj: Block): Array<Block> {
var list: Array<Block> = new Array()
for (var i=0; i<this.blocks.length; i++) {
var block = this.blocks[i]
var note_numbers = block.getData().get_notes()
if (note_numbers.indexOf(obj.getData().get_show()) >= 0)
list.push(block)
}
return list
}
getIsComplete(): boolean { getIsComplete(): boolean {
var b = true; var b = true;
for (var i=1; i<this.blocks.length; i++) { for (var i=1; i<this.blocks.length; i++) {