This commit is contained in:
YZ\249929363 2025-06-26 14:44:43 +08:00
commit 4ca3daaa48
3849 changed files with 671281 additions and 0 deletions

3
.vscode/settings.json vendored Normal file
View File

@ -0,0 +1,3 @@
{
"git.ignoreLimitWarning": true
}

21
assets/LoadScene.meta Normal file
View File

@ -0,0 +1,21 @@
{
"ver": "1.1.3",
"uuid": "264543aa-e611-4ca0-8a6e-737ae87ece33",
"importer": "folder",
"isBundle": true,
"bundleName": "",
"priority": "1",
"compressionType": {
"wechatgame": "subpackage"
},
"optimizeHotUpdate": {
"wechatgame": false
},
"inlineSpriteFrames": {
"wechatgame": false
},
"isRemoteBundle": {
"wechatgame": false
},
"subMetas": {}
}

13
assets/Scene.meta Normal file
View File

@ -0,0 +1,13 @@
{
"ver": "1.1.3",
"uuid": "29f52784-2fca-467b-92e7-8fd9ef8c57b7",
"importer": "folder",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}

18776
assets/Scene/GameScene.fire Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,8 @@
{
"ver": "1.3.2",
"uuid": "4eaf518b-35ec-4262-928d-4d497c3f2830",
"importer": "scene",
"asyncLoadAssets": false,
"autoReleaseAssets": false,
"subMetas": {}
}

10475
assets/Scene/HomeScene.fire Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,8 @@
{
"ver": "1.3.2",
"uuid": "66281f32-0047-4af8-8237-90c93fc4b0e8",
"importer": "scene",
"asyncLoadAssets": false,
"autoReleaseAssets": false,
"subMetas": {}
}

962
assets/Scene/LoadScene.fire Normal file
View File

@ -0,0 +1,962 @@
[
{
"__type__": "cc.SceneAsset",
"_name": "",
"_objFlags": 0,
"_native": "",
"scene": {
"__id__": 1
}
},
{
"__type__": "cc.Scene",
"_objFlags": 0,
"_parent": null,
"_children": [
{
"__id__": 2
},
{
"__id__": 6
}
],
"_active": false,
"_components": [],
"_prefab": null,
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 0,
"height": 0
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
0,
0,
0,
0,
0,
0,
1,
1,
1,
1
]
},
"_is3DNode": true,
"_groupIndex": 0,
"groupIndex": 0,
"autoReleaseAssets": false,
"_id": "9c08062d-4cf1-4b6e-a8ba-4a3881cc7e7d"
},
{
"__type__": "cc.Node",
"_name": "GameData",
"_objFlags": 0,
"_parent": {
"__id__": 1
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 3
},
{
"__id__": 4
},
{
"__id__": 22
},
{
"__id__": 23
}
],
"_prefab": null,
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 0,
"height": 0
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
0,
0,
0,
0,
0,
0,
1,
1,
1,
1
]
},
"_eulerAngles": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_skewX": 0,
"_skewY": 0,
"_is3DNode": false,
"_groupIndex": 0,
"groupIndex": 0,
"_id": "2dMM3dYbVDG6vnNZZa8IqA"
},
{
"__type__": "58403/n16JCa5sZhNMjZzGo",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 2
},
"_enabled": true,
"audioGameBgm0": {
"__uuid__": "75b4f368-70b5-452d-9afd-ca7a6f1e2e60"
},
"xiaochu": {
"__uuid__": "8d67c864-c7f4-4305-8b3b-2d66eb69e349"
},
"hit": {
"__uuid__": "7575a6bd-a21d-491e-aad2-e40a189683e9"
},
"down": {
"__uuid__": "ec293610-1767-46e8-b6b6-4a9a79ef2233"
},
"fangxiang": null,
"build": null,
"win": null,
"lose": null,
"anniu_Big": {
"__uuid__": "7362cac7-12b5-4704-af6d-5b110c5e9fcf"
},
"anniu_little": {
"__uuid__": "a5518b0f-7ed3-46f0-aa78-93f02f4579cc"
},
"zhuan1": {
"__uuid__": "e4d2f16e-7663-4ee5-a479-06ae0eae91d5"
},
"zhuan2": {
"__uuid__": "998a24bd-ffa0-4f96-bc39-a9789f42bd9b"
},
"_id": "f9HvPHc8ZDoJYWFfPoEmf1"
},
{
"__type__": "454adgphRpA6oq5lB6Cg1fK",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 2
},
"_enabled": true,
"node1": {
"__id__": 5
},
"node2": {
"__id__": 17
},
"node3": {
"__id__": 15
},
"localTest": false,
"clientTestVersion": "1.0.0",
"testVersion": null,
"_id": "ac/PqMKZlO95wACtRGBFbA"
},
{
"__type__": "cc.Node",
"_name": "jiazai1",
"_objFlags": 0,
"_parent": {
"__id__": 6
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 21
}
],
"_prefab": null,
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 52,
"height": 49
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
-97.164,
-284.062,
0,
0,
0,
0,
1,
1,
1,
1
]
},
"_eulerAngles": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_skewX": 0,
"_skewY": 0,
"_is3DNode": false,
"_groupIndex": 0,
"groupIndex": 0,
"_id": "65yrYdwqdG+ojlKn3md91o"
},
{
"__type__": "cc.Node",
"_name": "Canvas",
"_objFlags": 0,
"_parent": {
"__id__": 1
},
"_children": [
{
"__id__": 7
},
{
"__id__": 10
},
{
"__id__": 13
},
{
"__id__": 5
},
{
"__id__": 15
},
{
"__id__": 17
}
],
"_active": true,
"_components": [
{
"__id__": 19
},
{
"__id__": 20
}
],
"_prefab": null,
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 1080,
"height": 1920
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
540,
960,
0,
0,
0,
0,
1,
1,
1,
1
]
},
"_eulerAngles": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_skewX": 0,
"_skewY": 0,
"_is3DNode": false,
"_groupIndex": 0,
"groupIndex": 0,
"_id": "a5esZu+45LA5mBpvttspPD"
},
{
"__type__": "cc.Node",
"_name": "Main Camera",
"_objFlags": 0,
"_parent": {
"__id__": 6
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 8
},
{
"__id__": 9
}
],
"_prefab": null,
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 960,
"height": 640
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
0,
0,
0,
0,
0,
0,
1,
1,
1,
1
]
},
"_eulerAngles": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_skewX": 0,
"_skewY": 0,
"_is3DNode": false,
"_groupIndex": 0,
"groupIndex": 0,
"_id": "e1WoFrQ79G7r4ZuQE3HlNb"
},
{
"__type__": "cc.Camera",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 7
},
"_enabled": true,
"_cullingMask": 4294967295,
"_clearFlags": 7,
"_backgroundColor": {
"__type__": "cc.Color",
"r": 0,
"g": 0,
"b": 0,
"a": 255
},
"_depth": -1,
"_zoomRatio": 1,
"_targetTexture": null,
"_fov": 60,
"_orthoSize": 10,
"_nearClip": 1,
"_farClip": 4096,
"_ortho": true,
"_rect": {
"__type__": "cc.Rect",
"x": 0,
"y": 0,
"width": 1,
"height": 1
},
"_renderStages": 1,
"_alignWithScreen": true,
"_id": "81GN3uXINKVLeW4+iKSlim"
},
{
"__type__": "5c9b8FZiaNLMrMDs9T3rByf",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 7
},
"_enabled": true,
"_id": "82rBHh8bJIGKuGw03a3Yrd"
},
{
"__type__": "cc.Node",
"_name": "bg",
"_objFlags": 0,
"_parent": {
"__id__": 6
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 11
},
{
"__id__": 12
}
],
"_prefab": null,
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 1080,
"height": 1920
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
0,
0,
0,
0,
0,
0,
1,
1,
1,
1
]
},
"_eulerAngles": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_skewX": 0,
"_skewY": 0,
"_is3DNode": false,
"_groupIndex": 0,
"groupIndex": 0,
"_id": "b7i0z42uZCe6L6/4fdasjO"
},
{
"__type__": "cc.Sprite",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 10
},
"_enabled": true,
"_materials": [
{
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
}
],
"_srcBlendFactor": 770,
"_dstBlendFactor": 771,
"_spriteFrame": {
"__uuid__": "c09e129e-5195-4054-b8a5-65e1bd675c3f"
},
"_type": 0,
"_sizeMode": 0,
"_fillType": 0,
"_fillCenter": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"_fillStart": 0,
"_fillRange": 0,
"_isTrimmedMode": true,
"_atlas": null,
"_id": "9cjtfCxPNC9qtsarnIvaIV"
},
{
"__type__": "cc.Widget",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 10
},
"_enabled": true,
"alignMode": 1,
"_target": null,
"_alignFlags": 45,
"_left": 0,
"_right": 0,
"_top": 0,
"_bottom": 0,
"_verticalCenter": 0,
"_horizontalCenter": 0,
"_isAbsLeft": true,
"_isAbsRight": true,
"_isAbsTop": true,
"_isAbsBottom": true,
"_isAbsHorizontalCenter": true,
"_isAbsVerticalCenter": true,
"_originalWidth": 1080,
"_originalHeight": 2340,
"_id": "c0sWn10ZdBD6+shoZmPwoN"
},
{
"__type__": "cc.Node",
"_name": "logo",
"_objFlags": 0,
"_parent": {
"__id__": 6
},
"_children": [],
"_active": false,
"_components": [
{
"__id__": 14
}
],
"_prefab": null,
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 929,
"height": 216
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
-6.686,
369.958,
0,
0,
0,
0,
1,
1,
1,
1
]
},
"_eulerAngles": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_skewX": 0,
"_skewY": 0,
"_is3DNode": false,
"_groupIndex": 0,
"groupIndex": 0,
"_id": "9cDML2xA5FBo1N9jdY+vbR"
},
{
"__type__": "cc.Sprite",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 13
},
"_enabled": true,
"_materials": [
{
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
}
],
"_srcBlendFactor": 770,
"_dstBlendFactor": 771,
"_spriteFrame": null,
"_type": 0,
"_sizeMode": 1,
"_fillType": 0,
"_fillCenter": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"_fillStart": 0,
"_fillRange": 0,
"_isTrimmedMode": true,
"_atlas": null,
"_id": "b6c3wasj1AtodoC2eFiGL/"
},
{
"__type__": "cc.Node",
"_name": "jiazai3",
"_objFlags": 0,
"_parent": {
"__id__": 6
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 16
}
],
"_prefab": null,
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 50,
"height": 53
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
83.039,
-284.062,
0,
0,
0,
0,
1,
1,
1,
1
]
},
"_eulerAngles": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_skewX": 0,
"_skewY": 0,
"_is3DNode": false,
"_groupIndex": 0,
"groupIndex": 0,
"_id": "7dezOD8dVAhqWjyJdZ9zJ7"
},
{
"__type__": "cc.Sprite",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 15
},
"_enabled": true,
"_materials": [
{
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
}
],
"_srcBlendFactor": 770,
"_dstBlendFactor": 771,
"_spriteFrame": {
"__uuid__": "9a639b00-f202-4b8e-98f0-6be5cece1cc6"
},
"_type": 0,
"_sizeMode": 1,
"_fillType": 0,
"_fillCenter": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"_fillStart": 0,
"_fillRange": 0,
"_isTrimmedMode": true,
"_atlas": null,
"_id": "50bbTw60NKz6wVtFH5z2K9"
},
{
"__type__": "cc.Node",
"_name": "jiazai2",
"_objFlags": 0,
"_parent": {
"__id__": 6
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 18
}
],
"_prefab": null,
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 69,
"height": 64
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
-6.077,
-284.062,
0,
0,
0,
0,
1,
1,
1,
1
]
},
"_eulerAngles": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_skewX": 0,
"_skewY": 0,
"_is3DNode": false,
"_groupIndex": 0,
"groupIndex": 0,
"_id": "9dmdxyFsVEN6G83f8DvJ0l"
},
{
"__type__": "cc.Sprite",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 17
},
"_enabled": true,
"_materials": [
{
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
}
],
"_srcBlendFactor": 770,
"_dstBlendFactor": 771,
"_spriteFrame": {
"__uuid__": "24e560c5-22d5-44e4-8b55-85431fd8a61b"
},
"_type": 0,
"_sizeMode": 1,
"_fillType": 0,
"_fillCenter": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"_fillStart": 0,
"_fillRange": 0,
"_isTrimmedMode": true,
"_atlas": null,
"_id": "d6csD0iDBH4LhhASlK5PWc"
},
{
"__type__": "cc.Canvas",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 6
},
"_enabled": true,
"_designResolution": {
"__type__": "cc.Size",
"width": 1080,
"height": 1920
},
"_fitWidth": true,
"_fitHeight": false,
"_id": "59Cd0ovbdF4byw5sbjJDx7"
},
{
"__type__": "cc.Widget",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 6
},
"_enabled": true,
"alignMode": 1,
"_target": null,
"_alignFlags": 45,
"_left": 0,
"_right": 0,
"_top": 0,
"_bottom": 0,
"_verticalCenter": 0,
"_horizontalCenter": 0,
"_isAbsLeft": true,
"_isAbsRight": true,
"_isAbsTop": true,
"_isAbsBottom": true,
"_isAbsHorizontalCenter": true,
"_isAbsVerticalCenter": true,
"_originalWidth": 0,
"_originalHeight": 0,
"_id": "29zXboiXFBKoIV4PQ2liTe"
},
{
"__type__": "cc.Sprite",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 5
},
"_enabled": true,
"_materials": [
{
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
}
],
"_srcBlendFactor": 770,
"_dstBlendFactor": 771,
"_spriteFrame": {
"__uuid__": "081a89e4-cd4d-49b7-81a3-bd2b3321ca26"
},
"_type": 0,
"_sizeMode": 1,
"_fillType": 0,
"_fillCenter": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"_fillStart": 0,
"_fillRange": 0,
"_isTrimmedMode": true,
"_atlas": null,
"_id": "1cgewKbYRMtIgKEetpfwI+"
},
{
"__type__": "df248lSLllOZpCHwGqQ5Ye3",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 2
},
"_enabled": true,
"label": null,
"text": "hello",
"Block_Array": [],
"Wall_Prefab": [],
"Block_Color": [],
"_id": "89AARqGyBAkoEhGSfCdkpY"
},
{
"__type__": "669f4SuSl9ORqawBcbwCNpG",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 2
},
"_enabled": true,
"fontUI": {
"__uuid__": "fa9a438e-1f24-47fe-bbcd-b75abcff2ea8"
},
"_id": "e4QjzhztFAl4p0+5kRotxl"
}
]

View File

@ -0,0 +1,8 @@
{
"ver": "1.3.2",
"uuid": "9c08062d-4cf1-4b6e-a8ba-4a3881cc7e7d",
"importer": "scene",
"asyncLoadAssets": false,
"autoReleaseAssets": false,
"subMetas": {}
}

585
assets/Scene/New Scene.fire Normal file
View File

@ -0,0 +1,585 @@
[
{
"__type__": "cc.SceneAsset",
"_name": "",
"_objFlags": 0,
"_native": "",
"scene": {
"__id__": 1
}
},
{
"__type__": "cc.Scene",
"_objFlags": 0,
"_parent": null,
"_children": [
{
"__id__": 2
}
],
"_active": true,
"_components": [],
"_prefab": null,
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 0,
"height": 0
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
0,
0,
0,
0,
0,
0,
1,
1,
1,
1
]
},
"_is3DNode": true,
"_groupIndex": 0,
"groupIndex": 0,
"autoReleaseAssets": false,
"_id": "19659ed7-1823-42a9-b8e8-1884c19df817"
},
{
"__type__": "cc.Node",
"_name": "Canvas",
"_objFlags": 0,
"_parent": {
"__id__": 1
},
"_children": [
{
"__id__": 3
},
{
"__id__": 5
}
],
"_active": true,
"_components": [
{
"__id__": 14
},
{
"__id__": 15
}
],
"_prefab": null,
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 960,
"height": 640
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
480,
320,
0,
0,
0,
0,
1,
1,
1,
1
]
},
"_eulerAngles": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_skewX": 0,
"_skewY": 0,
"_is3DNode": false,
"_groupIndex": 0,
"groupIndex": 0,
"_id": "a5esZu+45LA5mBpvttspPD"
},
{
"__type__": "cc.Node",
"_name": "Main Camera",
"_objFlags": 0,
"_parent": {
"__id__": 2
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 4
}
],
"_prefab": null,
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 960,
"height": 640
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
0,
0,
0,
0,
0,
0,
1,
1,
1,
1
]
},
"_eulerAngles": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_skewX": 0,
"_skewY": 0,
"_is3DNode": false,
"_groupIndex": 0,
"groupIndex": 0,
"_id": "e1WoFrQ79G7r4ZuQE3HlNb"
},
{
"__type__": "cc.Camera",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 3
},
"_enabled": true,
"_cullingMask": 4294967295,
"_clearFlags": 7,
"_backgroundColor": {
"__type__": "cc.Color",
"r": 0,
"g": 0,
"b": 0,
"a": 255
},
"_depth": -1,
"_zoomRatio": 1,
"_targetTexture": null,
"_fov": 60,
"_orthoSize": 10,
"_nearClip": 1,
"_farClip": 4096,
"_ortho": true,
"_rect": {
"__type__": "cc.Rect",
"x": 0,
"y": 0,
"width": 1,
"height": 1
},
"_renderStages": 1,
"_alignWithScreen": true,
"_id": "81GN3uXINKVLeW4+iKSlim"
},
{
"__type__": "cc.Node",
"_name": "freeze",
"_objFlags": 0,
"_parent": {
"__id__": 2
},
"_children": [
{
"__id__": 6
},
{
"__id__": 9
}
],
"_active": true,
"_components": [
{
"__id__": 11
},
{
"__id__": 12
}
],
"_prefab": {
"__id__": 13
},
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 362,
"height": 372
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
0,
0,
0,
0,
0,
0,
1,
1,
1,
1
]
},
"_eulerAngles": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_skewX": 0,
"_skewY": 0,
"_is3DNode": false,
"_groupIndex": 0,
"groupIndex": 0,
"_id": "49jqxRUXRAxLDFbbRcou72"
},
{
"__type__": "cc.Node",
"_name": "icon",
"_objFlags": 0,
"_parent": {
"__id__": 5
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 7
}
],
"_prefab": {
"__id__": 8
},
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 40,
"height": 36
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
0,
0,
0,
0,
0,
0,
1,
1,
1,
1
]
},
"_eulerAngles": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_skewX": 0,
"_skewY": 0,
"_is3DNode": false,
"_groupIndex": 0,
"groupIndex": 0,
"_id": "eeUUfaX31G+q5appAMitqJ"
},
{
"__type__": "cc.Sprite",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 6
},
"_enabled": true,
"_materials": [
{
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
}
],
"_srcBlendFactor": 770,
"_dstBlendFactor": 771,
"_spriteFrame": null,
"_type": 0,
"_sizeMode": 1,
"_fillType": 0,
"_fillCenter": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"_fillStart": 0,
"_fillRange": 0,
"_isTrimmedMode": true,
"_atlas": null,
"_id": "40mhRhU0tLcoWPMyDYKqzK"
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 5
},
"asset": {
"__uuid__": "5ed13d95-5b93-4407-b770-0dedeb674b0f"
},
"fileId": "48vFumJApBjb/xUEZIhVH6",
"sync": false
},
{
"__type__": "cc.Node",
"_name": "time",
"_objFlags": 0,
"_parent": {
"__id__": 5
},
"_children": [],
"_active": true,
"_components": [],
"_prefab": {
"__id__": 10
},
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 0,
"height": 0
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
-25,
8,
0,
0,
0,
0,
1,
1,
1,
1
]
},
"_eulerAngles": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_skewX": 0,
"_skewY": 0,
"_is3DNode": false,
"_groupIndex": 0,
"groupIndex": 0,
"_id": "d2GpI/cSZNx5Pr2/sDPzho"
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 5
},
"asset": {
"__uuid__": "5ed13d95-5b93-4407-b770-0dedeb674b0f"
},
"fileId": "afr7mnXGdMXZMpTDxTmfms",
"sync": false
},
{
"__type__": "cc.Sprite",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 5
},
"_enabled": true,
"_materials": [
{
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
}
],
"_srcBlendFactor": 770,
"_dstBlendFactor": 771,
"_spriteFrame": {
"__uuid__": "2661e9df-d4da-4dcc-ac8d-cb16fcad7ea8"
},
"_type": 0,
"_sizeMode": 1,
"_fillType": 0,
"_fillCenter": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"_fillStart": 0,
"_fillRange": 0,
"_isTrimmedMode": true,
"_atlas": {
"__uuid__": "8b6fd107-6aa0-4523-8fd3-c0f064524b0c"
},
"_id": "5dcrLbiJhPCJwgmPSI4pkE"
},
{
"__type__": "ad8cbbzCohCR5uifssdRTf+",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 5
},
"_enabled": true,
"freeze": {
"__uuid__": "fff54feb-03db-4d8a-b079-57eedca8a644"
},
"_id": "a1NSNhhglGsI9I3Fvp6Hmx"
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 5
},
"asset": {
"__uuid__": "5ed13d95-5b93-4407-b770-0dedeb674b0f"
},
"fileId": "",
"sync": false
},
{
"__type__": "cc.Canvas",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 2
},
"_enabled": true,
"_designResolution": {
"__type__": "cc.Size",
"width": 960,
"height": 640
},
"_fitWidth": false,
"_fitHeight": true,
"_id": "59Cd0ovbdF4byw5sbjJDx7"
},
{
"__type__": "cc.Widget",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 2
},
"_enabled": true,
"alignMode": 1,
"_target": null,
"_alignFlags": 45,
"_left": 0,
"_right": 0,
"_top": 0,
"_bottom": 0,
"_verticalCenter": 0,
"_horizontalCenter": 0,
"_isAbsLeft": true,
"_isAbsRight": true,
"_isAbsTop": true,
"_isAbsBottom": true,
"_isAbsHorizontalCenter": true,
"_isAbsVerticalCenter": true,
"_originalWidth": 0,
"_originalHeight": 0,
"_id": "29zXboiXFBKoIV4PQ2liTe"
}
]

View File

@ -0,0 +1,8 @@
{
"ver": "1.3.2",
"uuid": "19659ed7-1823-42a9-b8e8-1884c19df817",
"importer": "scene",
"asyncLoadAssets": false,
"autoReleaseAssets": false,
"subMetas": {}
}

13
assets/Script.meta Normal file
View File

@ -0,0 +1,13 @@
{
"ver": "1.1.3",
"uuid": "4734c20c-0db8-4eb2-92ea-e692f4d70934",
"importer": "folder",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}

98
assets/Script/Barrier.ts Normal file
View File

@ -0,0 +1,98 @@
import CollisionDetection from "./CollisionDetection";
import MapConroler from "./Map";
const {ccclass, property} = cc._decorator;
@ccclass
export default class Block extends cc.Component {
// 新增缓存变量
private selfBoxColliders: cc.BoxCollider[] = [];
private allBoxColliders: cc.BoxCollider[] = [];
// @property({
// tooltip: '碰撞形状None就是无敌不参与碰撞',
// type: cc.Enum(BlockType),
// // default: BlockType.Nomal,
// displayName: '碰撞形状'
// })
// LIFE-CYCLE CALLBACKS:
// @property(cc.SpriteAtlas)
// UI: cc.SpriteAtlas = null;
private initialTouchOffset: cc.Vec2 = null;
private offsetTolerance = 100; // 偏移容忍度;
allBlocks:any; //所有的方块,用于计算posX,posY消除
touchPoint: cc.Vec2 = null; //触摸点
isTouch: boolean = false; //是否触摸
posX: number = 0; //地图块的X坐标
posY: number = 0; //地图块的Y坐标
moveLeft: boolean = true; //是否可以左移;
moveRight: boolean = true; //是否可以右移;
moveUp: boolean = true; //是否可以上移;
moveDown: boolean = true; //是否可以下移;
moveCorner: number = 0; //是否碰撞角落
moveY:number = 0; //是否可以上下移动;
moveX:number = 0; //是否可以左右移动;
touchPointX: number = 0; //触摸点X坐标;
touchPointY: number = 0; //触摸点Y坐标;
blockId: number = 0; //方块ID;
stacking: cc.Vec2; //叠加方块
level: number = 0; //叠加方块层数;
pz: boolean = false;
collider: any;
block_Info:any;
_touchListener: any;
relative_Position:cc.Vec2; //点击和方块相对位置
private _eventManager: any;
hit: cc.Node;
onLoad () {
// this.node.on(cc.Node.EventType.TOUCH_START, this.touchStart, this);
// this.node.on(cc.Node.EventType.TOUCH_MOVE, this.touchMove, this);
// this.node.on(cc.Node.EventType.TOUCH_CANCEL, this.touchEnd, this);
// this.node.on(cc.Node.EventType.TOUCH_END, this.touchEnd, this);
this.pz = false;
this.stacking = cc.v2(0,0);
// this.selfBoxColliders = this.node.getComponentsInChildren(cc.BoxCollider)
// .filter(collider => collider.tag < 4);
}
start () {
}
jsonDeepClone<T>(obj: T): T {
return JSON.parse(JSON.stringify(obj));
}
init(block_Info,posX,posY,node){
this.block_Info = this.jsonDeepClone(block_Info);
let mapInfo = MapConroler._instance.mapInfo;
for(let i=0; i<mapInfo.length; i++){
let blockRect = mapInfo[i].getBoundingBox();
// 使用 cc.Intersection.pointInRect 方法判断点是否在矩形范围内
let point = cc.v2(this.node.position.x-5, this.node.position.y+10)
if(blockRect.contains(point)){
this.posX = mapInfo[i].getComponent("MapBlock").posX;
this.posY = mapInfo[i].getComponent("MapBlock").posY;
this.level = 50 + this.posX - this.posY*3;
this.node.zIndex = this.level;
this.node.x = mapInfo[i].x + 65;
this.node.y = mapInfo[i].y - 60;
i= 10000;
break;
}
}
}
}

