Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
DG_FAF
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
DG_FAF
Commits
6e685908
Commit
6e685908
authored
Apr 26, 2023
by
zhangxinli
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
颜色判断
parent
269ffc61
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
132 additions
and
0 deletions
+132
-0
DrawingBoard_DG_FAF.ts
assets/DG_FAF/prefabs/DrawingBoard/DrawingBoard_DG_FAF.ts
+45
-0
DG_FAF.ts
assets/DG_FAF/scene/DG_FAF.ts
+87
-0
No files found.
assets/DG_FAF/prefabs/DrawingBoard/DrawingBoard_DG_FAF.ts
View file @
6e685908
...
@@ -373,6 +373,51 @@ export default class DrawingBoard extends cc.Component {
...
@@ -373,6 +373,51 @@ export default class DrawingBoard extends cc.Component {
}
}
}
}
// 获取已经画到画板上的颜色 用来判断答案是否正确
rgbaToHex
(
r
,
g
,
b
)
{
r
=
Math
.
round
(
r
);
g
=
Math
.
round
(
g
);
b
=
Math
.
round
(
b
);
var
hexR
=
r
.
toString
(
16
).
padStart
(
2
,
'
0
'
);
var
hexG
=
g
.
toString
(
16
).
padStart
(
2
,
'
0
'
);
var
hexB
=
b
.
toString
(
16
).
padStart
(
2
,
'
0
'
);
return
'
#
'
+
hexR
+
hexG
+
hexB
;
}
getColors
()
{
const
colorArray
=
[];
this
.
pathPointContainer
.
children
.
forEach
(
element
=>
{
let
curColor
=
this
.
rgbaToHex
(
element
.
color
.
r
,
element
.
color
.
g
,
element
.
color
.
b
);
if
(
curColor
==
'
#ff1500
'
&&
!
colorArray
.
includes
(
'
color_red
'
))
{
colorArray
.
push
(
'
color_red
'
);
}
if
(
curColor
==
'
#ff8e13
'
&&
!
colorArray
.
includes
(
'
color_orange
'
))
{
colorArray
.
push
(
'
color_orange
'
);
}
if
(
curColor
==
'
#ffd900
'
&&
!
colorArray
.
includes
(
'
color_yellow
'
))
{
colorArray
.
push
(
'
color_yellow
'
);
}
if
(
curColor
==
'
#3cd31b
'
&&
!
colorArray
.
includes
(
'
color_green
'
))
{
colorArray
.
push
(
'
color_green
'
);
}
if
(
curColor
==
'
#00bbf9
'
&&
!
colorArray
.
includes
(
'
color_blue
'
))
{
colorArray
.
push
(
'
color_blue
'
);
}
if
(
curColor
==
'
#a282ea
'
&&
!
colorArray
.
includes
(
'
color_purple
'
))
{
colorArray
.
push
(
'
color_purple
'
);
}
if
(
curColor
==
'
#ff84b3
'
&&
!
colorArray
.
includes
(
'
color_pink
'
))
{
colorArray
.
push
(
'
color_pink
'
);
}
if
(
curColor
==
'
#a45e10
'
&&
!
colorArray
.
includes
(
'
color_brown
'
))
{
colorArray
.
push
(
'
color_brown
'
);
}
if
(
curColor
==
'
#000000
'
&&
!
colorArray
.
includes
(
'
color_black
'
))
{
colorArray
.
push
(
'
color_black
'
);
}
});
return
colorArray
;
}
// 清除一条线的轨迹点
// 清除一条线的轨迹点
cleanOneLineData
(
data
)
{
cleanOneLineData
(
data
)
{
const
{
pointPicArr
}
=
data
;
const
{
pointPicArr
}
=
data
;
...
...
assets/DG_FAF/scene/DG_FAF.ts
View file @
6e685908
...
@@ -29,6 +29,7 @@ const CONNECTION_CHOICE = "11";
...
@@ -29,6 +29,7 @@ const CONNECTION_CHOICE = "11";
const
TEXTINPUT_GROUP
=
"
12
"
;
const
TEXTINPUT_GROUP
=
"
12
"
;
const
VIDEO_PLAY
=
"
13
"
;
const
VIDEO_PLAY
=
"
13
"
;
const
DRAWING
=
"
14
"
;
const
DRAWING
=
"
14
"
;
const
DRAWING_CHECK
=
"
15
"
;
// 评分体系
// 评分体系
const
RS_15_5L_FAF
=
"
0
"
;
const
RS_15_5L_FAF
=
"
0
"
;
...
@@ -663,6 +664,10 @@ export default class SceneComponent extends MyCocosSceneComponent {
...
@@ -663,6 +664,10 @@ export default class SceneComponent extends MyCocosSceneComponent {
case
DRAWING
:
case
DRAWING
:
this
.
setDrawingArea
(
configItem
,
this
.
data
.
hotZoneItemArr
[
configItem
.
linkHotZoneIndex
]);
this
.
setDrawingArea
(
configItem
,
this
.
data
.
hotZoneItemArr
[
configItem
.
linkHotZoneIndex
]);
break
;
break
;
case
DRAWING_CHECK
:
validater
=
this
.
setDrawingAreaWithCheck
(
configItem
,
this
.
data
.
hotZoneItemArr
[
configItem
.
linkHotZoneIndex
]);
this
.
scoreValidater
.
push
(
validater
);
break
;
}
}
});
});
...
@@ -2586,6 +2591,88 @@ export default class SceneComponent extends MyCocosSceneComponent {
...
@@ -2586,6 +2591,88 @@ export default class SceneComponent extends MyCocosSceneComponent {
rect
.
addChild
(
drawingBoard
);
rect
.
addChild
(
drawingBoard
);
};
};
setDrawingAreaWithCheck
(
contentData
,
hotZoneItemData
,
debugMode
=
false
)
{
const
rect
=
this
.
newRectNode
(
hotZoneItemData
,
layer_4
,
debugMode
);
const
drawingBoard
=
cc
.
instantiate
(
this
.
drawingBoardTemplate
);
drawingBoard
.
width
=
rect
.
width
;
drawingBoard
.
height
=
rect
.
height
;
drawingBoard
.
y
=
rect
.
height
/
2
;
drawingBoard
.
x
=
drawingBoard
.
width
/
2
;
drawingBoard
.
active
=
true
;
drawingBoard
.
on
(
"
onPaintingStart
"
,
()
=>
{
this
.
drawingCount
++
;
if
(
this
.
drawingCount
==
1
)
{
this
.
disableScroll
()
}
})
drawingBoard
.
on
(
"
onPaintingEnd
"
,
()
=>
{
this
.
drawingCount
--
;
if
(
this
.
drawingCount
==
0
)
{
this
.
enableScroll
();
}
})
rect
.
addChild
(
drawingBoard
);
// 判卷结果显示区域
// const resultRect = this.newRectNode(hotZoneItemData, layer_2, debugMode);
const
resultRectData
=
this
.
data
.
hotZoneItemArr
[
contentData
.
linkResultShowHotZoneIndex
];
const
resultRect
=
this
.
newRectNode
(
resultRectData
,
layer_2
,
debugMode
);
// // 正确校验方法 - 默认返null
let
validater
=
()
=>
{
const
result
=
{
detail
:
{
contentType
:
DRAWING_CHECK
,
configIndex
:
contentData
.
index
,
contentIndex
:
-
1
,
currentInputText
:
[],
correctText
:
contentData
.
drawingCheckCorrectColors
,
right
:
true
},
configIndex
:
contentData
.
index
,
rect
:
resultRect
,
allRight
:
true
,
score
:
0
}
// 验证答案
console
.
log
(
"
====> 画板
"
,
drawingBoard
);
const
boardScript
=
drawingBoard
.
getComponent
(
"
DrawingBoard_DG_FAF
"
);
const
colorsExist
=
boardScript
.
getColors
();
result
.
detail
.
currentInputText
=
colorsExist
;
console
.
log
(
"
====> 正确
"
,
contentData
.
drawingCheckCorrectColors
);
console
.
log
(
"
====> 存在
"
,
colorsExist
);
let
sameColorCount
=
0
;
for
(
let
i
=
0
;
i
<
contentData
.
drawingCheckCorrectColors
.
length
;
i
++
)
{
if
(
colorsExist
.
includes
(
contentData
.
drawingCheckCorrectColors
[
i
]))
{
sameColorCount
++
;
}
}
let
isRight
=
false
;
if
(
contentData
.
drawingCheckCorrectColors
.
drawingCheckStrictEqual
)
{
isRight
=
sameColorCount
===
contentData
.
drawingCheckCorrectColors
.
length
&&
sameColorCount
===
colorsExist
.
length
;
}
else
{
isRight
=
sameColorCount
===
contentData
.
drawingCheckCorrectColors
.
length
;
}
if
(
isRight
)
{
// 正确 返回分数
result
.
score
=
contentData
.
score
&&
!
isNaN
(
Number
(
contentData
.
score
))
?
Number
(
contentData
.
score
)
:
0
;
return
[
result
]
}
else
{
// 错误
result
.
allRight
=
false
;
result
.
detail
.
right
=
false
;
return
[
result
]
}
};
return
validater
;
};
// 语音评测题型
// 语音评测题型
setPronunciationAssessment
(
contentData
,
hotZoneItemData
,
debugMode
=
false
)
{
setPronunciationAssessment
(
contentData
,
hotZoneItemData
,
debugMode
=
false
)
{
let
recordUrl
=
""
;
let
recordUrl
=
""
;
...
...
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