Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
ngt7_fish
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
template admin
ngt7_fish
Commits
bf2127ca
Commit
bf2127ca
authored
Oct 23, 2022
by
Tt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
游戏完成
parent
b0d610b9
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
334 additions
and
265 deletions
+334
-265
layout_fish.ts
assets/gofishing/scene/game/layout_fish.ts
+10
-10
gofishing.fire
assets/gofishing/scene/gofishing.fire
+155
-222
gofishing.ts
assets/gofishing/scene/gofishing.ts
+142
-12
Game.ts
assets/gofishing/scene/tool/Game.ts
+27
-21
No files found.
assets/gofishing/scene/game/layout_fish.ts
View file @
bf2127ca
...
...
@@ -34,16 +34,16 @@ export default class NewClass extends cc.Component {
private
fishs
:
cc
.
Node
[];
gameStart
()
{
//游戏开始。允许出鱼
let
page
=
Game
.
getIns
().
getCurrentPage
();
let
list
=
page
.
optionList
.
concat
();
list
=
JSON
.
parse
(
JSON
.
stringify
(
list
));
list
.
sort
((
A
,
B
)
=>
{
return
Math
.
random
()
<
0.5
});
this
.
list
=
list
;
this
.
count
=
0
;
this
.
lastCount
=
null
;
this
.
fishs
=
[];
this
.
viewFishs
=
[];
this
.
touchFishs
=
[];
//
let page = Game.getIns().getCurrentPage();
//
let list = page.optionList.concat();
//
list = JSON.parse(JSON.stringify(list));
//
list.sort((A, B) => { return Math.random() < 0.5 });
//
this.list = list;
//
this.count = 0;
//
this.lastCount = null;
//
this.fishs = [];
//
this.viewFishs = [];
//
this.touchFishs = [];
//根据顺序生成对应的鱼。
//顺序根据时间来进行跳动。当顺序跳动之后,就会产生新的鱼。
}
...
...
assets/gofishing/scene/gofishing.fire
View file @
bf2127ca
...
...
@@ -84,25 +84,25 @@
"__id__": 47
},
{
"__id__": 9
7
"__id__": 9
5
},
{
"__id__":
100
"__id__":
97
},
{
"__id__": 10
6
"__id__": 10
3
}
],
"_active": true,
"_components": [
{
"__id__": 10
8
"__id__": 10
5
},
{
"__id__": 10
9
"__id__": 10
6
},
{
"__id__": 1
10
"__id__": 1
07
}
],
"_prefab": null,
...
...
@@ -2141,7 +2141,7 @@
},
{
"__type__": "cc.Node",
"_name": "layout_
game
",
"_name": "layout_
bottom
",
"_objFlags": 0,
"_parent": {
"__id__": 2
...
...
@@ -2149,72 +2149,9 @@
"_children": [
{
"__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
...
...
@@ -2227,9 +2164,6 @@
"_components": [
{
"__id__": 94
},
{
"__id__": 95
}
],
"_prefab": null,
...
...
@@ -2285,20 +2219,20 @@
"_name": "item",
"_objFlags": 0,
"_parent": {
"__id__": 4
8
"__id__": 4
7
},
"_children": [
{
"__id__":
50
"__id__":
49
},
{
"__id__": 7
2
"__id__": 7
1
}
],
"_active": true,
"_components": [
{
"__id__": 7
7
"__id__": 7
6
}
],
"_prefab": null,
...
...
@@ -2324,14 +2258,14 @@
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
-1617.697
,
-
412.29
,
2496.038
,
-
217.286
,
0,
0,
0,
0,
1,
-
1,
1,
1,
-1
]
...
...
@@ -2354,44 +2288,44 @@
"_name": "fish",
"_objFlags": 0,
"_parent": {
"__id__": 4
9
"__id__": 4
8
},
"_children": [
{
"__id__": 5
1
"__id__": 5
0
},
{
"__id__": 5
3
"__id__": 5
2
},
{
"__id__": 5
5
"__id__": 5
4
},
{
"__id__": 5
7
"__id__": 5
6
},
{
"__id__": 5
9
"__id__": 5
8
},
{
"__id__": 6
1
"__id__": 6
0
},
{
"__id__": 6
3
"__id__": 6
2
},
{
"__id__": 6
5
"__id__": 6
4
},
{
"__id__": 6
7
"__id__": 6
6
},
{
"__id__": 6
9
"__id__": 6
8
}
],
"_active": true,
"_components": [
{
"__id__": 7
1
"__id__": 7
0
}
],
"_prefab": null,
...
...
@@ -2447,13 +2381,13 @@
"_name": "fish_1",
"_objFlags": 0,
"_parent": {
"__id__":
50
"__id__":
49
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 5
2
"__id__": 5
1
}
],
"_prefab": null,
...
...
@@ -2509,7 +2443,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 5
1
"__id__": 5
0
},
"_enabled": true,
"_materials": [
...
...
@@ -2549,13 +2483,13 @@
"_name": "fish_2",
"_objFlags": 0,
"_parent": {
"__id__":
50
"__id__":
49
},
"_children": [],
"_active":
tru
e,
"_active":
fals
e,
"_components": [
{
"__id__": 5
4
"__id__": 5
3
}
],
"_prefab": null,
...
...
@@ -2611,7 +2545,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 5
3
"__id__": 5
2
},
"_enabled": true,
"_materials": [
...
...
@@ -2651,13 +2585,13 @@
"_name": "fish_3",
"_objFlags": 0,
"_parent": {
"__id__":
50
"__id__":
49
},
"_children": [],
"_active":
tru
e,
"_active":
fals
e,
"_components": [
{
"__id__": 5
6
"__id__": 5
5
}
],
"_prefab": null,
...
...
@@ -2713,7 +2647,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 5
5
"__id__": 5
4
},
"_enabled": true,
"_materials": [
...
...
@@ -2753,13 +2687,13 @@
"_name": "fish_4",
"_objFlags": 0,
"_parent": {
"__id__":
50
"__id__":
49
},
"_children": [],
"_active":
tru
e,
"_active":
fals
e,
"_components": [
{
"__id__": 5
8
"__id__": 5
7
}
],
"_prefab": null,
...
...
@@ -2815,7 +2749,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 5
7
"__id__": 5
6
},
"_enabled": true,
"_materials": [
...
...
@@ -2855,13 +2789,13 @@
"_name": "fish_5",
"_objFlags": 0,
"_parent": {
"__id__":
50
"__id__":
49
},
"_children": [],
"_active":
tru
e,
"_active":
fals
e,
"_components": [
{
"__id__":
60
"__id__":
59
}
],
"_prefab": null,
...
...
@@ -2917,7 +2851,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 5
9
"__id__": 5
8
},
"_enabled": true,
"_materials": [
...
...
@@ -2957,13 +2891,13 @@
"_name": "fish_6",
"_objFlags": 0,
"_parent": {
"__id__":
50
"__id__":
49
},
"_children": [],
"_active":
tru
e,
"_active":
fals
e,
"_components": [
{
"__id__": 6
2
"__id__": 6
1
}
],
"_prefab": null,
...
...
@@ -3019,7 +2953,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 6
1
"__id__": 6
0
},
"_enabled": true,
"_materials": [
...
...
@@ -3059,13 +2993,13 @@
"_name": "fish_7",
"_objFlags": 0,
"_parent": {
"__id__":
50
"__id__":
49
},
"_children": [],
"_active":
tru
e,
"_active":
fals
e,
"_components": [
{
"__id__": 6
4
"__id__": 6
3
}
],
"_prefab": null,
...
...
@@ -3121,7 +3055,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 6
3
"__id__": 6
2
},
"_enabled": true,
"_materials": [
...
...
@@ -3161,13 +3095,13 @@
"_name": "fish_8",
"_objFlags": 0,
"_parent": {
"__id__":
50
"__id__":
49
},
"_children": [],
"_active":
tru
e,
"_active":
fals
e,
"_components": [
{
"__id__": 6
6
"__id__": 6
5
}
],
"_prefab": null,
...
...
@@ -3223,7 +3157,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 6
5
"__id__": 6
4
},
"_enabled": true,
"_materials": [
...
...
@@ -3263,13 +3197,13 @@
"_name": "fish_9",
"_objFlags": 0,
"_parent": {
"__id__":
50
"__id__":
49
},
"_children": [],
"_active":
tru
e,
"_active":
fals
e,
"_components": [
{
"__id__": 6
8
"__id__": 6
7
}
],
"_prefab": null,
...
...
@@ -3325,7 +3259,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 6
7
"__id__": 6
6
},
"_enabled": true,
"_materials": [
...
...
@@ -3365,13 +3299,13 @@
"_name": "fish_10",
"_objFlags": 0,
"_parent": {
"__id__":
50
"__id__":
49
},
"_children": [],
"_active":
tru
e,
"_active":
fals
e,
"_components": [
{
"__id__":
70
"__id__":
69
}
],
"_prefab": null,
...
...
@@ -3427,7 +3361,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 6
9
"__id__": 6
8
},
"_enabled": true,
"_materials": [
...
...
@@ -3467,7 +3401,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__":
50
"__id__":
49
},
"_enabled": false,
"_materials": [
...
...
@@ -3499,14 +3433,14 @@
"_name": "layout_text",
"_objFlags": 0,
"_parent": {
"__id__": 4
9
"__id__": 4
8
},
"_children": [
{
"__id__": 7
3
"__id__": 7
2
},
{
"__id__": 7
5
"__id__": 7
4
}
],
"_active": true,
...
...
@@ -3564,13 +3498,13 @@
"_name": "bg",
"_objFlags": 0,
"_parent": {
"__id__": 7
2
"__id__": 7
1
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 7
4
"__id__": 7
3
}
],
"_prefab": null,
...
...
@@ -3626,7 +3560,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 7
3
"__id__": 7
2
},
"_enabled": true,
"_materials": [
...
...
@@ -3658,13 +3592,13 @@
"_name": "text",
"_objFlags": 0,
"_parent": {
"__id__": 7
2
"__id__": 7
1
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 7
6
"__id__": 7
5
}
],
"_prefab": null,
...
...
@@ -3697,7 +3631,7 @@
0,
0,
1,
-
1,
1,
1,
1
]
...
...
@@ -3720,7 +3654,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 7
5
"__id__": 7
4
},
"_enabled": true,
"_materials": [
...
...
@@ -3755,7 +3689,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 4
9
"__id__": 4
8
},
"_enabled": true,
"_normalMaterial": null,
...
...
@@ -3816,16 +3750,74 @@
"hoverSprite": null,
"_N$disabledSprite": null,
"_N$target": {
"__id__": 4
9
"__id__": 4
8
},
"_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",
"_name": "boat_left",
"_objFlags": 0,
"_parent": {
"__id__": 4
8
"__id__": 4
7
},
"_children": [
{
...
...
@@ -4207,7 +4199,7 @@
"_name": "boat_right",
"_objFlags": 0,
"_parent": {
"__id__": 4
8
"__id__": 4
7
},
"_children": [
{
...
...
@@ -4584,29 +4576,12 @@
"_width": 2,
"_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",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 4
8
"__id__": 4
7
},
"_enabled": true,
"alignMode": 1,
...
...
@@ -4628,33 +4603,6 @@
"_originalHeight": 0,
"_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",
"_name": "layout_info",
...
...
@@ -4666,10 +4614,7 @@
"_active": true,
"_components": [
{
"__id__": 98
},
{
"__id__": 99
"__id__": 96
}
],
"_prefab": null,
...
...
@@ -4720,24 +4665,12 @@
"groupIndex": 0,
"_id": "b65SPsnIVFdZmVHWO91cRI"
},
{
"__type__": "94948HWpi5ATq3UuUa0CD0U",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 97
},
"_enabled": true,
"label": null,
"text": "hello",
"_id": "16odXUd6lP1YqbaINHYfnR"
},
{
"__type__": "cc.Widget",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 9
7
"__id__": 9
5
},
"_enabled": true,
"alignMode": 1,
...
...
@@ -4768,16 +4701,16 @@
},
"_children": [
{
"__id__":
101
"__id__":
98
},
{
"__id__": 10
3
"__id__": 10
0
}
],
"_active": false,
"_components": [
{
"__id__": 10
5
"__id__": 10
2
}
],
"_prefab": null,
...
...
@@ -4833,13 +4766,13 @@
"_name": "touch",
"_objFlags": 0,
"_parent": {
"__id__":
100
"__id__":
97
},
"_children": [],
"_active": true,
"_components": [
{
"__id__":
102
"__id__":
99
}
],
"_prefab": null,
...
...
@@ -4895,7 +4828,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__":
101
"__id__":
98
},
"_enabled": true,
"_normalMaterial": null,
...
...
@@ -4963,13 +4896,13 @@
"_name": "label",
"_objFlags": 0,
"_parent": {
"__id__":
100
"__id__":
97
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 10
4
"__id__": 10
1
}
],
"_prefab": null,
...
...
@@ -5025,7 +4958,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 10
3
"__id__": 10
0
},
"_enabled": true,
"_materials": [
...
...
@@ -5058,7 +4991,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__":
100
"__id__":
97
},
"_enabled": true,
"_materials": [
...
...
@@ -5096,7 +5029,7 @@
"_active": false,
"_components": [
{
"__id__": 10
7
"__id__": 10
4
}
],
"_prefab": null,
...
...
@@ -5152,7 +5085,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 10
6
"__id__": 10
3
},
"_enabled": true,
"_materials": [
...
...
assets/gofishing/scene/gofishing.ts
View file @
bf2127ca
import
{
asyncDelay
,
onHomeworkFinish
}
from
"
../script/util
"
;
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
"
;
const
{
ccclass
,
property
}
=
cc
.
_decorator
;
...
...
@@ -29,7 +29,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
this
.
initView
();
this
.
initEvent
();
this
.
log
(
"
statr!!!!!!!!!!!!!
"
)
this
.
scheduleOnce
(()
=>
{
pg
.
event
.
emit
(
"
game_start
"
)
},
0.5
);
this
.
gameStart
()
}
protected
onDestroy
():
void
{
pg
.
event
.
clear
();
...
...
@@ -43,11 +43,13 @@ export default class SceneComponent extends MyCocosSceneComponent {
this
.
_cantouch
=
true
;
}
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
()
{
pg
.
event
.
on
(
"
game_start
"
,
()
=>
{
this
.
gameStart
();
})
pg
.
event
.
on
(
"
game_time_over
"
,
()
=>
{
// alert("game_time_over")
//这里的事件会发送的很早。但是我们需要等待动画执行完了之后再开始后续的内容
...
...
@@ -63,16 +65,144 @@ export default class SceneComponent extends MyCocosSceneComponent {
pg
.
audio
.
playLocalAudio
(
cc
.
find
(
`Canvas/res/audio/btn`
));
if
(
this
.
audioId
>
-
1
)
{
cc
.
audioEngine
.
stopAllEffects
();
// pg.audio.stopAudio(this.audioId);
}
Game
.
getIns
().
state
=
GAME_STATE
.
RUNNING
;
//游戏开始小鱼出现等等
if
(
this
.
audioId
>
-
1
&&
Game
.
getIns
().
state
!=
GAME_STATE
.
WAIT
)
{
cc
.
audioEngine
.
stopAllEffects
();
// pg.audio.stopAudio(this.audioId);
this
.
initFishs
();
}
initFishs
()
{
// 出现鱼
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
()
{
let
gameover
=
cc
.
find
(
"
gameover
"
,
this
.
node
);
gameover
.
scale
=
3
;
...
...
assets/gofishing/scene/tool/Game.ts
View file @
bf2127ca
...
...
@@ -41,8 +41,10 @@ export class Item {
private
static
ID
:
number
=
1000
;
public
audio
:
string
;
public
text
:
string
;
public
optionList
;
public
optionList
:
Array
<
Option
>
;
public
rightList
:
Array
<
Option
>
;
constructor
(
data
)
{
this
.
rightList
=
[]
this
.
audio
=
data
.
audio
;
this
.
text
=
data
.
text
;
this
.
optionList
=
data
.
options
.
map
(
o
=>
{
...
...
@@ -55,7 +57,15 @@ export class Item {
for
(
let
i
=
0
;
i
<
this
.
optionList
.
length
;
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
{
...
...
@@ -112,8 +122,8 @@ export default class Game {
this
.
data
=
data
.
questions
;
}
public
start
:
boolean
;
p
rivate
boatLeft
:
Item
;
p
rivate
boatRight
:
Item
;
p
ublic
boatLeft
:
Item
;
p
ublic
boatRight
:
Item
;
reset
()
{
this
.
player
.
reset
();
this
.
start
=
true
;
...
...
@@ -122,24 +132,20 @@ export default class Game {
this
.
boatRight
=
new
Item
(
this
.
data
[
1
]);
this
.
state
=
GAME_STATE
.
WAIT
;
}
checkSuccess
(
arr
:
Option
[])
{
let
data
=
this
.
getCurrentPage
();
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
;
getFishList
()
{
return
this
.
boatLeft
.
optionList
.
concat
(
this
.
boatRight
.
optionList
)
}
getCurrentPage
():
Item
{
if
(
!
this
.
lists
)
return
null
;
}
getTotalPageNum
()
{
return
this
.
lists
.
length
;
}
getCurrentPageNum
()
{
checkSuccess
(
arr
:
Option
[])
{
return
false
;
// let data = this.getCurrentPage();
// 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;
}
addPage
()
{
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment