Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
D
db-game-template
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
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
崔立强
db-game-template
Commits
ef479ff3
Commit
ef479ff3
authored
Aug 15, 2021
by
Joker Huang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1
parent
651de262
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
480 additions
and
85 deletions
+480
-85
Game.ts
egret/src/playScene/Game/Game.ts
+434
-0
Templete.ts
egret/src/playScene/Game/Templete.ts
+0
-0
User.ts
egret/src/playScene/Game/User.ts
+0
-0
PlayScene.ts
egret/src/playScene/PlayScene.ts
+46
-81
StartScene.ts
egret/src/startScene/StartScene.ts
+0
-4
No files found.
egret/src/playScene/
prePlayScen
e.ts
→
egret/src/playScene/
Game/Gam
e.ts
View file @
ef479ff3
This diff is collapsed.
Click to expand it.
egret/src/playScene/Game/Templete.ts
0 → 100644
View file @
ef479ff3
egret/src/playScene/Game/User.ts
0 → 100644
View file @
ef479ff3
egret/src/playScene/PlayScene.ts
View file @
ef479ff3
import
{
DataManager
}
from
'./../../libs/tw/manager/DataManager'
;
import
prePlayScene
from
"./prePlayScen
e"
;
import
Game
from
"./Game/Gam
e"
;
import
PlaySceneBase
from
"../../libs/new_wx/components/PlaySceneBase"
;
import
PanelCtrl
from
"../../libs/new_wx/ctrls/panelCtrl"
;
import
{
ModuleTypes
}
from
"../../libs/new_wx/types/sceneTypes"
;
import
{
NetManager
}
from
"../../libs/tw/manager/NetManager"
;
const
BABYLON
=
window
[
'BABYLON'
];
const
{
TouchEvent
}
=
egret
;
export
default
class
PlayScene
extends
PlaySceneBase
{
public
get
skinKey
()
{
return
'Play'
}
...
...
@@ -15,98 +15,58 @@ export default class PlayScene extends PlaySceneBase{
public
scoreTxt
:
eui
.
Label
;
public
scoreTip
:
eui
.
Image
;
public
BABYLON
:
any
=
window
[
'BABYLON'
];
public
rocketP
:
any
;
public
rocketLine
:
any
;
public
score
:
number
=
0
;
// 分数
private
touchDown
:
boolean
;
// 是否点击屏幕
private
createCount
:
number
=
0
;
// 生成云的计数
gameNode
constructor
(){
super
()
this
.
restart
();
}
restart
(){
prePlayScene
.
instance
.
disposeAll
();
prePlayScene
.
instance
.
rocketP
.
position
.
y
=
10
;
prePlayScene
.
instance
.
lastY
=
0
;
prePlayScene
.
instance
.
maxDepth
=
0
;
prePlayScene
.
instance
.
startTimestamp
=
Date
.
now
();
prePlayScene
.
instance
.
initElementPool
()
this
.
addEventListener
(
egret
.
Event
.
ENTER_FRAME
,
this
.
onEnterFrame
,
this
);
}
private
onEnterFrame
(){
this
.
createCount
++
;
// 是否触控发生
if
(
this
.
touchDown
){
prePlayScene
.
instance
.
rotateSpeed
=
0.1
;
}
else
{
prePlayScene
.
instance
.
rotateSpeed
=
0
;
}
prePlayScene
.
instance
.
mainObj
.
rotation
.
y
-=
prePlayScene
.
instance
.
rotateSpeed
;
prePlayScene
.
instance
.
scene
.
render
();
prePlayScene
.
instance
.
accelerateByVector3
(
prePlayScene
.
instance
.
rocketP
,
new
this
.
BABYLON
.
Vector3
(
0
,
-
1
,
0
),
prePlayScene
.
instance
.
downSpeed
,
prePlayScene
.
instance
.
downAddSpeed
)
if
(
prePlayScene
.
instance
.
eleTemplatePool
.
length
>
0
){
if
(
prePlayScene
.
instance
.
rocketP
.
position
.
y
<
prePlayScene
.
instance
.
lastY
+
prePlayScene
.
instance
.
elementInterval
*
5
){
let
num
=
Math
.
min
(
Math
.
floor
(
Math
.
random
()
*
5
)
,
4
)
let
nEle
=
prePlayScene
.
instance
.
eleTemplatePool
[
num
].
clone
(
`element_
${
num
}
`
);
let
newAngle
=
Math
.
random
()
*
Math
.
PI
*
2
;
nEle
.
position
.
y
=
prePlayScene
.
instance
.
lastY
-
prePlayScene
.
instance
.
elementInterval
;
nEle
.
rotate
(
new
this
.
BABYLON
.
Vector3
(
0
,
1
,
0
),
newAngle
);
nEle
.
parent
=
prePlayScene
.
instance
.
mainObj
;
prePlayScene
.
instance
.
lastY
-=
prePlayScene
.
instance
.
elementInterval
;
prePlayScene
.
instance
.
nElePool
.
push
(
nEle
);
for
(
let
e
=
0
;
e
<
nEle
[
'_children'
].
length
;
e
++
){
let
element
=
nEle
[
'_children'
][
e
];
let
redEleNum
=
Math
.
min
(
Math
.
floor
(
Math
.
random
()
*
prePlayScene
.
instance
.
eleTemplatePool
.
length
)
,
prePlayScene
.
instance
.
eleTemplatePool
.
length
-
1
);
if
(
e
==
redEleNum
){
element
.
gameType
=
'redElement'
;
element
.
material
=
prePlayScene
.
instance
.
redMaterial
.
clone
();
}
element
.
visibility
=
1
;
prePlayScene
.
instance
.
elementPool
.
push
(
element
);
}
}
if
(
prePlayScene
.
instance
.
rocketP
.
position
.
y
<
prePlayScene
.
instance
.
maxDepth
){
if
(
Math
.
abs
(
prePlayScene
.
instance
.
rocketP
.
position
.
y
-
prePlayScene
.
instance
.
maxDepth
)
>
prePlayScene
.
instance
.
elementInterval
){
this
.
updateScore
(
1
);
prePlayScene
.
instance
.
maxDepth
=
prePlayScene
.
instance
.
rocketP
.
position
.
y
;
}
}
}
// 碰撞检测
for
(
let
element
of
prePlayScene
.
instance
.
elementPool
){
if
(
element
.
intersectsMesh
(
prePlayScene
.
instance
.
realRocket
,
true
))
{
console
.
log
(
1
)
if
(
element
.
gameType
==
'redElement'
){
// 撞到了黑云 游戏结束
this
.
gameOver
();
}
else
{
// 如果碰到了就让速度反向
prePlayScene
.
instance
.
downSpeed
=
-
0.5
;
prePlayScene
.
instance
.
startTimestamp
=
Date
.
now
()
//
}
}
else
{
}
let
config
=
{
sps
:[{
depth
:
5
,
fall
:
5
},{
depth
:
35
,
fall
:
5
},{
depth
:
55
,
fall
:
5
},{
depth
:
65
,
fall
:
5
}],
beyondFriends
:
[{
score
:
5
,
id
:
1
},
{
score
:
15
,
id
:
2
},
{
score
:
25
,
id
:
3
},
{
score
:
35
,
id
:
4
}]
}
this
.
gameNode
=
new
Game
(
config
)
}
initEvents
()
{
this
.
touchPlane
.
addEventListener
(
egret
.
TouchEvent
.
TOUCH_BEGIN
,
this
.
onTouchBegin_touchPlane
,
this
);
this
.
touchPlane
.
addEventListener
(
egret
.
TouchEvent
.
TOUCH_END
,
this
.
onTouchOut_touchPlane
,
this
);
this
.
touchPlane
.
addEventListener
(
egret
.
TouchEvent
.
TOUCH_CANCEL
,
this
.
onTouchOut_touchPlane
,
this
);
this
.
touchPlane
.
addEventListener
(
egret
.
TouchEvent
.
TOUCH_RELEASE_OUTSIDE
,
this
.
onTouchOut_touchPlane
,
this
);
this
.
addEventListener
(
egret
.
Event
.
ENTER_FRAME
,
this
.
onEnterFrame
,
this
);
}
removeEvents
()
{
...
...
@@ -114,18 +74,22 @@ export default class PlayScene extends PlaySceneBase{
this
.
touchPlane
.
removeEventListener
(
egret
.
TouchEvent
.
TOUCH_END
,
this
.
onTouchOut_touchPlane
,
this
);
this
.
touchPlane
.
removeEventListener
(
egret
.
TouchEvent
.
TOUCH_CANCEL
,
this
.
onTouchOut_touchPlane
,
this
);
this
.
touchPlane
.
removeEventListener
(
egret
.
TouchEvent
.
TOUCH_RELEASE_OUTSIDE
,
this
.
onTouchOut_touchPlane
,
this
);
this
.
removeEventListener
(
egret
.
Event
.
ENTER_FRAME
,
this
.
onEnterFrame
,
this
);
}
onEnterFrame
(){
this
.
gameNode
?.
scene
?.
render
()
}
private
onTouchBegin_touchPlane
(
e
:
egret
.
TouchEvent
){
this
.
touchDown
=
true
;
this
.
gameNode
&&
(
this
.
gameNode
.
touchDown
=
true
)
;
}
private
onTouchOut_touchPlane
(
e
:
egret
.
TouchEvent
){
this
.
touchDown
=
false
;
this
.
gameNode
&&
(
this
.
gameNode
.
touchDown
=
false
)
;
}
gameOver
(){
this
.
removeEventListener
(
egret
.
Event
.
ENTER_FRAME
,
this
.
onEnterFrame
,
this
);
this
.
removeEventListener
(
egret
.
Event
.
ENTER_FRAME
,
this
.
gameNode
.
onEnterFrame
,
this
);
this
.
gameSubmitData
(
this
.
gameSubmitResult
.
bind
(
this
),
this
.
score
);
}
...
...
@@ -182,6 +146,7 @@ export default class PlayScene extends PlaySceneBase{
}
// 更新分数
private
updateScore
(
score
?:
number
){
let
_score
=
1
;
...
...
egret/src/startScene/StartScene.ts
View file @
ef479ff3
import
StartSceneBase
from
"../../libs/new_wx/components/StartSceneBase"
;
import
prePlayScene
from
"../playScene/prePlayScene"
;
export
default
class
StartScene
extends
StartSceneBase
{
async
start
(){
super
.
start
();
if
(
!
prePlayScene
.
instance
.
canvasWebgl
){
prePlayScene
.
instance
.
initScene
();
}
}
}
\ No newline at end of file
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