Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
sn04_classify
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
sn04_classify
Commits
2f32178a
Commit
2f32178a
authored
Nov 04, 2023
by
yu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1
parent
90ce9c4a
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
55 additions
and
19 deletions
+55
-19
sn04_classify.ts
assets/sn04_classify/scene/sn04_classify.ts
+55
-19
No files found.
assets/sn04_classify/scene/sn04_classify.ts
View file @
2f32178a
...
@@ -290,7 +290,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
...
@@ -290,7 +290,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
bg_bar_font
.
active
=
true
;
bg_bar_font
.
active
=
true
;
bg_bar_img
.
active
=
false
;
bg_bar_img
.
active
=
false
;
if
(
this
.
layout_card
.
children
.
length
<=
0
)
{
if
(
this
.
layout_card
.
children
.
length
<=
0
)
{
this
.
gameOver
();
this
.
rundEnd
();
}
}
}).
start
();
}).
start
();
...
@@ -362,36 +362,72 @@ export default class SceneComponent extends MyCocosSceneComponent {
...
@@ -362,36 +362,72 @@ export default class SceneComponent extends MyCocosSceneComponent {
}
}
private
sendData
(
score
)
{
private
rightCount
:
number
;
private
errorCount
:
number
;
private
totalCount
:
number
;
addRightCount
()
{
if
(
!
this
.
rightCount
)
this
.
rightCount
=
0
;
this
.
rightCount
++
;
}
addErrorCount
()
{
if
(
!
this
.
errorCount
)
this
.
errorCount
=
0
;
this
.
errorCount
++
;
}
setTotalCount
(
val
)
{
this
.
totalCount
=
val
;
}
sendData
()
{
return
new
Promise
(
res
=>
{
return
new
Promise
(
res
=>
{
if
(
!
this
.
totalCount
)
this
.
totalCount
=
this
.
rightCount
+
this
.
errorCount
;
if
(
!
this
.
totalCount
)
console
.
error
(
'
未设置总计数
'
);
if
(
this
.
totalCount
&&
!
this
.
rightCount
&&
!
this
.
errorCount
)
{
this
.
rightCount
=
this
.
totalCount
;
this
.
errorCount
=
0
;
}
let
upData
:
any
=
{
let
upData
:
any
=
{
word_count
:
this
.
data
.
word_count
||
0
,
right_count
:
this
.
rightCount
||
0
,
sentence_count
:
this
.
data
.
sentence_count
||
0
,
wrong_count
:
this
.
errorCount
||
0
,
zi_count
:
this
.
data
.
zi_count
||
0
,
total_count
:
this
.
totalCount
||
0
,
score
:
score
,
};
};
upData
.
score
=
upData
.
right_count
||
0
;
let
recordList
=
pg
.
hw
.
getRecord
();
let
recordList
=
pg
.
hw
.
getRecord
();
if
(
recordList
&&
recordList
.
length
>
0
)
{
if
(
recordList
&&
recordList
.
length
>
0
)
{
upData
.
re
cordLis
t
=
recordList
upData
.
re
sul
t
=
recordList
}
}
let
mid
=
cc
.
find
(
'
middleLayer
'
);
if
(
!
mid
)
return
;
const
middleLayer
=
mid
.
getComponent
(
'
middleLayer
'
);
console
.
log
(
'
upload->
'
+
JSON
.
stringify
(
upData
))
console
.
log
(
'
upload->
'
+
JSON
.
stringify
(
upData
))
if
(
!
cc
.
find
(
'
middleLayer
'
))
return
;
const
middleLayer
=
cc
.
find
(
'
middleLayer
'
).
getComponent
(
'
middleLayer
'
);
middleLayer
.
onHomeworkFinish
(
upData
,
()
=>
{
middleLayer
.
onHomeworkFinish
(
upData
,
()
=>
{
res
(
''
);
res
(
''
);
})
})
})
})
}
}
private
gameOver
()
{
Game
.
getIns
().
state
=
GAME_STATE
.
OVER
;
gameOver
()
{
this
.
sendData
(
this
.
data
.
questions
.
length
*
3
).
then
(()
=>
{
this
.
setTotalCount
(
Game
.
getIns
().
len
);
let
mid
=
cc
.
find
(
'
middleLayer
'
);
this
.
sendData
().
then
(()
=>
{
if
(
!
mid
)
return
;
if
(
!
cc
.
find
(
'
middleLayer
'
))
return
;
const
middleLayer
=
mid
.
getComponent
(
'
middleLayer
'
);
const
middleLayer
=
cc
.
find
(
'
middleLayer
'
);
middleLayer
.
saveGolds
(
this
.
data
.
questions
.
length
*
3
);
// 保存金币数量; num 是获得金币的数量,数字类
if
(
middleLayer
)
{
middleLayer
.
goNextPage
();
//跳转到下一页
const
middleLayerComponent
=
middleLayer
.
getComponent
(
'
middleLayer
'
);
middleLayerComponent
.
goNextPage
();
return
;
}
else
{
console
.
log
(
"
[onFinish] middleLayer not found
"
)
}
})
})
}
private
rundEnd
()
{
Game
.
getIns
().
state
=
GAME_STATE
.
OVER
;
// this.sendData(this.data.questions.length * 3).then(() => {
// let mid = cc.find('middleLayer');
// if (!mid) return;
// const middleLayer = mid.getComponent('middleLayer');
// middleLayer.saveGolds(this.data.questions.length * 3); // 保存金币数量; num 是获得金币的数量,数字类
// middleLayer.goNextPage(); //跳转到下一页
// })
this
.
gameOver
();
this
.
log
(
"
over~~~~~
"
)
this
.
log
(
"
over~~~~~
"
)
}
}
...
@@ -403,7 +439,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
...
@@ -403,7 +439,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
if
(
Game
.
getIns
().
state
!=
GAME_STATE
.
RUNNING
)
return
;
if
(
Game
.
getIns
().
state
!=
GAME_STATE
.
RUNNING
)
return
;
if
(
!
this
.
gameCount
||
this
.
gameCount
<=
0
)
{
if
(
!
this
.
gameCount
||
this
.
gameCount
<=
0
)
{
this
.
isFinish
=
true
;
this
.
isFinish
=
true
;
this
.
gameOver
();
this
.
rundEnd
();
return
;
return
;
}
}
if
(
this
.
gameCount
<
3
&&
this
.
playCount
)
{
if
(
this
.
gameCount
<
3
&&
this
.
playCount
)
{
...
...
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