Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
I
interactiveGames_Level
Project
Project
Details
Activity
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
xuxing@jiuaoedu.com
interactiveGames_Level
Commits
6fdb987b
Commit
6fdb987b
authored
Nov 10, 2021
by
unknown
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
准备做输入键盘
parent
0efd036f
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
304 additions
and
29 deletions
+304
-29
RingSum.scene
assets/sceneBundle/games/ringSum/scene/RingSum.scene
+45
-11
RingSumCfg.ts
assets/sceneBundle/games/ringSum/script/RingSumCfg.ts
+25
-0
RingSumCfg.ts.meta
assets/sceneBundle/games/ringSum/script/RingSumCfg.ts.meta
+9
-0
RingSumCircle.ts
assets/sceneBundle/games/ringSum/script/RingSumCircle.ts
+98
-0
RingSumCircle.ts.meta
...ts/sceneBundle/games/ringSum/script/RingSumCircle.ts.meta
+9
-0
RingSumCtr.ts
assets/sceneBundle/games/ringSum/script/RingSumCtr.ts
+80
-16
RingSumItem.ts
assets/sceneBundle/games/ringSum/script/RingSumItem.ts
+38
-2
No files found.
assets/sceneBundle/games/ringSum/scene/RingSum.scene
View file @
6fdb987b
...
...
@@ -29,7 +29,7 @@
"_prefab": null,
"autoReleaseAssets": false,
"_globals": {
"__id__": 2
68
"__id__": 2
70
},
"_id": "7ba0cc5b-1464-4e01-8985-4f5a35e49ee1"
},
...
...
@@ -212,13 +212,16 @@
"_active": true,
"_components": [
{
"__id__": 26
2
"__id__": 26
3
},
{
"__id__": 26
4
"__id__": 26
5
},
{
"__id__": 266
"__id__": 267
},
{
"__id__": 269
}
],
"_prefab": null,
...
...
@@ -529,6 +532,9 @@
},
{
"__id__": 261
},
{
"__id__": 262
}
],
"_prefab": null,
...
...
@@ -6388,6 +6394,20 @@
"_lockFlags": 0,
"_id": "a3mglBU75JoLlL+yYrmZ3x"
},
{
"__type__": "3ef97wNcrZEGp+9oJZU8d4F",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 16
},
"_enabled": true,
"__prefab": null,
"itemArrNode": {
"__id__": 16
},
"_id": "acdFKhDLFNCqt0edrUJWVz"
},
{
"__type__": "cc.UITransform",
"_name": "",
...
...
@@ -6397,7 +6417,7 @@
},
"_enabled": true,
"__prefab": {
"__id__": 26
3
"__id__": 26
4
},
"_contentSize": {
"__type__": "cc.Size",
...
...
@@ -6424,7 +6444,7 @@
},
"_enabled": true,
"__prefab": {
"__id__": 26
5
"__id__": 26
6
},
"_cameraComponent": {
"__id__": 9
...
...
@@ -6445,7 +6465,7 @@
},
"_enabled": true,
"__prefab": {
"__id__": 26
7
"__id__": 26
8
},
"_alignFlags": 45,
"_target": null,
...
...
@@ -6471,19 +6491,33 @@
"__type__": "cc.CompPrefabInfo",
"fileId": "e8a+bU/8dPDbbJguUzLdoF"
},
{
"__type__": "ef93cR0ympO9asx+oI55eKA",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 7
},
"_enabled": true,
"__prefab": null,
"circle": {
"__id__": 262
},
"_id": "a3b0bpXKVKi6G7Xsut/FHS"
},
{
"__type__": "cc.SceneGlobals",
"ambient": {
"__id__": 2
69
"__id__": 2
71
},
"shadows": {
"__id__": 27
0
"__id__": 27
2
},
"_skybox": {
"__id__": 27
1
"__id__": 27
3
},
"fog": {
"__id__": 27
2
"__id__": 27
4
}
},
{
...
...
assets/sceneBundle/games/ringSum/script/RingSumCfg.ts
0 → 100644
View file @
6fdb987b
import
{
_decorator
,
Component
,
Node
}
from
'cc'
;
import
{
RS_ITEM_TYPE
}
from
'./RingSumItem'
;
const
{
ccclass
,
property
}
=
_decorator
;
export
interface
RingSumCfg
{
result
:
number
,
numStrArr
:
string
[][],
fixCtrArr
:
RS_ITEM_TYPE
[][]
}
export
const
RS_LV_1
=
{
result
:
15
,
numStrArr
:
[
[
"2"
,
"9"
,
"4"
],
[
"7"
,
"5"
,
"3"
],
[
"6"
,
"1"
,
"8"
]
],
fixCtrArr
:
[
[
RS_ITEM_TYPE
.
FIX
,
RS_ITEM_TYPE
.
FIX
,
RS_ITEM_TYPE
.
FIX
],
[
RS_ITEM_TYPE
.
NOR
,
RS_ITEM_TYPE
.
FIX
,
RS_ITEM_TYPE
.
FIX
],
[
RS_ITEM_TYPE
.
FIX
,
RS_ITEM_TYPE
.
FIX
,
RS_ITEM_TYPE
.
NOR
]
]
}
\ No newline at end of file
assets/sceneBundle/games/ringSum/script/RingSumCfg.ts.meta
0 → 100644
View file @
6fdb987b
{
"ver": "4.0.22",
"importer": "typescript",
"imported": true,
"uuid": "b2c2a706-641d-4d85-8c52-41d530e4fedb",
"files": [],
"subMetas": {},
"userData": {}
}
assets/sceneBundle/games/ringSum/script/RingSumCircle.ts
0 → 100644
View file @
6fdb987b
import
{
_decorator
,
Component
,
Node
}
from
'cc'
;
import
{
RingSumItem
,
RS_ITEM_TYPE
}
from
'./RingSumItem'
;
const
{
ccclass
,
property
}
=
_decorator
;
@
ccclass
(
'RingSumCircle'
)
export
class
RingSumCircle
extends
Component
{
@
property
(
Node
)
itemArrNode
:
Node
=
null
!
;
private
itemArr
:
RingSumItem
[][]
=
[];
onLoad
(){
let
items
=
this
.
itemArrNode
.
getComponentsInChildren
(
RingSumItem
);
this
.
itemArr
=
[
[
items
[
0
],
items
[
1
],
items
[
2
]],
[
items
[
3
],
items
[
4
],
items
[
5
]],
[
items
[
6
],
items
[
7
],
items
[
8
]]
];
}
start
()
{
// [3]
}
setAllText
(
texts
:
string
[][]){
for
(
let
i
=
0
;
i
<
texts
.
length
;
++
i
){
for
(
let
j
=
0
;
j
<
texts
[
i
].
length
;
++
j
){
this
.
itemArr
[
i
][
j
].
setText
(
texts
[
i
][
j
]);
}
}
}
getAllText
(){
return
[
[
this
.
itemArr
[
0
][
0
].
getText
(),
this
.
itemArr
[
0
][
1
].
getText
(),
this
.
itemArr
[
0
][
2
].
getText
()],
[
this
.
itemArr
[
1
][
0
].
getText
(),
this
.
itemArr
[
1
][
1
].
getText
(),
this
.
itemArr
[
1
][
2
].
getText
()],
[
this
.
itemArr
[
2
][
0
].
getText
(),
this
.
itemArr
[
2
][
1
].
getText
(),
this
.
itemArr
[
2
][
2
].
getText
()]
];
}
setAllItemType
(
itemTypes
:
RS_ITEM_TYPE
[][]){
for
(
let
i
=
0
;
i
<
itemTypes
.
length
;
++
i
){
for
(
let
j
=
0
;
j
<
itemTypes
[
i
].
length
;
++
j
){
this
.
itemArr
[
i
][
j
].
setItemType
(
itemTypes
[
i
][
j
]);
}
}
}
getAllItemType
(){
return
[
[
this
.
itemArr
[
0
][
0
].
getItemType
(),
this
.
itemArr
[
0
][
1
].
getItemType
(),
this
.
itemArr
[
0
][
2
].
getItemType
()],
[
this
.
itemArr
[
1
][
0
].
getItemType
(),
this
.
itemArr
[
1
][
1
].
getItemType
(),
this
.
itemArr
[
1
][
2
].
getItemType
()],
[
this
.
itemArr
[
2
][
0
].
getItemType
(),
this
.
itemArr
[
2
][
1
].
getItemType
(),
this
.
itemArr
[
2
][
2
].
getItemType
()]
];
}
hideAllNorItemText
(){
for
(
let
i
=
0
;
i
<
this
.
itemArr
.
length
;
++
i
){
for
(
let
j
=
0
;
j
<
this
.
itemArr
[
i
].
length
;
++
j
){
if
(
this
.
itemArr
[
i
][
j
].
getItemType
()
==
RS_ITEM_TYPE
.
NOR
)
this
.
itemArr
[
i
][
j
].
setText
(
""
);
}
}
}
checkRepeat
(){
let
isRepeat
=
false
;
let
countMap
:
Map
<
string
,
RingSumItem
[]
>
=
new
Map
<
string
,
RingSumItem
[]
>
();
for
(
let
i
=
0
;
i
<
this
.
itemArr
.
length
;
++
i
){
for
(
let
j
=
0
;
i
<
this
.
itemArr
[
i
].
length
;
++
j
){
this
.
itemArr
[
i
][
j
].
setNoRepLabColor
();
if
(
countMap
.
get
(
this
.
itemArr
[
i
][
j
].
getText
())){
countMap
.
get
(
this
.
itemArr
[
i
][
j
].
getText
())?.
push
(
this
.
itemArr
[
i
][
j
]);
}
else
{
countMap
.
set
(
this
.
itemArr
[
i
][
j
].
getText
(),
[
this
.
itemArr
[
i
][
j
]]);
}
}
}
countMap
.
forEach
((
value
,
key
)
=>
{
if
(
value
.
length
>
1
){
isRepeat
=
true
;
if
(
key
!=
""
){
for
(
let
i
=
0
;
i
<
value
.
length
;
++
i
){
value
[
i
].
setRepLabColor
();
}
}
}
});
return
isRepeat
;
}
// update (deltaTime: number) {
// // [4]
// }
}
assets/sceneBundle/games/ringSum/script/RingSumCircle.ts.meta
0 → 100644
View file @
6fdb987b
{
"ver": "4.0.22",
"importer": "typescript",
"imported": true,
"uuid": "3ef97c0d-72b6-441a-9fbd-a09654f1de05",
"files": [],
"subMetas": {},
"userData": {}
}
assets/sceneBundle/games/ringSum/script/RingSumCtr.ts
View file @
6fdb987b
import
{
_decorator
,
Component
,
Node
}
from
'cc'
;
import
{
RingSumCfg
,
RS_LV_1
}
from
'./RingSumCfg'
;
import
{
RingSumCircle
}
from
'./RingSumCircle'
;
const
{
ccclass
,
property
}
=
_decorator
;
@
ccclass
(
'RingSumCtr'
)
export
class
RingSumCtr
extends
Component
{
// [1]
// dummy = '';
// [2]
// @property
// serializableDummy = 0;
@
property
(
RingSumCircle
)
circle
:
RingSumCircle
=
null
!
;
private
level
=
2
;
private
levelData
:
RingSumCfg
=
null
!
;
start
()
{
// [3]
this
.
gameStart
();
}
gameStart
(){
this
.
loadLevelData
();
this
.
circle
.
setAllText
(
this
.
levelData
.
numStrArr
);
this
.
circle
.
setAllItemType
(
this
.
levelData
.
fixCtrArr
);
this
.
circle
.
hideAllNorItemText
();
}
calculator
(
numStrArr
:
string
[]):
number
{
let
operatorIdx
=
-
1
;
for
(
let
i
=
0
;
i
<
numStrArr
.
length
;
++
i
)
{
if
(
numStrArr
[
i
]
==
"+"
||
numStrArr
[
i
]
==
"-"
||
numStrArr
[
i
]
==
"÷"
||
numStrArr
[
i
]
==
"×"
)
{
operatorIdx
=
i
;
break
;
}
}
for
(
let
i
=
0
;
i
<
numStrArr
.
length
;
++
i
)
{
if
(
numStrArr
[
i
]
==
"÷"
||
numStrArr
[
i
]
==
"×"
)
{
operatorIdx
=
i
;
break
;
}
}
if
(
operatorIdx
==
0
||
operatorIdx
==
numStrArr
.
length
-
1
)
{
throw
new
Error
(
`传入的算式不符合规则1`
);
}
if
(
operatorIdx
==
-
1
)
{
if
(
numStrArr
.
length
==
1
)
return
Number
(
numStrArr
[
0
]);
else
throw
new
Error
(
`传入的算式不符合规则2`
);
}
let
num_1
=
Number
(
numStrArr
[
operatorIdx
-
1
]);
let
num_2
=
Number
(
numStrArr
[
operatorIdx
+
1
]);
let
num_ret
=
0
;
switch
(
numStrArr
[
operatorIdx
])
{
case
"+"
:
num_ret
=
num_1
+
num_2
;
break
;
case
"-"
:
num_ret
=
num_1
-
num_2
;
break
;
case
"÷"
:
if
(
num_2
==
0
)
throw
new
Error
(
`除数为零`
);
num_ret
=
num_1
/
num_2
;
break
;
case
"×"
:
num_ret
=
num_1
*
num_2
;
break
;
default
:
break
;
}
numStrArr
[
operatorIdx
-
1
]
=
num_ret
.
toString
();
numStrArr
.
splice
(
operatorIdx
,
2
);
return
this
.
calculator
(
numStrArr
);
}
loadLevelData
()
{
switch
(
this
.
level
)
{
case
1
:
this
.
levelData
=
RS_LV_1
;
break
;
case
2
:
this
.
levelData
=
RS_LV_1
;
break
;
default
:
this
.
levelData
=
RS_LV_1
;
break
;
}
}
checkWin
()
{
let
texts
=
this
.
circle
.
getAllText
();
return
false
;
}
// update (deltaTime: number) {
// // [4]
// }
}
/**
* [1] Class member could be defined like this.
* [2] Use `property` decorator if your want the member to be serializable.
* [3] Your initialization goes here.
* [4] Your update function goes here.
*
* Learn more about scripting: https://docs.cocos.com/creator/3.0/manual/en/scripting/
* Learn more about CCClass: https://docs.cocos.com/creator/3.0/manual/en/scripting/ccclass.html
* Learn more about life-cycle callbacks: https://docs.cocos.com/creator/3.0/manual/en/scripting/life-cycle-callbacks.html
*/
assets/sceneBundle/games/ringSum/script/RingSumItem.ts
View file @
6fdb987b
import
{
_decorator
,
Component
,
Node
,
Sprite
,
LabelComponent
,
Label
}
from
'cc'
;
import
{
_decorator
,
Component
,
Node
,
Sprite
,
LabelComponent
,
Label
,
Color
}
from
'cc'
;
const
{
ccclass
,
property
}
=
_decorator
;
export
enum
RS_ITEM_TYPE
{
NOR
=
10
,
FIX
=
20
}
@
ccclass
(
'RingSumItem'
)
export
class
RingSumItem
extends
Component
{
...
...
@@ -14,10 +19,41 @@ export class RingSumItem extends Component {
@
property
(
Node
)
clickNode
:
Node
=
null
!
;
start
()
{
private
_itemType
=
RS_ITEM_TYPE
.
NOR
;
start
()
{
// [3]
}
setText
(
text
:
string
)
{
this
.
numLab
.
string
=
text
;
}
getText
()
{
return
this
.
numLab
.
string
==
""
?
"+"
:
this
.
numLab
.
string
;
//直接在这里处理一下没填入的数字免得麻烦;
}
setItemType
(
type
:
RS_ITEM_TYPE
)
{
this
.
_itemType
=
type
;
if
(
this
.
_itemType
==
RS_ITEM_TYPE
.
NOR
)
{
this
.
numLab
.
color
=
new
Color
(
255
,
255
,
255
,
255
);
}
else
{
this
.
numLab
.
color
=
new
Color
(
31
,
168
,
142
,
255
);
}
}
getItemType
()
{
return
this
.
_itemType
;
}
setRepLabColor
(){
this
.
numLab
.
color
=
new
Color
(
255
,
0
,
0
,
255
);
}
setNoRepLabColor
(){
this
.
setItemType
(
this
.
getItemType
());
}
// update (deltaTime: number) {
// // [4]
// }
...
...
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