View File

@ -0,0 +1,10 @@
{
"ver": "1.1.0",
"uuid": "90c37607-5145-4fb1-8d26-94d9a89baeee",
"importer": "typescript",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}

1265
assets/Script/Block.ts Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,10 @@
{
"ver": "1.1.0",
"uuid": "c58de376-bb53-4664-bf27-270be7bb53d1",
"importer": "typescript",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}

View File

@ -0,0 +1,73 @@
// Learn TypeScript:
// - https://docs.cocos.com/creator/manual/en/scripting/typescript.html
// Learn Attribute:
// - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
// - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html
const {ccclass, property, requireComponent} = cc._decorator;
@ccclass
export default class CollisionDetection extends cc.Component {
static _instance: any; onLoad() {
if (CollisionDetection._instance == null) {
CollisionDetection._instance = this;
// cc.game.addPersistRootNode(this.node);
}
else {
return;
}
}
//碰撞检测函数
public isColliding(rect1: cc.Rect, rect2: cc.Rect): { isColliding: boolean } {
// 快速排除:检查边界框是否相交
if (rect1.xMax < rect2.xMin || rect2.xMax < rect1.xMin || rect1.yMax < rect2.yMin || rect2.yMax < rect1.yMin) {
return { isColliding: false };
}
// 调用原始的 intersects 方法
const isColliding = rect1.intersects(rect2);
return { isColliding };
}
// 获取多边形的所有边的法线
private getNormals(polygon: cc.Vec2[]): cc.Vec2[] {
const normals: cc.Vec2[] = [];
const length = polygon.length;
for (let i = 0; i < length; i++) {
const p1 = polygon[i];
const p2 = polygon[(i + 1) % length];
const edge = new cc.Vec2(p2.x - p1.x, p2.y - p1.y);
const normal = new cc.Vec2(-edge.y, edge.x);
normal.normalize();
normals.push(normal);
}
return normals;
}
// 将多边形投影到轴上
private project(polygon: cc.Vec2[], axis: cc.Vec2): { min: number; max: number } {
let min = cc.Vec2.dot(polygon[0], axis);
let max = min;
for (let i = 1; i < polygon.length; i++) {
const dotProduct = cc.Vec2.dot(polygon[i], axis);
if (dotProduct < min) {
min = dotProduct;
} else if (dotProduct > max) {
max = dotProduct;
}
}
return { min, max };
}
// 检查两个投影是否重叠
private overlap(projection1: { min: number; max: number }, projection2: { min: number; max: number }): boolean {
return !(projection1.max < projection2.min || projection2.max < projection1.min);
}
}

View File

@ -0,0 +1,10 @@
{
"ver": "1.1.0",
"uuid": "f1883a57-ccc5-48a7-9fc0-4430167d9ee3",
"importer": "typescript",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}

View File

@ -0,0 +1,178 @@
// Learn TypeScript:
// - https://docs.cocos.com/creator/manual/en/scripting/typescript.html
// Learn Attribute:
// - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
// - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html
const {ccclass, property} = cc._decorator;
@ccclass
export default class NewClass extends cc.Component {
@property(cc.Node)
Map: cc.Node = null;
@property(cc.Prefab)
tip: cc.Prefab = null;
@property(cc.Prefab)
reinforce: cc.Prefab = null;
@property(cc.Prefab)
soil: cc.Prefab = null;
tipArray:any;
controlArray:any;
canTouch:boolean;
Reinforce:boolean;
Soil:boolean;
mapHeight:number;
// LIFE-CYCLE CALLBACKS:
// onLoad () {}
start () {
this.tipArray = [];
this.controlArray = [];
this.canTouch = true;
this.Reinforce = false;
this.Soil = false;
this.mapHeight = 0;
}
setPosition(tip){
tip.setPosition(30,-25);
if(this.tipArray.length > 0){
let length = this.tipArray.length+1;
let posY = Math.ceil(length/8) - 1;
let posX = length - Math.floor(posY)*8 - 1;
tip.setPosition(30 + 48*posX,-25 -48*posY + this.mapHeight);
}
}
//清空所有
removeAllTip(){
if(!this.canTouch) return;
if(this.tipArray.length > 0){
cc.fx.AudioManager._instance.playEffect("qingkong",null);
for(let i=0; i<this.tipArray.length;i++){
let tip = this.tipArray[i];
tip.active = false;
tip.removeFromParent(this.Map);
tip = null;
}
this.tipArray = [];
this.controlArray = [];
var drawingReset = cc.fx.GameConfig.CLICK_DATA.drawingReset + 1;
cc.fx.GameConfig.CLICK_SET("drawingReset",drawingReset);
cc.fx.Notifications.emit(cc.fx.Message.removeTip,"remove");
this.mapHeight = 0;
}
}
//撤回一步
back_Click(){
if(!this.canTouch) return;
if(this.tipArray.length > 0){
cc.fx.AudioManager._instance.playEffect("chehui",null);
let tip = this.tipArray[this.tipArray.length-1];
tip.active = false;
tip.removeFromParent(this.Map);
tip = null;
this.tipArray.pop();
this.controlArray.pop();
var drawingBack = cc.fx.GameConfig.CLICK_DATA.drawingBack + 1;
cc.fx.GameConfig.CLICK_SET("drawingBack",drawingBack);
cc.fx.Notifications.emit(cc.fx.Message.removeTip,"back");
if(this.tipArray.length >= 24){
if((this.tipArray.length )%8 == 0){
this.mapMove(false);
}
}
}
}
//点击事件
btn_Click(target,data){
var GameManager = this.node.parent.getComponent("GameManager");
if(GameManager.btnClick == true){
GameManager.btnClick = false;
cc.fx.Notifications.emit(cc.fx.Message.guideNext);
}
cc.fx.Notifications.emit(cc.fx.Message.control,data);
if(!this.canTouch) return;
let prefab = this.tip;
if(data == "reinforce" || data == "soil"){
prefab = this[data];
if(data == "reinforce"){
if(this.Reinforce){
this.Reinforce = false;
this.back_Click();
return;
}else{
cc.fx.AudioManager._instance.playEffect("jineng",null);
this.Reinforce = true;
this.Soil = false;
}
}
else if(data == "soil"){
if(this.Soil){
this.Soil = false;
this.back_Click();
return;
}else{
cc.fx.AudioManager._instance.playEffect("jineng",null);
this.Soil = true;
this.Reinforce = false;
}
}
}
else{
cc.fx.AudioManager._instance.playEffect("fangxiang",null);
this.Reinforce = false;
this.Soil = false;
}
let tip = cc.instantiate(prefab);
if(data == "up") tip.angle = 180;
if(data == "left") tip.angle = -90;
if(data == "right") tip.angle = 90;
tip.parent = this.Map;
if(this.controlArray[this.controlArray.length-1] == "reinforce" ||
this.controlArray[this.controlArray.length-1] == "soil"){
if(data == "reinforce" || data == "soil"){
this.tipArray[this.tipArray.length-1].removeFromParent();
this.tipArray[this.tipArray.length-1] = null;
this.tipArray.pop();
this.controlArray.pop();
}
}
this.setPosition(tip);
this.tipArray.push(tip);
this.controlArray.push(data);
if(this.tipArray.length >= 25){
if((this.tipArray.length - 1)%8 == 0){
this.mapMove(true);
}
}
}
//地图放不下了上下移动
mapMove(type){
if(type) this.mapHeight += 48;
else this.mapHeight -= 48;
for(let i=0; i<this.tipArray.length;i++){
let tip = this.tipArray[i];
if(type)tip.y += 48;
else tip.y -= 48;
}
}
//点击开始 创建河道
start_Click(){
if(!this.canTouch) return;
this.canTouch = false;
cc.fx.AudioManager._instance.playEffect("build",null);
cc.fx.Notifications.emit(cc.fx.Message.startGame,this.controlArray);
}
// update (dt) {}
}

View File

@ -0,0 +1,10 @@
{
"ver": "1.1.0",
"uuid": "e35ab717-e554-40a0-8b4e-ea6805718c97",
"importer": "typescript",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}

View File

@ -0,0 +1,10 @@
cc.Class({
extends: cc.Component,
properties: {
},
onLoad () {
cc.dynamicAtlasManager.enabled = false;
},
});

View File

@ -0,0 +1,10 @@
{
"ver": "1.1.0",
"uuid": "5c9b8159-89a3-4b32-b303-b3d4f7ac1c9f",
"importer": "javascript",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}

View File

@ -0,0 +1,677 @@
// Learn TypeScript:
// - https://docs.cocos.com/creator/manual/en/scripting/typescript.html
// Learn Attribute:
// - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
// - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html
import { MiniGameManager } from "./Sdk/MiniGameManager";
import { MiniGameSdk } from "./Sdk/MiniGameSdk";
const {ccclass, property} = cc._decorator;
@ccclass
export default class GameManager extends cc.Component {
@property(cc.Label)
label: cc.Label = null;
@property
text: string = 'hello';
static _instance : GameManager = null;
@property({type: [cc.Prefab], tooltip:"方块数组"})
Block_Array : Array<cc.Prefab> = [];
@property({type: [cc.Prefab], tooltip:"墙壁数组"})
Wall_Prefab : Array<cc.Prefab> = [];
@property({type: [cc.SpriteAtlas], tooltip:"方块颜色"})
Block_Color : Array<cc.SpriteAtlas> = [];
particleEffects: cc.ParticleAsset[];
// @property({type: [cc.ParticleSystem], tooltip:"粒子数组"})
// particleEffects : Array<cc.ParticleSystem> = [];
load1 :boolean = false;
load2 :boolean = false;
load3 :boolean = false;
load4 :boolean = false;
load5 :boolean = false;
scheduleCallback: any;
timeNumber: number;
// LIFE-CYCLE CALLBACKS:
onLoad () {
window.initMgr();
this.timeNumber = 3;
this.startTimeCutDown();
cc.fx.GameConfig.init(true);
cc.fx.GameConfig.GM_INFO.gameState = false;
this.readMusicConfig();
console.log("音乐开关",cc.fx.GameConfig.GM_INFO.musicOpen);
cc.fx.AudioManager._instance.playMusicGame();
this.load1 = this.load2 = this.load3 = this.load4 = this.load5 =false;
setTimeout(() => {
this.readUserData();
}, 200);
if (GameManager._instance == null) {
GameManager._instance = this;
cc.game.addPersistRootNode(this.node);
}
else {
return;
}
const path = 'prefab/block';
const path2 = 'prefab/wall';
cc.resources.loadDir(path, cc.Prefab, (err, assets: cc.Prefab[]) => {
if (err) {
console.error('动态加载 Prefab 失败:', err);
cc.director.loadScene("LoadScene");
return;
}
// 将加载的 Prefab 赋值给 Block_Array
this.Block_Array = assets;
this.setSort();
this.load1 = true;
});
cc.resources.loadDir(path2, cc.Prefab, (err, assets: cc.Prefab[]) => {
if (err) {
console.error('动态加载 Prefab 失败:', err);
cc.director.loadScene("LoadScene");
return;
}
// 将加载的 Prefab 赋值给 Block_Array
this.Wall_Prefab = assets;
this.load2 = true;
this.setWallPrefabSort();
});
// debugger;
// setTimeout(() => {
// cc.director.preloadScene("HomeScene", (err) => {
// if (err) {
// console.error('预加载 HomeScene 场景失败:', err);
// return;
// }
// });
// }, 1000);
// 检测微信小游戏切到后台
if (cc.sys.platform === cc.sys.WECHAT_GAME) {
//@ts-ignore
wx.onHide(() => {
this.onHide();
});
// 检测微信小游戏回到前台
//@ts-ignore
wx.onShow(() => {
this.onShow();
});
}
}
onHide () {
cc.audioEngine.stopMusic();
cc.game.pause();
}
onShow () {
cc.audioEngine.resumeMusic();
cc.game.resume();
}
loadParticleEffects() {
}
setWallPrefabSort() {
const order = ['down', 'downLeft', 'downRight', 'left','right','up','upLeft','upRight'];
this.Wall_Prefab.sort((a, b) => {
const indexA = order.indexOf(a.name);
const indexB = order.indexOf(b.name);
if (indexA === -1) return 1;
if (indexB === -1) return -1;
return indexA - indexB;
});
}
setParticleSort() {
const order = ['top', 'bot', 'rig', 'lef'];
this.particleEffects.sort((a, b) => {
const indexA = order.indexOf(a.name.substr(0,3));
const indexB = order.indexOf(b.name.substr(0,3));
if (indexA === -1) return 1;
if (indexB === -1) return -1;
return indexA - indexB;
});
}
setSort(){
this.Block_Array.sort((a, b) => {
// 从名称中提取数字部分
const numberA = parseInt(a.name.match(/\d+/)?.[0] || '0', 10);
const numberB = parseInt(b.name.match(/\d+/)?.[0] || '0', 10);
return numberA - numberB;
});
}
start () {
}
startGame(){
console.log("进入场景之前_____________",cc.fx.GameConfig.GM_INFO.first);
cc.director.loadScene("HomeScene");
}
returnHome(){
cc.tween(this.node.getChildByName("Game"))
.to(0.5, {opacity: 100})
.call(() => {
// 预加载成功后加载场景
cc.director.loadScene("HomeScene", (err) => {
if (err) {
console.error('加载 HomeScene 场景失败:', err);
} else {
cc.director.loadScene("HomeScene");
}
});
})
.start();
cc.tween(this.node.getChildByName("mask"))
.to(0.5,{opacity: 255})
.start();
// cc.loader.releaseAll();
// 预加载 HomeScene 场景
}
readUserData(retryCount = 0){
//@ts-ignore
if (typeof wx !== 'undefined' && wx !== null) {
let levelInfo = cc.fx.StorageMessage.getStorage("level");
//旧的读取数据设置数据方法,以强联网为主
if(levelInfo == undefined || levelInfo == "" || levelInfo == null){
this.oldReadData(retryCount);
}
//新的读取数据设置方法,以本地为主
else{
this.newReadData();
}
console.log("即将读取体力值");
cc.fx.GameTool.getHealth((data)=>{
console.log("体力值完成进入游戏");
this.load5 = true;
});
}
else{
this.load3 = true;
this.load4 = true;
this.load5 = true;
cc.fx.GameTool.getHealth(null);
}
// 存储用户数据
}
readMusicConfig(){
let audioInfo = cc.fx.StorageMessage.getStorage("music");
if(audioInfo == undefined || audioInfo == "" || audioInfo == null){
audioInfo = {
"musicOpen": true, //音乐
"effectOpen": true, //音效
"vibrateOpen": true, //震动
}
cc.fx.StorageMessage.setStorage("music",audioInfo);
}
else{
cc.fx.GameConfig.GM_INFO.musicOpen = audioInfo.musicOpen;
cc.fx.GameConfig.GM_INFO.effectOpen = audioInfo.effectOpen;
cc.fx.GameConfig.GM_INFO.vibrateOpen = audioInfo.vibrateOpen;
}
}
//新用户,有本地缓存读取配置
newReadData(){
console.log("读取新信息");
let openid = cc.fx.StorageMessage.getStorage("openid");
if(openid == null || openid == "" || openid == undefined){
console.log("没有openid");
//@ts-ignore
wx.cloud.callFunction({
name: 'userData',
data: {
action: 'read'
},
success: res => {
console.log('读取用户数据成功', res.result)
if(res.result.code == 404 && res.result.message == "未找到用户数据"){
}
else if(res.result.code == 200){
if(res.result.data){
cc.fx.GameConfig.GM_INFO.openid = res.result.openid;
cc.fx.GameConfig.GM_INFO.username = res.result.data.username;
cc.fx.GameConfig.GM_INFO.useravatar = res.result.data.useravatar;
const register_time = res.result.data.register_time;
MiniGameSdk.API.shushu_userSet(register_time);
cc.fx.StorageMessage.setStorage("openid",cc.fx.GameConfig.GM_INFO.openid);
}
}
},
fail: err => {
console.error('读取用户数据失败', err)
}
})
}
else{
if(openid)
cc.fx.GameConfig.GM_INFO.openid = openid;
}
//等级信息
cc.fx.GameTool.getUserLevel((data) =>{
const timestamp = Date.now();
let levelInfo = cc.fx.StorageMessage.getStorage("level");
if(data.result.code == 404 && data.result.message == "未找到关卡数据"){
// console.log("没有等级信息,从用户接口拿到数据");
if(levelInfo.level){
cc.fx.GameConfig.GM_INFO.level = levelInfo.level;
}
this.load4 = true;
cc.fx.GameTool.setUserLevel((data)=>{
});
}
else if(data.result.code == 200){
// console.log("有等级信息,从关卡接口拿到数据",data.result.data);
//游戏前端存储 新于服务器端,以游戏前端信息为主,放服务器存储
let temp = data.result.timestamp - levelInfo.timestamp;
console.log("等级时间差:",temp);
if((data.result.timestamp - levelInfo.timestamp) < 10000){
if(levelInfo.level){
console.log("以游戏前端等级为准",data.result.data);
cc.fx.GameConfig.GM_INFO.level = levelInfo.level;
// console.log("等级为:",cc.fx.GameConfig.GM_INFO.level);
cc.fx.GameTool.setUserLevel((data)=>{
});
}
}
//服务器端存储时间新于游戏端,以服务器端为主,往前端存储
else{
console.log("以服务器等级为准",data.result.data);
cc.fx.GameConfig.GM_INFO.level = data.result.data;
levelInfo.level = cc.fx.GameConfig.GM_INFO.level;
levelInfo.timestamp = timestamp;
// console.log("1111111存储关卡数据:",cc.fx.GameConfig.GM_INFO.level);
cc.fx.StorageMessage.setStorage("level",levelInfo);
}
this.load4 = true;
}
});
//金币信息
cc.fx.GameTool.getUserCoin((data) =>{
const timestamp = Date.now();
let coinInfo = cc.fx.StorageMessage.getStorage("coin");
if(data.result.code == 404 && data.result.message == "未找到金币数据"){
if(coinInfo.coin)
cc.fx.GameConfig.GM_INFO.coin = coinInfo.coin;
console.log("没有金币信息,从用户接口拿到数据",cc.fx.GameConfig.GM_INFO.coin);
this.load3 = true;
cc.fx.GameTool.setUserCoin((data)=>{
});
}
else if(data.result.code == 200){
// console.log("有金币信息,从金币接口拿到数据",data.result.data);
//游戏前端存储 新于服务器端,以游戏前端信息为主,放服务器存储
let temp = data.result.timestamp - coinInfo.timestamp;
console.log("金币时间差:",temp);
if((data.result.timestamp - coinInfo.timestamp) < 10000){
console.log("以前端金幣为准:",coinInfo);
if(coinInfo.coin)
cc.fx.GameConfig.GM_INFO.coin = coinInfo.coin;
else{
cc.fx.GameConfig.GM_INFO.coin = data.result.data;
coinInfo.coin = cc.fx.GameConfig.GM_INFO.coin;
coinInfo.timestamp = timestamp;
console.log("11111111111");
cc.fx.StorageMessage.setStorage("coin",coinInfo);
}
console.log("改变后金币:",cc.fx.GameConfig.GM_INFO.coin);
cc.fx.GameTool.setUserCoin((data)=>{
});
}
//服务器端存储时间新于游戏端,以服务器端为主,往前端存储
else{
console.log("以服务器金幣为准:",data.result.data);
cc.fx.GameConfig.GM_INFO.coin = data.result.data;
coinInfo.coin = cc.fx.GameConfig.GM_INFO.coin;
coinInfo.timestamp = timestamp;
console.log("2222222222");
cc.fx.StorageMessage.setStorage("coin",coinInfo);
}
this.load3 = true;
}
});
//道具信息
cc.fx.GameTool.getUserProp((data) =>{
const timestamp = Date.now();
let propInfo = cc.fx.StorageMessage.getStorage("prop");
if(data.result.code == 404 && data.result.message == "未找到道具数据"){
console.log("没有道具信息,从用户接口拿到数据",propInfo);
if(propInfo.freezeAmount == undefined || propInfo.hammerAmount == undefined || propInfo.magicAmount == undefined){
console.log("2222222道具数据异常");
cc.fx.GameConfig.GM_INFO.freezeAmount = 0;
cc.fx.GameConfig.GM_INFO.hammerAmount = 0;
cc.fx.GameConfig.GM_INFO.magicAmoun = 0;
let propInfoNew = {
"freezeAmount":cc.fx.GameConfig.GM_INFO.freezeAmount,
"hammerAmount":cc.fx.GameConfig.GM_INFO.hammerAmount,
"magicAmount":cc.fx.GameConfig.GM_INFO.magicAmoun,
"timestamp":timestamp
}
console.log("1111111上传道具信息:",propInfoNew);
cc.fx.StorageMessage.setStorage("prop",propInfoNew);
}
else{
cc.fx.GameConfig.GM_INFO.freezeAmount = data.result.data.freeze;
cc.fx.GameConfig.GM_INFO.hammerAmount = data.result.data.hammer;
cc.fx.GameConfig.GM_INFO.magicAmount = data.result.data.magic_wand;
}
cc.fx.GameConfig.GM_INFO.freezeAmount = propInfo.freezeAmount;
cc.fx.GameConfig.GM_INFO.hammerAmount = propInfo.hammerAmount;
cc.fx.GameConfig.GM_INFO.magicAmount = propInfo.magicAmount;
cc.fx.GameTool.setUserProp(0,0,(data)=>{
});
}
else if(data.result.code == 200){
// console.log("本地时间戳",propInfo.timestamp,"服务器时间戳",data.result.timestamp);
if((data.result.timestamp - propInfo.timestamp) < 10000){
console.log("以前端道具为主:",propInfo);
if(propInfo.freezeAmount == undefined || propInfo.hammerAmount == undefined || propInfo.magicAmount == undefined){
console.log("111111道具数据异常",data.result.data);
cc.fx.GameConfig.GM_INFO.freezeAmount = data.result.data.freeze;
cc.fx.GameConfig.GM_INFO.hammerAmount = data.result.data.hammer;
cc.fx.GameConfig.GM_INFO.magicAmount = data.result.data.magic_wand;
let propInfoNew = {
"freezeAmount":cc.fx.GameConfig.GM_INFO.freezeAmount,
"hammerAmount":cc.fx.GameConfig.GM_INFO.hammerAmount,
"magicAmount":cc.fx.GameConfig.GM_INFO.magicAmount,
"timestamp":timestamp
}
console.log("333333上传道具信息:",propInfoNew);
cc.fx.StorageMessage.setStorage("prop",propInfoNew);
}
else{
console.log("道具数据正常");
cc.fx.GameConfig.GM_INFO.freezeAmount = propInfo.freezeAmount;
cc.fx.GameConfig.GM_INFO.hammerAmount = propInfo.hammerAmount;
cc.fx.GameConfig.GM_INFO.magicAmount = propInfo.magicAmount;
cc.fx.GameTool.setUserProp(0,0,(data)=>{
});
}
}
else{
cc.fx.GameConfig.GM_INFO.freezeAmount = data.result.data.freeze;
cc.fx.GameConfig.GM_INFO.hammerAmount = data.result.data.hammer;
cc.fx.GameConfig.GM_INFO.magicAmount = data.result.data.magic_wand;
let propInfoNew = {
"freezeAmount":cc.fx.GameConfig.GM_INFO.freezeAmount,
"hammerAmount":cc.fx.GameConfig.GM_INFO.hammerAmount,
"magicAmount":cc.fx.GameConfig.GM_INFO.magicAmount,
"timestamp":timestamp
}
console.log("22222222上传道具信息:",propInfoNew,data.result);
cc.fx.StorageMessage.setStorage("prop",propInfoNew);
}
}
});
}
//旧用户,无本地缓存读取配置
oldReadData(retryCount:number){
console.log("读取旧信息");
const MAX_RETRIES = 15;
const timestamp = Date.now();
// 读取用户数据
//@ts-ignore
wx.cloud.callFunction({
name: 'userData',
data: {
action: 'read'
},
success: res => {
console.log('读取用户数据成功', res.result)
if(res.result.code == 404 && res.result.message == "未找到用户数据"){
if(res.result.openid){
cc.fx.GameConfig.GM_INFO.openid = res.result.openid
}
cc.fx.GameConfig.GM_INFO.first = true;
this.load3 = true;
this.load4 = true;
let levelInfo = {"level":0,"timestamp":timestamp};
cc.fx.StorageMessage.setStorage("level",levelInfo);
let coinInfo = {"coin":0,"timestamp":timestamp};
console.log("33333333333");
cc.fx.StorageMessage.setStorage("coin",coinInfo);
let propInfo = {
"freezeAmount":0,
"hammerAmount":0,
"magicAmount":0,
"timestamp":timestamp,
}
cc.fx.StorageMessage.setStorage("prop",propInfo);
cc.fx.GameTool.setUserInfo((data)=>{
if(data.result.code == 200){
console.log("上传用户信息成功",data);
//@ts-ignore
wx.cloud.callFunction({
name: 'userData',
data: {
action: 'read'
},
success: res => {
console.log("上传后,读取用户信息,为上报注册时间")
if(res.result.code == 200){
const time = res.result.data.register_time;
MiniGameSdk.API.shushu_userSet(time);
}
}
})
}
});
console.log("服务器也没有金币信息",cc.fx.GameConfig.GM_INFO.coin);
cc.fx.GameTool.setUserCoin(cc.fx.GameConfig.GM_INFO.coin,(data)=>{
});
cc.fx.GameTool.setUserLevel((data)=>{
});
setTimeout(() => {
cc.fx.GameConfig.GM_INFO.freezeAmount = 0;
cc.fx.GameConfig.GM_INFO.hammerAmount = 0;
cc.fx.GameConfig.GM_INFO.magicAmount = 0;
cc.fx.GameTool.setUserProp(0,0,(data)=>{
if(data.result.code == 200){
console.log("上传道具信息成功",data);
}
else{
MiniGameSdk.API.showToast("网络异常,正在努力加载");
setTimeout(() => {
this.oldReadData(0);
}, 1000);
}
});
}, 0);
}
else if(res.result.code == 200){
if(res.result.data){
cc.fx.GameConfig.GM_INFO.openid = res.result.openid;
cc.fx.GameConfig.GM_INFO.level = res.result.data.level;
cc.fx.GameConfig.GM_INFO.coin = res.result.data.coinAmount;
cc.fx.GameConfig.GM_INFO.freezeAmount = res.result.data.freezeAmount;
cc.fx.GameConfig.GM_INFO.hammerAmount = res.result.data.hammerAmount;
cc.fx.GameConfig.GM_INFO.magicAmount = res.result.data.magicAmount;
cc.fx.GameConfig.GM_INFO.username = res.result.data.username;
cc.fx.GameConfig.GM_INFO.useravatar = res.result.data.useravatar;
cc.fx.StorageMessage.setStorage("openid",cc.fx.GameConfig.GM_INFO.openid);
const register_time = res.result.data.register_time;
MiniGameSdk.API.shushu_userSet(register_time);
}
setTimeout(() => {
cc.fx.GameTool.getUserCoin((data) =>{
if(data.result.code == 404 && data.result.message == "未找到金币数据"){
let coinInfo = {"coin":0,"timestamp":timestamp};
cc.fx.GameConfig.GM_INFO.coin = 0;
cc.fx.StorageMessage.setStorage("coin",coinInfo);
console.log("没有金币信息,从用户接口拿到数据",cc.fx.GameConfig.GM_INFO.coin);
cc.fx.GameTool.setUserCoin((data)=>{
// console.log("上传",data);
this.load3 = true;
});
}
else if(data.result.code == 200){
// console.log("有金币信息,从金币接口拿到数据",data.result.data);
cc.fx.GameConfig.GM_INFO.coin = data.result.data;
let coinInfo = {"coin":cc.fx.GameConfig.GM_INFO.coin,"timestamp":timestamp};
console.log("存储金币信息:",cc.fx.GameConfig.GM_INFO.coin);
console.log("4444444444");
cc.fx.StorageMessage.setStorage("coin",coinInfo);
this.load3 = true;
}
})
}, 500);
cc.fx.GameTool.getUserLevel((data) =>{
if(data.result.code == 404 && data.result.message == "未找到关卡数据"){
console.log("没有等级信息,从用户接口拿到数据");
let levelInfo = {"level":0,"timestamp":timestamp};
// console.log("333333存储关卡数据:",levelInfo);
cc.fx.GameConfig.GM_INFO.level = 0;
cc.fx.StorageMessage.setStorage("level",levelInfo);
cc.fx.GameTool.setUserLevel((data)=>{
console.log("拿到的数据",data);
this.load4 = true;
});
}
else if(data.result.code == 200){
console.log("有等级信息,从关卡接口拿到数据",data.result.data);
cc.fx.GameConfig.GM_INFO.level = data.result.data;
let levelInfo = {"level":cc.fx.GameConfig.GM_INFO.level,"timestamp":timestamp};
// console.log("444444存储关卡信息:",levelInfo);
cc.fx.StorageMessage.setStorage("level",levelInfo);
this.load4 = true;
}
})
setTimeout(() => {
cc.fx.GameTool.getUserProp((data) =>{
if(data.result.code == 404 && data.result.message == "未找到道具数据"){
console.log("没有道具信息,从用户接口拿到数据");
cc.fx.GameConfig.GM_INFO.freezeAmount = 0;
cc.fx.GameConfig.GM_INFO.hammerAmount = 0;
cc.fx.GameConfig.GM_INFO.magicAmount = 0;
let propInfo = {
"freezeAmount":0,
"hammerAmount":0,
"magicAmount":0,
"timestamp":timestamp,
}
console.log("上传道具信息:",propInfo);
cc.fx.StorageMessage.setStorage("prop",propInfo);
cc.fx.GameTool.setUserProp(0,0,(data)=>{
});
}
else if(data.result.code == 200){
console.log("有道具信息,从道具接口拿到数据",data.result.data);
cc.fx.GameConfig.GM_INFO.freezeAmount = data.result.data.freeze || 0;
cc.fx.GameConfig.GM_INFO.hammerAmount = data.result.data.hammer || 0;
cc.fx.GameConfig.GM_INFO.magicAmount = data.result.data.magic_wand || 0;
let propInfo = {
"freezeAmount":cc.fx.GameConfig.GM_INFO.freezeAmount,
"hammerAmount":cc.fx.GameConfig.GM_INFO.hammerAmount,
"magicAmount":cc.fx.GameConfig.GM_INFO.magicAmount,
"timestamp":timestamp,
}
console.log("上传道具信息:",propInfo);
cc.fx.StorageMessage.setStorage("prop",propInfo);
}
})
}, 0);
}
},
fail: err => {
console.error('读取用户数据失败', err)
if (retryCount < MAX_RETRIES) {
console.error(`读取用户数据失败,第 ${retryCount + 1} 次重试,错误信息:`, err);
// 延迟 2 秒后重试
setTimeout(() => {
this.readUserData(retryCount + 1);
}, 2000);
} else {
console.error('读取用户数据失败,达到最大重试次数,退出游戏', err);
// 退出游戏
cc.game.end();
}
}
})
}
setUserData(){
cc.fx.GameConfig.GameTool((data)=>{
console.log("上传",data);
})
}
startTimeCutDown(){
this.scheduleCallback = function(){
if(this.timeNumber <= 0){
this.stopTimeCutDown();
}
else{
this.timeNumber -= 1;
}
}.bind(this);
this.schedule(this.scheduleCallback, 1);
}
stopTimeCutDown(){
if(this.scheduleCallback){
this.unschedule(this.scheduleCallback);
}
}
update (dt) {
if(this.load1 && this.load2 && this.load3 && this.load4 && this.load5 && this.timeNumber <= 0){
this.load1 = this.load2 = false;
MiniGameSdk.API.shushu_Init();
this.startGame();
}
}
}

