Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Z
zeroing-libs
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
劳工
zeroing-libs
Commits
f1cc991a
Commit
f1cc991a
authored
Dec 27, 2019
by
XieChuanJin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
集合所有内容到game类
parent
877333e1
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
153 additions
and
133 deletions
+153
-133
shoot-planet.json
dist/customs/shoot-planet.json
+1
-1
Game.ts
src/custom/shoot-planet/Game/Game.ts
+111
-1
Net.ts
src/custom/shoot-planet/Global/Net.ts
+2
-3
ShootPlanet.ts
src/custom/shoot-planet/ShootPlanet.ts
+2
-124
test.js
src/custom/shoot-planet/test.js
+37
-4
No files found.
dist/customs/shoot-planet.json
View file @
f1cc991a
This source diff could not be displayed because it is too large. You can
view the blob
instead.
src/custom/shoot-planet/Game/Game.ts
View file @
f1cc991a
...
@@ -26,6 +26,9 @@ import DropPoolGroup from "../Pools/DropPool";
...
@@ -26,6 +26,9 @@ import DropPoolGroup from "../Pools/DropPool";
import
DropBlinkMgr
from
"../Mgr/DropBlinkMgr"
;
import
DropBlinkMgr
from
"../Mgr/DropBlinkMgr"
;
import
GameMgr
from
"../Mgr/GameMgr"
;
import
GameMgr
from
"../Mgr/GameMgr"
;
import
{
DataMgr
}
from
"../Mgr/DataMgr"
;
import
{
DataMgr
}
from
"../Mgr/DataMgr"
;
import
{
initNECaptcha
}
from
"../Component/InitNECaptcha"
;
import
{
NetUtils
}
from
"../Global/NetUtils"
;
import
Net
from
"../Global/Net"
;
type
LayerName
=
"Bullet"
|
"Ball"
|
"Drop"
|
"Effect"
;
type
LayerName
=
"Bullet"
|
"Ball"
|
"Drop"
|
"Effect"
;
...
@@ -109,6 +112,111 @@ export default class Game {
...
@@ -109,6 +112,111 @@ export default class Game {
public
_animationMgr
:
FrameAnimationMgr
=
new
FrameAnimationMgr
();
public
_animationMgr
:
FrameAnimationMgr
=
new
FrameAnimationMgr
();
public
_horizontalMoveMgr
:
HorizontalMoveMgr
=
new
HorizontalMoveMgr
();
public
_horizontalMoveMgr
:
HorizontalMoveMgr
=
new
HorizontalMoveMgr
();
private
constantSubmitSeq
=
1
;
private
needSubmitCount
=
0
;
//实际分数减去ConstantSubmitScoreNum的次数
private
isSubmiting
=
false
;
public
startId
:
number
=
0
;
private
_localScore
:
number
=
0
;
public
get
localScore
():
number
{
return
this
.
_localScore
;
}
public
set
localScore
(
v
:
number
)
{
this
.
_localScore
=
v
;
if
(
this
.
_localScore
>=
MConst
.
ConstantSubmitScoreNum
)
{
let
count
=
Math
.
floor
(
this
.
_localScore
/
MConst
.
ConstantSubmitScoreNum
);
this
.
needSubmitCount
+=
count
;
this
.
_localScore
-=
MConst
.
ConstantSubmitScoreNum
*
count
;
if
(
!
this
.
isSubmiting
)
{
this
.
constantSubmit
();
}
}
}
private
constantSubmit
(
score
:
number
=
MConst
.
ConstantSubmitScoreNum
)
{
if
(
this
.
isSubmiting
)
{
return
;
}
if
(
this
.
needSubmitCount
==
0
)
{
return
;
}
else
if
(
this
.
needSubmitCount
<
0
)
{
//异常,有bug
console
.
error
(
"invalid needSubmitCount value"
);
return
;
}
this
.
isSubmiting
=
true
;
let
seq
=
NetUtils
.
encryptSeq
(
this
.
constantSubmitSeq
);
return
new
Promise
((
resolve
,
reject
)
=>
{
Net
.
sendPost
(
Net
.
Url
.
constantSubmit
,
{
startId
:
this
.
startId
,
seq
:
seq
,
score
:
score
,
token
:
NetUtils
.
md5
(
this
.
startId
.
toString
()
+
seq
.
toString
()
+
score
.
toString
()
+
"qzBankRPW@dui88"
)
},
()
=>
{
this
.
constantSubmitSeq
++
;
console
.
error
(
"submited"
,
this
.
constantSubmitSeq
,
this
.
needSubmitCount
);
this
.
needSubmitCount
--
;
this
.
isSubmiting
=
false
;
resolve
();
},
(
res
)
=>
{
this
.
isSubmiting
=
false
;
reject
();
});
});
}
public
async
finalSubmit
(
propsId
?:
string
,
onSubmited
?:
()
=>
void
)
{
if
(
this
.
needSubmitCount
>
0
)
{
if
(
!
this
.
isSubmiting
)
{
while
(
this
.
needSubmitCount
>
0
)
{
await
this
.
constantSubmit
();
}
}
}
const
score
=
this
.
score
;
let
serverScore
=
this
.
localScore
+
(
this
.
constantSubmitSeq
-
1
+
this
.
needSubmitCount
)
*
MConst
.
ConstantSubmitScoreNum
;
if
(
serverScore
!=
score
)
{
console
.
error
(
`[score error] server:
${
serverScore
}
local:
${
score
}
`
);
}
else
{
console
.
log
(
`[score] server:
${
serverScore
}
local:
${
score
}
`
);
}
//中途提交最后一次
if
(
this
.
localScore
>
0
)
{
this
.
needSubmitCount
++
;
await
this
.
constantSubmit
(
this
.
localScore
);
console
.
log
(
"extra submit:"
+
this
.
localScore
);
}
//滑块验证
let
validate
=
await
new
Promise
<
string
>
(
resolve
=>
{
if
(
typeof
engine
.
env
.
minEnableCaptchaScore
==
"number"
&&
score
>=
engine
.
env
.
minEnableCaptchaScore
)
{
initNECaptcha
({
captchaId
:
MConst
.
captchaId
,
callback
:
(
ret
:
{
validate
:
string
})
=>
{
resolve
(
ret
.
validate
);
}
});
}
else
{
resolve
(
""
);
}
});
engine
.
globalEvent
.
dispatchEvent
(
"ShootPlanetFinalSubmit"
,
{
startId
:
this
.
startId
,
score
:
score
,
useSpId
:
propsId
||
""
,
token
:
NetUtils
.
md5
(
this
.
startId
.
toString
()
+
score
.
toString
()
+
"qzBankRPW@dui88"
),
validate
:
validate
});
}
private
loadRes
()
{
private
loadRes
()
{
FrameAnimation
.
loadRes
(
RES
.
getRes
(
"217164f4-a185-429c-8706-818137a4e438"
),
DuangAltaData
);
FrameAnimation
.
loadRes
(
RES
.
getRes
(
"217164f4-a185-429c-8706-818137a4e438"
),
DuangAltaData
);
SpriteFont
.
load
(
RES
.
getRes
(
"b4d821e8-8274-4b60-95d0-47da803ac5cf"
),
NumFontData
);
SpriteFont
.
load
(
RES
.
getRes
(
"b4d821e8-8274-4b60-95d0-47da803ac5cf"
),
NumFontData
);
...
@@ -201,6 +309,7 @@ export default class Game {
...
@@ -201,6 +309,7 @@ export default class Game {
private
over
()
{
private
over
()
{
this
.
pause
=
true
;
this
.
pause
=
true
;
engine
.
globalEvent
.
dispatchEvent
(
"ShootPlanetGameOver"
);
engine
.
globalEvent
.
dispatchEvent
(
"ShootPlanetGameOver"
);
this
.
finalSubmit
();
this
.
onGameOver
&&
this
.
onGameOver
();
this
.
onGameOver
&&
this
.
onGameOver
();
}
}
...
@@ -296,6 +405,7 @@ export default class Game {
...
@@ -296,6 +405,7 @@ export default class Game {
//时间到
//时间到
this
.
pause
=
true
;
this
.
pause
=
true
;
engine
.
globalEvent
.
dispatchEvent
(
"ShootPlanetGameOver"
);
engine
.
globalEvent
.
dispatchEvent
(
"ShootPlanetGameOver"
);
this
.
finalSubmit
();
this
.
onGameOver
&&
this
.
onGameOver
();
this
.
onGameOver
&&
this
.
onGameOver
();
}
}
}
}
...
@@ -396,7 +506,7 @@ export default class Game {
...
@@ -396,7 +506,7 @@ export default class Game {
return
this
.
__score
;
return
this
.
__score
;
}
}
public
set
_score
(
v
:
number
)
{
public
set
_score
(
v
:
number
)
{
this
.
onScoreChange
&&
this
.
onScoreChange
(
v
-
this
.
__score
);
this
.
localScore
+=
(
v
-
this
.
__score
);
this
.
__score
=
v
;
this
.
__score
=
v
;
}
}
/**不建议使用 */
/**不建议使用 */
...
...
src/custom/shoot-planet/Global/Net.ts
View file @
f1cc991a
import
{
NetUtils
}
from
"./NetUtils"
;
import
{
NetUtils
}
from
"./NetUtils"
;
import
{
ToastPanel
}
from
"../ShootPlanet"
;
const
projectId
=
NetUtils
.
getProjectId
();
const
projectId
=
NetUtils
.
getProjectId
();
export
default
class
Net
{
export
default
class
Net
{
...
@@ -92,13 +91,13 @@ export default class Net {
...
@@ -92,13 +91,13 @@ export default class Net {
let
errorMsg
=
res
&&
((
res
[
"desc"
]
||
res
[
"message"
])
||
((
res
[
"code"
]
&&
"network error:"
+
res
[
"code"
])
||
"network error"
))
||
"network error"
;
let
errorMsg
=
res
&&
((
res
[
"desc"
]
||
res
[
"message"
])
||
((
res
[
"code"
]
&&
"network error:"
+
res
[
"code"
])
||
"network error"
))
||
"network error"
;
if
(
typeof
net
.
onFail
==
"function"
)
{
if
(
typeof
net
.
onFail
==
"function"
)
{
if
(
!
net
.
onFail
(
res
))
{
//若客户没有处理错误码,怎么默认显示错误消息或描述文字的弹窗
if
(
!
net
.
onFail
(
res
))
{
//若客户没有处理错误码,怎么默认显示错误消息或描述文字的弹窗
ToastPanel
.
show
(
errorMsg
);
console
.
error
(
errorMsg
);
}
}
}
else
{
}
else
{
if
(
typeof
net
.
onFail
==
"boolean"
&&
net
.
onFail
==
true
)
{
if
(
typeof
net
.
onFail
==
"boolean"
&&
net
.
onFail
==
true
)
{
Net
.
defaultOnFail
&&
Net
.
defaultOnFail
(
res
);
Net
.
defaultOnFail
&&
Net
.
defaultOnFail
(
res
);
}
}
ToastPanel
.
show
(
errorMsg
);
console
.
error
(
errorMsg
);
}
}
}
}
...
...
src/custom/shoot-planet/ShootPlanet.ts
View file @
f1cc991a
...
@@ -16,28 +16,6 @@ import { initNECaptcha } from "./Component/InitNECaptcha";
...
@@ -16,28 +16,6 @@ import { initNECaptcha } from "./Component/InitNECaptcha";
export
class
ShootPlanet
extends
engine
.
Container
{
export
class
ShootPlanet
extends
engine
.
Container
{
public
game
:
Game
=
null
;
public
game
:
Game
=
null
;
private
constantSubmitSeq
=
1
;
private
needSubmitCount
=
0
;
//实际分数减去ConstantSubmitScoreNum的次数
private
isSubmiting
=
false
;
public
startId
:
number
=
0
;
private
_localScore
:
number
=
0
;
public
get
localScore
():
number
{
return
this
.
_localScore
;
}
public
set
localScore
(
v
:
number
)
{
this
.
_localScore
=
v
;
if
(
this
.
_localScore
>=
MConst
.
ConstantSubmitScoreNum
)
{
let
count
=
Math
.
floor
(
this
.
_localScore
/
MConst
.
ConstantSubmitScoreNum
);
this
.
needSubmitCount
+=
count
;
this
.
_localScore
-=
MConst
.
ConstantSubmitScoreNum
*
count
;
if
(
!
this
.
isSubmiting
)
{
this
.
constantSubmit
();
}
}
}
public
onSleep
()
{
public
onSleep
()
{
this
.
game
.
destroy
();
this
.
game
.
destroy
();
...
@@ -45,19 +23,7 @@ export class ShootPlanet extends engine.Container {
...
@@ -45,19 +23,7 @@ export class ShootPlanet extends engine.Container {
}
}
public
onActive
()
{
public
onActive
()
{
this
.
constantSubmitSeq
=
1
;
this
.
needSubmitCount
=
0
;
this
.
isSubmiting
=
false
;
this
.
_localScore
=
0
;
this
.
game
=
new
Game
(
this
);
this
.
game
=
new
Game
(
this
);
//监听游戏分数变化
this
.
game
.
onScoreChange
=
(
delta
:
number
)
=>
{
this
.
localScore
+=
delta
;
};
this
.
game
.
onGameOver
=
()
=>
{
this
.
finalSubmit
();
}
if
(
GuideMgr
.
instance
.
guideFlag
==
true
)
{
if
(
GuideMgr
.
instance
.
guideFlag
==
true
)
{
const
car
=
this
.
game
.
_car
;
const
car
=
this
.
game
.
_car
;
GuideMgr
.
instance
.
runGuide
(
0
,
car
.
x
+
car
.
width
/
2
,
car
.
y
+
car
.
height
/
2
/* - 130 */
);
GuideMgr
.
instance
.
runGuide
(
0
,
car
.
x
+
car
.
width
/
2
,
car
.
y
+
car
.
height
/
2
/* - 130 */
);
...
@@ -70,6 +36,8 @@ export class ShootPlanet extends engine.Container {
...
@@ -70,6 +36,8 @@ export class ShootPlanet extends engine.Container {
this
.
width
=
750
;
this
.
width
=
750
;
this
.
height
=
1624
;
this
.
height
=
1624
;
this
.
init
();
this
.
init
();
this
.
onActive
();
}
}
private
init
()
{
private
init
()
{
...
@@ -100,94 +68,4 @@ export class ShootPlanet extends engine.Container {
...
@@ -100,94 +68,4 @@ export class ShootPlanet extends engine.Container {
this
.
parent
.
removeChild
(
this
);
this
.
parent
.
removeChild
(
this
);
}
}
}
}
private
constantSubmit
(
score
:
number
=
MConst
.
ConstantSubmitScoreNum
)
{
if
(
this
.
isSubmiting
)
{
return
;
}
if
(
this
.
needSubmitCount
==
0
)
{
return
;
}
else
if
(
this
.
needSubmitCount
<
0
)
{
//异常,有bug
console
.
error
(
"invalid needSubmitCount value"
);
return
;
}
this
.
isSubmiting
=
true
;
let
seq
=
NetUtils
.
encryptSeq
(
this
.
constantSubmitSeq
);
return
new
Promise
((
resolve
,
reject
)
=>
{
Net
.
sendPost
(
Net
.
Url
.
constantSubmit
,
{
startId
:
this
.
startId
,
seq
:
seq
,
score
:
score
,
token
:
NetUtils
.
md5
(
this
.
startId
.
toString
()
+
seq
.
toString
()
+
score
.
toString
()
+
"qzBankRPW@dui88"
)
},
()
=>
{
this
.
constantSubmitSeq
++
;
console
.
error
(
"submited"
,
this
.
constantSubmitSeq
);
this
.
needSubmitCount
--
;
this
.
isSubmiting
=
false
;
resolve
();
},
(
res
)
=>
{
this
.
isSubmiting
=
false
;
Net
.
defaultOnFail
(
res
);
reject
();
});
});
}
public
async
finalSubmit
(
propsId
?:
string
,
onSubmited
?:
()
=>
void
)
{
Loading
.
instace
.
show
();
if
(
this
.
needSubmitCount
>
0
)
{
if
(
!
this
.
isSubmiting
)
{
while
(
this
.
needSubmitCount
>
0
)
{
await
this
.
constantSubmit
();
}
}
}
const
score
=
this
.
game
.
score
;
let
serverScore
=
this
.
localScore
+
(
this
.
constantSubmitSeq
-
1
+
this
.
needSubmitCount
)
*
MConst
.
ConstantSubmitScoreNum
;
if
(
serverScore
!=
score
)
{
console
.
error
(
`[score error] server:
${
serverScore
}
local:
${
score
}
`
);
}
else
{
console
.
log
(
`[score] server:
${
serverScore
}
local:
${
score
}
`
);
}
//中途提交最后一次
if
(
this
.
localScore
>
0
)
{
this
.
needSubmitCount
++
;
await
this
.
constantSubmit
(
this
.
localScore
);
console
.
log
(
"extra submit:"
+
this
.
localScore
);
}
//滑块验证
let
validate
=
await
new
Promise
<
string
>
(
resolve
=>
{
if
(
typeof
engine
.
env
.
minEnableCaptchaScore
==
"number"
&&
score
>=
engine
.
env
.
minEnableCaptchaScore
)
{
initNECaptcha
({
captchaId
:
MConst
.
captchaId
,
callback
:
(
ret
:
{
validate
:
string
})
=>
{
resolve
(
ret
.
validate
);
}
});
}
else
{
resolve
(
""
);
}
});
engine
.
globalEvent
.
dispatchEvent
(
"ShootPlanetFinalSubmit"
,
{
startId
:
this
.
startId
,
score
:
score
,
useSpId
:
propsId
||
""
,
token
:
NetUtils
.
md5
(
this
.
startId
.
toString
()
+
score
.
toString
()
+
"qzBankRPW@dui88"
),
validate
:
validate
});
}
}
export
class
ToastPanel
{
public
static
show
(
msg
:
string
)
{
console
.
log
(
"toast:"
+
msg
);
}
}
}
src/custom/shoot-planet/test.js
View file @
f1cc991a
let
labelMsg
=
new
engine
.
Label
();
let
share
=
{
title
:
engine
.
env
.
shareTitle
,
desc
:
engine
.
env
.
shareDesc
,
link
:
engine
.
env
.
shareLink
,
imgUrl
:
engine
.
env
.
shareImgUrl
};
if
(
typeof
msg
!=
"string"
)
{
msg
=
typeof
msg
;
const
share
=
args
;
}
wx
.
onMenuShareTimeline
({
\ No newline at end of file
title
:
share
.
title
,
desc
:
share
.
desc
,
link
:
share
.
url
,
imgUrl
:
share
.
imgUrl
,
success
:
function
()
{
mui
.
Toast
.
show
(
"分享成功"
);
engine
.
globalEvent
.
dispatchEvent
(
"ShareSuccess"
);
},
cancel
:
function
()
{
mui
.
Toast
.
show
(
"分享取消"
);
engine
.
globalEvent
.
dispatchEvent
(
"ShareCancel"
);
}
});
wx
.
onMenuShareAppMessage
({
title
:
share
.
title
,
desc
:
share
.
desc
,
link
:
share
.
url
,
imgUrl
:
share
.
imgUrl
,
success
:
function
()
{
mui
.
Toast
.
show
(
"分享成功"
);
engine
.
globalEvent
.
dispatchEvent
(
"ShareSuccess"
);
},
cancel
:
function
()
{
mui
.
Toast
.
show
(
"分享取消"
);
engine
.
globalEvent
.
globa
.
dispatchEvent
(
"ShareCancel"
);
}
});
\ 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