调整核心玩法细节表现
This commit is contained in:
Binary file not shown.
@@ -1,3 +0,0 @@
|
||||
{
|
||||
"uuid": "55f943ef-58d2-4b30-8498-271c4213cce4"
|
||||
}
|
||||
@@ -69,7 +69,7 @@
|
||||
"skin": "res://2e8c9585-e650-4494-a329-807fd2d2a532",
|
||||
"sizeGrid": "24,40,24,40,0",
|
||||
"label": "新游戏",
|
||||
"labelFont": "res://55f943ef-58d2-4b30-8498-271c4213cce4",
|
||||
"labelFont": "",
|
||||
"labelSize": 60,
|
||||
"labelBold": true,
|
||||
"labelColors": "#1d5cdc,#1d5cdc,#1d5cdc",
|
||||
@@ -87,7 +87,7 @@
|
||||
"centerX": 0,
|
||||
"centerY": -115,
|
||||
"text": "Well done",
|
||||
"font": "res://55f943ef-58d2-4b30-8498-271c4213cce4",
|
||||
"font": "",
|
||||
"fontSize": 80,
|
||||
"color": "rgba(0, 0, 0, 1)",
|
||||
"bold": true,
|
||||
@@ -103,7 +103,7 @@
|
||||
"width": 736,
|
||||
"height": 200,
|
||||
"text": "[color=#7b818c]你击败了[color=#f1bf44]80%[/color]的玩家[/color]",
|
||||
"font": "res://55f943ef-58d2-4b30-8498-271c4213cce4",
|
||||
"font": "",
|
||||
"fontSize": 60,
|
||||
"color": "#FFFFFF",
|
||||
"ubb": true,
|
||||
|
||||
@@ -42,7 +42,7 @@
|
||||
"skin": "res://2e8c9585-e650-4494-a329-807fd2d2a532",
|
||||
"sizeGrid": "24,40,24,40,0",
|
||||
"label": "重新开始",
|
||||
"labelFont": "res://55f943ef-58d2-4b30-8498-271c4213cce4",
|
||||
"labelFont": "",
|
||||
"labelSize": 60,
|
||||
"labelBold": true,
|
||||
"labelColors": "#1d5cdc,#1d5cdc,#1d5cdc",
|
||||
@@ -64,7 +64,7 @@
|
||||
"skin": "res://2e8c9585-e650-4494-a329-807fd2d2a532",
|
||||
"sizeGrid": "24,40,24,40,0",
|
||||
"label": "新游戏",
|
||||
"labelFont": "res://55f943ef-58d2-4b30-8498-271c4213cce4",
|
||||
"labelFont": "",
|
||||
"labelSize": 60,
|
||||
"labelBold": true,
|
||||
"labelColors": "#1d5cdc,#1d5cdc,#1d5cdc",
|
||||
@@ -82,7 +82,7 @@
|
||||
"centerX": 0,
|
||||
"centerY": -400,
|
||||
"text": "游戏结束",
|
||||
"font": "res://55f943ef-58d2-4b30-8498-271c4213cce4",
|
||||
"font": "",
|
||||
"fontSize": 80,
|
||||
"color": "rgba(0, 0, 0, 1)",
|
||||
"bold": true,
|
||||
@@ -101,7 +101,7 @@
|
||||
"centerX": 0,
|
||||
"centerY": -143,
|
||||
"text": "你犯了3个错误所以你输掉了游戏",
|
||||
"font": "res://55f943ef-58d2-4b30-8498-271c4213cce4",
|
||||
"font": "",
|
||||
"fontSize": 60,
|
||||
"color": "rgba(123, 129, 140, 1)",
|
||||
"align": "center",
|
||||
|
||||
@@ -50,7 +50,7 @@
|
||||
"centerY": -173,
|
||||
"skin": "res://7eeb7e11-21ca-41ca-b7c2-dd2afa0c3ba7",
|
||||
"label": "继续",
|
||||
"labelFont": "res://55f943ef-58d2-4b30-8498-271c4213cce4",
|
||||
"labelFont": "",
|
||||
"labelSize": 60,
|
||||
"labelColors": "#ffffff,#32cc6b,#ff0000",
|
||||
"labelAlign": "center",
|
||||
@@ -71,7 +71,7 @@
|
||||
"skin": "res://a75b43fb-bcf6-47d1-a1ef-e5261122a4e2",
|
||||
"sizeGrid": "24,40,24,40,0",
|
||||
"label": "新游戏",
|
||||
"labelFont": "res://55f943ef-58d2-4b30-8498-271c4213cce4",
|
||||
"labelFont": "",
|
||||
"labelSize": 60,
|
||||
"labelBold": true,
|
||||
"labelColors": "#ffffff,#ffffff,#ffffff",
|
||||
@@ -91,7 +91,7 @@
|
||||
"centerX": 0,
|
||||
"skin": "res://7eeb7e11-21ca-41ca-b7c2-dd2afa0c3ba7",
|
||||
"label": "清理",
|
||||
"labelFont": "res://55f943ef-58d2-4b30-8498-271c4213cce4",
|
||||
"labelFont": "",
|
||||
"labelSize": 60,
|
||||
"labelColors": "#ffffff,#32cc6b,#ff0000",
|
||||
"labelAlign": "center",
|
||||
|
||||
@@ -1,73 +1,56 @@
|
||||
{
|
||||
"_$ver": 1,
|
||||
"_$id": "ze5gx82a",
|
||||
"_$id": "pl8y75ht",
|
||||
"_$type": "Box",
|
||||
"name": "ScoreAdd",
|
||||
"x": -17,
|
||||
"y": 28,
|
||||
"x": 465,
|
||||
"y": 930,
|
||||
"width": 150,
|
||||
"height": 60,
|
||||
"centerX": 0,
|
||||
"centerY": 0,
|
||||
"_$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",
|
||||
"scriptPath": "../src/views/AutoDestroy.ts",
|
||||
"lifeTime": 1
|
||||
"lifeTime": 2
|
||||
},
|
||||
{
|
||||
"_$type": "c910a064-d127-442e-a884-b5289c488647",
|
||||
"scriptPath": "../src/views/ScoreAdd.ts"
|
||||
}
|
||||
],
|
||||
"_$child": [
|
||||
{
|
||||
"_$id": "mqksqekt",
|
||||
"_$id": "chd952dx",
|
||||
"_$type": "Box",
|
||||
"name": "offset",
|
||||
"y": -150,
|
||||
"y": -60,
|
||||
"width": 150,
|
||||
"height": 60,
|
||||
"_$child": [
|
||||
{
|
||||
"_$id": "muzcdy3q",
|
||||
"_$id": "7popbrt7",
|
||||
"_$type": "Label",
|
||||
"name": "Label",
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"x": 75,
|
||||
"y": 30,
|
||||
"width": 150,
|
||||
"height": 60,
|
||||
"anchorX": 0.5,
|
||||
"anchorY": 0.5,
|
||||
"scaleX": 1,
|
||||
"scaleY": 1,
|
||||
"text": "+150",
|
||||
"font": "res://55f943ef-58d2-4b30-8498-271c4213cce4",
|
||||
"fontSize": 60,
|
||||
"color": "rgba(29, 92, 220, 1)",
|
||||
"bold": true,
|
||||
"align": "center",
|
||||
"valign": "middle",
|
||||
"padding": "0,0,0,0"
|
||||
"borderColor": null,
|
||||
"padding": "0,0,0,0",
|
||||
"stroke": 16,
|
||||
"strokeColor": "rgba(255, 255, 255, 1)"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -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
@@ -1,9 +1,13 @@
|
||||
|
||||
|
||||
export const config = {
|
||||
|
||||
BREAK_POINT: 1, // 竖版和横版的分界宽度
|
||||
|
||||
DEBUG: false,
|
||||
OPEN_GUIDE: true,
|
||||
BREAK_POINT: 1, // 竖版和横版的分界宽度
|
||||
|
||||
MISTAKE_MAX: 3,//最大错误数
|
||||
|
||||
DIFFICULTY_TYPE: {//难度
|
||||
Easy: 1,
|
||||
@@ -13,6 +17,11 @@ export const config = {
|
||||
Extreme: 5,
|
||||
},
|
||||
|
||||
|
||||
BLOCK_COLOR: {
|
||||
WHITE: "#ffffff",
|
||||
GREY: "#f0f2f7",
|
||||
RED: "#ef3e67",
|
||||
BLUE: "#2559c0",
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -30,8 +30,6 @@ export class DOBlock {
|
||||
this.data.show = show
|
||||
if (show == this.get_correct())
|
||||
this.checked = true
|
||||
if (this.get_checked() || show == 0)
|
||||
this.clean_notes()//正确或者擦除
|
||||
StorageManager.getInstance().onChanged()
|
||||
}
|
||||
|
||||
@@ -46,14 +44,18 @@ export class DOBlock {
|
||||
public get_notes(): Array<number> {
|
||||
return this.data.notes
|
||||
}
|
||||
public add_note(noteNumber: number): boolean {
|
||||
var b = false
|
||||
public add_note(noteNumber: number): void {
|
||||
if (this.data.notes.indexOf(noteNumber) < 0) {
|
||||
this.data.notes.push(noteNumber)
|
||||
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 {
|
||||
if (this.data.notes.length > 0) {
|
||||
|
||||
@@ -5,7 +5,7 @@ const { regClass, property } = Laya;
|
||||
|
||||
@regClass()
|
||||
export class Block extends Laya.Script {
|
||||
declare owner : Laya.Button;
|
||||
declare owner : Laya.Sprite;
|
||||
|
||||
@property(Number)
|
||||
public XIndex: number = 0;
|
||||
@@ -16,23 +16,32 @@ export class Block extends Laya.Script {
|
||||
@property(Number)
|
||||
public YGroup: number = 0;
|
||||
|
||||
private tips_bgs: Array<Laya.Sprite> = new Array();
|
||||
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;
|
||||
|
||||
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
|
||||
var VBox = label_obj.getChildByName("VBox")
|
||||
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++) {
|
||||
@@ -42,7 +51,6 @@ export class Block extends Laya.Script {
|
||||
}
|
||||
}
|
||||
this.owner.on(Laya.Event.CLICK, handler, func);
|
||||
this.animator = this.owner.getComponent(Laya.Animator2D)
|
||||
}
|
||||
|
||||
public setSelected(selected: boolean): void {
|
||||
@@ -52,16 +60,52 @@ export class Block extends Laya.Script {
|
||||
this.updateBlock()
|
||||
}
|
||||
|
||||
public setButtonSkin(skin: string): void {
|
||||
this.owner.skin = skin
|
||||
public setBlockColor(color: string, alpha: number=1, animated: boolean=false, completedColor: string = "", completedAlpha: number=1): void {
|
||||
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 {
|
||||
if (this.animator) {
|
||||
this.animator.play("fade_to_red")
|
||||
Laya.timer.frameOnce(40, this, ()=>{
|
||||
this.animator.stop()
|
||||
})
|
||||
var color = this.label_show.color
|
||||
var flag = true
|
||||
Laya.timer.loop(200, this, ()=>{
|
||||
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()) {
|
||||
score = 150
|
||||
this.data.set_score(score)
|
||||
G_ShowScoreTips(score.toString(), this.owner)
|
||||
G_ShowScoreTips(score.toString(), this.label_show)
|
||||
}
|
||||
}
|
||||
this.data.clean_notes()
|
||||
this.updateBlock()
|
||||
}
|
||||
return this.data.get_checked()
|
||||
}
|
||||
|
||||
public addNoteNumber(noteNumber: number): void {
|
||||
if (this.data.add_note(noteNumber)) {
|
||||
this.updateBlock()
|
||||
this.data.set_show(0)
|
||||
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 {
|
||||
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"
|
||||
//设置文字颜色
|
||||
if (this.selected) {
|
||||
this.label_show.color = "#ffffff"
|
||||
for (var i=0; i<this.tips_labels.length; i++) {
|
||||
this.tips_labels[i].color = "#ffffff"
|
||||
}
|
||||
}
|
||||
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 {
|
||||
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 {
|
||||
this.label_show.text = "";
|
||||
@@ -115,12 +187,6 @@ export class Block extends Laya.Script {
|
||||
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"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,17 +4,31 @@ const { regClass, property } = Laya;
|
||||
|
||||
@regClass()
|
||||
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_left: Laya.Label;
|
||||
|
||||
private data: DOCandy
|
||||
|
||||
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_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 {
|
||||
|
||||
@@ -3,7 +3,8 @@ import { respath } from "../constants/respath";
|
||||
export function G_ShowScoreTips(text: string, parent: any): void {
|
||||
Laya.loader.load(respath.score_add_ui_res).then((go)=>{
|
||||
var prefab = go.create()
|
||||
var label = parent.addChild(prefab).getChildByName("offset").getChildByName("Label") as Laya.Label
|
||||
label.text = text
|
||||
var obj = parent.addChild(prefab)
|
||||
var Label = obj.getChildByName("offset").getChildByName("Label") as Laya.Label
|
||||
Label.text = text
|
||||
})
|
||||
}
|
||||
@@ -1,4 +1,6 @@
|
||||
|
||||
import { UIManager } from "../models/UIManager";
|
||||
import { StorageManager } from "../models/StorageManager";
|
||||
|
||||
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) => {
|
||||
console.log("btn_clean=", evt);
|
||||
StorageManager.getInstance().cleanStage()
|
||||
Laya.LocalStorage.clear()
|
||||
})
|
||||
}
|
||||
|
||||
14
src/views/ScoreAdd.ts
Normal file
14
src/views/ScoreAdd.ts
Normal 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)
|
||||
}
|
||||
}
|
||||
3
src/views/ScoreAdd.ts.meta
Normal file
3
src/views/ScoreAdd.ts.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"uuid": "c910a064-d127-442e-a884-b5289c488647"
|
||||
}
|
||||
@@ -3,6 +3,7 @@ import { UIManager } from "../models/UIManager";
|
||||
import { Block } from "./Block";
|
||||
import { Candy } from "./Candy";
|
||||
import { DOStage } from "../models/DOStage";
|
||||
import { config } from "../constants/config";
|
||||
|
||||
const { regClass, property } = Laya;
|
||||
|
||||
@@ -16,7 +17,6 @@ export class Stage extends Laya.Script {
|
||||
public label_score: Laya.Label;
|
||||
@property(Laya.Label)
|
||||
public label_mistake: Laya.Label;
|
||||
private mistake_all = 3
|
||||
@property(Laya.Label)
|
||||
public label_diff: Laya.Label;
|
||||
@property(Laya.Label)
|
||||
@@ -48,21 +48,6 @@ export class Stage extends Laya.Script {
|
||||
private selectedBlock: Block;
|
||||
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 {
|
||||
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.selectedBlock = null;
|
||||
|
||||
this.obj_block_colors.visible = false
|
||||
}
|
||||
|
||||
public onLoadStage(doStage: DOStage): void {
|
||||
@@ -131,8 +114,9 @@ export class Stage extends Laya.Script {
|
||||
for (var i=0; i<blocks.length; i++) {
|
||||
var doBlock = blocks[i]
|
||||
var block = this.blocks[i]
|
||||
block.setButtonSkin(this.img_block_normal.skin)
|
||||
block.setBlockColor(config.BLOCK_COLOR.WHITE)
|
||||
block.setBlock(doBlock)
|
||||
block.setTipsBgColor(false)
|
||||
}
|
||||
var candys = doStage.get_candys()
|
||||
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++) {
|
||||
score += blocks[i].get_score()
|
||||
}
|
||||
this.label_score.text = `分数: ${score}`
|
||||
this.label_score.text = `Score: ${score}`
|
||||
}
|
||||
|
||||
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++) {
|
||||
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)
|
||||
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) {
|
||||
block.setButtonSkin(this.img_block_correct.skin)
|
||||
block.setBlockColor(config.BLOCK_COLOR.BLUE)
|
||||
}
|
||||
else {
|
||||
//相同数字的格子
|
||||
var sames = this.findSameNumberBlocks(block)
|
||||
for (var i=0; i<sames.length; i++)
|
||||
sames[i].setButtonSkin(this.img_block_weak_correct.skin)
|
||||
|
||||
if (block.getData().get_checked()) {//正确的格子
|
||||
block.setButtonSkin(this.img_block_correct.skin)
|
||||
var sames = this.findSameNumberBlocks(block)//相同数字的格子
|
||||
for (var i=0; i<sames.length; i++) {
|
||||
sames[i].setBlockColor(config.BLOCK_COLOR.BLUE, 0.4)
|
||||
}
|
||||
else {//错误的格子
|
||||
for (var i=0; i<relateds.length; i++) {
|
||||
if (relateds[i].getData().get_show() == block.getData().get_show())
|
||||
relateds[i].setButtonSkin(this.img_block_weak_wrong.skin)
|
||||
var sames = this.findSameNoteBlocks(block)//相同数字的铅笔格子
|
||||
for (var i=0; i<sames.length; i++) {
|
||||
sames[i].setTipsBgColor(true, block.getData().get_show(), config.BLOCK_COLOR.BLUE, 0.4)
|
||||
}
|
||||
//正确
|
||||
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_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 {
|
||||
@@ -271,23 +278,29 @@ export class Stage extends Laya.Script {
|
||||
}
|
||||
}
|
||||
else {
|
||||
var b = this.selectedBlock.setShowNumber(showNumber);
|
||||
this.onUpdateScore()
|
||||
this.onSetBlock(this.selectedBlock)
|
||||
if (b) {
|
||||
var left = candy.getData().get_left();
|
||||
candy.setLeft(left-1);
|
||||
if (this.getIsComplete()) {
|
||||
console.log("完成关卡")
|
||||
UIManager.getInstance().loadGameDone()
|
||||
}
|
||||
if (this.selectedBlock.getData().get_show() == showNumber) {
|
||||
this.selectedBlock.setShowNumber(0);
|
||||
this.onSetBlock(this.selectedBlock)
|
||||
}
|
||||
else {//失败
|
||||
this.data.set_mistake(this.data.get_mistake()+1)
|
||||
this.onUpdateMistake()
|
||||
if (this.data.get_mistake() >= this.mistake_all) {
|
||||
//关卡失败
|
||||
UIManager.getInstance().loadGameOver()
|
||||
else {
|
||||
var b = this.selectedBlock.setShowNumber(showNumber);
|
||||
this.onUpdateScore()
|
||||
this.onSetBlock(this.selectedBlock, true)
|
||||
if (b) {
|
||||
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
|
||||
}
|
||||
|
||||
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 {
|
||||
var b = true;
|
||||
for (var i=1; i<this.blocks.length; i++) {
|
||||
|
||||
Reference in New Issue
Block a user