View File

@ -0,0 +1,10 @@
{
"ver": "1.1.0",
"uuid": "df248952-2e59-4e66-9087-c06a90e587b7",
"importer": "typescript",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}

186
assets/Script/GameOver.ts Normal file
View File

@ -0,0 +1,186 @@
const {ccclass, property} = cc._decorator;
@ccclass
export default class NewClass extends cc.Component {
@property(cc.Label)
count: cc.Label = null;
@property(cc.Label)
time: cc.Label = null;
@property(cc.Node)
selfNode: cc.Node = null;
@property(cc.Node)
one: cc.Node = null;
@property(cc.Node)
two: cc.Node = null;
@property(cc.Node)
three: cc.Node = null;
@property(cc.Node)
four: cc.Node = null;
@property(cc.Node)
five: cc.Node = null;
listData: any;
selfData: any;
// onLoad () {}
start () {
this.count.string = cc.fx.GameConfig.GM_INFO.score + "";
var yes = 0;
var successList = cc.fx.GameConfig.GM_INFO.successList;
if(successList.length > 0){
var success = 0;
for(let i=0; i<successList.length; i++){
if(successList[i] == true) success += 1;
}
yes = success/successList.length;
}
yes = Math.floor(yes * 1000)/10;
this.time.string = yes + "%";
this.init();
}
//初始化数据
init(){
this.listData = [];
this.selfData = null;
this.one.active = false;
this.two.active = false;
this.three.active = false;
this.four.active = false;
this.five.active = false;
var urlNow = window.location.href;
if(this.containsTrain(urlNow)){
this.node.getChildByName("again").active = false;
this.node.getChildByName("back").active = false;
this.node.getChildByName("finishi").active = true;
this.setLocalStorage();
}
else{
this.setLocalStorage();
this.node.getChildByName("again").active = true;
this.node.getChildByName("back").active = true;
this.node.getChildByName("finishi").active = false;
}
this.getRank();
}
setLocalStorage(){
let timeData = cc.fx.GameConfig.TIME_INFO.totalTime;
const today = new Date().toLocaleDateString();
var name = `success_${today}_${cc.fx.GameConfig.GM_INFO.scode}_${cc.fx.GameConfig.GM_INFO.gameId}`
localStorage.setItem(name, JSON.stringify({success:true}));
}
//打开排行榜
openRank(){
cc.director.loadScene("RankScene");
}
//重新开始玩
again(){
cc.fx.GameConfig.GM_INFO.round = 0;
cc.fx.GameConfig.GM_INFO.level = 0;
cc.fx.GameConfig.GM_INFO.stepTimeList = 0;
cc.fx.GameConfig.GM_INFO.successList = [];
cc.fx.GameConfig.GM_INFO.fen = 0;
cc.fx.GameConfig.GM_INFO.score = 0;
cc.fx.GameConfig.GM_INFO.min_Steps = 0;
cc.fx.GameConfig.GM_INFO.min_Time = 0;
cc.fx.GameConfig.TIME_INFO.totalTime = 120;
cc.director.loadScene("GameScene");
}
//判断来源
containsTrain(str) {
return /from=train/i.test(str);
}
//获取排行榜
getRank(){
//获取排行榜数据 所需数据量
let dataFile = {
length:5
}
cc.fx.GameTool.getRank(dataFile,data =>this.getRankData(data));
}
//打开排行榜
jumpFinishi(){
let url = "https://train.sparkus.cn/poster/game/" + cc.fx.GameConfig.GM_INFO.scode + "?suc=1";
window.location.href = url;
}
//设置排行信息
getRankData(data){
if(data){
cc.fx.GameTool.getRankData(data,this,4);
cc.fx.GameTool.setPic(this.selfNode.getChildByName("pic").getChildByName("icon"),this.selfData.pic);
var length = this.listData.length-1; if(length > 4) length = 4;
for(let i=0;i<=length;i++){
this.setRank(i,this.listData[i]);
}
}
}
//根据内容填充排行榜
setRank(num,data){
if(!data){
return;
}
var hitNode = null;
if(num == 0){
hitNode = this.one;
}
else if(num == 1){
hitNode = this.two;
}
else if(num == 2){
hitNode = this.three;
}
else if(num == 3){
hitNode = this.four;
}
else if(num == 4){
hitNode = this.five;
}
let trun = num + 1;
for(let i=0; i< trun; i++){
if(this.listData[i] && this.listData[i].nickName == cc.fx.GameConfig.GM_INFO.nickName){
trun = i + 1;
break;
}
else if(!this.listData[i] == null ){
trun = i * 2;
break;
}
this.node.color = cc.color(this.listData[0],this.listData[1],this.listData[2]);
cc.tween(this.node)
.to(0.5,{scale:2})
.by(1,{opacity:0})
.delay(0.5)
.call(() =>{
this.node.scale = 1;
this.node.opacity = 255;
this.node.color = cc.color(255,255,255);
})
.start();
}
hitNode.getChildByName("num").getComponent(cc.Label).string = num + "";
cc.tween(hitNode.getChildByName("num").getComponent(cc.Label))
.to(0.5,{string:trun+""})
.start();
let record = cc.fx.GameConfi.GM_INFO.score;
if(data.score >= record){
this.selfData = data;
this.selfNode.active = true;
}
if(hitNode){
hitNode.active = true;
if(data.nickName.length >= 4)
data.nickName = cc.fx.GameTool.subName(data.nickName,4);
hitNode.getChildByName("name").getComponent(cc.Label).string = data.nickName;
hitNode.getChildByName("total").getComponent(cc.Label).string = data.score;
cc.fx.GameTool.setPic(hitNode.getChildByName("pic").getChildByName("icon"),data.pic);
}
}
}

View File

@ -0,0 +1,10 @@
{
"ver": "1.1.0",
"uuid": "805c69df-dfdf-4759-97ae-5a7341f424c7",
"importer": "typescript",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}

View File

@ -0,0 +1,48 @@
// cc.Class({
// extends: cc.Component,
// properties: {
// localTest: {
// default: false,
// tooltip: '本地测试时勾选避免tz_url和Configure报错提交前勾掉'
// },
// clientTest: {
// default: false,
// tooltip: '客户端测试时勾选,展示版本标记方便测试区分,上线前勾掉'
// },
// clientTestVersion: {
// default: '',
// tooltip: '版本标记'
// },
// testVersion: cc.Label,
// score: cc.Label,
// double_hit: cc.Node,
// add: cc.Node,
// add2: cc.Node,
// double_title: cc.Node,
// count_time: cc.Node,
// beginNode: cc.Node,
// ball_nomal: [cc.SpriteFrame],
// bg_nomal: [cc.SpriteFrame],
// ball_light: [cc.SpriteFrame],
// kuang_Frame: [cc.SpriteFrame],
// daojishi: cc.Label,
// pause_anniu: cc.Sprite,
// mask: cc.Node,
// flashUI: {
// default: null,
// type: cc.SpriteAtlas
// },
// },
// onLoad() {
// },
// update(dt) {
// },
// });

View File

@ -0,0 +1,10 @@
{
"ver": "1.1.0",
"uuid": "e8b23e56-8d10-44ad-a8f0-2e637cc45533",
"importer": "javascript",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}

269
assets/Script/JiaZai.ts Normal file
View File

@ -0,0 +1,269 @@
// Learn TypeScript:
// - https://docs.cocos.com/creator/manual/en/scripting/typescript.html
// Learn Attribute:
// - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
// - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html
import GameManager from "./GameManager";
import NumberToImage from "./NumberToImage";
import { MiniGameSdk } from "./Sdk/MiniGameSdk";
import {LQCollideSystem} from "./lq_collide_system/lq_collide_system";
const {ccclass, property} = cc._decorator;
@ccclass
export default class NewClass extends cc.Component {
@property(cc.Node)
node1: cc.Node = null;
@property(cc.Node)
node2: cc.Node = null;
@property(cc.Node)
node3: cc.Node = null;
@property({type: [cc.SpriteAtlas], tooltip:"方块颜色"})
Block_Color : Array<cc.SpriteAtlas> = [];
@property(cc.EditBox)
custom: cc.EditBox = null;
@property(cc.Node)
level: cc.Node = null;
@property(cc.Node)
coin: cc.Node = null;
@property(cc.Node)
Stamina: cc.Node = null;
scheduleCallback: any;
// LIFE-CYCLE CALLBACKS:
onLoad () {
cc.game.setFrameRate(63);
LQCollideSystem.is_enable = true;
// console.log("加载关卡配置2");
// window.initMgr();
GameManager._instance.Block_Color = this.Block_Color;
if(cc.fx.GameConfig.GM_INFO.first){
console.log("————————准备注册事件",cc.fx.GameConfig.GM_INFO.openid);
if(cc.fx.GameConfig.GM_INFO.openid != ""){
console.log("————————发送注册事件");
cc.fx.GameTool.shushu_Track("register");
}
cc.fx.AudioManager._instance.playEffect("zhuan1",null);
this.node.getChildByName("zhuanchang").active = true;
this.node.getChildByName("zhuanchang").getComponent(sp.Skeleton).setAnimation(1,"up",false);
setTimeout(() => {
cc.fx.GameConfig.GM_INFO.first = false;
cc.director.loadScene("GameScene");
}, 1000);
}
}
start () {
// console.log("已经进入Home界面");
// console.log("金币",cc.fx.GameConfig.GM_INFO.coin);
// console.log("关卡",cc.fx.GameConfig.GM_INFO.level+1);
cc.fx.GameTool.getHealth(null);
// cc.fx.GameConfig.LEVEL_INFO_init(false,0);
setTimeout(() => {
NumberToImage.numberToImageNodes((cc.fx.GameConfig.GM_INFO.level+1),25,15,"big_",this.level,false);
NumberToImage.numberToImageNodes(cc.fx.GameConfig.GM_INFO.coin,30,15,"coin_",this.coin,true);
this.setHealthInfo();
}, 0);
if(cc.fx.GameConfig.GM_INFO.gameState){
this.node.getChildByName("zhuanchang").active = true;
setTimeout(() => {
cc.fx.AudioManager._instance.playEffect("zhuan2",null);
this.node.getChildByName("zhuanchang").getComponent(sp.Skeleton).setAnimation(1,"down",false);
this.node.getChildByName("zhuanchang").getComponent(sp.Skeleton).setCompleteListener((entry) => {
if (entry.animation.name === "down" && !cc.fx.GameConfig.GM_INFO.first) {
// 动画播放结束后执行的逻辑
this.node.getChildByName("zhuanchang").active = false;
}
});
}, 500);
}
else{
if(!cc.fx.GameConfig.GM_INFO.first)
this.node.getChildByName("zhuanchang").active = false;
}
}
//开始倒计时
startTimeCutDown(){
this.scheduleCallback = function(){
if(this.pause) return;
if(cc.fx.GameConfig.GM_INFO.min_Time <= 0){
this.stopTimeCutDown();
var timeTemp = cc.fx.GameTool.getTimeMargin(cc.fx.GameConfig.GM_INFO.min_Time);
this.Stamina.getChildByName("time").getComponent(cc.Label).string = timeTemp;
cc.fx.GameTool.setUserHealth(1,(data)=>{
cc.fx.GameTool.getHealth(null);
this.setHealthInfo();
})
}
else{
cc.fx.GameConfig.GM_INFO.min_Time -= 1;
var timeTemp = cc.fx.GameTool.getTimeMargin(cc.fx.GameConfig.GM_INFO.min_Time);
this.Stamina.getChildByName("time").getComponent(cc.Label).string = timeTemp;
}
}.bind(this);
this.schedule(this.scheduleCallback, 1);
}
// 停止倒计时
stopTimeCutDown(){
if(this.scheduleCallback){
this.unschedule(this.scheduleCallback);
}
}
setHealthInfo(){
if(cc.fx.GameConfig.GM_INFO.hp == 5){
this.Stamina.getChildByName("man").active = true;
this.Stamina.getChildByName("health").active = false;
this.Stamina.getChildByName("time").active = false;
}
else{
this.Stamina.getChildByName("man").active = false;
this.Stamina.getChildByName("health").active = true;
NumberToImage.numberToImageNodes((cc.fx.GameConfig.GM_INFO.hp),25,15,"coin_",this.Stamina.getChildByName("health"),false);
this.Stamina.getChildByName("time").active = true;
if(cc.fx.GameConfig.GM_INFO.min_Time != 0){
let time = cc.fx.GameTool.getTimeMargin(cc.fx.GameConfig.GM_INFO.min_Time);
this.Stamina.getChildByName("time").getComponent(cc.Label).string = time;
this.startTimeCutDown();
}
}
}
startGame(){
cc.fx.AudioManager._instance.playEffect("anniu_Big",null);
if(cc.fx.GameConfig.GM_INFO.hp < 1){
MiniGameSdk.API.showToast("体力值不足");
return;
}
if(this.node.getChildByName("Load").getChildByName("startBtn").getComponent("btnControl")._touch){
this.node.getChildByName("Load").getChildByName("startBtn").getComponent("btnControl").setTouch(false);
// if(this.custom.string != ""){
// cc.fx.GameConfig.GM_INFO.level = parseInt(this.custom.string) - 1;
// // cc.fx.StorageMessage.setStorage("level",cc.fx.GameConfig.GM_INFO.level.toString());
// cc.fx.GameConfig.LEVEL_INFO_init(true);
// }
// else{
cc.fx.AudioManager._instance.playEffect("zhuan1",null);
this.node.getChildByName("zhuanchang").active = true;
this.node.getChildByName("zhuanchang").getComponent(sp.Skeleton).setAnimation(1,"up",false);
cc.fx.GameConfig.LEVEL_INFO_init(true,1000);
// }
}
}
closeRank(){
this.node.getChildByName("Rank").active = false;
}
openRank(){
this.node.getChildByName("Rank").active = true;
}
openReward(){
this.node.getChildByName("Reward").active = true;
}
clickShop() {
// 假设已经获取到了 userId 和 productId
const userId = cc.fx.GameConfig.GM_INFO.openid;
const productId = '1';
console.log("即将创建createorder");
//@ts-ignore
wx.cloud.callFunction({
name: "createOrder",
data: {
"userId":userId,
"productId":productId,
},
success: (res) => {
// 取得云函数返回的订单信息
console.log("createOrder结果:",res.result);
const payment = res.result.paymentResult.payment;
console.log("payment:",payment);
// 调起微信客户端支付
//@ts-ignore
// 调起微信客户端支付
//@ts-ignore
wx.requestPayment({
// 时间戳,从 1970 年 1 月 1 日 00:00:00 至今的秒数,即当前的时间
timeStamp: payment.timeStamp,
// 随机字符串长度为32个字符以下
nonceStr: payment.nonceStr,
// 统一下单接口返回的 prepay_id 参数值
package: payment.package,
// 签名算法,暂支持 MD5、HMAC-SHA256
signType: payment.signType || 'MD5',
// 支付签名
paySign: payment.paySign,
success(res) {
/* 成功回调 */
console.log("支付成功",res);
},
fail(res) {
/* 失败回调 */
console.log("支付失败",res);
},
complete(res){
console.log("支付完成",res);
}
});
},
});
}
openPause(){
cc.fx.AudioManager._instance.playEffect("anniu_little",null);
console.log(cc.fx.GameConfig.GM_INFO);
if(cc.fx.GameConfig.GM_INFO.openid == undefined){
console.log(cc.fx.GameConfig.GM_INFO.openid);
cc.fx.GameConfig.GM_INFO.openid = "";
}
this.node.getChildByName("Pause").active = true;
this.node.getChildByName("Pause").getChildByName("openID").getComponent(cc.Label).string = cc.fx.GameConfig.GM_INFO.openid;
}
closePause(){
cc.fx.AudioManager._instance.playEffect("anniu_little",null);
this.node.getChildByName("Pause").active = false;
}
closeReward(){
this.node.getChildByName("Reward").active = false;
}
openStamina(){
this.node.getChildByName("Stamina").active = true;
}
closeStamina(){
this.node.getChildByName("Stamina").active = false;
}
// update (dt) {}
}

View File

@ -0,0 +1,10 @@
{
"ver": "1.1.0",
"uuid": "1dc936f8-7de8-4eae-91a0-4e48a1047e20",
"importer": "typescript",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}

191
assets/Script/Load.ts Normal file
View File

