Commit bf2127ca authored by Tt's avatar Tt

游戏完成

parent b0d610b9
...@@ -34,16 +34,16 @@ export default class NewClass extends cc.Component { ...@@ -34,16 +34,16 @@ export default class NewClass extends cc.Component {
private fishs: cc.Node[]; private fishs: cc.Node[];
gameStart() { gameStart() {
//游戏开始。允许出鱼 //游戏开始。允许出鱼
let page = Game.getIns().getCurrentPage(); // let page = Game.getIns().getCurrentPage();
let list = page.optionList.concat(); // let list = page.optionList.concat();
list = JSON.parse(JSON.stringify(list)); // list = JSON.parse(JSON.stringify(list));
list.sort((A, B) => { return Math.random() < 0.5 }); // list.sort((A, B) => { return Math.random() < 0.5 });
this.list = list; // this.list = list;
this.count = 0; // this.count = 0;
this.lastCount = null; // this.lastCount = null;
this.fishs = []; // this.fishs = [];
this.viewFishs = []; // this.viewFishs = [];
this.touchFishs = []; // this.touchFishs = [];
//根据顺序生成对应的鱼。 //根据顺序生成对应的鱼。
//顺序根据时间来进行跳动。当顺序跳动之后,就会产生新的鱼。 //顺序根据时间来进行跳动。当顺序跳动之后,就会产生新的鱼。
} }
......
...@@ -84,25 +84,25 @@ ...@@ -84,25 +84,25 @@
"__id__": 47 "__id__": 47
}, },
{ {
"__id__": 97 "__id__": 95
}, },
{ {
"__id__": 100 "__id__": 97
}, },
{ {
"__id__": 106 "__id__": 103
} }
], ],
"_active": true, "_active": true,
"_components": [ "_components": [
{ {
"__id__": 108 "__id__": 105
}, },
{ {
"__id__": 109 "__id__": 106
}, },
{ {
"__id__": 110 "__id__": 107
} }
], ],
"_prefab": null, "_prefab": null,
...@@ -2141,7 +2141,7 @@ ...@@ -2141,7 +2141,7 @@
}, },
{ {
"__type__": "cc.Node", "__type__": "cc.Node",
"_name": "layout_game", "_name": "layout_bottom",
"_objFlags": 0, "_objFlags": 0,
"_parent": { "_parent": {
"__id__": 2 "__id__": 2
...@@ -2149,72 +2149,9 @@ ...@@ -2149,72 +2149,9 @@
"_children": [ "_children": [
{ {
"__id__": 48 "__id__": 48
} },
],
"_active": true,
"_components": [
{
"__id__": 96
}
],
"_prefab": null,
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 1920,
"height": 1080
},
"_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": "b4AnDLfapILJ1Y08uyU1E0"
},
{
"__type__": "cc.Node",
"_name": "layout_fish",
"_objFlags": 0,
"_parent": {
"__id__": 47
},
"_children": [
{ {
"__id__": 49 "__id__": 77
}, },
{ {
"__id__": 78 "__id__": 78
...@@ -2227,9 +2164,6 @@ ...@@ -2227,9 +2164,6 @@
"_components": [ "_components": [
{ {
"__id__": 94 "__id__": 94
},
{
"__id__": 95
} }
], ],
"_prefab": null, "_prefab": null,
...@@ -2285,20 +2219,20 @@ ...@@ -2285,20 +2219,20 @@
"_name": "item", "_name": "item",
"_objFlags": 0, "_objFlags": 0,
"_parent": { "_parent": {
"__id__": 48 "__id__": 47
}, },
"_children": [ "_children": [
{ {
"__id__": 50 "__id__": 49
}, },
{ {
"__id__": 72 "__id__": 71
} }
], ],
"_active": true, "_active": true,
"_components": [ "_components": [
{ {
"__id__": 77 "__id__": 76
} }
], ],
"_prefab": null, "_prefab": null,
...@@ -2324,14 +2258,14 @@ ...@@ -2324,14 +2258,14 @@
"__type__": "TypedArray", "__type__": "TypedArray",
"ctor": "Float64Array", "ctor": "Float64Array",
"array": [ "array": [
-1617.697, 2496.038,
-412.29, -217.286,
0, 0,
0, 0,
0, 0,
0, 0,
1, 1,
-1, 1,
1, 1,
-1 -1
] ]
...@@ -2354,44 +2288,44 @@ ...@@ -2354,44 +2288,44 @@
"_name": "fish", "_name": "fish",
"_objFlags": 0, "_objFlags": 0,
"_parent": { "_parent": {
"__id__": 49 "__id__": 48
}, },
"_children": [ "_children": [
{ {
"__id__": 51 "__id__": 50
}, },
{ {
"__id__": 53 "__id__": 52
}, },
{ {
"__id__": 55 "__id__": 54
}, },
{ {
"__id__": 57 "__id__": 56
}, },
{ {
"__id__": 59 "__id__": 58
}, },
{ {
"__id__": 61 "__id__": 60
}, },
{ {
"__id__": 63 "__id__": 62
}, },
{ {
"__id__": 65 "__id__": 64
}, },
{ {
"__id__": 67 "__id__": 66
}, },
{ {
"__id__": 69 "__id__": 68
} }
], ],
"_active": true, "_active": true,
"_components": [ "_components": [
{ {
"__id__": 71 "__id__": 70
} }
], ],
"_prefab": null, "_prefab": null,
...@@ -2447,13 +2381,13 @@ ...@@ -2447,13 +2381,13 @@
"_name": "fish_1", "_name": "fish_1",
"_objFlags": 0, "_objFlags": 0,
"_parent": { "_parent": {
"__id__": 50 "__id__": 49
}, },
"_children": [], "_children": [],
"_active": true, "_active": true,
"_components": [ "_components": [
{ {
"__id__": 52 "__id__": 51
} }
], ],
"_prefab": null, "_prefab": null,
...@@ -2509,7 +2443,7 @@ ...@@ -2509,7 +2443,7 @@
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 51 "__id__": 50
}, },
"_enabled": true, "_enabled": true,
"_materials": [ "_materials": [
...@@ -2549,13 +2483,13 @@ ...@@ -2549,13 +2483,13 @@
"_name": "fish_2", "_name": "fish_2",
"_objFlags": 0, "_objFlags": 0,
"_parent": { "_parent": {
"__id__": 50 "__id__": 49
}, },
"_children": [], "_children": [],
"_active": true, "_active": false,
"_components": [ "_components": [
{ {
"__id__": 54 "__id__": 53
} }
], ],
"_prefab": null, "_prefab": null,
...@@ -2611,7 +2545,7 @@ ...@@ -2611,7 +2545,7 @@
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 53 "__id__": 52
}, },
"_enabled": true, "_enabled": true,
"_materials": [ "_materials": [
...@@ -2651,13 +2585,13 @@ ...@@ -2651,13 +2585,13 @@
"_name": "fish_3", "_name": "fish_3",
"_objFlags": 0, "_objFlags": 0,
"_parent": { "_parent": {
"__id__": 50 "__id__": 49
}, },
"_children": [], "_children": [],
"_active": true, "_active": false,
"_components": [ "_components": [
{ {
"__id__": 56 "__id__": 55
} }
], ],
"_prefab": null, "_prefab": null,
...@@ -2713,7 +2647,7 @@ ...@@ -2713,7 +2647,7 @@
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 55 "__id__": 54
}, },
"_enabled": true, "_enabled": true,
"_materials": [ "_materials": [
...@@ -2753,13 +2687,13 @@ ...@@ -2753,13 +2687,13 @@
"_name": "fish_4", "_name": "fish_4",
"_objFlags": 0, "_objFlags": 0,
"_parent": { "_parent": {
"__id__": 50 "__id__": 49
}, },
"_children": [], "_children": [],
"_active": true, "_active": false,
"_components": [ "_components": [
{ {
"__id__": 58 "__id__": 57
} }
], ],
"_prefab": null, "_prefab": null,
...@@ -2815,7 +2749,7 @@ ...@@ -2815,7 +2749,7 @@
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 57 "__id__": 56
}, },
"_enabled": true, "_enabled": true,
"_materials": [ "_materials": [
...@@ -2855,13 +2789,13 @@ ...@@ -2855,13 +2789,13 @@
"_name": "fish_5", "_name": "fish_5",
"_objFlags": 0, "_objFlags": 0,
"_parent": { "_parent": {
"__id__": 50 "__id__": 49
}, },
"_children": [], "_children": [],
"_active": true, "_active": false,
"_components": [ "_components": [
{ {
"__id__": 60 "__id__": 59
} }
], ],
"_prefab": null, "_prefab": null,
...@@ -2917,7 +2851,7 @@ ...@@ -2917,7 +2851,7 @@
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 59 "__id__": 58
}, },
"_enabled": true, "_enabled": true,
"_materials": [ "_materials": [
...@@ -2957,13 +2891,13 @@ ...@@ -2957,13 +2891,13 @@
"_name": "fish_6", "_name": "fish_6",
"_objFlags": 0, "_objFlags": 0,
"_parent": { "_parent": {
"__id__": 50 "__id__": 49
}, },
"_children": [], "_children": [],
"_active": true, "_active": false,
"_components": [ "_components": [
{ {
"__id__": 62 "__id__": 61
} }
], ],
"_prefab": null, "_prefab": null,
...@@ -3019,7 +2953,7 @@ ...@@ -3019,7 +2953,7 @@
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 61 "__id__": 60
}, },
"_enabled": true, "_enabled": true,
"_materials": [ "_materials": [
...@@ -3059,13 +2993,13 @@ ...@@ -3059,13 +2993,13 @@
"_name": "fish_7", "_name": "fish_7",
"_objFlags": 0, "_objFlags": 0,
"_parent": { "_parent": {
"__id__": 50 "__id__": 49
}, },
"_children": [], "_children": [],
"_active": true, "_active": false,
"_components": [ "_components": [
{ {
"__id__": 64 "__id__": 63
} }
], ],
"_prefab": null, "_prefab": null,
...@@ -3121,7 +3055,7 @@ ...@@ -3121,7 +3055,7 @@
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 63 "__id__": 62
}, },
"_enabled": true, "_enabled": true,
"_materials": [ "_materials": [
...@@ -3161,13 +3095,13 @@ ...@@ -3161,13 +3095,13 @@
"_name": "fish_8", "_name": "fish_8",
"_objFlags": 0, "_objFlags": 0,
"_parent": { "_parent": {
"__id__": 50 "__id__": 49
}, },
"_children": [], "_children": [],
"_active": true, "_active": false,
"_components": [ "_components": [
{ {
"__id__": 66 "__id__": 65
} }
], ],
"_prefab": null, "_prefab": null,
...@@ -3223,7 +3157,7 @@ ...@@ -3223,7 +3157,7 @@
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 65 "__id__": 64
}, },
"_enabled": true, "_enabled": true,
"_materials": [ "_materials": [
...@@ -3263,13 +3197,13 @@ ...@@ -3263,13 +3197,13 @@
"_name": "fish_9", "_name": "fish_9",
"_objFlags": 0, "_objFlags": 0,
"_parent": { "_parent": {
"__id__": 50 "__id__": 49
}, },
"_children": [], "_children": [],
"_active": true, "_active": false,
"_components": [ "_components": [
{ {
"__id__": 68 "__id__": 67
} }
], ],
"_prefab": null, "_prefab": null,
...@@ -3325,7 +3259,7 @@ ...@@ -3325,7 +3259,7 @@
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 67 "__id__": 66
}, },
"_enabled": true, "_enabled": true,
"_materials": [ "_materials": [
...@@ -3365,13 +3299,13 @@ ...@@ -3365,13 +3299,13 @@
"_name": "fish_10", "_name": "fish_10",
"_objFlags": 0, "_objFlags": 0,
"_parent": { "_parent": {
"__id__": 50 "__id__": 49
}, },
"_children": [], "_children": [],
"_active": true, "_active": false,
"_components": [ "_components": [
{ {
"__id__": 70 "__id__": 69
} }
], ],
"_prefab": null, "_prefab": null,
...@@ -3427,7 +3361,7 @@ ...@@ -3427,7 +3361,7 @@
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 69 "__id__": 68
}, },
"_enabled": true, "_enabled": true,
"_materials": [ "_materials": [
...@@ -3467,7 +3401,7 @@ ...@@ -3467,7 +3401,7 @@
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 50 "__id__": 49
}, },
"_enabled": false, "_enabled": false,
"_materials": [ "_materials": [
...@@ -3499,14 +3433,14 @@ ...@@ -3499,14 +3433,14 @@
"_name": "layout_text", "_name": "layout_text",
"_objFlags": 0, "_objFlags": 0,
"_parent": { "_parent": {
"__id__": 49 "__id__": 48
}, },
"_children": [ "_children": [
{ {
"__id__": 73 "__id__": 72
}, },
{ {
"__id__": 75 "__id__": 74
} }
], ],
"_active": true, "_active": true,
...@@ -3564,13 +3498,13 @@ ...@@ -3564,13 +3498,13 @@
"_name": "bg", "_name": "bg",
"_objFlags": 0, "_objFlags": 0,
"_parent": { "_parent": {
"__id__": 72 "__id__": 71
}, },
"_children": [], "_children": [],
"_active": true, "_active": true,
"_components": [ "_components": [
{ {
"__id__": 74 "__id__": 73
} }
], ],
"_prefab": null, "_prefab": null,
...@@ -3626,7 +3560,7 @@ ...@@ -3626,7 +3560,7 @@
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 73 "__id__": 72
}, },
"_enabled": true, "_enabled": true,
"_materials": [ "_materials": [
...@@ -3658,13 +3592,13 @@ ...@@ -3658,13 +3592,13 @@
"_name": "text", "_name": "text",
"_objFlags": 0, "_objFlags": 0,
"_parent": { "_parent": {
"__id__": 72 "__id__": 71
}, },
"_children": [], "_children": [],
"_active": true, "_active": true,
"_components": [ "_components": [
{ {
"__id__": 76 "__id__": 75
} }
], ],
"_prefab": null, "_prefab": null,
...@@ -3697,7 +3631,7 @@ ...@@ -3697,7 +3631,7 @@
0, 0,
0, 0,
1, 1,
-1, 1,
1, 1,
1 1
] ]
...@@ -3720,7 +3654,7 @@ ...@@ -3720,7 +3654,7 @@
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 75 "__id__": 74
}, },
"_enabled": true, "_enabled": true,
"_materials": [ "_materials": [
...@@ -3755,7 +3689,7 @@ ...@@ -3755,7 +3689,7 @@
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 49 "__id__": 48
}, },
"_enabled": true, "_enabled": true,
"_normalMaterial": null, "_normalMaterial": null,
...@@ -3816,16 +3750,74 @@ ...@@ -3816,16 +3750,74 @@
"hoverSprite": null, "hoverSprite": null,
"_N$disabledSprite": null, "_N$disabledSprite": null,
"_N$target": { "_N$target": {
"__id__": 49 "__id__": 48
}, },
"_id": "a1Avh4LwBKJKeCLMrv0hnM" "_id": "a1Avh4LwBKJKeCLMrv0hnM"
}, },
{
"__type__": "cc.Node",
"_name": "layout_fish",
"_objFlags": 0,
"_parent": {
"__id__": 47
},
"_children": [],
"_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.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": "caaErGNFxPurtCNQ5sRy6I"
},
{ {
"__type__": "cc.Node", "__type__": "cc.Node",
"_name": "boat_left", "_name": "boat_left",
"_objFlags": 0, "_objFlags": 0,
"_parent": { "_parent": {
"__id__": 48 "__id__": 47
}, },
"_children": [ "_children": [
{ {
...@@ -4207,7 +4199,7 @@ ...@@ -4207,7 +4199,7 @@
"_name": "boat_right", "_name": "boat_right",
"_objFlags": 0, "_objFlags": 0,
"_parent": { "_parent": {
"__id__": 48 "__id__": 47
}, },
"_children": [ "_children": [
{ {
...@@ -4584,29 +4576,12 @@ ...@@ -4584,29 +4576,12 @@
"_width": 2, "_width": 2,
"_id": "b7Q6RcacJHWZZ4dQ5k5qe+" "_id": "b7Q6RcacJHWZZ4dQ5k5qe+"
}, },
{
"__type__": "e9a1cwEffdJ+ol4mfn0p1aL",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 48
},
"_enabled": true,
"res": {
"__id__": 5
},
"item_left": {
"__id__": 49
},
"item_right": null,
"_id": "df0dbbmsVPMLnMZFIH2QVh"
},
{ {
"__type__": "cc.Widget", "__type__": "cc.Widget",
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 48 "__id__": 47
}, },
"_enabled": true, "_enabled": true,
"alignMode": 1, "alignMode": 1,
...@@ -4628,33 +4603,6 @@ ...@@ -4628,33 +4603,6 @@
"_originalHeight": 0, "_originalHeight": 0,
"_id": "7dsgeOVm5HnrVH1WWwgMG8" "_id": "7dsgeOVm5HnrVH1WWwgMG8"
}, },
{
"__type__": "cc.Widget",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 47
},
"_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": 1334,
"_originalHeight": 750,
"_id": "85BR1R+35OZJ/Dl7ReJRJM"
},
{ {
"__type__": "cc.Node", "__type__": "cc.Node",
"_name": "layout_info", "_name": "layout_info",
...@@ -4666,10 +4614,7 @@ ...@@ -4666,10 +4614,7 @@
"_active": true, "_active": true,
"_components": [ "_components": [
{ {
"__id__": 98 "__id__": 96
},
{
"__id__": 99
} }
], ],
"_prefab": null, "_prefab": null,
...@@ -4720,24 +4665,12 @@ ...@@ -4720,24 +4665,12 @@
"groupIndex": 0, "groupIndex": 0,
"_id": "b65SPsnIVFdZmVHWO91cRI" "_id": "b65SPsnIVFdZmVHWO91cRI"
}, },
{
"__type__": "94948HWpi5ATq3UuUa0CD0U",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 97
},
"_enabled": true,
"label": null,
"text": "hello",
"_id": "16odXUd6lP1YqbaINHYfnR"
},
{ {
"__type__": "cc.Widget", "__type__": "cc.Widget",
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 97 "__id__": 95
}, },
"_enabled": true, "_enabled": true,
"alignMode": 1, "alignMode": 1,
...@@ -4768,16 +4701,16 @@ ...@@ -4768,16 +4701,16 @@
}, },
"_children": [ "_children": [
{ {
"__id__": 101 "__id__": 98
}, },
{ {
"__id__": 103 "__id__": 100
} }
], ],
"_active": false, "_active": false,
"_components": [ "_components": [
{ {
"__id__": 105 "__id__": 102
} }
], ],
"_prefab": null, "_prefab": null,
...@@ -4833,13 +4766,13 @@ ...@@ -4833,13 +4766,13 @@
"_name": "touch", "_name": "touch",
"_objFlags": 0, "_objFlags": 0,
"_parent": { "_parent": {
"__id__": 100 "__id__": 97
}, },
"_children": [], "_children": [],
"_active": true, "_active": true,
"_components": [ "_components": [
{ {
"__id__": 102 "__id__": 99
} }
], ],
"_prefab": null, "_prefab": null,
...@@ -4895,7 +4828,7 @@ ...@@ -4895,7 +4828,7 @@
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 101 "__id__": 98
}, },
"_enabled": true, "_enabled": true,
"_normalMaterial": null, "_normalMaterial": null,
...@@ -4963,13 +4896,13 @@ ...@@ -4963,13 +4896,13 @@
"_name": "label", "_name": "label",
"_objFlags": 0, "_objFlags": 0,
"_parent": { "_parent": {
"__id__": 100 "__id__": 97
}, },
"_children": [], "_children": [],
"_active": true, "_active": true,
"_components": [ "_components": [
{ {
"__id__": 104 "__id__": 101
} }
], ],
"_prefab": null, "_prefab": null,
...@@ -5025,7 +4958,7 @@ ...@@ -5025,7 +4958,7 @@
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 103 "__id__": 100
}, },
"_enabled": true, "_enabled": true,
"_materials": [ "_materials": [
...@@ -5058,7 +4991,7 @@ ...@@ -5058,7 +4991,7 @@
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 100 "__id__": 97
}, },
"_enabled": true, "_enabled": true,
"_materials": [ "_materials": [
...@@ -5096,7 +5029,7 @@ ...@@ -5096,7 +5029,7 @@
"_active": false, "_active": false,
"_components": [ "_components": [
{ {
"__id__": 107 "__id__": 104
} }
], ],
"_prefab": null, "_prefab": null,
...@@ -5152,7 +5085,7 @@ ...@@ -5152,7 +5085,7 @@
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 106 "__id__": 103
}, },
"_enabled": true, "_enabled": true,
"_materials": [ "_materials": [
......
import { asyncDelay, onHomeworkFinish } from "../script/util"; import { asyncDelay, onHomeworkFinish } from "../script/util";
import { MyCocosSceneComponent } from "../script/MyCocosSceneComponent"; import { MyCocosSceneComponent } from "../script/MyCocosSceneComponent";
import Game, { GAME_STATE } from "./tool/Game"; import Game, { GAME_STATE, Option } from "./tool/Game";
import pg from "./tool/pg"; import pg from "./tool/pg";
const { ccclass, property } = cc._decorator; const { ccclass, property } = cc._decorator;
...@@ -29,7 +29,7 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -29,7 +29,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
this.initView(); this.initView();
this.initEvent(); this.initEvent();
this.log("statr!!!!!!!!!!!!!") this.log("statr!!!!!!!!!!!!!")
this.scheduleOnce(() => { pg.event.emit("game_start") }, 0.5); this.gameStart()
} }
protected onDestroy(): void { protected onDestroy(): void {
pg.event.clear(); pg.event.clear();
...@@ -43,11 +43,13 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -43,11 +43,13 @@ export default class SceneComponent extends MyCocosSceneComponent {
this._cantouch = true; this._cantouch = true;
} }
private audioId: any; private audioId: any;
async initView() { } async initView() {
let boat_left = pg.view.find(this, 'layout_bottom/boat_left')
let boat_right = pg.view.find(this, 'layout_bottom/boat_right')
pg.view.setString(pg.view.find(boat_left, 'text'), Game.getIns().boatLeft.text)
pg.view.setString(pg.view.find(boat_right, 'text'), Game.getIns().boatRight.text)
}
initEvent() { initEvent() {
pg.event.on("game_start", () => {
this.gameStart();
})
pg.event.on("game_time_over", () => { pg.event.on("game_time_over", () => {
// alert("game_time_over") // alert("game_time_over")
//这里的事件会发送的很早。但是我们需要等待动画执行完了之后再开始后续的内容 //这里的事件会发送的很早。但是我们需要等待动画执行完了之后再开始后续的内容
...@@ -63,16 +65,144 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -63,16 +65,144 @@ export default class SceneComponent extends MyCocosSceneComponent {
pg.audio.playLocalAudio(cc.find(`Canvas/res/audio/btn`)); pg.audio.playLocalAudio(cc.find(`Canvas/res/audio/btn`));
if (this.audioId > -1) { if (this.audioId > -1) {
cc.audioEngine.stopAllEffects(); cc.audioEngine.stopAllEffects();
// pg.audio.stopAudio(this.audioId);
} }
Game.getIns().state = GAME_STATE.RUNNING; Game.getIns().state = GAME_STATE.RUNNING;
//游戏开始小鱼出现等等 this.initFishs();
if (this.audioId > -1 && Game.getIns().state != GAME_STATE.WAIT) { }
cc.audioEngine.stopAllEffects(); initFishs() {
// pg.audio.stopAudio(this.audioId); // 出现鱼
let fishList = Game.getIns().getFishList();
let layout_fish = pg.view.find(this, 'layout_bottom/layout_fish')
let item = pg.view.find(this, 'layout_bottom/item')
fishList.forEach((fish, index) => {
let node = cc.instantiate(item);
layout_fish.addChild(node);
this.updateItem(node, fish);
});
}
updateItem(item, data: Option) {
item.data = data;
console.log(data);
let text = pg.view.find(item, 'layout_text/text')
pg.view.setString(text, data.txt)
let count = data.id % 10 + 1;
for (let i = 1; i <= 10; i++) {
let fishNode = pg.view.find(item, `fish/fish_${i}`)
fishNode.active = i == count
} }
//左往右
if (Math.random() < 0.5) {
item.x = -(1920 / 2 + Math.random() * 200)
item.y = -315 - Math.random() * 150;
item.scaleX = -1;
text.scaleX = -1;
cc.tween(item).repeatForever(cc.tween().by(7 + Math.random() * 8, { x: 1920 + 400 }).call(() => {
item.scaleX = -item.scaleX;
text.scaleX = -text.scaleX;
}).by(7 + Math.random() * 8, { x: - 1920 - 400 }).call(() => {
item.scaleX = -item.scaleX;
text.scaleX = -text.scaleX;
})).start();
} else {
item.x = 1920 / 2 + Math.random() * 200
item.y = -315 - Math.random() * 150;
item.scaleX = 1;
text.scaleX = 1;
cc.tween(item).repeatForever(cc.tween().by(7 + Math.random() * 8, { x: -1920 - 400 }).call(() => {
item.scaleX = -item.scaleX;
text.scaleX = -text.scaleX;
}).by(7 + Math.random() * 8, { x: 1920 + 400 }).call(() => {
item.scaleX = -item.scaleX;
text.scaleX = -text.scaleX;
})).start();
}
item.on(cc.Node.EventType.TOUCH_START, this.onItemTouchStart, this);
item.on(cc.Node.EventType.TOUCH_MOVE, this.onItemTouchMove, this);
item.on(cc.Node.EventType.TOUCH_END, this.onItemTouchEnd, this);
item.on(cc.Node.EventType.TOUCH_CANCEL, this.onItemTouchCancel, this);
}
onTouchItem(e) {
let item = e.target;
let data = item.data;
item.x = 0;
item.y = 0;
cc.Tween.stopAllByTarget(item);
setTimeout(() => {
this.updateItem(item, data);
}, 100);
}
private setTouchPos(e) {
let item = e.target;
let location = e.getLocation();
cc.Tween.stopAllByTarget(item);
let pos = location.sub(cc.v2(1920 / 2, 1080 / 2));
item.x = pos.x;
item.y = pos.y;
} }
onItemTouchStart(e) {
let target: cc.Node = e.target;
let data = target.data;
if (data.isChecked) return;
this.setTouchPos(e);
}
onItemTouchMove(e) {
let target: cc.Node = e.target;
let data = target.data;
if (data.isChecked) return;
this.setTouchPos(e);
}
onItemTouchEnd(e) {
//
let target: cc.Node = e.target;
let data = target.data;
if (data.isChecked) return;
// let rect = cc.rect(target.x, target.y, target.width, target.height);
let rect = cc.rect(target.x, target.y, 50, 50);
let boat_left = pg.view.find(this, 'layout_bottom/boat_left')
let boat_right = pg.view.find(this, 'layout_bottom/boat_right')
let leftRect = cc.rect(boat_left.x - boat_left.width / 2, boat_left.y - boat_left.height / 2, boat_left.width, boat_left.height);
let rightRect = cc.rect(boat_right.x - boat_right.width / 2, boat_right.y - boat_right.height / 2, boat_right.width, boat_right.height);
let isRight = false;
let currentRect = null;
if (rect.intersects(leftRect)) {
isRight = !!Game.getIns().boatLeft.isChild(data);
Game.getIns().boatLeft.setRight(data);
currentRect = leftRect;
} else if (rect.intersects(rightRect)) {
isRight = !!Game.getIns().boatRight.isChild(data);
Game.getIns().boatRight.setRight(data);
currentRect = rightRect;
}
if (isRight) {
// target
let item = target;
let lastArea = 100;
if (item.scaleX == -1) {
// 计算当前坐标距离最左侧的距离
let space = currentRect.width - ((rect.x + rect.width) - currentRect.x) - lastArea / 5;
let time = space / 10;
cc.tween(item).by(time, { x: space }).start();
} else {
// 计算当前坐标距离最左侧的距离
let space = rect.x - currentRect.x - lastArea;
let time = space / 10;
cc.tween(item).by(time, { x: -space }).start();
}
} else {
this.updateItem(target, data);
}
//判断是否结束了
if (Game.getIns().boatLeft.isAllRight() && Game.getIns().boatRight.isAllRight()) {
this.showGameOver();
}
}
onItemTouchCancel() {
}
private showGameOver() { private showGameOver() {
let gameover = cc.find("gameover", this.node); let gameover = cc.find("gameover", this.node);
gameover.scale = 3; gameover.scale = 3;
......
...@@ -41,8 +41,10 @@ export class Item { ...@@ -41,8 +41,10 @@ export class Item {
private static ID: number = 1000; private static ID: number = 1000;
public audio: string; public audio: string;
public text: string; public text: string;
public optionList; public optionList: Array<Option>;
public rightList: Array<Option>;
constructor(data) { constructor(data) {
this.rightList = []
this.audio = data.audio; this.audio = data.audio;
this.text = data.text; this.text = data.text;
this.optionList = data.options.map(o => { this.optionList = data.options.map(o => {
...@@ -55,7 +57,15 @@ export class Item { ...@@ -55,7 +57,15 @@ export class Item {
for (let i = 0; i < this.optionList.length; i++) { for (let i = 0; i < this.optionList.length; i++) {
this.optionList[i].count = i; this.optionList[i].count = i;
} }
}
isChild(data) {
return this.optionList.find(option => option.id == data.id)
}
setRight(data) {
this.rightList.push(data);
}
isAllRight() {
return this.optionList.length == this.rightList.length;
} }
} }
class Role { class Role {
...@@ -112,8 +122,8 @@ export default class Game { ...@@ -112,8 +122,8 @@ export default class Game {
this.data = data.questions; this.data = data.questions;
} }
public start: boolean; public start: boolean;
private boatLeft: Item; public boatLeft: Item;
private boatRight: Item; public boatRight: Item;
reset() { reset() {
this.player.reset(); this.player.reset();
this.start = true; this.start = true;
...@@ -122,24 +132,20 @@ export default class Game { ...@@ -122,24 +132,20 @@ export default class Game {
this.boatRight = new Item(this.data[1]); this.boatRight = new Item(this.data[1]);
this.state = GAME_STATE.WAIT; this.state = GAME_STATE.WAIT;
} }
checkSuccess(arr: Option[]) { getFishList() {
let data = this.getCurrentPage(); return this.boatLeft.optionList.concat(this.boatRight.optionList)
let options = data.optionList.concat();
options.sort((A, B) => A.id - B.id)
for (let i = 0; i < options.length; i++) {
if (arr[i] && arr[i].id != options[i].id) {
return false;
}
}
return true;
} }
getCurrentPage(): Item { checkSuccess(arr: Option[]) {
if (!this.lists) return null; return false;
} // let data = this.getCurrentPage();
getTotalPageNum() { // let options = data.optionList.concat();
return this.lists.length; // options.sort((A, B) => A.id - B.id)
} // for (let i = 0; i < options.length; i++) {
getCurrentPageNum() { // if (arr[i] && arr[i].id != options[i].id) {
// return false;
// }
// }
// return true;
} }
addPage() { addPage() {
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment