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
d593838e
Commit
d593838e
authored
Oct 11, 2021
by
unknown
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
数独先配上4关
parent
e6af1bfd
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
402 additions
and
61 deletions
+402
-61
名称框.png.meta
assets/sceneBundle/games/sudoku/image/名称框.png.meta
+38
-4
图标_橡皮.png.meta
assets/sceneBundle/games/sudoku/image/图标_橡皮.png.meta
+38
-4
图标_铅笔.png.meta
assets/sceneBundle/games/sudoku/image/图标_铅笔.png.meta
+38
-4
得分框.png.meta
assets/sceneBundle/games/sudoku/image/得分框.png.meta
+38
-4
时间框.png.meta
assets/sceneBundle/games/sudoku/image/时间框.png.meta
+38
-4
目标分数框.png.meta
assets/sceneBundle/games/sudoku/image/目标分数框.png.meta
+38
-4
SudokuLevelView.prefab
...ts/sceneBundle/games/sudoku/prefab/SudokuLevelView.prefab
+6
-6
Sudoku.scene
assets/sceneBundle/games/sudoku/scene/Sudoku.scene
+0
-0
SudokuCfg.ts
assets/sceneBundle/games/sudoku/script/SudokuCfg.ts
+0
-0
SudokuCfg.ts.meta
assets/sceneBundle/games/sudoku/script/SudokuCfg.ts.meta
+9
-0
SudokuCtr.ts
assets/sceneBundle/games/sudoku/script/SudokuCtr.ts
+80
-15
SudokuItemCtr.ts
assets/sceneBundle/games/sudoku/script/SudokuItemCtr.ts
+22
-8
SudokuLevelCtr.ts
assets/sceneBundle/games/sudoku/script/SudokuLevelCtr.ts
+46
-5
ViewDef.ts
assets/startFolder/script/common/ViewDef.ts
+11
-3
No files found.
assets/sceneBundle/games/sudoku/image/名称框.png.meta
View file @
d593838e
...
@@ -15,8 +15,8 @@
...
@@ -15,8 +15,8 @@
"id": "6c48a",
"id": "6c48a",
"name": "texture",
"name": "texture",
"userData": {
"userData": {
"wrapModeS": "
repeat
",
"wrapModeS": "
clamp-to-edge
",
"wrapModeT": "
repeat
",
"wrapModeT": "
clamp-to-edge
",
"minfilter": "linear",
"minfilter": "linear",
"magfilter": "linear",
"magfilter": "linear",
"mipfilter": "none",
"mipfilter": "none",
...
@@ -30,11 +30,45 @@
...
@@ -30,11 +30,45 @@
".json"
".json"
],
],
"subMetas": {}
"subMetas": {}
},
"f9941": {
"importer": "sprite-frame",
"uuid": "529951ff-e67f-4887-8240-54121bfa5daf@f9941",
"displayName": "名称框",
"id": "f9941",
"name": "spriteFrame",
"userData": {
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 262,
"height": 69,
"rawWidth": 262,
"rawHeight": 69,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"packable": true,
"isUuid": true,
"imageUuidOrDatabaseUri": "529951ff-e67f-4887-8240-54121bfa5daf@6c48a",
"atlasUuid": ""
},
"ver": "1.0.9",
"imported": true,
"files": [
".json"
],
"subMetas": {}
}
}
},
},
"userData": {
"userData": {
"hasAlpha": true,
"hasAlpha": true,
"type": "
textur
e",
"type": "
sprite-fram
e",
"redirect": "529951ff-e67f-4887-8240-54121bfa5daf@
6c48a
"
"redirect": "529951ff-e67f-4887-8240-54121bfa5daf@
f9941
"
}
}
}
}
assets/sceneBundle/games/sudoku/image/图标_橡皮.png.meta
View file @
d593838e
...
@@ -15,8 +15,8 @@
...
@@ -15,8 +15,8 @@
"id": "6c48a",
"id": "6c48a",
"name": "texture",
"name": "texture",
"userData": {
"userData": {
"wrapModeS": "
repeat
",
"wrapModeS": "
clamp-to-edge
",
"wrapModeT": "
repeat
",
"wrapModeT": "
clamp-to-edge
",
"minfilter": "linear",
"minfilter": "linear",
"magfilter": "linear",
"magfilter": "linear",
"mipfilter": "none",
"mipfilter": "none",
...
@@ -30,11 +30,45 @@
...
@@ -30,11 +30,45 @@
".json"
".json"
],
],
"subMetas": {}
"subMetas": {}
},
"f9941": {
"importer": "sprite-frame",
"uuid": "688ec887-bd95-45c5-b2f6-9c77d5471a1d@f9941",
"displayName": "图标_橡皮",
"id": "f9941",
"name": "spriteFrame",
"userData": {
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0.5,
"offsetY": 1.5,
"trimX": 3,
"trimY": 1,
"width": 55,
"height": 55,
"rawWidth": 60,
"rawHeight": 60,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"packable": true,
"isUuid": true,
"imageUuidOrDatabaseUri": "688ec887-bd95-45c5-b2f6-9c77d5471a1d@6c48a",
"atlasUuid": ""
},
"ver": "1.0.9",
"imported": true,
"files": [
".json"
],
"subMetas": {}
}
}
},
},
"userData": {
"userData": {
"hasAlpha": true,
"hasAlpha": true,
"type": "
textur
e",
"type": "
sprite-fram
e",
"redirect": "688ec887-bd95-45c5-b2f6-9c77d5471a1d@
6c48a
"
"redirect": "688ec887-bd95-45c5-b2f6-9c77d5471a1d@
f9941
"
}
}
}
}
assets/sceneBundle/games/sudoku/image/图标_铅笔.png.meta
View file @
d593838e
...
@@ -15,8 +15,8 @@
...
@@ -15,8 +15,8 @@
"id": "6c48a",
"id": "6c48a",
"name": "texture",
"name": "texture",
"userData": {
"userData": {
"wrapModeS": "
repeat
",
"wrapModeS": "
clamp-to-edge
",
"wrapModeT": "
repeat
",
"wrapModeT": "
clamp-to-edge
",
"minfilter": "linear",
"minfilter": "linear",
"magfilter": "linear",
"magfilter": "linear",
"mipfilter": "none",
"mipfilter": "none",
...
@@ -30,11 +30,45 @@
...
@@ -30,11 +30,45 @@
".json"
".json"
],
],
"subMetas": {}
"subMetas": {}
},
"f9941": {
"importer": "sprite-frame",
"uuid": "8aa9d4a3-3ae5-4cd7-b058-a99aa459778e@f9941",
"displayName": "图标_铅笔",
"id": "f9941",
"name": "spriteFrame",
"userData": {
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": -1.5,
"offsetY": 1,
"trimX": 0,
"trimY": 0,
"width": 50,
"height": 51,
"rawWidth": 53,
"rawHeight": 53,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"packable": true,
"isUuid": true,
"imageUuidOrDatabaseUri": "8aa9d4a3-3ae5-4cd7-b058-a99aa459778e@6c48a",
"atlasUuid": ""
},
"ver": "1.0.9",
"imported": true,
"files": [
".json"
],
"subMetas": {}
}
}
},
},
"userData": {
"userData": {
"hasAlpha": true,
"hasAlpha": true,
"type": "
textur
e",
"type": "
sprite-fram
e",
"redirect": "8aa9d4a3-3ae5-4cd7-b058-a99aa459778e@
6c48a
"
"redirect": "8aa9d4a3-3ae5-4cd7-b058-a99aa459778e@
f9941
"
}
}
}
}
assets/sceneBundle/games/sudoku/image/得分框.png.meta
View file @
d593838e
...
@@ -15,8 +15,8 @@
...
@@ -15,8 +15,8 @@
"id": "6c48a",
"id": "6c48a",
"name": "texture",
"name": "texture",
"userData": {
"userData": {
"wrapModeS": "
repeat
",
"wrapModeS": "
clamp-to-edge
",
"wrapModeT": "
repeat
",
"wrapModeT": "
clamp-to-edge
",
"minfilter": "linear",
"minfilter": "linear",
"magfilter": "linear",
"magfilter": "linear",
"mipfilter": "none",
"mipfilter": "none",
...
@@ -30,11 +30,45 @@
...
@@ -30,11 +30,45 @@
".json"
".json"
],
],
"subMetas": {}
"subMetas": {}
},
"f9941": {
"importer": "sprite-frame",
"uuid": "42cbbdac-76da-4e12-831e-13910dc3835d@f9941",
"displayName": "得分框",
"id": "f9941",
"name": "spriteFrame",
"userData": {
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 196,
"height": 63,
"rawWidth": 196,
"rawHeight": 63,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"packable": true,
"isUuid": true,
"imageUuidOrDatabaseUri": "42cbbdac-76da-4e12-831e-13910dc3835d@6c48a",
"atlasUuid": ""
},
"ver": "1.0.9",
"imported": true,
"files": [
".json"
],
"subMetas": {}
}
}
},
},
"userData": {
"userData": {
"hasAlpha": true,
"hasAlpha": true,
"type": "
textur
e",
"type": "
sprite-fram
e",
"redirect": "42cbbdac-76da-4e12-831e-13910dc3835d@
6c48a
"
"redirect": "42cbbdac-76da-4e12-831e-13910dc3835d@
f9941
"
}
}
}
}
assets/sceneBundle/games/sudoku/image/时间框.png.meta
View file @
d593838e
...
@@ -15,8 +15,8 @@
...
@@ -15,8 +15,8 @@
"id": "6c48a",
"id": "6c48a",
"name": "texture",
"name": "texture",
"userData": {
"userData": {
"wrapModeS": "
repeat
",
"wrapModeS": "
clamp-to-edge
",
"wrapModeT": "
repeat
",
"wrapModeT": "
clamp-to-edge
",
"minfilter": "linear",
"minfilter": "linear",
"magfilter": "linear",
"magfilter": "linear",
"mipfilter": "none",
"mipfilter": "none",
...
@@ -30,11 +30,45 @@
...
@@ -30,11 +30,45 @@
".json"
".json"
],
],
"subMetas": {}
"subMetas": {}
},
"f9941": {
"importer": "sprite-frame",
"uuid": "f8dcf46a-f6cb-4b3c-8253-4a9945e9391f@f9941",
"displayName": "时间框",
"id": "f9941",
"name": "spriteFrame",
"userData": {
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 376,
"height": 69,
"rawWidth": 376,
"rawHeight": 69,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"packable": true,
"isUuid": true,
"imageUuidOrDatabaseUri": "f8dcf46a-f6cb-4b3c-8253-4a9945e9391f@6c48a",
"atlasUuid": ""
},
"ver": "1.0.9",
"imported": true,
"files": [
".json"
],
"subMetas": {}
}
}
},
},
"userData": {
"userData": {
"hasAlpha": true,
"hasAlpha": true,
"type": "
textur
e",
"type": "
sprite-fram
e",
"redirect": "f8dcf46a-f6cb-4b3c-8253-4a9945e9391f@
6c48a
"
"redirect": "f8dcf46a-f6cb-4b3c-8253-4a9945e9391f@
f9941
"
}
}
}
}
assets/sceneBundle/games/sudoku/image/目标分数框.png.meta
View file @
d593838e
...
@@ -15,8 +15,8 @@
...
@@ -15,8 +15,8 @@
"id": "6c48a",
"id": "6c48a",
"name": "texture",
"name": "texture",
"userData": {
"userData": {
"wrapModeS": "
repeat
",
"wrapModeS": "
clamp-to-edge
",
"wrapModeT": "
repeat
",
"wrapModeT": "
clamp-to-edge
",
"minfilter": "linear",
"minfilter": "linear",
"magfilter": "linear",
"magfilter": "linear",
"mipfilter": "none",
"mipfilter": "none",
...
@@ -30,11 +30,45 @@
...
@@ -30,11 +30,45 @@
".json"
".json"
],
],
"subMetas": {}
"subMetas": {}
},
"f9941": {
"importer": "sprite-frame",
"uuid": "36092018-5dae-44cd-8603-c86a799139b1@f9941",
"displayName": "目标分数框",
"id": "f9941",
"name": "spriteFrame",
"userData": {
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 196,
"height": 63,
"rawWidth": 196,
"rawHeight": 63,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"packable": true,
"isUuid": true,
"imageUuidOrDatabaseUri": "36092018-5dae-44cd-8603-c86a799139b1@6c48a",
"atlasUuid": ""
},
"ver": "1.0.9",
"imported": true,
"files": [
".json"
],
"subMetas": {}
}
}
},
},
"userData": {
"userData": {
"hasAlpha": true,
"hasAlpha": true,
"type": "
textur
e",
"type": "
sprite-fram
e",
"redirect": "36092018-5dae-44cd-8603-c86a799139b1@
6c48a
"
"redirect": "36092018-5dae-44cd-8603-c86a799139b1@
f9941
"
}
}
}
}
assets/sceneBundle/games/sudoku/prefab/SudokuLevelView.prefab
View file @
d593838e
...
@@ -143,7 +143,7 @@
...
@@ -143,7 +143,7 @@
},
},
"_lpos": {
"_lpos": {
"__type__": "cc.Vec3",
"__type__": "cc.Vec3",
"x":
0
,
"x":
-77
,
"y": -45.622,
"y": -45.622,
"z": 0
"z": 0
},
},
...
@@ -255,10 +255,10 @@
...
@@ -255,10 +255,10 @@
"_alignFlags": 18,
"_alignFlags": 18,
"_target": null,
"_target": null,
"_left": 0,
"_left": 0,
"_right":
0
,
"_right":
387
,
"_top": 0,
"_top": 0,
"_bottom": 0,
"_bottom": 0,
"_horizontalCenter":
0
,
"_horizontalCenter":
-77
,
"_verticalCenter": -45.622,
"_verticalCenter": -45.622,
"_isAbsLeft": true,
"_isAbsLeft": true,
"_isAbsRight": true,
"_isAbsRight": true,
...
@@ -308,7 +308,7 @@
...
@@ -308,7 +308,7 @@
},
},
"_lpos": {
"_lpos": {
"__type__": "cc.Vec3",
"__type__": "cc.Vec3",
"x":
0
,
"x":
-77
,
"y": -45.622,
"y": -45.622,
"z": 0
"z": 0
},
},
...
@@ -375,10 +375,10 @@
...
@@ -375,10 +375,10 @@
"_alignFlags": 18,
"_alignFlags": 18,
"_target": null,
"_target": null,
"_left": 0,
"_left": 0,
"_right":
0
,
"_right":
413
,
"_top": 0,
"_top": 0,
"_bottom": 0,
"_bottom": 0,
"_horizontalCenter":
0
,
"_horizontalCenter":
-77
,
"_verticalCenter": -45.622,
"_verticalCenter": -45.622,
"_isAbsLeft": true,
"_isAbsLeft": true,
"_isAbsRight": true,
"_isAbsRight": true,
...
...
assets/sceneBundle/games/sudoku/scene/Sudoku.scene
View file @
d593838e
This diff is collapsed.
Click to expand it.
assets/sceneBundle/games/sudoku/script/SudokuCfg.ts
0 → 100644
View file @
d593838e
This diff is collapsed.
Click to expand it.
assets/sceneBundle/games/sudoku/script/SudokuCfg.ts.meta
0 → 100644
View file @
d593838e
{
"ver": "4.0.22",
"importer": "typescript",
"imported": true,
"uuid": "2a41cb09-6bd9-46b3-a949-ec0680bacf53",
"files": [],
"subMetas": {},
"userData": {}
}
assets/sceneBundle/games/sudoku/script/SudokuCtr.ts
View file @
d593838e
import
{
_decorator
,
Component
,
Node
}
from
'cc'
;
import
{
_decorator
,
Component
,
Node
,
instantiate
,
Button
,
Toggle
,
Label
,
director
}
from
'cc'
;
import
{
ViewPathUnitItf
,
VIEW_DEF
}
from
'../../../../startFolder/script/common/ViewDef'
;
import
{
VIEW_DEF
}
from
'../../../../startFolder/script/common/ViewDef'
;
import
{
viewMgr
}
from
'../../../../startFolder/script/common/ViewMgr'
;
import
{
SK_LV_1
,
SK_LV_2
,
SK_LV_3
,
SK_LV_4
}
from
'./SudokuCfg'
;
import
{
SudokuItemCtr
}
from
'./SudokuItemCtr'
;
import
{
SudokuLevelViewCtr
}
from
'./SudokuLevelCtr'
;
const
{
ccclass
,
property
}
=
_decorator
;
const
{
ccclass
,
property
}
=
_decorator
;
enum
GAME_STATE
{
enum
GAME_STATE
{
...
@@ -13,38 +17,99 @@ enum GAME_STATE {
...
@@ -13,38 +17,99 @@ enum GAME_STATE {
@
ccclass
(
'SudokuCtr'
)
@
ccclass
(
'SudokuCtr'
)
export
class
SudokuCtr
extends
Component
{
export
class
SudokuCtr
extends
Component
{
@
property
(
Node
)
numOptsNode
:
Node
=
null
!
;
private
gameState
=
GAME_STATE
.
READY
;
private
gameState
=
GAME_STATE
.
READY
;
private
levelView
:
ViewPathUnitItf
=
null
!
;
private
fillNum
=
1
;
private
level
=
1
;
private
sqr
=
5
;
;
start
()
{
start
()
{
// [3]
// [3]
director
.
on
(
"sk_item_click"
,
this
.
onItemClick
,
this
);
this
.
gameStart
();
}
onDestroy
()
{
director
.
off
(
"sk_item_click"
,
this
.
onItemClick
,
this
);
}
onItemClick
(
item
:
SudokuItemCtr
)
{
if
(
this
.
gameState
==
GAME_STATE
.
FILL
)
{
item
.
setNumStr
(
this
.
fillNum
.
toString
());
if
(
this
.
checkWin
())
{
console
.
log
(
`游戏成功`
);
this
.
gameEnd
(
true
);
}
}
else
if
(
this
.
gameState
==
GAME_STATE
.
ERASE
)
{
item
.
setNumStr
(
""
);
}
}
checkWin
()
{
return
viewMgr
.
getView
(
VIEW_DEF
.
SudokuLevelView
).
getComponent
(
SudokuLevelViewCtr
)?.
checkWin
();
}
}
gameStart
()
{
gameStart
()
{
this
.
gameState
=
GAME_STATE
.
READY
;
this
.
fillNum
=
1
;
let
level
=
4
;
let
cfg
=
this
.
getLevelCfg
(
level
)[
Math
.
floor
(
Math
.
random
()
*
this
.
getLevelCfg
(
level
).
length
)];
this
.
sqr
=
cfg
.
sqr
;
viewMgr
.
openView
(
VIEW_DEF
.
SudokuLevelView
,
(
node
)
=>
{
node
.
getComponent
(
SudokuLevelViewCtr
)?.
setItemIfos
(
cfg
);
});
this
.
setNumTogs
();
this
.
gameState
=
GAME_STATE
.
FILL
;
}
setNumTogs
()
{
while
(
this
.
numOptsNode
.
children
.
length
<
this
.
sqr
)
{
this
.
numOptsNode
.
addChild
(
instantiate
(
this
.
numOptsNode
.
children
[
0
]));
}
for
(
let
i
=
0
;
i
<
this
.
numOptsNode
.
children
.
length
;
++
i
)
{
this
.
numOptsNode
.
children
[
i
].
active
=
i
<
this
.
sqr
;
this
.
numOptsNode
.
children
[
i
].
getComponent
(
Toggle
)
!
.
clickEvents
[
0
].
customEventData
=
(
i
+
1
)
+
""
;
this
.
numOptsNode
.
children
[
i
].
getComponentInChildren
(
Label
)
!
.
string
=
(
i
+
1
)
+
""
;
}
}
gameEnd
(
isWin
:
boolean
)
{
this
.
gameState
=
GAME_STATE
.
END
;
}
}
gameEnd
()
{
update
(
deltaTime
:
number
)
{
// [4]
}
onFillNumClick
(
err
:
any
,
numStr
:
string
)
{
this
.
fillNum
=
Number
(
numStr
);
}
onPencilClick
()
{
if
(
this
.
gameState
!=
GAME_STATE
.
ERASE
)
return
;
this
.
gameState
=
GAME_STATE
.
FILL
;
}
}
getLevelView
(
level
:
number
):
ViewPathUnitItf
{
onEraserClick
()
{
if
(
this
.
gameState
!=
GAME_STATE
.
FILL
)
return
;
this
.
gameState
=
GAME_STATE
.
ERASE
;
}
getLevelCfg
(
level
:
number
)
{
switch
(
level
)
{
switch
(
level
)
{
case
1
:
case
1
:
return
VIEW_DEF
.
MgcSpAswTwoView
;
return
SK_LV_1
;
case
2
:
case
2
:
return
VIEW_DEF
.
MgcSpAswTwoView
;
return
SK_LV_2
;
case
3
:
case
3
:
return
VIEW_DEF
.
MgcSpAswTwoView
;
return
SK_LV_3
;
case
4
:
case
4
:
return
VIEW_DEF
.
MgcSpAswTwoView
;
return
SK_LV_4
;
default
:
default
:
return
VIEW_DEF
.
MgcSpAswTwoView
;
return
SK_LV_1
;
}
}
}
}
update
(
deltaTime
:
number
)
{
// [4]
}
}
}
assets/sceneBundle/games/sudoku/script/SudokuItemCtr.ts
View file @
d593838e
import
{
_decorator
,
Component
,
Node
,
SpriteFrame
,
Sprite
,
Label
,
CCString
,
CCInteger
,
ccenum
,
director
,
Color
,
log
,
math
}
from
'cc'
;
import
{
_decorator
,
Component
,
Node
,
SpriteFrame
,
Sprite
,
Label
,
CCString
,
CCInteger
,
ccenum
,
director
,
Color
,
log
,
math
}
from
'cc'
;
import
{
EDITOR
}
from
'cc/env'
;
import
{
EDITOR
}
from
'cc/env'
;
import
{
ItemPosIfo
}
from
'./SudokuLevelCtr'
;
const
{
ccclass
,
property
}
=
_decorator
;
const
{
ccclass
,
property
}
=
_decorator
;
export
enum
SK_ITEM_TYPE
{
export
enum
SK_ITEM_TYPE
{
...
@@ -25,11 +26,8 @@ export class SudokuItemCtr extends Component {
...
@@ -25,11 +26,8 @@ export class SudokuItemCtr extends Component {
@
property
(
Node
)
@
property
(
Node
)
clickNode
:
Node
=
null
!
;
clickNode
:
Node
=
null
!
;
@
property
(
CCInteger
)
private
posIfo
:
ItemPosIfo
=
null
!
;
row
:
number
=
1
;
private
rightNumStr
=
""
;
@
property
(
CCInteger
)
column
:
number
=
1
;
start
()
{
start
()
{
// [3]
// [3]
...
@@ -38,7 +36,7 @@ export class SudokuItemCtr extends Component {
...
@@ -38,7 +36,7 @@ export class SudokuItemCtr extends Component {
onItemClick
()
{
onItemClick
()
{
if
(
this
.
itemType
==
SK_ITEM_TYPE
.
INVARIABLE
)
return
;
if
(
this
.
itemType
==
SK_ITEM_TYPE
.
INVARIABLE
)
return
;
director
.
emit
(
""
,
this
);
director
.
emit
(
"
sk_item_click
"
,
this
);
}
}
getItemType
()
{
getItemType
()
{
...
@@ -57,11 +55,27 @@ export class SudokuItemCtr extends Component {
...
@@ -57,11 +55,27 @@ export class SudokuItemCtr extends Component {
this
.
numLab
.
string
=
value
;
this
.
numLab
.
string
=
value
;
}
}
setItemIfo
(
id
:
number
,
numStr
:
string
,
color
:
Color
,
type
:
SK_ITEM_TYPE
,
posIfo
:
ItemPosIfo
)
{
this
.
setItemType
(
type
);
this
.
setNumStr
(
numStr
);
this
.
rightNumStr
=
numStr
;
this
.
bgSpr
.
color
=
color
;
if
(
type
==
SK_ITEM_TYPE
.
VARIABLE
){
this
.
setNumStr
(
""
);
}
this
.
posIfo
=
posIfo
;
this
.
posIfo
.
target
=
this
.
node
;
}
isRight
(){
return
this
.
numLab
.
string
==
this
.
rightNumStr
;
}
/**
/**
* @returns [row, column]
* @returns [row, column]
*/
*/
get
Coordinates
()
{
get
PosIfo
()
{
return
[
this
.
row
,
this
.
column
]
;
return
this
.
posIfo
;
}
}
// update (deltaTime: number) {
// update (deltaTime: number) {
...
...
assets/sceneBundle/games/sudoku/script/SudokuLevelCtr.ts
View file @
d593838e
import
{
_decorator
,
Component
,
Node
,
Vec3
,
v3
,
CCInteger
,
Prefab
,
instantiate
,
UITransform
}
from
'cc'
;
import
{
_decorator
,
Component
,
Node
,
Vec3
,
v3
,
CCInteger
,
Prefab
,
instantiate
,
UITransform
,
Color
}
from
'cc'
;
import
{
SK_ItemIfoItf
,
SK_ItemVarItf
,
SK_LevelItf
}
from
'./SudokuCfg'
;
import
{
SudokuItemCtr
}
from
'./SudokuItemCtr'
;
const
{
ccclass
,
property
}
=
_decorator
;
const
{
ccclass
,
property
}
=
_decorator
;
export
interface
ItemPosIfo
{
export
interface
ItemPosIfo
{
...
@@ -34,17 +36,52 @@ export class SudokuLevelViewCtr extends Component {
...
@@ -34,17 +36,52 @@ export class SudokuLevelViewCtr extends Component {
private
itemSpaceY
=
2
;
private
itemSpaceY
=
2
;
private
itemPosIfoArr
:
ItemPosIfo
[]
=
[];
private
itemPosIfoArr
:
ItemPosIfo
[]
=
[];
start
()
{
start
()
{
// [3]
// [3]
}
setItemIfos
(
ifo
:
SK_LevelItf
)
{
let
itemIfoArr
:
SK_ItemIfoItf
[]
=
[];
for
(
let
i
=
0
;
i
<
ifo
.
itemIfoArr
.
length
;
++
i
)
{
itemIfoArr
.
push
(
ifo
.
itemIfoArr
[
i
]);
}
itemIfoArr
.
sort
((
a
,
b
)
=>
{
return
a
.
id
-
b
.
id
;
});
let
itemVarArr
:
SK_ItemVarItf
[]
=
[];
for
(
let
i
=
0
;
i
<
ifo
.
itemVarArr
.
length
;
++
i
)
{
itemVarArr
.
push
(
ifo
.
itemVarArr
[
i
]);
}
itemVarArr
.
sort
((
a
,
b
)
=>
{
return
a
.
id
-
b
.
id
;
});
if
(
ifo
.
sqr
*
ifo
.
sqr
!=
itemIfoArr
.
length
||
ifo
.
sqr
*
ifo
.
sqr
!=
itemVarArr
.
length
)
{
throw
new
Error
(
"想要创建的数据与提供的数据数量不匹配"
);
}
this
.
posArrNode
.
destroyAllChildren
();
this
.
row
=
ifo
.
sqr
;
this
.
column
=
ifo
.
sqr
;
this
.
itemPosIfoArr
=
this
.
getSqPosIfoArr
(
this
.
row
,
this
.
column
,
this
.
itemWidth
,
this
.
itemHeight
,
this
.
itemSpaceX
,
this
.
itemSpaceY
);
this
.
itemPosIfoArr
=
this
.
getSqPosIfoArr
(
this
.
row
,
this
.
column
,
this
.
itemWidth
,
this
.
itemHeight
,
this
.
itemSpaceX
,
this
.
itemSpaceY
);
for
(
let
i
=
0
;
i
<
this
.
itemPosIfoArr
.
length
;
++
i
){
// console.log(`位置信息`);
// console.log(this.itemPosIfoArr);
for
(
let
i
=
0
;
i
<
this
.
itemPosIfoArr
.
length
;
++
i
)
{
let
node
=
instantiate
(
this
.
itemPre
);
let
node
=
instantiate
(
this
.
itemPre
);
this
.
posArrNode
.
addChild
(
node
);
this
.
posArrNode
.
addChild
(
node
);
node
.
setPosition
(
this
.
itemPosIfoArr
[
i
].
pos
);
node
.
setPosition
(
this
.
itemPosIfoArr
[
i
].
pos
);
// console.log(`信息赋值:`);
// console.log(itemIfoArr[i]);
node
.
getComponent
(
SudokuItemCtr
)?.
setItemIfo
(
itemIfoArr
[
i
].
id
,
itemIfoArr
[
i
].
num
.
toString
(),
Color
.
fromHEX
(
new
Color
(),
itemIfoArr
[
i
].
color
),
itemVarArr
[
i
].
variable
,
this
.
itemPosIfoArr
[
i
]);
}
}
this
.
setBgSprSize
();
this
.
setBgSprSize
();
}
}
checkWin
(){
for
(
let
i
=
0
;
i
<
this
.
itemPosIfoArr
.
length
;
++
i
){
if
(
!
this
.
itemPosIfoArr
[
i
].
target
.
getComponent
(
SudokuItemCtr
)?.
isRight
())
return
false
;
}
return
true
;
}
setBgSprSize
()
{
setBgSprSize
()
{
let
minWidth
=
this
.
column
*
this
.
itemWidth
+
(
this
.
column
-
1
)
*
this
.
itemSpaceX
;
let
minWidth
=
this
.
column
*
this
.
itemWidth
+
(
this
.
column
-
1
)
*
this
.
itemSpaceX
;
let
minHeight
=
this
.
row
*
this
.
itemHeight
+
(
this
.
row
-
1
)
*
this
.
itemSpaceY
;
let
minHeight
=
this
.
row
*
this
.
itemHeight
+
(
this
.
row
-
1
)
*
this
.
itemSpaceY
;
...
@@ -62,10 +99,14 @@ export class SudokuLevelViewCtr extends Component {
...
@@ -62,10 +99,14 @@ export class SudokuLevelViewCtr extends Component {
for
(
let
r
=
1
;
r
<=
row
;
++
r
)
{
for
(
let
r
=
1
;
r
<=
row
;
++
r
)
{
let
y
=
s_height
*
(
r
-
1
+
0.5
)
+
(
r
-
1
)
*
spacingY
-
(
row
*
s_height
+
(
row
-
1
)
*
spacingY
)
/
2
;
let
y
=
s_height
*
(
r
-
1
+
0.5
)
+
(
r
-
1
)
*
spacingY
-
(
row
*
s_height
+
(
row
-
1
)
*
spacingY
)
/
2
;
y_arr
.
push
(
y
);
y_arr
.
push
(
y
);
y_arr
.
sort
((
a
,
b
)
=>
{
return
b
-
a
;
});
}
}
let
pos_arr
:
ItemPosIfo
[]
=
[];
let
pos_arr
:
ItemPosIfo
[]
=
[];
for
(
let
c
=
0
;
c
<
x_arr
.
length
;
++
c
)
{
for
(
let
r
=
0
;
r
<
y_arr
.
length
;
++
r
)
{
for
(
let
r
=
0
;
r
<
y_arr
.
length
;
++
r
)
{
for
(
let
c
=
0
;
c
<
x_arr
.
length
;
++
c
)
{
pos_arr
.
push
({
pos_arr
.
push
({
pos
:
v3
(
x_arr
[
c
],
y_arr
[
r
],
0
)
pos
:
v3
(
x_arr
[
c
],
y_arr
[
r
],
0
)
,
xIdx
:
c
,
xIdx
:
c
...
...
assets/startFolder/script/common/ViewDef.ts
View file @
d593838e
...
@@ -60,6 +60,8 @@ interface ViewPathItf {
...
@@ -60,6 +60,8 @@ interface ViewPathItf {
MgcSpAswOneView
:
ViewPathUnitItf
,
MgcSpAswOneView
:
ViewPathUnitItf
,
//魔法咒语问题2弹窗
//魔法咒语问题2弹窗
MgcSpAswTwoView
:
ViewPathUnitItf
,
MgcSpAswTwoView
:
ViewPathUnitItf
,
//锯齿数独游戏弹窗
SudokuLevelView
:
ViewPathUnitItf
,
//测试弹窗
//测试弹窗
TestView_1
:
ViewPathUnitItf
TestView_1
:
ViewPathUnitItf
}
}
...
@@ -155,18 +157,23 @@ export const VIEW_DEF: ViewPathItf = {
...
@@ -155,18 +157,23 @@ export const VIEW_DEF: ViewPathItf = {
path
:
"games/foodForTheParty/prefab/FFTPPipAnswerView"
,
path
:
"games/foodForTheParty/prefab/FFTPPipAnswerView"
,
},
},
//魔法咒语记忆弹窗
//魔法咒语记忆弹窗
MgcSpQueView
:
{
MgcSpQueView
:
{
bundleName
:
"sceneBundle"
,
bundleName
:
"sceneBundle"
,
path
:
"games/magicSpells/prefab/MgcSpQueView"
,
path
:
"games/magicSpells/prefab/MgcSpQueView"
,
},
},
//魔法咒语问题1弹窗
//魔法咒语问题1弹窗
MgcSpAswOneView
:
{
MgcSpAswOneView
:
{
bundleName
:
"sceneBundle"
,
bundleName
:
"sceneBundle"
,
path
:
"games/magicSpells/prefab/MgcSpAswOneView"
,
path
:
"games/magicSpells/prefab/MgcSpAswOneView"
,
},
},
//魔法咒语问题2弹窗
//魔法咒语问题2弹窗
MgcSpAswTwoView
:
{
MgcSpAswTwoView
:
{
bundleName
:
"sceneBundle"
,
bundleName
:
"sceneBundle"
,
path
:
"games/magicSpells/prefab/MgcSpAswTwoView"
,
path
:
"games/magicSpells/prefab/MgcSpAswTwoView"
,
},
},
//锯齿数独游戏弹窗
SudokuLevelView
:
{
bundleName
:
"sceneBundle"
,
path
:
"games/sudoku/prefab/SudokuLevelView"
,
}
}
}
\ 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