@ -0,0 +1,191 @@
const {ccclass, property, requireComponent} = cc._decorator;
@ccclass
export default class NewClass extends cc.Component {
@property(cc.Node)
node1: cc.Node = null;
@property(cc.Node)
node2: cc.Node = null;
@property(cc.Node)
node3: cc.Node = null;
@property(false)
localTest: boolean = false;
@property("")
clientTestVersion: string = "1.0.0";
@property(cc.Label)
testVersion: cc.Label = null;
onLoad () {
// cc.director.getPhysicsManager().enabled = true;
// cc.director.getPhysicsManager().debugDrawFlags = 1;
// cc.director.getPhysicsManager().enabledAccumulator = true;
// cc.PhysicsManager.VELOCITY_ITERATIONS = 20;
// cc.PhysicsManager.FIXED_TIME_STEP = 1 / 120;
// cc.PhysicsManager.POSITION_ITERATIONS = 20;
//@ts-ignore
cc.internal.inputManager._maxTouches = 1
let manager = cc.director.getCollisionManager();
manager.enabled = true;
this.setWX();
cc.debug.setDisplayStats(false);
cc.tween(this.node1)
.delay(0 * 0.3)
.to(0.3, {scale: 1})
.to(0.3, {scale: 1.3})
.to(0.3, {scale: 1})
.union()
.repeatForever()
.start();
cc.tween(this.node2)
.delay(1 * 0.3)
.to(0.3, {scale: 1})
.to(0.3, {scale: 1.3})
.to(0.3, {scale: 1})
.union()
.repeatForever()
.start();
cc.tween(this.node3)
.delay(2 * 0.3)
.to(0.3, {scale: 1})
.to(0.3, {scale: 1.3})
.to(0.3, {scale: 1})
.union()
.repeatForever()
.start();
}
setWX(){
//@ts-ignore
if (typeof wx !== 'undefined' && wx !== null) { // 判断是否在微信环境
wx.setPreferredFramesPerSecond(60);
// // 设置转发按钮点击后的回调
// wx.onShareAppMessage(() => {
// return {
// title: '你想玩上怎样的游戏?',
// imageUrl: '',
// query: ''
// };
// });
wx.onShareAppMessage(function () {
// 用户点击了“转发”按钮
return {
title: '你想玩上怎样的游戏?'
}
})
// 监听分享到朋友圈事件
//@ts-ignore
wx.onShareTimeline(() => {
return {
title: '你想玩上怎样的游戏?'
};
});
wx.showShareMenu(() => {
return {
title: '你想玩上怎样的游戏?',
imageUrl: '',
query: ''
};
});
setTimeout(() => {
wx.showShareMenu({
menus: ['shareAppMessage', 'shareTimeline']
})
}, 2000);
// 设置分享到朋友圈
//@ts-ignore
// wx.updateShareMenu({
// withShareTicket: true,
// success: (data) => {
// console.log('更新分享菜单成功', data);
// },
// fail: (data) => {
// console.log('更新分享菜单失败', data);
// },
// complete: (data) => {
// console.log('更新分享菜单完成', data);
// }
// });
//@ts-ignore
}
}
//判断来源
containsTrain(str) {
return /from=train/i.test(str);
}
//开始游戏,跳转至引导页面
startGame(){
cc.director.loadScene("GameScene");
// cc.director.loadScene("GuideScene");
}
//备用,用来测试跳转 指定关卡
clickBtn(event,data){
cc.fx.GameConfig.GM_INFO.custom = parseInt(data);
cc.director.loadScene("GameScene");
}
//打开排行榜
openRank(){
cc.director.loadScene("RankScene");
}
protected update(dt: number): void {
}
// 3月17日 - 3月21日 工作完成内容
// 1游戏框架搭建
// 2制作18个基础方块预制体 (方块可编辑颜色与道具和状态)
// 3完成地图的搭建可配置8*8以内任意组合包括可缺口和障碍物配置
// 4完成地图墙面建立根据 ↑3上面构建的地图自动生成墙体。
// 5做完方块的基础移动跟随手指遇到方块或者墙壁或者障碍物阻碍移动。
// 6方块的自动落点做完11个基础方块的未做完还差11个
// 3月24日 - 3月28日 预计完成目标
// 1完成全部方块的落点。
// 2完成门的搭建门可选颜色可选开关或者星星等特殊状态
// 3完成方块通过门的游戏逻辑使游戏可以最基础运行玩起来
// 4出5关版本配合小白备案审核。
// 5根据方块地图以及道具制作地图编辑器 (方块和地图制作的时候都已经考虑到编辑器的需求了)
// 优先制作,后续开发拓展玩法功能时,小白可同步进行制作关卡。
}

View File

@ -0,0 +1,10 @@
{
"ver": "1.1.0",
"uuid": "454ad829-851a-40ea-8ab9-941e828357ca",
"importer": "typescript",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}

2037
assets/Script/Map.ts Normal file

File diff suppressed because it is too large Load Diff

10
assets/Script/Map.ts.meta Normal file
View File

@ -0,0 +1,10 @@
{
"ver": "1.1.0",
"uuid": "2234ab2c-a7b4-48be-90e0-ae7aa58e9d91",
"importer": "typescript",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}

43
assets/Script/MapBlock.ts Normal file
View File

@ -0,0 +1,43 @@
// Learn TypeScript:
// - https://docs.cocos.com/creator/manual/en/scripting/typescript.html
// Learn Attribute:
// - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
// - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html
const {ccclass, property} = cc._decorator;
@ccclass
export default class NewClass extends cc.Component {
@property(cc.Label)
label: cc.Label = null;
@property
block_Id: string = '';
// LIFE-CYCLE CALLBACKS:
posX: number = 0; //地图块的X坐标
posY: number = 0; //地图块的Y坐标
direction: string = ""; //地图块的方向
// onLoad () {}
start () {
this.direction = "";
this.block_Id = "";
// this.node.getChildByName("num").getComponent(cc.Label).string = this.direction;
}
setDiraction(direction){
this.direction = direction;
// this.node.getChildByName("num").getComponent(cc.Label).string = this.direction;
}
init(posX,posY){
this.posX = posX;
this.posY = posY;
}
// update (dt) {}
}

View File

@ -0,0 +1,10 @@
{
"ver": "1.1.0",
"uuid": "52958c6c-bab5-40a7-9e16-328fb1143a3a",
"importer": "typescript",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}

66
assets/Script/NewMode.ts Normal file
View File

@ -0,0 +1,66 @@
// Learn TypeScript:
// - https://docs.cocos.com/creator/manual/en/scripting/typescript.html
// Learn Attribute:
// - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
// - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html
const {ccclass, property} = cc._decorator;
@ccclass
export default class NewClass extends cc.Component {
@property(cc.Label)
label: cc.Label = null;
@property
text: string = 'hello';
btnStatic: number = 0;
propName: string = "";
// LIFE-CYCLE CALLBACKS:
// onLoad () {}
start () {
for(let i=0; i<cc.fx.GameConfig.NEW_LEVEL.length; i++){
if((cc.fx.GameConfig.GM_INFO.level+1) == cc.fx.GameConfig.NEW_LEVEL[i].level){
this.propName = cc.fx.GameConfig.NEW_LEVEL[i].name;
const path = 'Window_Prop/' + this.propName;
cc.resources.load(path, cc.SpriteFrame, (err, spriteFrame: cc.SpriteFrame) => {
if (err) {
console.error('动态加载背景图失败:', err);
return;
}
this.node.getChildByName("icon").getComponent(cc.Sprite).spriteFrame = spriteFrame;
})
break;
}
}
}
setMode(mode:number){
this.btnStatic = mode;
let name = "GameScene";
if(mode == 1){
name = "HomeScene";
}
cc.director.preloadScene(name, ()=>{
})
}
clickBtn(){
cc.fx.AudioManager._instance.playEffect("anniu_Big",null);
if(this.btnStatic == 1){
cc.director.loadScene("HomeScene");
}
else if(this.btnStatic == 2){
cc.director.loadScene("GameScene");
}
}
// update (dt) {}
}

View File

@ -0,0 +1,10 @@
{
"ver": "1.1.0",
"uuid": "7fe14751-1506-4a48-a280-a049f84bb394",
"importer": "typescript",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}

View File

@ -0,0 +1,116 @@
// Learn TypeScript:
// - https://docs.cocos.com/creator/manual/en/scripting/typescript.html
// Learn Attribute:
// - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
// - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html
const {ccclass, property} = cc._decorator;
@ccclass
export default class NumberToImage extends cc.Component {
@property(cc.SpriteAtlas)
fontUI: cc.SpriteAtlas = null;
static font:any = null;
// LIFE-CYCLE CALLBACKS:
onLoad () {
if(this.fontUI != null){
NumberToImage.font = this.fontUI;
}
}
//第一个参数 数字, 第二个参数 数字间距 第三个参数 占位宽度 第四个参数 目标节点
static numberToImageNodes(number, width, posX, name ,targetNode:cc.Node,middle:boolean = false) {
const numStr = number.toString();
let cha = 0;
if(number > 99) cha = -posX
else if(number < 10) cha = posX
if(targetNode.children.length > 0)
targetNode.removeAllChildren();
for (let i = 0; i < numStr.length; i++) {
const digit = parseInt(numStr[i], 10);
const node = new cc.Node();
const sprite = node.addComponent(cc.Sprite);
// debugger;
sprite.spriteFrame = this.font._spriteFrames[name + digit + ""];
// 将节点添加到目标节点下
node.x = i * width + cha;
node.parent = targetNode;
}
if(middle){
targetNode.x = targetNode.x - targetNode.children.length * (width-15) / 2;
}
}
static getTimeMargin(number, width, name ,targetNode:cc.Node) {
let timeArr = [];
let total = 0;
total = number;
let hour = 0;
hour = parseInt((total / 3600) + "");//计算整数小时数
let afterHour = total - hour * 60 * 60;//取得算出小时数后剩余的秒数
let min = parseInt((afterHour / 60)+"");//计算整数分
let m = "" + min;
if(min < 10) m = "0"+min;
let afterMin = total - hour * 60 * 60 - min * 60;//取得算出分后剩余的秒数
let miao = afterMin + "";
if(afterMin < 10) miao = "0" + afterMin;
let result = m + miao;
for (let i = 0; i < result.length; i++) {
const digit = parseInt(result[i], 10);
timeArr.push(digit);
}
if(targetNode.children.length > 0){
for (let i = 0; i < targetNode.children.length; i++) {
targetNode.children[i].getComponent(cc.Sprite).spriteFrame = this.font._spriteFrames[name + timeArr[i] + ""];
}
}
else{
for (let i = 0; i < 4; i++) {
const node = new cc.Node();
const sprite = node.addComponent(cc.Sprite);
const digit = timeArr[i];
// debugger;
sprite.spriteFrame = this.font._spriteFrames[name + digit + ""];
// 将节点添加到目标节点下
node.x = i * width;
if(i > 1) node.x += 35;
node.parent = targetNode;
}
}
}
// static calculateAndConvert(num1: number, num2: number, operator: '+' | '-' | '*' | '/', spriteFrames: SpriteFrame[]): Node[] {
// let result: number;
// switch (operator) {
// case '+':
// result = num1 + num2;
// break;
// case '-':
// result = num1 - num2;
// break;
// case '*':
// result = num1 * num2;
// break;
// case '/':
// result = num1 / num2;
// break;
// default:
// throw new Error('不支持的运算符');
// }
// // 处理结果为小数的情况,这里简单取整
// result = Math.floor(result);
// return this.numberToImageNodes(result, spriteFrames);
// }
// update (dt) {}
}

View File

@ -0,0 +1,10 @@
{
"ver": "1.1.0",
"uuid": "669f44ae-4a5f-4e46-a6b0-05c6f008da46",
"importer": "typescript",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}

144
assets/Script/Pause.ts Normal file
View File

@ -0,0 +1,144 @@
// Learn TypeScript:
// - https://docs.cocos.com/creator/manual/en/scripting/typescript.html
// Learn Attribute:
// - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
// - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html
const {ccclass, property} = cc._decorator;
@ccclass
export default class Pause extends cc.Component {
static _instance: any;
time: number = 0;
@property(cc.Node)
music: cc.Node = null;
@property(cc.Node)
effect: cc.Node = null;
@property(cc.Node)
vibrate: cc.Node = null;
@property(cc.SpriteFrame)
open: cc.SpriteFrame = null;
@property(cc.SpriteFrame)
close: cc.SpriteFrame = null;
// mapInfo: number[][] = [];
musicState: boolean = true;
effectState: boolean = true;
vibrateState: boolean = true;
onLoad () {
if(cc.fx.GameConfig.GM_INFO.musicOpen){
this.music.getComponent(cc.Sprite).spriteFrame = this.open;
this.music.x = 278;
}
else{
this.music.getComponent(cc.Sprite).spriteFrame = this.close;
this.music.x = 161;
}
if(cc.fx.GameConfig.GM_INFO.effectOpen){
this.effect.getComponent(cc.Sprite).spriteFrame = this.open;
this.effect.x = 278;
}
else{
this.effect.getComponent(cc.Sprite).spriteFrame = this.close;
this.effect.x = 161;
}
if(cc.fx.GameConfig.GM_INFO.vibrateOpen){
this.vibrate.getComponent(cc.Sprite).spriteFrame = this.open;
this.vibrate.x = 278;
}
else{
this.vibrate.getComponent(cc.Sprite).spriteFrame = this.close;
this.vibrate.x = 161;
}
this.musicState = cc.fx.GameConfig.GM_INFO.musicOpen;
this.effectState = cc.fx.GameConfig.GM_INFO.effectOpen;
this.vibrateState = cc.fx.GameConfig.GM_INFO.vibrateOpen;
}
start () {
}
init(time){
}
clickMusic(){
if(this.musicState){
this.musicState = false;
cc.fx.GameConfig.GM_INFO.musicOpen = this.musicState;
this.setMusicConfig();
this.music.runAction(cc.sequence(cc.spawn(cc.moveTo(0.05, cc.v2(161,this.music.y)), cc.fadeOut(0.05)),cc.callFunc(()=>{
this.music.getComponent(cc.Sprite).spriteFrame = this.close;
}),cc.fadeIn(0.1)))
cc.fx.AudioManager._instance.stopMusic();
}
else{
this.musicState = true;
cc.fx.GameConfig.GM_INFO.musicOpen = this.musicState;
this.setMusicConfig();
this.music.runAction(cc.sequence(cc.spawn(cc.moveTo(0.05, cc.v2(278,this.music.y)), cc.fadeOut(0.05)),cc.callFunc(()=>{
this.music.getComponent(cc.Sprite).spriteFrame = this.open;
}),cc.fadeIn(0.1)))
cc.fx.AudioManager._instance.playMusicGame();
}
}
setMusicConfig(){
let audioInfo = {
"musicOpen": cc.fx.GameConfig.GM_INFO.musicOpen, //音乐
"effectOpen": cc.fx.GameConfig.GM_INFO.effectOpen, //音效
"vibrateOpen": cc.fx.GameConfig.GM_INFO.vibrateOpen, //震动
}
cc.fx.StorageMessage.setStorage("music",audioInfo);
}
clickEffect(){
if(this.effectState){
this.effectState = false;
cc.fx.GameConfig.GM_INFO.effectOpen = this.effectState;
this.setMusicConfig();
this.effect.runAction(cc.sequence(cc.spawn(cc.moveTo(0.05, cc.v2(161,this.effect.y)), cc.fadeOut(0.05)),cc.callFunc(()=>{
this.effect.getComponent(cc.Sprite).spriteFrame = this.close;
}),cc.fadeIn(0.1)))
}
else{
this.effectState = true;
cc.fx.GameConfig.GM_INFO.effectOpen = this.effectState;
this.setMusicConfig();
this.effect.runAction(cc.sequence(cc.spawn(cc.moveTo(0.05, cc.v2(278,this.effect.y)), cc.fadeOut(0.05)),cc.callFunc(()=>{
this.effect.getComponent(cc.Sprite).spriteFrame = this.open;
}),cc.fadeIn(0.1)))
}
}
clickVibrate(){
if(this.vibrateState){
this.vibrateState = false;
cc.fx.GameConfig.GM_INFO.vibrateOpen = this.vibrateState;
this.setMusicConfig();
this.vibrate.runAction(cc.sequence(cc.spawn(cc.moveTo(0.05, cc.v2(161,this.vibrate.y)), cc.fadeOut(0.05)),cc.callFunc(()=>{
this.vibrate.getComponent(cc.Sprite).spriteFrame = this.close;
}),cc.fadeIn(0.1)))
}
else{
this.vibrateState = true;
cc.fx.GameConfig.GM_INFO.vibrateOpen = this.vibrateState;
this.setMusicConfig();
this.vibrate.runAction(cc.sequence(cc.spawn(cc.moveTo(0.05, cc.v2(278,this.vibrate.y)), cc.fadeOut(0.05)),cc.callFunc(()=>{
this.vibrate.getComponent(cc.Sprite).spriteFrame = this.open;
}),cc.fadeIn(0.1)))
}
}
// update (dt) {}
}

View File

@ -0,0 +1,10 @@
{
"ver": "1.1.0",
"uuid": "aca4abad-df73-42bc-80b4-ca0dc9998d21",
"importer": "typescript",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}

View File

@ -0,0 +1,133 @@
import List from "./module/RankList/List";
const { ccclass, property } = cc._decorator;
//排行榜
@ccclass
export default class RankManager extends cc.Component {
@property(cc.Node) //用户上方头像
Player: cc.Node = null;
@property(cc.Node) //用户最下方个人信息
selfNode: cc.Node = null;
@property(cc.Sprite) //用户头像换图
phone: cc.Sprite = null;
private rankList: List; //排行榜
tween: cc.Tween<cc.Node>; //最上方用户头像动画
listData: any; //总列表信息
selfData: any; //自己信息
rankNumber: number; //用户自己排名 有可能不在排行榜内99+
rankTotal: number; //获取排行榜用户数量 现在为100
onLoad() {
this.init();
}
//初始化数据
init(){
this.rankList = cc.find("ScrollView", this.node).getComponent(List);
this.Player.getChildByName("rank").active = false;
this.listData = [];
this.selfData = null;
this.rankNumber = 100;
this.rankTotal= 100;
this.selfNode.opacity = 0;
}
start() {
this.Player.active = false;
this.getRank();
}
//调用获取排行榜接口
getRank(){
let dataFile = {
length:100
}
cc.fx.GameTool.getRank(dataFile,data =>this.getRankData(data));
}
//实际设置排行数据
getRankData(data){
if(data){
// console.log(data);
cc.fx.GameTool.getRankData(data,this,6);
this.setPic(this.selfData.pic);
}
}
//返回按钮
backClick(){
cc.director.loadScene("LoadScene");
}
//最上方用户动画
playerAction(){
//-254 377 210 453
this.Player.getChildByName("rank").active = false;
let time = 1;
this.tween = cc.tween(this.Player)
.to(2,{position:cc.v3(215,525,0)})
.call(() =>{
this.Player.getChildByName("rank").active = true;
this.Player.getChildByName("rank").getChildByName("number")
.getComponent(cc.Label).string = parseInt(time*100 + "") + "%";
})
.start();
time = (this.listData.length - this.rankNumber)/this.listData.length;
if(this.listData.length >= 99){
if(this.rankNumber >= 99){
time = (Math.random()*49+1)/100
var matchId = cc.sys.localStorage.getItem("matchNumber");
if(matchId == null || matchId == undefined){
time = 0;
}
}
}
setTimeout(() => {
if(this.tween)this.tween.stop();
this.Player.getChildByName("rank").active = true;
this.Player.getChildByName("rank").getChildByName("number")
.getComponent(cc.Label).string = parseInt(time*100 + "") + "%";
}, time*2000);
}
//设置头像 处理的逻辑比较多,不用公共类的了
public setPic(pic){
this.phone.node.parent.getChildByName("icon").active = false;
this.phone.node.active = false;
this.Player.active = true;
this.Player.opacity = 0;
this.Player.getChildByName("mask").getChildByName("icon").active = false;
this.Player.getChildByName("mask").getChildByName("phone").active = false;
fetch(pic)
.then(response => {
return response.headers.get('Content-Length');
})
.then(errNo => {
if(errNo == "5093"){
this.phone.node.parent.getChildByName("icon").active = true;
this.Player.getChildByName("mask").getChildByName("icon").active = true;
}
})
.catch(error => {
// console.error('Error fetching X-Info:', error);
});
var self = this;
cc.assetManager.loadRemote(pic, {ext:'.png'},(err, texture:cc.Texture2D) => {
self.Player.opacity = 255;
if(texture){
self.phone.node.active = true;
self.phone.spriteFrame = new cc.SpriteFrame(texture);
self.Player.getChildByName("mask").getChildByName("icon").active = false;
self.Player.getChildByName("mask").getChildByName("phone").active = true;
self.Player.getChildByName("mask").getChildByName("phone").getComponent(cc.Sprite)
.spriteFrame = new cc.SpriteFrame(texture);
setTimeout(() => {
self.playerAction();
}, 500);
}
else{
self.Player.getChildByName("mask").getChildByName("icon").active = true;
setTimeout(() => {
self.playerAction();
}, 500);
}
})
}
}

View File

@ -0,0 +1,10 @@
{
"ver": "1.1.0",
"uuid": "e74a9f7d-2031-4e69-bcb2-9998174088b2",
"importer": "typescript",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}

34
assets/Script/Reduce.ts Normal file
View File

@ -0,0 +1,34 @@
// Learn TypeScript:
// - https://docs.cocos.com/creator/manual/en/scripting/typescript.html
// Learn Attribute:
// - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
// - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html
const {ccclass, property} = cc._decorator;
@ccclass
export default class NewClass extends cc.Component {
@property({type: [cc.SpriteFrame], tooltip:"方块颜色图片"})
Block_Color : Array<cc.SpriteFrame> = [];
@property(cc.Label)
level: cc.Label = null;
// LIFE-CYCLE CALLBACKS:
onLoad () {
}
start () {
}
// update (dt) {}
}

View File

@ -0,0 +1,10 @@
{
"ver": "1.1.0",
"uuid": "ca599214-e611-4461-8af3-a0de7d60ea53",
"importer": "typescript",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}

View File

