From dcb12db40d76453686befd1063cc1ad39c297229 Mon Sep 17 00:00:00 2001 From: yangwen Date: Tue, 13 May 2025 14:17:33 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A1=A5=E5=85=85=E5=85=B3=E5=8D=A1=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- assets/animations/score_up.mc | Bin 0 -> 312 bytes assets/animations/score_up.mc.meta | 3 + assets/animations/score_up.mcc | 48 +++++++++++ assets/animations/score_up.mcc.meta | 3 + assets/atlas/comp/btn_back.png | Bin 0 -> 686 bytes assets/atlas/comp/btn_back.png.meta | 6 ++ assets/resources/ScoreAdd.lh | 75 ++++++++++++++++ assets/resources/ScoreAdd.lh.meta | 3 + assets/resources/Stage.lh | 129 ++++++++++++++++++++++++++++ src/constants/respath.ts | 2 + src/types/Block.ts | 30 +++++-- src/views/AutoDestroy.ts | 19 ++++ src/views/AutoDestroy.ts.meta | 3 + src/views/GUITips.ts | 9 ++ src/views/GUITips.ts.meta | 3 + src/views/Stage.ts | 56 +++++++++++- 16 files changed, 382 insertions(+), 7 deletions(-) create mode 100644 assets/animations/score_up.mc create mode 100644 assets/animations/score_up.mc.meta create mode 100644 assets/animations/score_up.mcc create mode 100644 assets/animations/score_up.mcc.meta create mode 100644 assets/atlas/comp/btn_back.png create mode 100644 assets/atlas/comp/btn_back.png.meta create mode 100644 assets/resources/ScoreAdd.lh create mode 100644 assets/resources/ScoreAdd.lh.meta create mode 100644 src/views/AutoDestroy.ts create mode 100644 src/views/AutoDestroy.ts.meta create mode 100644 src/views/GUITips.ts create mode 100644 src/views/GUITips.ts.meta diff --git a/assets/animations/score_up.mc b/assets/animations/score_up.mc new file mode 100644 index 0000000000000000000000000000000000000000..acba3993b85d43a83d7ccbecca10059a1df26b13 GIT binary patch literal 312 zcmWe)@NtZEboBG|bqw+J_cL;_GBEtfz`$S+#Ed}9z;G5!GB9ugX$~kGBrSHBfkDA( z^(rkp28IGBW#>>Q28ITEpdK3rHU=i3W)Nluk}v=^4#;H&%dr4SRv;S;fD{YRJ~p6E zAYg@B4Wtoj*?{U{03ixu!2m*(9VW_-Yyt<8C<6lz1KiWWMlK9MoAcAsic?D%87f&B hd=isVb2u2%^7Bf9GpkY=87kNqijxy_QX`;rBmfLV9)SP= literal 0 HcmV?d00001 diff --git a/assets/animations/score_up.mc.meta b/assets/animations/score_up.mc.meta new file mode 100644 index 0000000..7a98a35 --- /dev/null +++ b/assets/animations/score_up.mc.meta @@ -0,0 +1,3 @@ +{ + "uuid": "3ff6c374-5ecd-4de1-b271-a3280f87f9d9" +} \ No newline at end of file diff --git a/assets/animations/score_up.mcc b/assets/animations/score_up.mcc new file mode 100644 index 0000000..526dc7e --- /dev/null +++ b/assets/animations/score_up.mcc @@ -0,0 +1,48 @@ +{ + "_$type": "Animator", + "enabled": true, + "path": "", + "cullingMode": 2, + "controllerLayers": [ + { + "name": "Base Layer", + "states": [ + { + "x": 108, + "y": 105, + "id": "-1", + "name": "进入", + "nexts": [], + "soloTransitions": [ + { + "id": "1" + } + ] + }, + { + "y": 112, + "id": "-2", + "name": "任何状态", + "x": 447 + }, + { + "x": 285.5874536260055, + "y": 220.0965316887919, + "_isLooping": 0, + "id": "1", + "name": "score_up", + "speed": 1, + "clipEnd": 1, + "clip": { + "_$uuid": "3ff6c374-5ecd-4de1-b271-a3280f87f9d9" + }, + "loop": -1 + } + ], + "playOnWake": true, + "blendingMode": 0, + "defaultWeight": 1 + } + ], + "layerW": 150 +} \ No newline at end of file diff --git a/assets/animations/score_up.mcc.meta b/assets/animations/score_up.mcc.meta new file mode 100644 index 0000000..0817ef2 --- /dev/null +++ b/assets/animations/score_up.mcc.meta @@ -0,0 +1,3 @@ +{ + "uuid": "96c849ea-9704-40bc-8bb5-c00a4f341d30" +} \ No newline at end of file diff --git a/assets/atlas/comp/btn_back.png b/assets/atlas/comp/btn_back.png new file mode 100644 index 0000000000000000000000000000000000000000..1dfb21eb91e1d505a026851a0f17876a52a27c53 GIT binary patch literal 686 zcmV;f0#W^mP)@~0drDELIAGL9O(c600d`2O+f$vv5yP%x(=nLH*inTO%|rBP4K<~?L41NZBzPMiA^Sv{_z~jZSkkuo}Z$23Pfu}Jva;LK&QVZ$H%4#s5XQrGzsyVyEA}7i8)DV5g<|a`CgE zL>mpf5&I=ue_1ZdOG>beMyL~em$CVT5-mEo3p@3qf=jUxG zo2C!;?q)fsgbNN1?8AbB1N*pO;J|J!2sp6YQwIljcdFpPcBcjoY*{Mcz?L@{9N2yh z0tdE#y}^OquU_E5?w>a}u!rRZ4(#EH!GW!l2prgYIl+OgTPHZM^=kzOc9R literal 0 HcmV?d00001 diff --git a/assets/atlas/comp/btn_back.png.meta b/assets/atlas/comp/btn_back.png.meta new file mode 100644 index 0000000..6b67268 --- /dev/null +++ b/assets/atlas/comp/btn_back.png.meta @@ -0,0 +1,6 @@ +{ + "uuid": "06a9c4a8-d664-4f3a-9c35-25b610195ced", + "importer": { + "textureType": 2 + } +} \ No newline at end of file diff --git a/assets/resources/ScoreAdd.lh b/assets/resources/ScoreAdd.lh new file mode 100644 index 0000000..9d96113 --- /dev/null +++ b/assets/resources/ScoreAdd.lh @@ -0,0 +1,75 @@ +{ + "_$ver": 1, + "_$id": "ze5gx82a", + "_$type": "Box", + "name": "ScoreAdd", + "x": -17, + "y": 28, + "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 + } + ], + "_$child": [ + { + "_$id": "mqksqekt", + "_$type": "Box", + "name": "offset", + "y": -150, + "width": 150, + "height": 60, + "_$child": [ + { + "_$id": "muzcdy3q", + "_$type": "Label", + "name": "Label", + "x": 0, + "y": 0, + "width": 150, + "height": 60, + "scaleX": 1, + "scaleY": 1, + "text": "+150", + "font": "res://55f943ef-58d2-4b30-8498-271c4213cce4", + "fontSize": 60, + "color": "rgba(29, 92, 220, 1)", + "align": "center", + "valign": "middle", + "padding": "0,0,0,0" + } + ] + } + ] +} \ No newline at end of file diff --git a/assets/resources/ScoreAdd.lh.meta b/assets/resources/ScoreAdd.lh.meta new file mode 100644 index 0000000..72b2074 --- /dev/null +++ b/assets/resources/ScoreAdd.lh.meta @@ -0,0 +1,3 @@ +{ + "uuid": "324b6a80-ccee-46d2-bbbd-5a7bf92067b3" +} \ No newline at end of file diff --git a/assets/resources/Stage.lh b/assets/resources/Stage.lh index 5a5b947..79109f3 100644 --- a/assets/resources/Stage.lh +++ b/assets/resources/Stage.lh @@ -14,6 +14,21 @@ { "_$type": "692a672b-2457-456c-8093-321ea7a10e1b", "scriptPath": "../src/views/Stage.ts", + "label_stage_name": { + "_$ref": "w8r3l8ie" + }, + "label_score": { + "_$ref": "zgzyqyoc" + }, + "label_mistake": { + "_$ref": "azfx9pw2" + }, + "label_diff": { + "_$ref": "qxei5ih3" + }, + "label_time": { + "_$ref": "m5cdq70n" + }, "obj_blocks": { "_$ref": "mv2d4o7d" }, @@ -75,6 +90,49 @@ "skin": "res://63e88ec0-8898-4190-9f70-a4df67200ce3", "color": "#ffffff" }, + { + "_$id": "xllpjjqz", + "_$type": "Box", + "name": "back", + "x": 60, + "y": 60, + "width": 400, + "height": 64, + "_mouseState": 2, + "left": 60, + "top": 60, + "_$child": [ + { + "_$id": "l1ebdt6a", + "_$type": "Button", + "name": "btn_back", + "width": 92, + "height": 64, + "_mouseState": 2, + "stateNum": 1, + "skin": "res://06a9c4a8-d664-4f3a-9c35-25b610195ced", + "label": "", + "labelSize": 20, + "labelAlign": "center", + "labelVAlign": "middle" + }, + { + "_$id": "w8r3l8ie", + "_$type": "Text", + "name": "label_stage_name", + "x": 116, + "width": 200, + "height": 64, + "text": "[color=#000000]关卡 [/color][color=#1d5cdc]20[/color]", + "font": "res://55f943ef-58d2-4b30-8498-271c4213cce4", + "fontSize": 60, + "color": "#FFFFFF", + "ubb": true, + "valign": "middle", + "leading": 2 + } + ] + }, { "_$id": "jtbep2gl", "_$type": "Box", @@ -87,6 +145,77 @@ "centerX": 0, "centerY": -128, "_$child": [ + { + "_$id": "zgzyqyoc", + "_$type": "Label", + "name": "label_score", + "x": 372, + "y": -122, + "width": 300, + "height": 60, + "centerX": 0, + "centerY": -614, + "text": "分数:999", + "font": "res://55f943ef-58d2-4b30-8498-271c4213cce4", + "fontSize": 50, + "color": "rgba(29, 92, 220, 1)", + "align": "center", + "valign": "middle", + "padding": "0,0,0,0" + }, + { + "_$id": "azfx9pw2", + "_$type": "Label", + "name": "label_mistake", + "x": 4, + "y": -58, + "width": 300, + "height": 60, + "centerX": -368, + "centerY": -550, + "text": "错误:3/3", + "font": "res://55f943ef-58d2-4b30-8498-271c4213cce4", + "fontSize": 30, + "color": "rgba(123, 129, 140, 1)", + "valign": "middle", + "padding": "0,0,0,0" + }, + { + "_$id": "qxei5ih3", + "_$type": "Label", + "name": "label_diff", + "x": 372, + "y": -58, + "width": 300, + "height": 60, + "centerX": 0, + "centerY": -550, + "text": "难度", + "font": "res://55f943ef-58d2-4b30-8498-271c4213cce4", + "fontSize": 30, + "color": "rgba(123, 129, 140, 1)", + "align": "center", + "valign": "middle", + "padding": "0,0,0,0" + }, + { + "_$id": "m5cdq70n", + "_$type": "Label", + "name": "label_time", + "x": 741, + "y": -58, + "width": 300, + "height": 60, + "centerX": 369, + "centerY": -550, + "text": "99:99:99", + "font": "res://55f943ef-58d2-4b30-8498-271c4213cce4", + "fontSize": 30, + "color": "rgba(123, 129, 140, 1)", + "align": "right", + "valign": "middle", + "padding": "0,0,0,0" + }, { "_$id": "mv2d4o7d", "_$type": "HBox", diff --git a/src/constants/respath.ts b/src/constants/respath.ts index a474fa7..2d8fd43 100644 --- a/src/constants/respath.ts +++ b/src/constants/respath.ts @@ -3,5 +3,7 @@ export const respath = { home_ui_res: "resources/Home.lh", stage_ui_res: "resources/Stage.lh", + + score_add_ui_res: "resources/ScoreAdd.lh", } diff --git a/src/types/Block.ts b/src/types/Block.ts index fcd53f0..db9bccb 100644 --- a/src/types/Block.ts +++ b/src/types/Block.ts @@ -1,3 +1,5 @@ +import { G_ShowScoreTips } from "../views/GUITips"; + const { regClass, property } = Laya; @regClass() @@ -14,10 +16,12 @@ export class Block extends Laya.Script { 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; @@ -46,6 +50,8 @@ export class Block extends Laya.Script { public setSelected(selected: boolean): void { this.selected = selected + if (selected) + this.newSelect = true this.updateBlock() } @@ -67,6 +73,7 @@ export class Block extends Laya.Script { this.checked = preset; this.showNumber = showNumber; this.correctNumber = correctNumber; + this.score = 0 this.updateBlock(); } @@ -82,22 +89,35 @@ export class Block extends Laya.Script { return this.showNumber; } - public getCorrectNumber(): number { - return this.correctNumber; - } - public setShowNumber(showNumber: number): boolean { if (this.checked == false) { if (showNumber == this.correctNumber) this.checked = true; this.showNumber = showNumber; - if (this.checked || showNumber == 0)//正确或者擦除 + 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) diff --git a/src/views/AutoDestroy.ts b/src/views/AutoDestroy.ts new file mode 100644 index 0000000..d7b3ab4 --- /dev/null +++ b/src/views/AutoDestroy.ts @@ -0,0 +1,19 @@ +const { regClass, property } = Laya; + +@regClass() +export class AutoDestroy extends Laya.Script { + declare owner : Laya.Box; + + @property(Number) + public lifeTime: number = 1; + + //组件被激活后执行,此时所有节点和组件均已创建完毕,此方法只执行一次 + onAwake(): void { + if (this.lifeTime < 1) { + this.lifeTime = 1 + } + Laya.timer.once(this.lifeTime*1000, this, ()=>{ + this.owner.destroy() + }) + } +} \ No newline at end of file diff --git a/src/views/AutoDestroy.ts.meta b/src/views/AutoDestroy.ts.meta new file mode 100644 index 0000000..2cc73cf --- /dev/null +++ b/src/views/AutoDestroy.ts.meta @@ -0,0 +1,3 @@ +{ + "uuid": "bdb0e671-99fa-47a5-9101-7ec008b1d25d" +} \ No newline at end of file diff --git a/src/views/GUITips.ts b/src/views/GUITips.ts new file mode 100644 index 0000000..4214636 --- /dev/null +++ b/src/views/GUITips.ts @@ -0,0 +1,9 @@ +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 + }) +} \ No newline at end of file diff --git a/src/views/GUITips.ts.meta b/src/views/GUITips.ts.meta new file mode 100644 index 0000000..b7081d2 --- /dev/null +++ b/src/views/GUITips.ts.meta @@ -0,0 +1,3 @@ +{ + "uuid": "0a00337c-1c20-470f-930f-2b47f0294e23" +} \ No newline at end of file diff --git a/src/views/Stage.ts b/src/views/Stage.ts index 1f56ddb..3c14816 100644 --- a/src/views/Stage.ts +++ b/src/views/Stage.ts @@ -11,6 +11,20 @@ export class Stage extends Laya.Script { private letterToNumber: any; private numberToLetter: any; + @property(Laya.Text) + public label_stage_name: Laya.Text; + @property(Laya.Label) + public label_score: Laya.Label; + @property(Laya.Label) + public label_mistake: Laya.Label; + private mistake_now = 0 + private mistake_all = 3 + @property(Laya.Label) + public label_diff: Laya.Label; + @property(Laya.Label) + public label_time: Laya.Label; + private stage_last: number + @property(Laya.Box) public obj_blocks: Laya.Box; @property(Laya.Box) @@ -120,6 +134,7 @@ export class Stage extends Laya.Script { public onLoadStage(levelStr: string): void { + this.mistake_now = 0 this.selectedBlock = null; if (levelStr.length == 81 && this.blocks.length == 81) { @@ -155,6 +170,35 @@ export class Stage extends Laya.Script { else { console.log("onLoadStage error", levelStr.length, this.blocks.length) } + + this.onUpdateScore() + this.onUpdateMistake() + this.stage_last = 0 + var begin = Date.now() + Laya.timer.loop(1000, this, ()=>{ + var now = Date.now() + this.stage_last += Math.floor((now-begin)/1000) + begin = now + var last = this.stage_last + var hour = Math.floor(last/3600) + last = last - hour * 3600 + var minite = Math.floor(last/60) + last = last - minite * 60 + var second = Math.floor(last) + this.label_time.text = `${hour>=10?hour:("0"+hour)}:${minite>=10?minite:("0"+minite)}:${second>10?second:("0"+second)}` + }) + } + + onUpdateScore(): void { + var score = 0 + for (var i=0; i= this.mistake_all) { + //关卡失败 + } } } }