@ -0,0 +1,273 @@
// Learn TypeScript:
// - https://docs.cocos.com/creator/manual/en/scripting/typescript.html
// Learn Attribute:
// - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
// - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html
import MapConroler from "./Map";
import { MiniGameSdk } from "./Sdk/MiniGameSdk";
const {ccclass, property} = cc._decorator;
@ccclass
export default class SceneManager extends cc.Component {
@property(cc.Label)
label: cc.Label = null;
@property
text: string = 'hello';
@property(cc.Node)
freeze: cc.Node = null;
@property(cc.Node)
hammer: cc.Node = null;
@property(cc.Node)
magic_wand: cc.Node = null;
@property(cc.Node)
pause: cc.Node = null;
@property({type: [cc.Prefab], tooltip:"方块数组"})
Block_Array : Array<cc.Prefab> = [];
@property({type: [cc.Prefab], tooltip:"墙壁数组"})
Wall_Prefab : Array<cc.Prefab> = [];
particleEffects: cc.ParticleAsset[];
// @property({type: [cc.ParticleSystem], tooltip:"粒子数组"})
// particleEffects : Array<cc.ParticleSystem> = [];
load1 :boolean = false;
load2 :boolean = false;
load3 :boolean = false;
btnName: string = '';
callBack: any;
// LIFE-CYCLE CALLBACKS:
onLoad () {
cc.game.setFrameRate(63);
this.changeBg();
setTimeout(() => {
cc.director.preloadScene("HomeScene", (err) => {
if (err) {
// console.error('预加载 HomeScene 场景失败:', err);
return;
}
// console.log('成功预加载 HomeScene 场景');
});
}, 1000);
}
changeBg(){
let number = Math.floor(Math.random() * 8) + 1;
const path = 'bg/bg' + number;
cc.resources.load(path, cc.SpriteFrame, (err, spriteFrame: cc.SpriteFrame) => {
if (err) {
console.error('动态加载背景图失败:', err);
return;
}
this.node.getChildByName("Game").getChildByName("bg").getComponent(cc.Sprite).spriteFrame = spriteFrame;
})
}
loadParticleEffects() {
const path = 'Particle';
cc.resources.loadDir(path, cc.ParticleAsset, (err, assets: cc.ParticleAsset[]) => {
if (err) {
console.error('动态加载粒子特效失败:', err);
return;
}
this.particleEffects = assets;
this.setParticleSort();
this.load3 = true;
//console.log('粒子特效加载成功,共加载了', this.particleEffects.length, '个粒子特效');
});
}
setWallPrefabSort() {
const order = ['down', 'downLeft', 'downRight', 'left','right','up','upLeft','upRight'];
this.Wall_Prefab.sort((a, b) => {
const indexA = order.indexOf(a.name);
const indexB = order.indexOf(b.name);
if (indexA === -1) return 1;
if (indexB === -1) return -1;
return indexA - indexB;
});
}
setParticleSort() {
const order = ['top', 'bot', 'rig', 'lef'];
this.particleEffects.sort((a, b) => {
// console.log(a.name.substr(0,3),b.name.substr(0,3));
const indexA = order.indexOf(a.name.substr(0,3));
const indexB = order.indexOf(b.name.substr(0,3));
if (indexA === -1) return 1;
if (indexB === -1) return -1;
return indexA - indexB;
});
}
setSort(){
this.Block_Array.sort((a, b) => {
// 从名称中提取数字部分
const numberA = parseInt(a.name.match(/\d+/)?.[0] || '0', 10);
const numberB = parseInt(b.name.match(/\d+/)?.[0] || '0', 10);
return numberA - numberB;
});
}
start () {
}
startGame(){
cc.director.loadScene("HomeScene", (err) => {
if (err) {
console.error('加载 HomeScene 场景失败:', err);
} else {
// console.log('成功切换到 HomeScene 场景');
cc.director.loadScene("HomeScene");
}
});
}
returnHome(){
if(this.node.getChildByName("Pause").getChildByName("btn").getComponent("btnControl")._touch){
if(MapConroler._instance.gameStart == true){
MiniGameSdk.API.showToast("体力值减少");
cc.fx.GameTool.setUserHealth(-1,(data)=>{
})
let data = {
time:MapConroler._instance.count_Time,
add_Time:MapConroler._instance.add_Time,
result:"give_up"
}
cc.fx.GameTool.shushu_Track("finish_stage",data);
}
this.node.getChildByName("Pause").getChildByName("btn").getComponent("btnControl").setTouch(false);
cc.fx.AudioManager._instance.playEffect("zhuan1",null);
this.node.getChildByName("zhuanchang").active = true;
this.node.getChildByName("zhuanchang").getComponent(sp.Skeleton).setAnimation(1,"up",false);
cc.director.preloadScene("HomeScene", (err, asset) => {
if (err) {
console.error('动态加载 Prefab 失败:', err);
return;
}
});
setTimeout(() => {
cc.director.loadScene("HomeScene");
}, 1200);
}
}
destroyNodesInFrames(nodes: cc.Node[], callback: () => void) {
const BATCH_SIZE = 10; // 每帧销毁的节点数量
let index = 0;
const destroyBatch = () => {
let count = 0;
while (index < nodes.length && count < BATCH_SIZE) {
const node = nodes[index];
if (node) {
node.active = false;
}
index++;
count++;
}
if (index < nodes.length) {
this.scheduleOnce(destroyBatch, 6);
} else {
callback();
}
};
destroyBatch();
}
// 改进后的切换场景方法
switchToEmptyScene() {
const allNodes = cc.director.getScene().children;
this.destroyNodesInFrames(allNodes, () => {
cc.director.loadScene("HomeScene");
});
}
openPause(){
cc.fx.AudioManager._instance.playEffect("anniu_little",null);
if(this.pause.getComponent("btnControl")._touch){
this.pause.getComponent("btnControl").setTouch(false);
this.node.getChildByName("Pause").active = true;
MapConroler._instance.pause = true;
}
}
closePause(){
cc.fx.AudioManager._instance.playEffect("anniu_little",null);
this.pause.getComponent("btnControl").setTouch(true);
this.node.getChildByName("Pause").active = false;
if(MapConroler._instance.node.parent.getChildByName("Ice").active == false){
MapConroler._instance.pause = false;
}
}
openPropBuy(name){
MapConroler._instance.pause = true;
this.btnName = name;
let propWindow = this.node.getChildByName("Game").getChildByName("propWindow");
propWindow.active = true;
propWindow.getChildByName("freeze").active = false;
propWindow.getChildByName("hammer").active = false;
propWindow.getChildByName("magic").active = false;
propWindow.getChildByName("buy_Btn").getComponent("btnControl").setTouch(true);
propWindow.getChildByName(name).active = true;
}
clickBtn(){
cc.fx.AudioManager._instance.playEffect("anniu_Big",null);
let propWindow = this.node.getChildByName("Game").getChildByName("propWindow");
if(propWindow.getChildByName("buy_Btn").getComponent("btnControl")._touch){
propWindow.getChildByName("buy_Btn").getComponent("btnControl").setTouch(false);
if(this.btnName == "freeze")
MapConroler._instance.buyFreeze();
else if(this.btnName == "hammer")
MapConroler._instance.buyHammer();
else if(this.btnName == "magic")
MapConroler._instance.buyMagic();
}
}
closePropBuy(){
MapConroler._instance.pause = false;
let freezeBtn = MapConroler._instance.node.parent.getChildByName("Bottom").getChildByName("timeBtn");
let hammerBtn = MapConroler._instance.node.parent.getChildByName("Bottom").getChildByName("destroyBtn");
let magicBtn = MapConroler._instance.node.parent.getChildByName("Bottom").getChildByName("magicBtn");
if(this.btnName == "freeze") freezeBtn.getComponent("btnControl").setTouch(true);
else if(this.btnName == "hammer") hammerBtn.getComponent("btnControl").setTouch(true);
else if(this.btnName == "magic") magicBtn.getComponent("btnControl").setTouch(true);
this.node.getChildByName("Game").getChildByName("propWindow").active = false;
}
update (dt) {
}
}

View File

@ -0,0 +1,10 @@
{
"ver": "1.1.0",
"uuid": "809984f5-0183-4d45-9751-c6c56f5d1eb9",
"importer": "typescript",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}

13
assets/Script/Sdk.meta Normal file
View File

@ -0,0 +1,13 @@
{
"ver": "1.1.3",
"uuid": "93c9bdf3-8205-46e5-a8f1-3576b0dbc836",
"importer": "folder",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}

View File

@ -0,0 +1,29 @@
import { MiniGameSdk } from "./MiniGameSdk";
const { ccclass, property } = cc._decorator;
@ccclass
export class DouyinEntranceView extends cc.Component {
start() {
}
update(deltaTime: number) {
}
onCloseClick() {
this.node.active = false;
}
onNavigateToDouyinClick() {
MiniGameSdk.BytedanceSidebar.navigateToSidebar((success: boolean) => { // 跳转到抖音侧边栏
if (success) {
console.log('跳转成功');
} else {
console.log('跳转失败');
}
});
}
}

View File

@ -0,0 +1,10 @@
{
"ver": "1.1.0",
"uuid": "8a024faa-e4af-4cae-9c5c-693bee7120c1",
"importer": "typescript",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}

View File

@ -0,0 +1,340 @@
import { MiniGameSdk } from "./MiniGameSdk";
const { ccclass, property } = cc._decorator;
enum EWechatAD {
CUMSTOM_01 = 'adunit-f7c2417eb2c2e473'
}
@ccclass
export class MiniGameManager extends cc.Component {
@property(cc.Node)
entranceView: cc.Node = null;
/**
*
*
*
* @remarks
*
*
*
*
*/
private _id:any;
private _userData:any;
private static _instance: MiniGameManager;
static get instance(): MiniGameManager {
if (!MiniGameManager._instance) {
MiniGameManager._instance = new MiniGameManager();
}
return MiniGameManager._instance;
}
start() {
// 禁用游戏入口视图
// this.entranceView.active = false;
// MiniGameSdk.API.getUserProfile(this.setUserId);
// cc.fx.GameTool.setUserInfo("");
this.onGetLoginCode();
// 尝试获取游戏入口按钮,如果存在则直接返回,不进行后续操作
// let buttonEntrance = this.node.getChildByName('Btns')?.getChildByName('Button_EntranceView');
// if (buttonEntrance) {
// return;
// }
// 如果是字节跳动小游戏环境,检查侧边栏是否存在
if (MiniGameSdk.isBytedance()) {
//抖音环境,检测侧边栏存在
MiniGameSdk.BytedanceSidebar.checkSideBar((success: boolean) => {
// 根据侧边栏存在性激活或禁用游戏入口按钮
// buttonEntrance.active = success;
});
} else {
// 非抖音小游戏环境,直接激活游戏入口按钮
// 非抖音环境,正常显示按钮
// buttonEntrance.active = true;
}
// 设置监听器,以处理来自侧边栏的交互事件
MiniGameSdk.BytedanceSidebar.listenFromSidebar((success: boolean) => {
// 如果交互成功,显示奖励提示
if (success) {
MiniGameSdk.API.showToast('侧边栏奖励', 5);
}
});
}
update(deltaTime: number) {
}
/**
* 广
* 广广广广
* 广广MiniGameSdk.AdvertManager的实例方法来实现的
*
* @remarks
* 广
* 1. showBanner方法显示广告
* 2. 广
*
* 广使
*/
onShowBanner() {
// 加载指定广告位的横幅广告。
MiniGameSdk.AdvertManager.instance.loadBanner('adunit-4e7ef467e3eaab51');
// 默认方式显示横幅广告。
// 方法1默认调用
MiniGameSdk.AdvertManager.instance.showBanner();
// 示例:指定屏幕底部正中显示横幅广告。
// 方法2指定屏幕顶部或底部正中
// MiniGameSdk.AdvertManager.instance.showBanner('adunit-4e7ef467e3eaab51', MiniGameSdk.EAdBannerLocation.BOTTOM);
// 示例:通过坐标指定位置显示横幅广告。
// 方法2指定坐标
// MiniGameSdk.AdvertManager.instance.showBanner('adunit-4e7ef467e3eaab51', { top: 10, left: 10 });
}
/**
* 广
*
* MiniGameSdk.AdvertManager实例的方法广
* 广广
*
* @remarks
*
* 广AdvertManager的实现
*/
onHideBanner() {
MiniGameSdk.AdvertManager.instance.hideBanner();
}
/**
* 广
*
* MiniGameSdk.AdvertManager实例的方法广
* 使广广
* 广
*/
onShowInterstitial() {
MiniGameSdk.AdvertManager.instance.showInterstitial('adunit-eadd67851d3050ad');
}
/**
* 广广
* 广广广
* 广广
* 广
*/
onShowCustom() {
// 加载指定的自定义广告单元。
MiniGameSdk.AdvertManager.instance.loadCustom(EWechatAD.CUMSTOM_01);
// 展示已加载的自定义广告。
MiniGameSdk.AdvertManager.instance.showCustom(EWechatAD.CUMSTOM_01);
}
/**
* 广
*
* MiniGameSdk.AdvertManager.instance.hideCustom()广
* 广广
* 广
*/
onHideCustom() {
MiniGameSdk.AdvertManager.instance.hideCustom(EWechatAD.CUMSTOM_01);
}
/**
* 广
* MiniGameSdk.AdvertManager.instance.showVideo方法广广
*
* @remarks
* 广ID广广
* 广广
*/
onShowVideo() {
// 广告单元ID用于标识要显示的视频广告
// 广告单元ID的样例
//抖音形如: 1re3nfqkmy81m4m8ge
//微信形如: adunit-a7718f6e195e42fe
MiniGameSdk.AdvertManager.instance.showVideo('1re3nfqkmy81m4m8ge', (res: MiniGameSdk.EAdVideoResult, count: number) => {
// 输出用户观看的广告数量
console.log('用户看的视频广告个数是:', count);
// 根据用户观看广告的结果,执行不同的逻辑
switch (res) {
case MiniGameSdk.EAdVideoResult.ACCEPT:
// 用户完成了广告观看,显示奖励提示
MiniGameSdk.API.showToast('用户看完广告,可以奖励');
break;
case MiniGameSdk.EAdVideoResult.REJECT:
// 用户拒绝了广告观看,显示不奖励提示
MiniGameSdk.API.showToast('用户拒绝掉广告,不奖励');
break;
case MiniGameSdk.EAdVideoResult.ERROR:
// 广告播放发生错误,显示错误提示
MiniGameSdk.API.showToast('播放广告发生错误,不奖励');
break;
default:
// 其他情况,不作处理
break;
}
});
}
/**
*
*
* MiniGameSdk的API分享功能
* 广
*
* @remarks
* API依赖于特定的小游戏平台
*/
onShare() {
MiniGameSdk.API.shareAppToFriends('来玩游戏吧');
}
/**
* toast提示
*
* MiniGameSdk的API方法来显示一个简短的提示信息toast是一种轻量级的提示方式
* 使 '这是一个toast'
*/
onShowToast() {
MiniGameSdk.API.showToast('这是一个toast');
}
/**
*
*
* MiniGameSdk提供的API
*
*
* @remarks
*
*/
onVirbrate() {
MiniGameSdk.API.vibrate();
}
/**
*
*
* MiniGameSdk中的API重新启动游戏
*
*
* @remarks
*
*
* @returns
*/
onReboot() {
MiniGameSdk.API.reboot();
}
/**
* 退
* MiniGameSdk提供的API方法来触发退出操作
*
*/
onExit() {
MiniGameSdk.API.exit();
}
/**
*
*
* MiniGameSdk的API方法
* 便SDK接口交互
*
* @remarks
*
*/
onShowShareMenu() {
MiniGameSdk.API.showShareMenu();
}
/**
*
*
* ID
* 便
*
* 'xxx'使ID
*/
onNavigate() {
MiniGameSdk.API.navigateTo('xxx'); // xxx替换为你的小游戏id
}
/**
*
*
*
* 使
*/
onBytedanceEntranceView() {
// this.entranceView.active = true;
}
/**
*
*
*
*
*/
onGetLoginCode() {
// 调用MiniGameSdk的API登录方法传入一个回调函数处理登录结果
MiniGameSdk.API.login((code: string, anonymousCode: string) => {
// 打印微信或头条的登录代码
console.log('Wechat Or Bytedance Code:', code);
// 打印头条的匿名登录代码
// console.log('Bytedance Anonymous Code:', anonymousCode);
if(code){
// cc.fx.GameTool.getUserId(code, data => this.setUserId(data));
}
});
}
// setUserId(data){
// cc.fx.GameConfig.GM_INFO.userId = data.data.userId;
// MiniGameSdk.API.getUserInfo(this.setUserInfo);
// }
// setUserInfo(data){
// console.log("获取到的用户信息",data.userInfo);
// var useData = {
// "gameId": cc.fx.GameConfig.GM_INFO.gameId,
// "userId": cc.fx.GameConfig.GM_INFO.userId,
// "nickName":data.userInfo.nickName,
// "pic": data.userInfo.avatarUrl
// }
// console.log("即将上传的用户信息:",cc.fx.GameConfig.GM_INFO.userId,data.userInfo.nickName,data.userInfo.avatarUrl);
// console.log("Post数据:",useData);
// cc.fx.GameTool.setUserInfo(useData,(res)=>{
// console.log("上传成功:",res);
// });
// }
/**
*
*
* MiniGameSdk的GameClub实例方法
*
*
*/
onCreateClub() {
// 配置俱乐部图标为绿色设置图标的位置为顶部200像素左侧0像素
MiniGameSdk.GameClub.instance.create(
MiniGameSdk.EGameClubIcon.GREEN,
{ top: 200, left: 0 },
{ width: 50, height: 50 });
// 显示游戏俱乐部图标
MiniGameSdk.GameClub.instance.show();
}
}

View File

@ -0,0 +1,10 @@
{
"ver": "1.1.0",
"uuid": "0d272a57-5428-450e-a8b9-1574c3d89951",
"importer": "typescript",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,10 @@
{
"ver": "1.1.0",
"uuid": "c1af99dd-ee03-40f7-9609-d3887d0dd357",
"importer": "typescript",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}

312
assets/Script/Wall.ts Normal file
View File

@ -0,0 +1,312 @@
// Learn TypeScript:
// - https://docs.cocos.com/creator/manual/en/scripting/typescript.html
// Learn Attribute:
// - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
// - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html
import MapConroler from "./Map";
const {ccclass, property} = cc._decorator;
export enum WallSpecial{
/*普通门*/
"普通门" = 0,
/*星星门*/
"星星门" = 1,
/*开关门*/
"开关门" = 2,
/*冻结门 */
"冻结门" = 3,
}
export enum WallType{
/*普通地块 */
"门横向下" = 0,
/*起点地块 */
"门横向上" = 1,
/*湿地 */
"门竖向右" = 2,
/*山峰 */
"门竖向左" = 3,
/*终点地块 */
"墙横向下" = 4,
/*息壤 */
"墙横向上" = 5,
/*加固 */
"墙竖向右" = 6,
/*加固 */
"墙竖向左" = 7,
}
export enum WallColor{
/*普通地块 */
"紫色" = 0,
/*湿地 */
"黄色" = 1,
/*山峰 */
"绿色" = 2,
/*终点地块 */
"蓝色" = 3,
/*息壤 */
"粉色" = 4,
/*加固 */
"橘黄色" = 5,
/*加固 */
"青色" = 6,
/*加固 */
"白色" = 7,
/*普通地块 */
"红色" = 8,
/*普通地块 */
"灰色" = 9,
}
@ccclass
export default class Wall extends cc.Component {
@property(cc.Label)
number: cc.Label = null;
@property({
tooltip: '墙或者门的方向',
type: cc.Enum(WallType),
})
type: WallType = WallType.;
@property({
tooltip: '墙或者门的方向',
type: cc.Enum(WallSpecial),
})
special: WallSpecial = WallSpecial.;
@property({
tooltip: '门的颜色',
type: cc.Enum(WallColor),
})
color: WallColor = WallColor.;
@property(cc.SpriteAtlas)
wall_SpriteFrames: cc.SpriteAtlas = null;
@property(cc.SpriteAtlas)
down_SpriteFrames: cc.SpriteAtlas = null;
posX: number;
posY: number;
direction: any;
wall_Info: any;
openNode: cc.Node;
freezeNode: cc.Node;
open:boolean;
// LIFE-CYCLE CALLBACKS:
// onLoad () {}
start () {
// console.log(this.type);
}
jsonDeepClone<T>(obj: T): T {
return JSON.parse(JSON.stringify(obj));
}
init(wall_Info, posX: number, posY: number, direction: any){
this.wall_Info = this.jsonDeepClone(wall_Info);
// this.open = true;
if(wall_Info == null){
this.posX = posX;
this.posY = posY;
if(direction)this.direction = direction;
// console.log("门方向赋值",direction);
if(direction == "up" ){
this.node.parent.zIndex = 100 + this.posX - this.posY*3;
}
else if( direction == "down" || direction == "right" ||
direction == "rightdown" || direction == "downright"
|| direction == "rightup" || direction == "upright"){
this.node.parent.zIndex = 30 + this.posX - this.posY*3;
}
else if( direction == "left"|| direction == "leftdown" || direction == "downleft"){
this.node.parent.zIndex = 70 + this.posX - this.posY*3;
}
else this.node.parent.zIndex = 70 + this.posX - this.posY*3;
MapConroler._instance.mapBlocksWall[this.posX][this.posY].getComponent("MapBlock").block_Id = "Wall";
//console.log(this.posX,this.posY,MapConroler._instance.mapBlocksWall[this.posX][this.posY].getComponent("MapBlock").block_Id);
// console.log(this.posX,this.posY,this.node.zIndex);
//this.node.getChildByName("num").getComponent(cc.Label).string = direction;
//this.node.getChildByName("num").getComponent(cc.Label).string = ":" + this.node.parent.zIndex;
}
if(wall_Info != null){
this.color = wall_Info.color;
this.special = wall_Info.special;
this.initType();
if(wall_Info.length > 0){
this.initColor(wall_Info.length);
}
else this.node.removeComponent("cc.Sprite");
if(this.posX != null){
MapConroler._instance.mapBlocksWall[this.posX][this.posY].getComponent("MapBlock").block_Id = "Wall";
//console.log(this.posX,this.posY,MapConroler._instance.mapBlocksWall[this.posX][this.posY].getComponent("MapBlock").block_Id);
}
}
// setTimeout(() => {
// this.node.getChildByName("num").getComponent(cc.Label).string = ":" + this.node.parent.zIndex;
// }, 1000);
}
//创建门的颜色
initColor(length: number){
let direction = this.node.parent.name;
let double = 0;
if(direction == "left" || direction == "right"){
double = 3;
}
// debugger;
if(this.wall_SpriteFrames){
let name = this.color+"color" + (length+double);
var spriteFrame = this.wall_SpriteFrames._spriteFrames[name];
this.node.getComponent(cc.Sprite).spriteFrame = spriteFrame;
}
if(this.down_SpriteFrames){
let name2 = this.color + "down" + (length+double);
var downFrame = this.down_SpriteFrames._spriteFrames[name2];
this.node.parent.getChildByName("down").getComponent(cc.Sprite).spriteFrame = downFrame;
}
}
//创建特殊类型门
initType(){
switch(this.special){
case WallSpecial.:
let star = cc.instantiate(MapConroler._instance.Block_Prop[this.special]);
star.parent = this.node.parent;
// console.log("门的方向",this.direction,"长度",this.wall_Info.length);
// star.scaleX = star.scaleY = 0.5;
if(this.wall_Info.length > 0){
if(this.direction == "right" || this.direction == "left"){
star.children[this.wall_Info.length + 2].active = true;
}
else if(this.direction == "up" || this.direction == "down"){
star.children[this.wall_Info.length - 1].active = true;
}
}
star.setPosition(this.node.width/2+this.node.x,this.node.height/2+this.node.y);
break;
case WallSpecial.:
let name = "open" + this.wall_Info.length;
this.openNode = this.node.parent.getChildByName("open").getChildByName(name);
this.openNode.active = true;
if(this.wall_Info.lock == false){
this.open = true;
this.openNode.children[0].scaleX *= 0.01;
this.openNode.children[1].scaleX *= 0.01;
}
else{
this.open = false;
}
break;
case WallSpecial.:
let freeze = "freeze" + this.wall_Info.length;
this.freezeNode = this.node.parent.getChildByName("freeze").getChildByName(freeze);
this.freezeNode.active = true;
if(this.wall_Info.freeze){
this.freezeNode.getChildByName("num").getComponent(cc.Label).string = this.wall_Info.freeze+"";
}
break;
}
}
//播放星星门通过
playStarDoor(){
if(this.node.parent.getChildByName("star")){
let star = this.node.parent.getChildByName("star");
for(let i=0; i<star.children.length; i++){
if(star.children[i].active == true){
let starChild = star.children[i];
for(let j=0; j<starChild.children.length; j++){
starChild.children[j].active = true
starChild.children[j].getComponent(sp.Skeleton).setAnimation(1,"taopao1",false);
}
}
}
}
}
//改变开关门状态
changeLock(){
this.open = !this.open;
console.log("开关门状态改变",this.open);
if(!this.openNode.active){
this.openNode.active = true;
}
let fill = this.openNode.children[0].scaleX==1 ? 0.01:1;
if(this.openNode.children[0].scaleX < 0) fill = -fill;
// console.log("目标",fill);
cc.tween(this.openNode.children[0])
.to(0.3, {scaleX: this.openNode.children[0].scaleX < 0?-fill:fill})
.call(()=>{
// console.log("左边完成");
})
.start();
cc.tween(this.openNode.children[1])
.to(0.3, {scaleX: this.openNode.children[1].scaleX < 0?-fill:fill})
.call(()=>{
// console.log("右边完成");
})
.start();
}
changeFreeze(){
let numStr = this.freezeNode.getChildByName("num").getComponent(cc.Label);
let num = parseInt(numStr.string);
num -= 1;
this.freezeNode.getChildByName("num").getComponent(cc.Label).string = num+"";
if(num == 0){
this.freezeNode.parent.active = false;
}
}
downDoor(){
if(this.openNode){
if(this.openNode.children[0].scaleX == 1)
return;
}
if(this.freezeNode){
if(this.freezeNode.active == true)
return;
}
this.node.opacity = 0;
if(this.special == WallSpecial.){
this.node.parent.getChildByName("star").y -= 10;
}
this.node.parent.getChildByName("down").active = true;
}
upDoor(){
if(this.special == WallSpecial.){
this.node.parent.getChildByName("star").y += 10;
}
this.node.parent.getChildByName("down").active = false;
this.node.opacity = 250;
}
// update (dt) {}
}

View File

@ -0,0 +1,10 @@
{
"ver": "1.1.0",
"uuid": "87a449b9-7ffa-4f00-a22b-b3202b4abfd5",
"importer": "typescript",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}

86
assets/Script/Window.ts Normal file
View File

@ -0,0 +1,86 @@
// Learn TypeScript:
// - https://docs.cocos.com/creator/manual/en/scripting/typescript.html
// Learn Attribute:
// - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
// - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html
const {ccclass, property} = cc._decorator;
@ccclass
export default class NewClass extends cc.Component {
can_Touch: boolean;
// LIFE-CYCLE CALLBACKS:
onLoad () {
this.can_Touch = false;
}
start () {
}
init(data){
this.can_Touch = false;
this.node.getChildByName("win").active = false;
this.node.getChildByName("lose").active = false;
this.node.getChildByName("finishi").active = false;
this.node.getChildByName(data.result).active = true;
if(data.result == "lose"){
this.setErrLabel(data.code);
}
var target = this.node.getChildByName(data.result);
target.getChildByName("btn").active = false;
target.opacity = 0; target.scale = 2;target.getChildByName("tip").opacity = 0;
if(data.result == "win"){
var lianXi = false;
if(cc.fx.GameConfig.GM_INFO.level == 2) lianXi = true;
target.getChildByName("yes").active = !lianXi;
target.getChildByName("start").active = lianXi;
}
cc.tween(target)
.delay(0.1)
.to(0.25,{opacity:255,scale:1})
.delay(0.3)
.call(()=>{
if(target.name == "lose"){
cc.tween(target.getChildByName("tip"))
.to(0.5,{opacity:255})
.delay(0.5)
.call(() =>{
this.can_Touch = true;
target.getChildByName("btn").active = true;
})
.start();
}
else{
this.can_Touch = true;
target.getChildByName("btn").active = true;
}
})
.start();
}
setErrLabel(code){
var tip = this.node.getChildByName("lose").getChildByName("tip").getComponent(cc.Label);
tip.string = cc.fx.GameConfig.TIP_ERR[code];
}
click_Next(){
if(!this.can_Touch){
return;
}
this.can_Touch = false;
cc.tween(this.node)
.to(0.3,{opacity:0})
.call(() =>{
this.node.active = false;
cc.director.loadScene("GameScene");
})
.start();
}
// update (dt) {}
}

View File

@ -0,0 +1,10 @@
{
"ver": "1.1.0",
"uuid": "3bad2bb2-3b0e-4ccc-bab7-6f983d6879f6",
"importer": "typescript",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}

View File

@ -0,0 +1,31 @@
// Learn TypeScript:
// - https://docs.cocos.com/creator/manual/en/scripting/typescript.html
// Learn Attribute:
// - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
// - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html
const {ccclass, property} = cc._decorator;
@ccclass
export default class btnControl extends cc.Component {
static _instance: any;
_touch: boolean;
onLoad () {
this._touch = true;
}
start () {
}
setTouch(type){
this._touch = type;
}
update (dt) {
}
}

View File

@ -0,0 +1,10 @@
{
"ver": "1.1.0",
"uuid": "6ee6ccc9-e1e5-4d6f-815e-8aaa6ce5221a",
"importer": "typescript",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}

View File

@ -0,0 +1,13 @@
{
"ver": "1.1.3",
"uuid": "b6fd3869-f3bc-4fcb-9660-e4cbe0824ad3",
"importer": "folder",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}

View File

@ -0,0 +1,13 @@
{
"ver": "1.1.3",
"uuid": "6413d7ad-bfc3-4b8c-bc1c-c1d819e9d892",
"importer": "folder",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}

View File

@ -0,0 +1,71 @@
import Vec2 = cc.Vec2;
export enum LQRecordStatus {
Idle, Start, Pause
}
export enum LQBulletEmitterStatus {
Idle, Start, End
}
export enum LQCollideShape {
Rect = 1, Circle, Polygon
}
export enum LQFollowTargetMode {
Always, Once, Pass
}
export enum LQCollideStatus {
Idle, Live
}
export enum LQEasing {
BackIn = 'backIn', BackOut = 'backOut', quadIn = 'quadIn',
quadOut = 'quadOut', quadInOut = 'quadInOut', cubicIn = 'cubicIn', expoOut = 'expoOut'
}
export enum LQHttpRequestType {
Get = 'get', Post = 'post'
}
export enum LQHttpDataType {
Text, Binary
}
export enum LQPlatformType {
unknown = '未知平台', all = '全平台', wx = '微信', tt = '字节跳动', oppo = 'oppo', vivo = 'vivo', qq = 'qq', baidu = '百度', kwaigame = '快手', android = '安卓', ios = '苹果', browser = '浏览器'
}
export enum LQByteDanceType {
tt = '头条', tt_lite = '头条极速版', douyin = '抖音', douyin_lite = '抖音极速版', ppx = '皮皮虾', devtools = '字节开发工具'
}
export enum LQAnalysisTag {
VideoComplete = 'video_complete', VideoBegin = 'video_begin', VideoInterrupt = 'video_interrupt', InterstitialShow = 'interstitial_show', BannerShow = 'banner_show', ExportShow = 'export_show', NativeShow = 'native_show', NativeClick = 'native_show'
}
export enum LQCallBase {
InitSdk, KeepScreenOn, Vibrate, GetVersionCode, GetVersionName, OpenUrl, DeleteDir, DeleteFile
}
export enum LQCallAd {
ShowBanner, HideBanner, ShowVideo, ShowInterstitial, ShowNative, CacheAd
}
export enum LQAdErrStr {
Unsupported = '不支持', NoParameters = '没有配置参数', NoAD = '暂无广告', VersionOld = '版本过低', VideoInterrupt = '中断播放', InstanceErr = '实例为空', AlreadyExist = '已经存在', IntervalTooShort = '间隔太短'
}
export enum LQLevelStatus {
Begin, Failed, Complete
}
export enum LQOperateType {
ClickNode, ClickScreen, Move, Null
}
export class LQConst {
public static VEC_ZERO = Vec2.ZERO;
}

View File

@ -0,0 +1,10 @@
{
"ver": "1.1.0",
"uuid": "9830980f-5d4c-4417-acc1-7bd7bbe4a9db",
"importer": "typescript",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}

View File

@ -0,0 +1,118 @@
import {IPos, IRect} from "./lq_interface";
import Vec2 = cc.Vec2;
import Rect = cc.Rect;
import Sprite = cc.Sprite;
import Label = cc.Label;
import Node = cc.Node;
export class LQRect implements IRect {
public x: number;
public y: number;
public width: number;
public height: number;
public half_width: number;
public half_height: number;
constructor(x: number, y: number, width: number, height: number) {
this.x = x;
this.y = y;
this.width = width;
this.height = height;
this.half_width = width * 0.5;
this.half_height = height * 0.5;
}
public top_left(): Vec2 {
return new Vec2(this.x - this.half_width, this.y + this.half_height);
}
public top_right(): Vec2 {
return new Vec2(this.x + this.half_width, this.y + this.half_height);
}
public bottom_left(): Vec2 {
return new Vec2(this.x - this.half_width, this.y - this.half_height);
}
public bottom_right(): Vec2 {
return new Vec2(this.x + this.half_width, this.y - this.half_height);
}
public pos(): cc.Vec2 {
return new Vec2(this.x, this.y);
}
public sub(pos: IPos): Vec2 {
return new Vec2(pos.x - this.x, pos.y - this.y);
}
public add(pos: IPos): Vec2 {
return new Vec2(pos.x + this.x, pos.y + this.y);
}
public to_cocos_rect() {
return new Rect(this.x - this.half_width, this.y - this.half_height, this.width, this.height);
}
}
export class LQNativeComponent {
public node_btn_arr: Node[] = [];
public sprite_logo!: Sprite;
public sprite_img!: Sprite;
public sprite_ad_tip!: Sprite;
public label_title!: Label;
public label_desc!: Label;
}
export class LQShareData {
public title!: string;
public remote_url!: string;
public url_id!: string;
public query!: string;
public content!: string;
public extra!: any;
public type!: string;
constructor(obj?: { title?: string, remote_url?: string, url_id?: string, query?: string, content?: string, extra?: any, type?: string }) {
if (obj.title) {
this.title = obj.title;
}
if (obj.remote_url) {
this.remote_url = obj.remote_url;
}
if (obj.url_id) {
this.url_id = obj.url_id;
}
if (obj.query) {
this.query = obj.query;
}
if (obj.content) {
this.content = obj.content;
}
if (obj.extra) {
this.extra = obj.extra;
}
if (obj.type) {
this.type = obj.type;
}
}
}
export class LQPlatformData {
public app_id!: string;
public print_log!: boolean;
public show_share_menu!: boolean;
public keep_screen_on!: boolean;
public banner_id!: string;
public banner_width!: number;
public interstitial_id!: string;
public native_id!: string;
public video_id!: string;
public is_video_free!: boolean;
public is_cache_video!: boolean;
public ad_type!: string;
public ad_id!: string;
public ad_key!: string;
public switch_ad!: boolean;
public share_data_arr!: LQShareData[];
}

View File

@ -0,0 +1,10 @@
{
"ver": "1.1.0",
"uuid": "a5470d94-355f-4d03-ba58-81077a780e7f",
"importer": "typescript",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}

View File

@ -0,0 +1,23 @@
import Vec2 = cc.Vec2;
export interface IPos {
x: number;
y: number;
sub(pos: IPos): Vec2;
add(pos: IPos): Vec2;
}
export interface IRect {
x: number;
y: number;
width: number;
height: number;
half_width: number;
half_height: number;
sub(pos: IPos): Vec2;
add(pos: IPos): Vec2;
}

View File

@ -0,0 +1,10 @@
{
"ver": "1.1.0",
"uuid": "41e4557a-fef0-4dcf-97ed-8070a81667a2",
"importer": "typescript",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}

View File

@ -0,0 +1,13 @@
{
"ver": "1.1.3",
"uuid": "0432403f-8c23-4a3e-813a-1a9a1d88aeed",
"importer": "folder",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}

View File

@ -0,0 +1,162 @@
import {LQPlatformUtil} from "./lq_platform_util";
import {LQPlatformType} from "../data/lq_const";
import view = cc.view;
import Vec2 = cc.Vec2;
export class LQBaseUtil {
// public static readonly unit_arr = ['K', 'M', 'B', 'T'];
public static has_value<T>(arr: T[], v: T): boolean {
let has = false;
for (let i = 0; i < arr.length; i++) {
if (arr[i] === v) {
has = true;
break;
}
}
return has;
}
public static get_value_by_duration(percent: number, timeline: Vec2[]): number {
if (timeline.length === 0) {
return 1;
}
let end_index = -1;
for (let i = 1; i < timeline.length; i++) {
if (timeline[i].x > percent) {
end_index = i;
break;
}
}
if (end_index === -1) {
return timeline[timeline.length - 1].y;
}
const start_index = end_index - 1;
return timeline[start_index].y + (timeline[end_index].y - timeline[start_index].y) * ((percent - timeline[start_index].x) / (timeline[end_index].x - timeline[start_index].x));
}
public static number_to_counting(num: number): string {
if (num < 1000) {
return num + '';
} else if (num < 1000000) {
return Math.floor(num / 1000) + 'K';
} else if (num < 1000000000) {
return Math.floor(num / 1000000) + 'M';
} else if (num < 1000000000000) {
return Math.floor(num / 1000000000) + 'B';
} else if (num < 1000000000000000) {
return Math.floor(num / 1000000000000) + 'T';
}
return Math.floor(num / 1000000000000) + 'T';
}
public static number_to_time(time: number): [string, string, string] {
const t = Math.floor(time / (60 * 60));
time = time - t * 60 * 60;
let hour = t.toString();
let min = Math.floor(time / 60).toString();
let sec = (time % 60).toString();
if (hour.length === 1) {
hour = '0' + hour;
}
if (min.length === 1) {
min = '0' + min;
}
if (sec.length === 1) {
sec = '0' + sec;
}
return [hour, min, sec];
}
public static set_normal_angle(angle: number) {
while (angle > 360) {
angle -= 360;
}
while (angle < 0) {
angle += 360;
}
return angle;
}
public static compare_version(v1: string, v2: string): number {
let v1_arr = v1.split('.');
let v2_arr = v2.split('.');
const len = Math.max(v1_arr.length, v2_arr.length);
while (v1_arr.length < len) {
v1_arr.push('0');
}
while (v2_arr.length < len) {
v2_arr.push('0');
}
for (let i = 0; i < len; i++) {
const num1 = parseInt(v1_arr[i]);
const num2 = parseInt(v2_arr[i]);
if (num1 > num2) {
return 1;
} else if (num1 < num2) {
return -1;
}
}
return 0;
}
public static is_today(date: string): boolean {
const d1 = new Date();
let d2;
if (date && date !== '') {
d2 = new Date(date);
} else {
d2 = new Date();
d2.setDate(d2.getDate() - 1);
}
return d1.getFullYear() === d2.getFullYear() && d1.getMonth() === d2.getMonth() && d1.getDate() === d2.getDate();
}
public static is_safe_area(): boolean {
const cb = (width: number, height: number) => {
return (width === 2280 && height === 1080) || (width === 1792 && height === 828) || (width === 2436 && height === 1125) || (width === 2688 && height === 1242);
};
switch (LQPlatformUtil.get_platform()) {
case LQPlatformType.baidu:
const sys_info_swan = swan.getSystemInfoSync();
return cb(sys_info_swan.pixelRatio * sys_info_swan.screenWidth, sys_info_swan.pixelRatio * sys_info_swan.screenHeight);
case LQPlatformType.qq:
const sys_info_qq = qq.getSystemInfoSync();
return cb(sys_info_qq.pixelRatio * sys_info_qq.screenWidth, sys_info_qq.pixelRatio * sys_info_qq.screenHeight);
case LQPlatformType.tt:
const sys_info_tt = tt.getSystemInfoSync();
return cb(sys_info_tt.pixelRatio * sys_info_tt.screenWidth, sys_info_tt.pixelRatio * sys_info_tt.screenHeight);
case LQPlatformType.oppo:
case LQPlatformType.vivo:
const sys_info_vivo = qg.getSystemInfoSync();
return cb(sys_info_vivo.pixelRatio * sys_info_vivo.screenWidth, sys_info_vivo.pixelRatio * sys_info_vivo.screenHeight);
case LQPlatformType.wx:
const sys_info_wx = wx.getSystemInfoSync();
return cb(sys_info_wx.pixelRatio * sys_info_wx.screenWidth, sys_info_wx.pixelRatio * sys_info_wx.screenHeight);
case LQPlatformType.android:
break;
case LQPlatformType.ios:
let size = view.getFrameSize();
return cb(size.width, size.height);
}
return false;
}
public static deep_clone(obj: any) {
if (typeof obj !== 'object') {
return obj;
}
let new_obj = (obj instanceof Array ? [] : {}) as any;
for (let key in obj) {
if (typeof obj[key] === 'object') {
new_obj[key] = this.deep_clone(obj[key]);
} else {
new_obj[key] = obj[key];
}
}
return new_obj;
}
}

View File

@ -0,0 +1,10 @@
{
"ver": "1.1.0",
"uuid": "cd21fb93-658e-4b3a-8897-b4deba47bc31",
"importer": "typescript",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}

View File

@ -0,0 +1,147 @@
import SpriteFrame = cc.SpriteFrame;
import director = cc.director;
import tween = cc.tween;
import Texture2D = cc.Texture2D;
import Canvas = cc.Canvas;
import visibleRect = cc.visibleRect;
import find = cc.find;
import Node = cc.Node;
export class LQGameUtil {
private static image_cache: { [key: string]: SpriteFrame } = {};
public static get_image(url: string, callback: (success: boolean, sf: SpriteFrame | undefined) => void, cache = true) {
if (!url || url === '') {
callback(false, undefined);
return;
}
if (this.image_cache[url]) {
callback(true, this.image_cache[url]);
return;
}
// cc.loader.load(
// {url: url, type: 'png'},
// (err: string, texture: Texture2D | undefined) => {
// if (err) {
// // console.error('err:' + err);
// callback(false, undefined);
// return;
// }
// const frame = new SpriteFrame(texture);
// callback(true, frame);
// if (cache) {
// this.image_cache[url] = frame;
// }
// });
}
public static canvas_policy(c: Canvas, width: number, height: number): boolean {
// @ts-ignore
const ratio = visibleRect.height / visibleRect.width;
if (ratio > height / width) {
c.fitHeight = false;
c.fitWidth = true;
} else {
c.fitHeight = true;
c.fitWidth = false;
}
return c.fitHeight;
}
public static recursion_node_property(node: Node, p: { key: string, value: number }) {
if (node.parent) {
// @ts-ignore
p.value *= node.parent[p.key];
this.recursion_node_property(node.parent, p);
}
}
/**
*
* @param path
* eg.'Canvas>node_main>btn_start'
*/
public static find_node(path: string): Node | undefined {
if (!path || path.length <= 0) {
console.warn('路径不正确');
return undefined;
}
const arr = path.split('/');
const root = find(arr[0]);
if (!root) {
console.warn('没找到节点:' + arr[0]);
return undefined;
}
let node = root;
for (let i = 1; i < arr.length; i++) {
const temp = node.getChildByName(arr[i]);
if (!temp) {
console.warn('没找到节点:' + arr[i]);
return undefined;
}
node = temp;
}
return node;
}
public static wait(time: number) {
return new Promise((resolve) => {
tween(director.getScene()).delay(time).call(() => {
resolve();
}).start();
});
}
public static set_clip(clip: cc.AnimationClip, off: cc.Vec2, flip_x: boolean, flip_y: boolean) {
let s = (arr: number[]) => {
for (let i = 0; i < arr.length; i++) {
if (i % 2 === 0) {
if (flip_x) {
arr[i] = -arr[i];
}
arr[i] += off.x;
} else {
if (flip_y) {
arr[i] = -arr[i];
}
arr[i] += off.y;
}
}
};
const pos_arr = clip.curveData.props.position;
for (let i = 0; i < pos_arr.length; i++) {
const motionPath = pos_arr[i].motionPath;
const value = pos_arr[i].value;
if (motionPath) {
for (let i = 0; i < motionPath.length; i++) {
s(motionPath[i]);
}
}
s(value);
}
}
public static scroll_layout(layout: cc.Layout, speed: number = 50) {
layout.updateLayout();
const len = layout.type === cc.Layout.Type.HORIZONTAL ? layout.node.width : layout.node.height;
const time = len / speed;
if (layout.type === cc.Layout.Type.HORIZONTAL) {
let offset = layout.node.anchorX === 1 ? layout.node.width * 0.5 : -layout.node.width * 0.5;
layout.node.runAction(cc.repeatForever(cc.sequence(
cc.moveBy(time, cc.v2(offset, 0)),
cc.callFunc(() => {
layout.node.x -= offset;
})
)));
} else if (layout.type === cc.Layout.Type.VERTICAL || layout.type === cc.Layout.Type.GRID) {
let offset = layout.node.anchorY === 1 ? layout.node.height * 0.5 : -layout.node.height * 0.5;
layout.node.runAction(cc.repeatForever(cc.sequence(
cc.moveBy(time, cc.v2(0, offset)),
cc.callFunc(() => {
layout.node.y -= offset;
})
)));
}
}
}

View File

@ -0,0 +1,10 @@
{
"ver": "1.1.0",
"uuid": "63c53081-f5d8-4bfe-9845-38fb537ae17b",
"importer": "typescript",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}

View File

@ -0,0 +1,48 @@
import {IPos, IRect} from "../data/lq_interface";
export class LQMathUtil {
public static random(min: number, max: number): number {
if (min === max) {
return min;
} else if (min < max) {
return Math.random() * (max - min) + min;
} else {
return Math.random() * (min - max) + max;
}
}
public static random_int(min: number, max: number): number {
return Math.floor(this.random(min, max));
}
public static get_radians(pos: IPos, target_pos: IPos) {
const r = Math.atan2(target_pos.y - pos.y, target_pos.x - pos.x);
return r > 0 ? r : r + 6.28;
}
public static intersects_rect(r1: IRect, r2: IRect): boolean {
return Math.abs(r1.x - r2.x) < r1.half_width + r2.half_width && Math.abs(r1.y - r2.y) < r1.half_height + r2.half_height;
}
public static intersects_point_rect(p: IPos, r: IRect): boolean {
return (p.x > r.x - r.width * 0.5) && (p.x < r.x + r.width * 0.5) && (p.y > r.y - r.height * 0.5) && (p.y < r.y + r.height * 0.5);
}
public static intersects_point_circle(p1: IPos, p2: IPos, r: number) {
return p1.sub(p2).magSqr() < r * r;
}
public static intersects_circle(p1: IPos, r1: number, p2: IPos, r2: number) {
return p1.sub(p2).mag() < r1 + r2;
}
public static intersects_circle_rect(p: IPos, r: number, rect: IRect) {
const relative_x = p.x - rect.x;
const relative_y = p.y - rect.y;
const dx = Math.min(relative_x, rect.half_width);
const dx1 = Math.max(dx, -rect.half_width);
const dy = Math.min(relative_y, rect.half_height);
const dy1 = Math.max(dy, -rect.half_height);
return (dx1 - relative_x) * (dx1 - relative_x) + (dy1 - relative_y) * (dy1 - relative_y) <= r * r;
}
}

View File

@ -0,0 +1,10 @@
{
"ver": "1.1.0",
"uuid": "997fce7c-cb7f-4e14-b7e5-87a4f9f1f643",
"importer": "typescript",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}

View File

@ -0,0 +1,118 @@
import {LQByteDanceType, LQPlatformType} from "../data/lq_const";
export class LQPlatformUtil {
private static platform_type: LQPlatformType;
private static byte_dance_type: LQByteDanceType;
public static init() {
if (typeof qq !== 'undefined') {
this.platform_type = LQPlatformType.qq;
} else if (typeof swan !== 'undefined') {
this.platform_type = LQPlatformType.baidu;
} else if (typeof tt !== 'undefined') {
this.platform_type = LQPlatformType.tt;
const info = tt.getSystemInfoSync();
switch (info.appName) {
case 'Toutiao':
this.byte_dance_type = LQByteDanceType.tt;
break;
case 'news_article_lite':
this.byte_dance_type = LQByteDanceType.tt_lite;
break;
case 'Douyin':
this.byte_dance_type = LQByteDanceType.douyin;
break;
case 'douyin_lite':
this.byte_dance_type = LQByteDanceType.douyin_lite;
break;
case 'PPX':
this.byte_dance_type = LQByteDanceType.ppx;
break;
case 'devtools':
this.byte_dance_type = LQByteDanceType.devtools;
break;
}
} else if (typeof qg !== 'undefined') {
if (!!qg.getBattle) {
this.platform_type = LQPlatformType.oppo;
} else {
this.platform_type = LQPlatformType.vivo;
}
} else if (typeof wx !== 'undefined') {
this.platform_type = LQPlatformType.wx;
} else if (typeof jsb !== 'undefined') {
if (cc.sys.os === cc.sys.OS_ANDROID) {
this.platform_type = LQPlatformType.android;
} else if (cc.sys.os === cc.sys.OS_IOS) {
this.platform_type = LQPlatformType.ios;
} else {
this.platform_type = LQPlatformType.unknown;
}
} else if (cc.sys.isBrowser) {
this.platform_type = LQPlatformType.browser;
}
}
public static get_platform(): LQPlatformType {
return this.platform_type;
}
public static get_byte_dance(): LQByteDanceType {
return this.byte_dance_type;
}
public static is_wx() {
return this.platform_type === LQPlatformType.wx;
}
public static is_tt() {
return this.platform_type === LQPlatformType.tt;
}
public static is_oppo() {
return this.platform_type === LQPlatformType.oppo;
}
public static is_vivo() {
return this.platform_type === LQPlatformType.vivo;
}
public static is_ov() {
return this.platform_type === LQPlatformType.oppo || this.platform_type === LQPlatformType.vivo;
}
public static is_browser() {
return this.platform_type === LQPlatformType.browser;
}
public static is_android() {
return this.platform_type === LQPlatformType.android;
}
public static is_ios() {
return this.platform_type === LQPlatformType.ios;
}
public static is_native() {
return this.platform_type === LQPlatformType.android || this.platform_type === LQPlatformType.ios;
}
public static is_qq() {
return this.platform_type === LQPlatformType.qq;
}
public static is_baidu() {
return this.platform_type === LQPlatformType.baidu;
}
public static is_kwaigame() {
return this.platform_type === LQPlatformType.kwaigame;
}
}
LQPlatformUtil.init();
if (LQPlatformUtil.is_tt()) {
// console.log('---------当前平台:' + LQPlatformUtil.get_byte_dance());
} else {
// console.log('---------当前平台:' + LQPlatformUtil.get_platform());
}

View File

@ -0,0 +1,10 @@
{
"ver": "1.1.0",
"uuid": "358754f4-96c4-4bde-bce1-36451d5f8fc6",
"importer": "typescript",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}

View File

@ -0,0 +1,118 @@
import Node = cc.Node;
import Animation = cc.Animation;
import ParticleSystem = cc.ParticleSystem;
import instantiate = cc.instantiate;
export class LQPoolUtil {
private static any_pool: { [key: string]: Node[] } = {};
private static reset_ani(node: Node) {
let ani = node.getComponent(Animation);
if (ani) {
let clip = ani.currentClip ? ani.currentClip : ani.defaultClip;
if (!clip) {
return;
}
if (ani.playOnLoad && clip && clip.wrapMode === cc.WrapMode.Normal) {
ani.play(clip.name);
}
} else {
let ani = node.getComponent(sp.Skeleton);
if (ani && !ani.loop) {
ani.setAnimation(0, ani.animation, false);
}
}
for (let i = 0; i < node.childrenCount; i++) {
const child = node.children[i];
this.reset_ani(child);
}
}
public static recursion_stop_particle(node: Node, obj: { has: boolean }) {
const p = node.getComponent(ParticleSystem);
if (p) {
p.stopSystem();
obj.has = true;
p.node.opacity = 0;
}
for (let i = 0; i < node.childrenCount; i++) {
const child = node.children[i];
this.recursion_stop_particle(child, obj);
}
}
public static recursion_reset_particle(node: Node) {
if (!node.isValid) {
return;
}
const p = node.getComponent(ParticleSystem);
if (p) {
p.resetSystem();
p.node.opacity = 255;
}
for (let i = 0; i < node.childrenCount; i++) {
const child = node.children[i];
this.recursion_reset_particle(child);
}
}
public static get_node_from_pool(node_parent: Node, prefab: Node) {
let arr = this.any_pool[prefab.uuid];
if (!arr) {
this.any_pool[prefab.uuid] = [];
arr = [];
}
let node = arr.pop();
if (!node || !node.isValid) {
node = instantiate(prefab);
//@ts-ignore
node.recovery_uuid = prefab.uuid;
//@ts-ignore
node.is_from_pool = false;
node_parent.addChild(node);
} else {
node.active = true;
//@ts-ignore
node.is_from_pool = true;
this.reset_ani(node);
}
return node;
}
private static check_pool_push(arr: Node[], node: Node) {
for (let i = 0; i < arr.length; i++) {
if (arr[i] === node) {
//@ts-ignore
console.warn(`池子不能重复添加节点`, node.name, node.recovery_uuid);
return;
}
}
node.active = false;
arr.push(node);
}
public static push_node_to_pool(node: Node) {
//@ts-ignore
if (!node.recovery_uuid || !this.any_pool[node.recovery_uuid]) {
if (node.isValid) {
node.destroy();
}
return;
}
const obj: { has: boolean } = {has: false};
this.recursion_stop_particle(node, obj);
if (obj.has) {
let old_opacity = node.opacity;
node.opacity = 0;
setTimeout(() => {
this.recursion_reset_particle(node);
node.opacity = old_opacity;
//@ts-ignore
this.check_pool_push(this.any_pool[node.recovery_uuid], node);
}, 500);
} else {
//@ts-ignore
this.check_pool_push(this.any_pool[node.recovery_uuid], node);
}
}
}

View File

@ -0,0 +1,10 @@
{
"ver": "1.1.0",
"uuid": "98488d9e-d9da-43d7-b2ef-0909d30f2904",
"importer": "typescript",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}

View File

@ -0,0 +1,13 @@
{
"ver": "1.1.3",
"uuid": "7262f828-3947-4d61-ab6b-0c5ef01a6473",
"importer": "folder",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}

View File

@ -0,0 +1,505 @@
import ccclass = cc._decorator.ccclass;
import property = cc._decorator.property;
import requireComponent = cc._decorator.requireComponent;
import menu = cc._decorator.menu;
import Component = cc.Component;
import Enum = cc.Enum;
import Size = cc.Size;
import Vec2 = cc.Vec2;
import Graphics = cc.Graphics;
import Node = cc.Node;
import macro = cc.macro;
import Color = cc.Color;
import {LQCollideShape, LQCollideStatus} from "../lq_base/data/lq_const";
import {LQCollideConfig, LQCollideInfoList} from "./lq_collide_config";
import {LQCollideSystem} from "./lq_collide_system";
import {LQRect} from "../lq_base/data/lq_data";
import {LQCollideBase} from "./lq_collide_base";
import {LQGameUtil} from "../lq_base/util/lq_game_util";
import MapConroler from "../Map";
@ccclass
@requireComponent(LQCollideBase)
@menu("lq/collide")
export class LQCollide extends Component {
velocity: any;
@property({displayName: '绘制形状'})
get draw_collide(): boolean {
return this._draw_collide;
}
set draw_collide(value: boolean) {
this._draw_collide = value;
this.draw_shape();
}
@property
protected _draw_collide: boolean = true;
@property({tooltip: '能否移动'})
protected can_move: boolean = true;
@property({
tooltip: '碰撞形状None就是无敌不参与碰撞',
type: Enum(LQCollideShape),
displayName: '碰撞形状'
})
get collide_shape(): LQCollideShape {
return this._collide_shape;
}
set collide_shape(value: LQCollideShape) {
this._collide_shape = value;
this.draw_shape();
}
@property()
public _collide_shape: LQCollideShape = LQCollideShape.Rect;
@property({
type: Enum(LQCollideInfoList), tooltip: '碰撞类别',
displayName: '碰撞类别'
})
get collide_group_index() {
if (this._collide_group_index === -1) {
this._collide_group_index = LQCollideSystem.get_info_by_id(this.collide_group_id).index;
}
return this._collide_group_index;
}
set collide_group_index(value) {
if (this._collide_group_index === value) {
return;
}
this._collide_group_index = value;
this.collide_group_id = LQCollideSystem.get_group_by_index(value).id;
}
@property({serializable: false})
private _collide_group_index = -1;
@property({visible: false})
protected collide_group_id: number = 0;
@property({visible: false})
protected collide_scle: number = 1;
@property({
tooltip: 'collide半径',
visible() {
// @ts-ignore
return this._collide_shape === LQCollideShape.Circle;
},
displayName: '半径'
})
get radius(): number {
return this._radius;
}
set radius(value: number) {
this._radius = value;
this.draw_shape();
}
@property()
protected _radius: number = 50;
// 物体速度
// public velocity: Vec2 = new Vec2(0, 0);
@property({
tooltip: 'collide长宽',
visible() {
// @ts-ignore
return this._collide_shape === LQCollideShape.Rect;
},
displayName: '长宽'
})
get size(): Size {
return this._size;
}
set size(value: Size) {
this._size = value;
if (this.world_rect) {
this.world_rect.width = value.width;
this.world_rect.height = value.height;
this.world_rect.half_width = value.width * 0.5;
this.world_rect.half_height = value.height * 0.5;
}
this.draw_shape();
}
@property()
protected _size: Size = new Size(100, 100);
@property({displayName: '位置偏移'})
get offset(): Vec2 {
return this._offset;
}
set offset(value: Vec2) {
this._offset = value;
this.draw_shape();
}
@property({
type: Vec2,
visible() {
// @ts-ignore
return this._collide_shape === LQCollideShape.Polygon;
},
displayName: '多边形碰撞点'
})
get polygon_points(): Vec2[] {
return this._polygon_points;
}
set polygon_points(value: Vec2[]) {
this._polygon_points = value;
this.draw_shape();
}
@property()
public _polygon_points: Vec2[] = [new Vec2(-45, -45), new Vec2(45, -45), new Vec2(60, 40), new Vec2(0, 70), new Vec2(-60, 40)];
//collide碰撞位置偏移
@property()
public _offset: Vec2 = new Vec2(0, 0);
@property({displayName: '自定义字符串'})
public data_string: string = '';
//每个collide的id唯一
public collide_id: number = 0;
//状态
public collide_status: LQCollideStatus = LQCollideStatus.Idle;
//是否可碰撞
public is_enable: boolean = true;
//是否开启碰撞前后的函数
public is_open_func: boolean = true;
//碰撞类别
public collide_category = 0;
//碰撞筛选
public collide_mask = 0;
//缓存多边形碰撞数据
public cache_polygon_points: number[];
//绘制collide形状组件
private _debugDrawer!: Graphics;
public world_rect!: LQRect;
public collide_map: { [key: number]: { collide: LQCollide, status: 1 | 2 } } = {};
public follow_target_category: number | undefined;
private static id_maker: number = 1;
//检测绘制组件是否添加
private checkDebugDrawValid() {
if (!this._debugDrawer || !this._debugDrawer.isValid) {
let node = this.node.getChildByName('Collide');
if (!node) {
node = new Node('Collide');
node.zIndex = macro.MAX_ZINDEX;
this.node.addChild(node);
// @ts-ignore
node._objFlags = 1096;
this._debugDrawer = node.addComponent(Graphics);
this._debugDrawer.lineWidth = 3;
this._debugDrawer.strokeColor = new Color(255, 0, 0);
this._debugDrawer.fillColor = new Color(255, 0, 0);
} else {
this._debugDrawer = node.getComponent(Graphics);
}
}
}
//绘制形状
protected draw_shape() {
if (!this._draw_collide) {
if (this._debugDrawer) {
this._debugDrawer.clear();
}
return;
}
this.checkDebugDrawValid();
this._debugDrawer.clear();
let o1 = {key: 'scaleX', value: this.node.scale};
let o2 = {key: 'scaleY', value: this.node.scale};
LQGameUtil.recursion_node_property(this.node, o1);
LQGameUtil.recursion_node_property(this.node, o2);
if (o1.value === 0 || o2.value === 0) {
return;
}
this._debugDrawer.node.scaleX = 1 / o1.value;
this._debugDrawer.node.scaleY = 1 / o2.value;
switch (this._collide_shape) {
case LQCollideShape.Circle:
this._debugDrawer.circle(+this._offset.x, +this._offset.y, this._radius);
this._debugDrawer.stroke();
break;
case LQCollideShape.Rect:
this._debugDrawer.moveTo(-this._size.width * 0.5 + this._offset.x, -this._size.height * 0.5 + this._offset.y);
this._debugDrawer.lineTo(-this._size.width * 0.5 + this._offset.x, +this._size.height * 0.5 + this._offset.y);
this._debugDrawer.lineTo(this._size.width * 0.5 + this._offset.x, +this._size.height * 0.5 + this._offset.y);
this._debugDrawer.lineTo(this._size.width * 0.5 + this._offset.x, -this._size.height * 0.5 + this._offset.y);
this._debugDrawer.lineTo(-this._size.width * 0.5 + this._offset.x, -this._size.height * 0.5 + this._offset.y);
this._debugDrawer.stroke();
break;
case LQCollideShape.Polygon:
this._debugDrawer.moveTo(this._polygon_points[0].x + this._offset.x, this._polygon_points[0].y + this._offset.y);
for (let i = 1; i < this._polygon_points.length; i++) {
this._debugDrawer.lineTo(this._polygon_points[i].x + this._offset.x, this._polygon_points[i].y + this._offset.y);
}
this._debugDrawer.lineTo(this._polygon_points[0].x + this._offset.x, this._polygon_points[0].y + this._offset.y);
this._debugDrawer.stroke();
break;
}
}
//仅用于矩形
public update_size(width: number, height: number) {
this._size.width = width;
this.world_rect.width = width;
this.world_rect.half_width = width * 0.5;
this._size.height = height;
this.world_rect.height = height;
this.world_rect.half_height = height * 0.5;
this.draw_shape();
}
public init_lq_collide() {
this.world_rect = new LQRect(0, 0, this._size.width, this._size.height);
this.draw_shape();
const info = LQCollideSystem.get_info_by_id(this.collide_group_id);
this.collide_mask = info.mask;
this.collide_category = info.category;
this.collide_id = LQCollide.id_maker++;
this.updateCollisionArea();
}
private updateCollisionArea() {
if(this._size.width==0 || this._size.height==0 || MapConroler._instance == undefined){
return;
}
if(MapConroler._instance.node.scale){
let scaleX = MapConroler._instance.node.scale;
let scaleY = MapConroler._instance.node.scale;
if (scaleX === 0 || scaleX == undefined || scaleX == null || scaleX == 1) {
return;
}
switch (this._collide_shape) {
case LQCollideShape.Circle:
// 圆形碰撞区域半径更新
this._radius = this._radius * Math.max(scaleX, scaleY);
break;
case LQCollideShape.Rect:
// 矩形碰撞区域尺寸更新
// console.log(this.data_string);
if (this._size.width !== 10 && this.data_string!="-1") {
// if(this._size.width == 105 || this._size.height == 105){}
this._size.width = this._size.width * scaleX;
// console.log("放大倍数",scaleX);
}
if (this._size.height!== 10 && this.data_string!="-1") {
// if(this._size.width == 105 || this._size.height == 105){}
this._size.height = this._size.height * scaleY;
// console.log("放大倍数",scaleY);
}
// this._size.width = this._size.width * scaleX;
// this._size.height = this._size.height * scaleY;
if (this.world_rect) {
this.world_rect.width = this._size.width;
this.world_rect.height = this._size.height;
this.world_rect.half_width = this._size.width * 0.5;
this.world_rect.half_height = this._size.height * 0.5;
}
break;
case LQCollideShape.Polygon:
// 多边形碰撞点坐标更新
this._polygon_points = this._polygon_points.map(point => {
return new Vec2(point.x * scaleX, point.y * scaleY);
});
break;
}
this.draw_shape();
}
}
public enable_lq_collide() {
if (this.collide_status === LQCollideStatus.Live) {
console.warn(this.node.name + '重复添加');
return;
}
this.is_enable = true;
this.collide_status = LQCollideStatus.Live;
LQCollideSystem.add_collide(this);
}
public disable_lq_collide() {
if (this.collide_status !== LQCollideStatus.Live) {
return;
}
this.is_enable = false;
this.collide_status = LQCollideStatus.Idle;
LQCollideSystem.remove_collide(this);
}
public update_lq_collide() {
}
// @ts-ignore
// public on_collide(collide: LQCollide): void {
// if(collide.node.parent.uuid == this.node.parent.uuid){
// return;
// }
// if (LQCollideConfig.switch_print_log) {
// if(this.node.parent.getComponent("Block")){
// let block = this.node.parent.getComponent("Block");
// if(block.isTouch){
// block.checkCollision = true;
// // console.log("碰撞",this.node.name);
// if(this.node.name == "top" ){
// console.log("碰到上边缘");
// block.moveUp = false;
// if(block.touchPointY > (this.node.parent.y+this.node.height)){
// block.moveY = 1;
// }
// }
// if(this.node.name === "down"){
// block.moveDown = false;
// console.log("碰到下边缘");
// if(block.touchPointY < (this.node.parent.y )){
// block.moveY = -1;
// }
// }
// if(this.node.name === "left" ){
// block.moveLeft = false;
// console.log("碰到左边缘");
// if(block.touchPointX < (this.node.parent.x - this.node.parent.width)){
// block.moveX = -1;
// }
// }
// if(this.node.name === "right"){
// block.moveRight = false;
// console.log("碰到右边缘");
// if(block.touchPointX > (this.node.parent.x)){
// block.moveX = 1;
// }
// }
// }
// }
// }
// }
//@ts-ignore
public on_enter(collide: LQCollide) {
if(this.disableCollider(collide)){
return;
}
// if (LQCollideConfig.switch_print_log) {
// console.log(this.node.name + ' on_enter');
// }
}
//@ts-ignore
public on_exit(collide: LQCollide) {
if(this.disableCollider(collide)){
return;
}
if (LQCollideConfig.switch_print_log) {
if(this.node.parent.getComponent("Block")){
let block = this.node.parent.getComponent("Block");
// if(!block.isTouch){
// return;
// }
block.checkCollision = false;
if(this.node.name == "top" ){
block.moveUp = true;
}
if(this.node.name === "down"){
block.moveDown = true;
}
if(this.node.name === "left" ){
block.moveLeft = true;
}
if(this.node.name === "right"){
block.moveRight = true;
}
}
}
}
public on_collide(collide: LQCollide): void {
if(this.disableCollider(collide)){
return;
}
if (LQCollideConfig.switch_print_log) {
if(this.node.parent.getComponent("Block")){
let block = this.node.parent.getComponent("Block");
let jg = false;
if(block.isTouch){
block.checkCollision = true;
// console.log("碰撞",this.node.name);
if(this.node.name == "top" ){
// console.log(collide.node.parent.name);
block.moveUp = false;
if(block.touchPointY > (this.node.parent.y+this.node.parent.height)){
block.moveY = 1;
}
// console.log("碰到上边缘");
}
if(this.node.name === "down"){
block.moveDown = false;
if(block.touchPointY < (this.node.parent.y )){
block.moveY = -1;
}
// console.log("碰到下边缘");
}
if(this.node.name === "left" ){
block.moveLeft = false;
if(block.touchPointX < (this.node.parent.x - this.node.parent.width)){
block.moveX = -1;
}
}
if(this.node.name === "right"){
block.moveRight = false;
if(block.touchPointX > (this.node.parent.x)){
block.moveX = 1;
}
}
}
}
}
}
public disableCollider(collide: LQCollide){
let jg = false;
if(collide.node && this.node){
if(collide.node.parent && this.node.parent){
if(collide.node.parent.uuid == this.node.parent.uuid){
jg = true;
}
if(this.node.parent.getComponent("Block")){
let block = this.node.parent.getComponent("Block");
if(block.type == 1 || block.type == 10 || block.type == 9){
if(collide.node.parent == block.block_Info.node){
jg = true;
}
}
}
}
}
return jg;
}
}

View File

@ -0,0 +1,10 @@
{
"ver": "1.1.0",
"uuid": "d2add891-a975-4a43-8604-a7ab0ae5de91",
"importer": "typescript",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}

View File

@ -0,0 +1,92 @@
import ccclass = cc._decorator.ccclass;
import executeInEditMode = cc._decorator.executeInEditMode;
import PolygonCollider = cc.PolygonCollider;
import property = cc._decorator.property;
import {LQCollide} from "./lq_collide";
import {LQCollideShape} from "../lq_base/data/lq_const";
@ccclass
@executeInEditMode
export class LQCollideBase extends cc.Component {
@property({tooltip: '多边形自动同步cocos PolygonCollider 组件中的碰撞点'})
protected auto_update_point: boolean = true;
private find_collide() {
const collide = this.node.getComponent(LQCollide);
if (!collide) {
console.error(this.node.name + ':没有找到LQCollide组件');
return undefined;
}
return collide;
}
protected onLoad() {
const collide = this.find_collide();
if (!collide) {
return;
}
collide.init_lq_collide();
}
protected onEnable() {
const collide = this.find_collide();
if (!collide) {
return;
}
collide.enable_lq_collide();
}
protected onDisable() {
const collide = this.find_collide();
if (!collide) {
return;
}
collide.disable_lq_collide();
}
protected onDestroy() {
const collide = this.find_collide();
if (!collide) {
return;
}
}
protected onFocusInEditor() {
const collide = this.find_collide();
if (!collide) {
return;
}
}
protected onLostFocusInEditor() {
const collide = this.find_collide();
if (!collide) {
return;
}
}
protected resetInEditor() {
const collide = this.find_collide();
if (!collide) {
return;
}
}
protected update(dt: number) {
if (!CC_EDITOR || !this.auto_update_point) {
return;
}
const collide = this.find_collide();
if (!collide) {
return;
}
if (collide.collide_shape !== LQCollideShape.Polygon) {
return;
}
const polygonCollider = this.node.getComponent(PolygonCollider);
if (!polygonCollider) {
return;
}
collide.polygon_points = polygonCollider.points;
}
}

View File

@ -0,0 +1,10 @@
{
"ver": "1.1.0",
"uuid": "c22a3c1c-53fb-4174-9fea-8e7fd0eaeb80",
"importer": "typescript",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}

View File

@ -0,0 +1,24 @@
export enum LQCollideInfoList {
default, role, role_bullet, enemy, enemy_bullet, prop
}
export class LQCollideConfig {
public static switch_auto_run: boolean = true;
public static switch_print_log: boolean = true;
public static switch_quad_tree: boolean = false;
public static max_node_len: number = 10;
public static per_frame: number = 60;
public static max_node_level: number = 4;
public static active_area_x: number = 0;
public static active_area_y: number = 0;
public static active_area_width: number = 1000;
public static active_area_height: number = 1000;
public static collide_group_map = {
"default": {id: 1, category: 1, index: 0, mask: 1},
"role": {id: 2, category: 2, index: 1, mask: 56},
"role_bullet": {id: 3, category: 4, index: 2, mask: 8},
"enemy": {id: 4, category: 8, index: 3, mask: 6},
"enemy_bullet": {id: 5, category: 16, index: 4, mask: 2},
"prop": {id: 6, category: 32, index: 5, mask: 2},
}
}

View File

@ -0,0 +1,10 @@
{
"ver": "1.1.0",
"uuid": "4bd218bc-f09f-4a7e-8581-e9faa4ee85b5",
"importer": "typescript",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}

View File

@ -0,0 +1,30 @@
import {LQCollide} from "./lq_collide";
export class LQCollideSystem {
//是否开启检测
public static is_enable: boolean;
//所有collide集合
public static collide_arr: LQCollide[];
//驱动函数
public static update_logic(dt: number);
//注册
public static add_collide(collide: LQCollide);
//移除
public static remove_collide(collide: LQCollide);
//清除所有
public static clear(is_destroy: boolean = false);
//内部方法
public static get_group_by_index(id: number);
//内部方法
public static get_info_by_id(id: number);
//获取collide的碰撞体集合
public static check_collide(collide: LQCollide) :LQCollide[];
}

View File

@ -0,0 +1,6 @@
{
"ver": "2.0.2",
"uuid": "ad6beb84-3361-4f58-ac42-8c77980b3384",
"importer": "text",
"subMetas": {}
}

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,10 @@
{
"ver": "1.1.0",
"uuid": "81314984-dc17-444a-bf3b-48014af5caaf",
"importer": "javascript",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}

13
assets/Script/module.meta Normal file
View File

@ -0,0 +1,13 @@
{
"ver": "1.1.3",
"uuid": "eaa8b84d-69d0-4170-9f7d-8179ea948cde",
"importer": "folder",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}

View File

@ -0,0 +1,13 @@
{
"ver": "1.1.3",
"uuid": "8848cd9b-8115-456d-a656-2abcda1dadbe",
"importer": "folder",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}

View File

@ -0,0 +1,492 @@
import { GameTool } from "../Tool/GameTool";
const { ccclass, property } = cc._decorator;
@ccclass('GameConfig')
export class GameConfig {
//所有控制信息都通过GameAppStart内控制
private static _instance : GameConfig = null;
static GAME_DATA: any[];
//关卡数据
//用户需要存储在本地的数据, 金币,关卡等级,体力值以及恢复,道具数量。
static CUSTOM_INFO: {
moveSpeed: number; //洪峰移动速度
waitTime: number; //洪峰冲击倒计时
fastPath: number; //最短路径
}[];
static TIME_INFO: {
waterSpeed: number[]; //洪峰速度
totalTime: number; //游戏总时长
waterTime: number[]; //洪峰来的倒计时
roadSpeed: number; //河道修筑速度
ReinforceSpeed: number; //加固时间速度
Xi_SoilSpeed: number;
};
//用于盛放埋点数据上传,每次上传后清空
static CLICK_DATA: {
type: number; //上传数据类型
success: boolean; //此局游戏正确与否
round: number; //回合数轮次
getScore: number; //本轮得分失败为0分
cumulativeScore: number; //本剧游戏总计得分
mapId: string; //地图ID
difficulty: number; //地图难度
optimizedSteps: number; //关卡最短步数
usedSteps: number; //玩家修建总步数
stepList: any[]; //U、D、L、R X 息壤 F 加固
startTime: number; //从游戏开始到玩家操作的第一步截止时间 单位毫秒
submitTime: number; //从第一步操作到提交时间,如果未提交为-1 单位毫秒
duration: number; //游戏总用时(截止到提交) 单位毫秒
drawingBack: number; //后退次数
drawingReset: number; //清空次数
timer: number; //游戏倒计时剩余时长 秒
};
static TIP_ERR: string[]; //修筑失败错误提示
static BLOCK_INFO: {}[][];
//static WALL_INFO: ({ id: number; num: number; block: number; color: number; type: number; special: number; length: number; }[] | { id: number; num: number; block: number; color: number; type: number; special: number; }[])[];
static LEVEL_INFO: ({ id: string; map: number[]; risefall?: undefined; gap?: undefined; } | { id: string; map: number[]; risefall: { pos: cc.Vec2; color: number; }[]; gap?: undefined; } | { id: string; map: number[]; gap: cc.Vec2[]; risefall?: undefined; })[];
static WALL_INFO: (({ id: number; num: number; block: number; color: number; special: number; length: number; lock?: undefined; } | { id: number; num: number; block: number; color: number; special: number; length: number; lock: boolean; })[] | ({ id: number; num: number; block: number; color: number; special: number; length: number; freeze?: undefined; } | { id: number; num: number; block: number; color: number; special: number; length: number; freeze: number; })[])[];
static PROP_INFO: ({ pos1: { x: number; y: number; z: number; }; pos2: { x: number; y: number; z: number; }; pos3: { x: number; y: number; z: number; }; pos4: { x: number; y: number; z: number; }; pos5: { x: number; y: number; z: number; }; pos6: { x: number; y: number; z: number; }; } | { pos1: { x: number; y: number; z: number; }; pos2: { x: number; y: number; z: number; }; pos3: { x: number; y: number; z: number; }; pos4: { x: number; y: number; z: number; }; pos5: { x: number; y: number; z: number; }; pos6?: undefined; })[];
static NEW_LEVEL: any;
static TA: any;
static GM_INFO: {
// isEnd: false,
mean_Time: number; //平均放箭速度
hp: number; //体力值
review: number; //复活次数
//复活次数
currSeed: number; //用于随机数种子
openid: string; //微信用户唯一id
gameId: string; //游戏ID
userId: number; //用户ID
scode: string; //用户code,从网页后缀获取
username: string; //用户名称
useravatar: string; //用户头像地址
guide: boolean; //是否有引导
url: string; //访问域名
coin: number; //用户金币
success: boolean; //用户游戏成功与否
matchId: any; //用于埋点上传的ID
gameState: boolean; custom: number; //用于测试跳关卡
round: number; //回合数
level: number; //具体游戏内进行到第几步
stepTimeList: number; //整局游戏用时,由于涉及场景切换,数据需要保留
successList: any[]; //整局胜负
first: boolean; //是否首次进入游戏
score: number; //总得分
scale: number; //玩家总计成功点火数
min_Steps: number; //每次上一把最小步数
min_Time: number; //体力恢复的剩余时间
freezeAmount: number; //冻结道具次数
hammerAmount: number; //锤子道具次数
magicAmount: number; //魔法棒道具次数
musicOpen: boolean; //音乐
effectOpen: boolean; //音效
vibrateOpen: boolean;
};
//游戏内信息
static get Instance()
{
if (this._instance == null)
{
this._instance = new GameConfig();
}
return this._instance;
}
//getSeedRandom
static init(Authentication){
//@ts-ignore
if (typeof wx !== 'undefined' && wx !== null) {
//@ts-ignore
wx.cloud.init();
}
this.TA = null;
this.CLICK_init();
this.GM_INFO_init();
this.LEVEL_INFO_init(false,0);
var self = this;
//GAME_DATA 废弃了,暂时不删除以防后面修改回 一整局传一次
this.GAME_DATA = [
]
// if(!Authentication) self.Authentication();
}
static generateUUID(): string {
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
const r = Math.random() * 16 | 0;
const v = c === 'x' ? r : (r & 0x3 | 0x8);
return v.toString(16);
});
}
// 版本比较函数
static compareVersion(v1: string, v2: string): number {
const arr1 = v1.split('.');
const arr2 = v2.split('.');
const len = Math.max(arr1.length, arr2.length);
for (let i = 0; i < len; i++) {
const num1 = parseInt(arr1[i] || '0', 10);
const num2 = parseInt(arr2[i] || '0', 10);
if (num1 > num2) {
return 1;
} else if (num1 < num2) {
return -1;
}
}
return 0;
}
static GM_INFO_SET(key,value) {
this.GM_INFO[key] = value;
}
static CLICK_init() {
this.CLICK_DATA =
{
type: 1, //上传数据类型
success: false, //此局游戏正确与否
round: 0, //回合数轮次
getScore: 0, //本轮得分失败为0分
cumulativeScore: 0, //本剧游戏总计得分
mapId: "", //地图ID
difficulty: 0, //地图难度
optimizedSteps: 0, //关卡最短步数
usedSteps: 0, //玩家修建总步数
stepList: [], //U、D、L、R X 息壤 F 加固
startTime:-1, //从游戏开始到玩家操作的第一步截止时间 单位毫秒
submitTime:-1, //从第一步操作到提交时间,如果未提交为-1 单位毫秒
duration:0, //游戏总用时(截止到提交) 单位毫秒 如果未他移交则为时间上限
drawingBack:0, //后退次数
drawingReset:0, //清空次数
timer: 0 //测评倒计时剩余时间 去秒
}
}
static CLICK_SET(key,value) {
this.CLICK_DATA[key] = value;
}
//数据备用
static GM_INFO_init() {
this.GM_INFO = {
// isEnd: false,
mean_Time: 0, //平均放箭速度
hp: 5, //体力值
review:0, //复活次数
currSeed: 200000, //用于随机数种子
openid:"", //微信用户唯一id
gameId: "100001", //游戏ID
userId: 0, //用户ID
scode: "", //用户code,从网页后缀获取
username:"user", //用户名称
useravatar:"", //用户头像地址
guide: true, //是否有引导
url: "https://api.sparkus.cn",//访问域名
coin: 0, //用户金币
success: false, //用户游戏成功与否
matchId: null, //用于埋点上传的ID
gameState:false,
custom: 0, //用于测试跳关卡
round:0, //回合数
level: 0, //具体游戏内进行到第几步
stepTimeList:0, //整局游戏用时,由于涉及场景切换,数据需要保留
successList:[], //整局胜负
first:false, //是否首次进入游戏
score:0, //总得分
scale: 1, //玩家总计成功点火数
min_Steps:0, //每次上一把最小步数
min_Time:0, //体力恢复的剩余时间
freezeAmount:0, //冻结道具次数
hammerAmount:0, //锤子道具次数
magicAmount:0, //魔法棒道具次数
musicOpen: true, //音乐
effectOpen: true, //音效
vibrateOpen: true, //震动
};
// this.setCode(this.getKey("scode"));
// this.GM_INFO.level = 0;
cc.resources.load("Json/NEW_LEVEL", (err: any, res: cc.JsonAsset) => {
if (err) {
console.error("加载 NEW_LEVEL.JSON 失败:", err);
return;
}
const newLevelData = res.json;
this.NEW_LEVEL = newLevelData.NEW_LEVEL;
// 可以根据需求对 newLevelData 进行处理
// //console.log("NEW_LEVEL.JSON 加载成功:", newLevelData);
})
}
static LEVEL_INFO_init(type,time) {
// 示例 围墙会根据缺的地块自动生成
// 带缺口 {"id":"1006","map":[10,11],"gap":[cc.v2(4,9),cc.v2(5,9)]},
// 带升降地块 {"id":"1004","map":[7,8],"risefall":[{pos:cc.v2(5,4),color:2},{pos:cc.v2(5,5),color:5}]},
// 如果普通的就 {"id":"1001","map":[6,7]}, 这个样子就可以了
var self = this;
if((cc.fx.GameConfig.GM_INFO.level) > 156){
cc.fx.GameConfig.GM_INFO.level = 156;
}
let name = "Json/level" + (cc.fx.GameConfig.GM_INFO.level+1);
// //console.log("关卡名称:",name);
// name = "Json/level" + 68;
// cc.fx.StorageMessage.setStorage("level",cc.fx.GameConfig.GM_INFO.level.toString());
cc.resources.load(name, (err: any, res: cc.JsonAsset) => {
if (err) {
cc.fx.GameTool.addLevel();
self.LEVEL_INFO_init(type,time);
return;
}
let jsonData: object = res.json!;
self.BLOCK_INFO = jsonData["BLOCK_INFO"];
self.LEVEL_INFO = jsonData["LEVEL_INFO"];
self.WALL_INFO = jsonData["WALL_INFO"];
// //console.log("配置加载完成");
if(type){
cc.director.preloadScene("GameScene", ()=>{
if(time == 0) cc.director.loadScene("GameScene");
else{
setTimeout(() => {
cc.director.loadScene("GameScene");
}, time);
}
})
}
})
//道具位置信息
this.PROP_INFO = [
{
"pos1": { "x": -66, "y": 60, "z": 0 },
"pos2": { "x": -19, "y": 36, "z": 0 },
"pos3": { "x": -34.362, "y": 13.246, "z": 0 },
"pos4": { "x": -17, "y": 12, "z": 0 },
"pos5": { "x": -85, "y": 70, "z": 0 },
"pos6": { "x": -5, "y": 3, "z": 0 },
},
{
"pos1": { "x": -126, "y": 61, "z": 0 },
"pos2": { "x": -25.792, "y": 34.675, "z": 0 },
"pos3": { "x": -94.792, "y": 21.675, "z": 0 },
"pos4": { "x": -20, "y": 13, "z": 0 },
"pos5": { "x": -140, "y": 68, "z": 0 },
"pos6": { "x": -2, "y": 0, "z": 0 },
},
{
"pos1": { "x": -67, "y": 122, "z": 0 },
"pos2": { "x": -20, "y": 94, "z": 0 },
"pos3": { "x": -34.792, "y": 23.675, "z": 0 },
"pos4": { "x": -14, "y": 24, "z": 0 },
"pos5": { "x": -84, "y": 128, "z": 0 },
"pos6": { "x": -5, "y": 3, "z": 0 },
},
{
"pos1": { "x": -178, "y": 61, "z": 0 },
"pos2": { "x": -34.792, "y": 37.675, "z": 0 },
"pos3": { "x": -150, "y": 23.675, "z": 0 },
"pos4": { "x": -22, "y": 16, "z": 0 },
"pos5": { "x": -200, "y": 67, "z": 0 },
"pos6": { "x": 0, "y": 0, "z": 0 },
},
{
"pos1": { "x": -63, "y": 178, "z": 0 },
"pos2": { "x": -17.792, "y": 166.675, "z": 0 },
"pos3": { "x": -31.792, "y": 33.675, "z": 0 },
"pos4": { "x": -14, "y": 37, "z": 0 },
"pos5": { "x": -78, "y": 182, "z": 0 },
"pos6": { "x": 0, "y": 2, "z": 0 },
},
{
"pos1": { "x": -123, "y": 124, "z": 0 },
"pos2": { "x": -25.792, "y": 99.675, "z": 0 },
"pos3": { "x": -97.792, "y": 27.675, "z": 0 },
"pos4": { "x": -27, "y": 19, "z": 0 },
"pos5": { "x": -135, "y": 127, "z": 0 },
"pos6": { "x": 0, "y": 0, "z": 0 },
},
{
"pos1": { "x": -64, "y": 178, "z": 0 },
"pos2": { "x": -24.792, "y": 275.675, "z": 0 },
"pos3": { "x": -31.792, "y": 35.675, "z": 0 },
"pos4": { "x": -7, "y": 39, "z": 0 },
"pos5": { "x": -77, "y": 188, "z": 0 },
"pos6": { "x": 0, "y": 0, "z": 0 },
},
{
"pos1": { "x": -178, "y": 186, "z": 0 },
"pos2": { "x": -31.792, "y": 163.675, "z": 0 },
"pos3": { "x": -33.792, "y": 34.675, "z": 0 },
"pos4": { "x": -18, "y": 30, "z": 0 },
"pos5": { "x": -200, "y": 192, "z": 0 },
"pos6": { "x": 0, "y": 5, "z": 0 },
},
{
"pos1": { "x": -186, "y": 178, "z": 0 },
"pos2": { "x": -25.792, "y": 38.675, "z": 0 },
"pos3": { "x": -153.792, "y": 34.675, "z": 0 },
"pos4": { "x": -23, "y": 14, "z": 0 },
"pos5": { "x": -200, "y": 185, "z": 0 },
"pos6": { "x": 0, "y": 0, "z": 0 },
},
{
"pos1": { "x": -183, "y": 64, "z": 0 },
"pos2": { "x": -37.792, "y": 37.675, "z": 0 },
"pos3": { "x": -36.792, "y": 26.675, "z": 0 },
"pos4": { "x": -24, "y": 17, "z": 0 },
"pos5": { "x": -212, "y": 74, "z": 0 },
"pos6": { "x": 0, "y": 0, "z": 0 },
},
{
"pos1": { "x": -65, "y": 177, "z": 0 },
"pos2": { "x": 93.208, "y": 276.675, "z": 0 },
"pos3": { "x": -33.792, "y": 34.675, "z": 0 },
"pos4": { "x": 3, "y": 31, "z": 0 },
"pos5": { "x": -80, "y": 190, "z": 0 },
"pos6": { "x": 0, "y": 3, "z": 0 },
},
{
"pos1": { "x": 58, "y": 179, "z": 0 },
"pos2": { "x": 205.225, "y": 154.034, "z": 0 },
"pos3": { "x": -29.642, "y": 25.691, "z": 0 },
"pos4": { "x": 7.218, "y": 29.765, "z": 0 },
"pos5": { "x": 45, "y": 185, "z": 0 },
"pos6": { "x": 0, "y": 0, "z": 0 },
},
{
"pos1": { "x": -68, "y": 182, "z": 0 },
"pos2": { "x": -25.792, "y": 37.675, "z": 0 },
"pos3": { "x": -35.792, "y": 33.675, "z": 0 },
"pos4": { "x": -14, "y": 12, "z": 0 },
"pos5": { "x": -82, "y": 190, "z": 0 },
"pos6": { "x": -2, "y": 1, "z": 0 },
},
{
"pos1": { "x": -184, "y": 62, "z": 0 },
"pos2": { "x": -35.792, "y": 36.675, "z": 0 },
"pos3": { "x": -271.792, "y": 24.675, "z": 0 },
"pos4": { "x": -17, "y": 20, "z": 0 },
"pos5": { "x": -200, "y": 72, "z": 0 },
"pos6": { "x": 0, "y": 0, "z": 0 },
},
{
"pos1": { "x": -62, "y": 175, "z": 0 },
"pos2": { "x": 87.208, "y": 164.675, "z": 0 },
"pos3": { "x": -31.792, "y": 35.675, "z": 0 },
"pos4": { "x": -6, "y": 24, "z": 0 },
"pos5": { "x": -79, "y": 172, "z": 0 },
"pos6": { "x": 0, "y": 5, "z": 0 },
},
{
"pos1": { "x": -184, "y": 72, "z": 0 },
"pos2": { "x": -33.792, "y": 38.675, "z": 0 },
"pos3": { "x": -154.792, "y": 29.675, "z": 0 },
"pos4": { "x": -29, "y": 16, "z": 0 },
"pos5": { "x": -201, "y": 85, "z": 0 },
"pos6": { "x": -1, "y": 3, "z": 0 },
},
{
"pos1": { "x": -64, "y": 181, "z": 0 },
"pos2": { "x": 95.208, "y": 155.675, "z": 0 },
"pos3": { "x": -30.792, "y": 36.675, "z": 0 },
"pos4": { "x": -12, "y": 32, "z": 0 },
"pos5": { "x": -78, "y": 190, "z": 0 },
"pos6": { "x": 0, "y": 3, "z": 0 },
},
{
"pos1": { "x": -65, "y": 178, "z": 0 },
"pos2": { "x": -21.792, "y": 156.675, "z": 0 },
"pos3": { "x": -31.792, "y": 37.675, "z": 0 },
"pos4": { "x": -12, "y": 32, "z": 0 },
"pos5": { "x": -78, "y": 188, "z": 0 },
"pos6": { "x": 0, "y": 2, "z": 0 },
},
{
"pos1": { "x": -62, "y": 183, "z": 0 },
"pos2": { "x": 88.208, "y": 162.675, "z": 0 },
"pos3": { "x": -29.792, "y": 41.675, "z": 0 },
"pos4": { "x": -12, "y": 18, "z": 0 },
"pos5": { "x": -80, "y": 188, "z": 0 },
"pos6": { "x": -4, "y": 2, "z": 0 },
},
{
"pos1": { "x": -67, "y": 80, "z": 0 },
"pos2": { "x": -26.792, "y": 32.675, "z": 0 },
"pos3": { "x": -34.792, "y": 23.675, "z": 0 },
"pos4": { "x": -12, "y": 18, "z": 0 },
"pos5": { "x": -84, "y": 90, "z": 0 },
"pos6": { "x": 0, "y": 0, "z": 0 },
},
{
"pos1": { "x": -184, "y": 80, "z": 0 },
"pos2": { "x": -25.792, "y": 34.675, "z": 0 },
"pos3": { "x": -155.792, "y": 25.675, "z": 0 },
"pos4": { "x": -18, "y": 26, "z": 0 },
"pos5": { "x": -196, "y": 96, "z": 0 },
"pos6": { "x": 0, "y": 0, "z": 0 },
},
{
"pos1": { "x": -62, "y": 160, "z": 0 },
"pos2": { "x": 95.208, "y": 158.675, "z": 0 },
"pos3": { "x": -33.792, "y": 29.675, "z": 0 },
"pos4": { "x": -18, "y": 26, "z": 0 },
"pos5": { "x": -78, "y": 170, "z": 0 },
"pos6": { "x": 0, "y": 2, "z": 0 },
},
{
"pos1": { "x": -68, "y": 160, "z": 0 },
"pos2": { "x": -25.792, "y": 156.675, "z": 0 },
"pos3": { "x": -35.792, "y": 27.675, "z": 0 },
"pos4": { "x": -25, "y": 40, "z": 0 },
"pos5": { "x": -82, "y": 170, "z": 0 },
"pos6": { "x": -2, "y": 2, "z": 0 },
}
];
// this.PROP_INFO = [{"pos1": {"x": -60,"y": 60,"z": 0},"pos2": {"x": -16.442,"y": 30,"z": 0},"pos3": {"x": -34.362,"y": 13.246,"z": 0},"pos4": {"x": -17,"y": 12,"z": 0}},{"pos1": {"x": -126,"y": 63,"z": 0},"pos2": {"x": -25.792,"y": 34.675,"z": 0},"pos3": {"x": -94.792,"y": 21.675,"z": 0},"pos4": {"x": -20,"y": 13,"z": 0}},{"pos1": {"x": -60,"y": 125,"z": 0},"pos2": {"x": -12.792,"y": 92.675,"z": 0},"pos3": {"x": -34.792,"y": 23.675,"z": 0},"pos4": {"x": -14,"y": 24,"z": 0}},{"pos1": {"x": -185,"y": 63,"z": 0},"pos2": {"x": -34.792,"y": 37.675,"z": 0},"pos3": {"x": -154.792,"y": 23.675,"z": 0},"pos4": {"x": -22,"y": 16,"z": 0}},{"pos1": {"x": -57,"y": 178,"z": 0},"pos2": {"x": -17.792,"y": 166.675,"z": 0},"pos3": {"x": -31.792,"y": 33.675,"z": 0},"pos4": {"x": -14,"y": 37,"z": 0}},{"pos1": {"x": -123,"y": 127,"z": 0},"pos2": {"x": -25.792,"y": 99.675,"z": 0},"pos3": {"x": -97.792,"y": 27.675,"z": 0},"pos4": {"x": -27,"y": 19,"z": 0}},{"pos1": {"x": -62,"y": 181,"z": 0},"pos2": {"x": -24.792,"y": 275.675,"z": 0},"pos3": {"x": -31.792,"y": 35.675,"z": 0},"pos4": {"x": -7,"y": 39,"z": 0}},{"pos1": {"x": -181,"y": 180,"z": 0},"pos2": {"x": -31.792,"y": 163.675,"z": 0},"pos3": {"x": -33.792,"y": 34.675,"z": 0},"pos4": {"x": -18,"y": 30,"z": 0}},{"pos1": {"x": -182,"y": 182,"z": 0},"pos2": {"x": -25.792,"y": 38.675,"z": 0},"pos3": {"x": -153.792,"y": 34.675,"z": 0},"pos4": {"x": -23,"y": 14,"z": 0}},{"pos1": {"x": -186,"y": 61,"z": 0},"pos2": {"x": -37.792,"y": 37.675,"z": 0},"pos3": {"x": -36.792,"y": 26.675,"z": 0},"pos4": {"x": -24,"y": 17,"z": 0}},{"pos1": {"x": -62,"y": 177,"z": 0},"pos2": {"x": 93.208,"y": 276.675,"z": 0},"pos3": {"x": -33.792,"y": 34.675,"z": 0},"pos4": {"x": 3,"y": 31,"z": 0}},{"pos1": {"x": 58,"y": 179,"z": 0},"pos2": {"x": 205.225,"y": 154.034,"z": 0},"pos3": {"x": -29.642,"y": 25.691,"z": 0},"pos4": {"x": 7.218,"y": 29.765,"z": 0}},{"pos1": {"x": -57,"y": 182,"z": 0},"pos2": {"x": -25.792,"y": 37.675,"z": 0},"pos3": {"x": -35.792,"y": 33.675,"z": 0},"pos4": {"x": -14,"y": 12,"z": 0}},{"pos1": {"x": -180,"y": 62,"z": 0},"pos2": {"x": -35.792,"y": 36.675,"z": 0},"pos3": {"x": -271.792,"y": 24.675,"z": 0},"pos4": {"x": -17,"y": 20,"z": 0}},{"pos1": {"x": -62,"y": 178,"z": 0},"pos2": {"x": 87.208,"y": 164.675,"z": 0},"pos3": {"x": -31.792,"y": 35.675,"z": 0},"pos4": {"x": -6,"y": 24,"z": 0}},{"pos1": {"x": -176,"y": 60,"z": 0},"pos2": {"x": -33.792,"y": 38.675,"z": 0},"pos3": {"x": -154.792,"y": 29.675,"z": 0},"pos4": {"x": -29,"y": 16,"z": 0}},{"pos1": {"x": -60,"y": 181,"z": 0},"pos2": {"x": 95.208,"y": 155.675,"z": 0},"pos3": {"x": -30.792,"y": 36.675,"z": 0},"pos4": {"x": -12,"y": 32,"z": 0}},{"pos1": {"x": -63,"y": 178,"z": 0},"pos2": {"x": -21.792,"y": 156.675,"z": 0},"pos3": {"x": -31.792,"y": 37.675,"z": 0},"pos4": {"x": -12,"y": 32,"z": 0}},{"pos1": {"x": -60,"y": 183,"z": 0},"pos2": {"x": 88.208,"y": 162.675,"z": 0},"pos3": {"x": -29.792,"y": 41.675,"z": 0},"pos4": {"x": -12,"y": 18,"z": 0}},{"pos1": {"x": -64,"y": 58,"z": 0},"pos2": {"x": -26.792,"y": 32.675,"z": 0},"pos3": {"x": -34.792,"y": 23.675,"z": 0},"pos4": {"x": -12,"y": 18,"z": 0}},{"pos1": {"x": -184,"y": 62,"z": 0},"pos2": {"x": -25.792,"y": 34.675,"z": 0},"pos3": {"x": -155.792,"y": 25.675,"z": 0},"pos4": {"x": -18,"y": 26,"z": 0}},{"pos1": {"x": -57,"y": 190,"z": 0},"pos2": {"x": 95.208,"y": 158.675,"z": 0},"pos3": {"x": -33.792,"y": 29.675,"z": 0},"pos4": {"x": -18,"y": 26,"z": 0}},{"pos1": {"x": -71,"y": 184,"z": 0},"pos2": {"x": -25.792,"y": 156.675,"z": 0},"pos3": {"x": -35.792,"y": 27.675,"z": 0},"pos4": {"x": -25,"y": 40,"z": 0}}];
}
static setCode(code){
this.GM_INFO.scode = code;
}
static getKey(key){
// var reg = new RegExp('(^|&)' + key + '=([^&]*)(&|$)', 'i');
// var r = window.location.search.substring(1).match(reg);
// if (r != null) {
// return unescape(r[2]);
// }
return "";
}
static Authentication(){
cc.fx.GameTool.Authentication();
}
}

View File

@ -0,0 +1,10 @@
{
"ver": "1.1.0",
"uuid": "c5692be7-8703-45e4-9f67-23b54d290356",
"importer": "typescript",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}

View File

@ -0,0 +1,13 @@
{
"ver": "1.1.3",
"uuid": "13a0b173-d59e-4a9d-b5e3-4dbe4dc37cc1",
"importer": "folder",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}

View File

@ -0,0 +1,114 @@
const {ccclass, property} = cc._decorator;
import CryptoJS = require('./crypto-js.min.js'); //引用AES源码js
const BASE_URL = "https://api.sparkus.cn";
//只负责网络接口 次类只负责和后端交互,不负责处理数据 数据处理在GameTool
@ccclass
export default class HttpUtil extends cc.Component {
//排行榜
}
// 响应拦截器
// Rq.interceptors.response.use(responseHandler)
const config = {
gameId: "100012",
secretKey: "onnfPKJW",
EK:"hui231%1"
};
interface CrypotoType {
encryptByDES: any
decryptByDES: any
hmacSha256: any
}
class Crypoto implements CrypotoType {
// 加密的向明值,自己根据项目实际情况定,需要跟后端开发保持一致
private keyHex = this.getHetKey()
private getHetKey() {
return CryptoJS.enc.Utf8.parse(config.EK);
}
/** DES加密 */
encryptByDES(message: string, secret?: string) {
if(!message) {
return message
}
const key = secret? CryptoJS.enc.Utf8.parse(secret): this.keyHex
const encrypted = CryptoJS.DES.encrypt(message, key, {
mode: CryptoJS.mode.ECB,
padding: CryptoJS.pad.Pkcs7
});
return encrypted.toString()
}
/** DES解密 */
decryptByDES(message: string, secret?: string) {
const key = secret? CryptoJS.enc.Utf8.parse(secret): this.keyHex
const decrypted = CryptoJS.DES.decrypt({
ciphertext: CryptoJS.enc.Base64.parse(message)
}, key, {
mode: CryptoJS.mode.ECB,
padding: CryptoJS.pad.Pkcs7
})
return decrypted.toString(CryptoJS.enc.Utf8)
}
/** hmacSHA256加密 */
hmacSha256(message: string, secret?: string) {
const keyHex = secret? CryptoJS.enc.Utf8.parse(secret): this.keyHex
const hash = CryptoJS.HmacSHA256(message, keyHex);
return hash.toString()
}
/** hmacSHA256验证 */
verifyHmacSha256(message: string, signature: string) {
const hash = CryptoJS.HmacSHA256(message, this.keyHex);
return hash.toString() === signature
}
/** CBC加密 */
encryptCBC(word: string) {
if (!word) {
return word;
}
const srcs = CryptoJS.enc.Utf8.parse(word);
const encrypted = CryptoJS.AES.encrypt(srcs, this.keyHex, {
iv: this.keyHex,
mode: CryptoJS.mode.CBC,
padding: CryptoJS.pad.ZeroPadding
});
return encrypted.toString();
}
/** CBC解密 */
decryptCBC(word: string) {
if (!word) {
return word;
}
const encryptedHexStr = CryptoJS.enc.Hex.parse(word);
const srcs = CryptoJS.enc.Base64.stringify(encryptedHexStr);
const decrypt = CryptoJS.AES.decrypt(srcs, this.keyHex, {
iv: this.keyHex,
mode: CryptoJS.mode.CBC,
padding: CryptoJS.pad.ZeroPadding
});
const decryptedStr = decrypt.toString(CryptoJS.enc.Utf8);
return decryptedStr.toString();
}
}
const fxCry = new Crypoto();

View File

@ -0,0 +1,10 @@
{
"ver": "1.1.0",
"uuid": "771a3d9a-4013-4654-a777-fbaea0c93280",
"importer": "typescript",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,10 @@
{
"ver": "1.1.0",
"uuid": "e64e1a97-c93f-4257-ab34-80341d8ff79d",
"importer": "javascript",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}

Some files were not shown because too many files have changed in this diff Show More