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
b930a813
Commit
b930a813
authored
Nov 02, 2021
by
unknown
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
邻接数组好了
parent
18642d0e
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
319 additions
and
12 deletions
+319
-12
名称框.png
assets/sceneBundle/games/adjacentArray/image/名称框.png
+0
-0
名称框.png.meta
assets/sceneBundle/games/adjacentArray/image/名称框.png.meta
+74
-0
AdjacentArray_1.scene
...eneBundle/games/adjacentArray/scene/AdjacentArray_1.scene
+0
-0
AdjacentArray_1.scene.meta
...ndle/games/adjacentArray/scene/AdjacentArray_1.scene.meta
+0
-0
AdjacentArrayCfg.ts
...ceneBundle/games/adjacentArray/script/AdjacentArrayCfg.ts
+19
-0
AdjacentArrayCfg.ts.meta
...undle/games/adjacentArray/script/AdjacentArrayCfg.ts.meta
+9
-0
AdjacentArrayCtr.ts
...ceneBundle/games/adjacentArray/script/AdjacentArrayCtr.ts
+173
-11
AdjacentArrayItemCtr.ts
...Bundle/games/adjacentArray/script/AdjacentArrayItemCtr.ts
+7
-0
LevelCfg.ts
assets/startFolder/script/LevelCfg.ts
+29
-0
LevelHomeCtr.ts
assets/startFolder/script/LevelHomeCtr.ts
+1
-1
SceneDef.ts
assets/startFolder/script/common/SceneDef.ts
+7
-0
No files found.
assets/sceneBundle/games/adjacentArray/image/名称框.png
0 → 100644
View file @
b930a813
2.53 KB
assets/sceneBundle/games/adjacentArray/image/名称框.png.meta
0 → 100644
View file @
b930a813
{
"ver": "1.0.21",
"importer": "image",
"imported": true,
"uuid": "46dc415a-025e-482a-8b9d-7afed35c78a2",
"files": [
".png",
".json"
],
"subMetas": {
"6c48a": {
"importer": "texture",
"uuid": "46dc415a-025e-482a-8b9d-7afed35c78a2@6c48a",
"displayName": "名称框",
"id": "6c48a",
"name": "texture",
"userData": {
"wrapModeS": "clamp-to-edge",
"wrapModeT": "clamp-to-edge",
"minfilter": "linear",
"magfilter": "linear",
"mipfilter": "none",
"anisotropy": 0,
"isUuid": true,
"imageUuidOrDatabaseUri": "46dc415a-025e-482a-8b9d-7afed35c78a2"
},
"ver": "1.0.21",
"imported": true,
"files": [
".json"
],
"subMetas": {}
},
"f9941": {
"importer": "sprite-frame",
"uuid": "46dc415a-025e-482a-8b9d-7afed35c78a2@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": "46dc415a-025e-482a-8b9d-7afed35c78a2@6c48a",
"atlasUuid": ""
},
"ver": "1.0.9",
"imported": true,
"files": [
".json"
],
"subMetas": {}
}
},
"userData": {
"hasAlpha": true,
"type": "sprite-frame",
"redirect": "46dc415a-025e-482a-8b9d-7afed35c78a2@f9941"
}
}
assets/sceneBundle/games/adjacentArray/scene/AdjacentArray.scene
→
assets/sceneBundle/games/adjacentArray/scene/AdjacentArray
_1
.scene
View file @
b930a813
This diff is collapsed.
Click to expand it.
assets/sceneBundle/games/adjacentArray/scene/AdjacentArray.scene.meta
→
assets/sceneBundle/games/adjacentArray/scene/AdjacentArray
_1
.scene.meta
View file @
b930a813
File moved
assets/sceneBundle/games/adjacentArray/script/AdjacentArrayCfg.ts
0 → 100644
View file @
b930a813
import
{
_decorator
,
Component
,
Node
}
from
'cc'
;
const
{
ccclass
,
property
}
=
_decorator
;
export
const
adjacentArrayLV_1
:
number
[][]
=
[
[
1
,
0
,
0
,
3
],
[
2
,
3
,
2
,
1
],
[
3
,
3
,
0
,
3
],
[
2
,
1
,
1
,
2
]
];
export
const
adjacentArrayLV_2
:
number
[][]
=
[
[
1
,
0
,
0
,
3
],
[
2
,
3
,
2
,
1
],
[
3
,
3
,
0
,
3
],
[
3
,
1
,
1
,
2
],
[
2
,
2
,
1
,
1
]
];
\ No newline at end of file
assets/sceneBundle/games/adjacentArray/script/AdjacentArrayCfg.ts.meta
0 → 100644
View file @
b930a813
{
"ver": "4.0.22",
"importer": "typescript",
"imported": true,
"uuid": "5cb4c21e-2428-4549-8b22-47a9e1286ec6",
"files": [],
"subMetas": {},
"userData": {}
}
assets/sceneBundle/games/adjacentArray/script/AdjacentArrayCtr.ts
View file @
b930a813
import
{
_decorator
,
Component
,
Node
,
Vec3
,
v3
,
Prefab
,
Label
,
CCFloat
,
instantiate
,
UITransform
,
SpriteFrame
,
Sprite
,
Color
,
EventTouch
}
from
'cc'
;
import
{
_decorator
,
Component
,
Node
,
Vec3
,
v3
,
Prefab
,
Label
,
CCFloat
,
instantiate
,
UITransform
,
SpriteFrame
,
Sprite
,
Color
,
EventTouch
,
director
}
from
'cc'
;
import
{
countdownMus
,
failMus
,
succMus
}
from
'../../../../startFolder/script/common/AudioDef'
;
import
{
AudioMgr
}
from
'../../../../startFolder/script/common/AudioMgr'
;
import
{
Utils
}
from
'../../../../startFolder/script/common/Utils'
;
import
{
VIEW_DEF
}
from
'../../../../startFolder/script/common/ViewDef'
;
import
{
viewMgr
,
VIEW_INDEX
}
from
'../../../../startFolder/script/common/ViewMgr'
;
import
{
BeginCountdownView
}
from
'../../commonView/script/BeginCountdownView'
;
import
{
ChallengeSuccView
}
from
'../../commonView/script/ChallengeSuccView'
;
import
{
GameDescView
}
from
'../../commonView/script/GameDescView'
;
import
{
adjacentArrayLV_1
,
adjacentArrayLV_2
}
from
'./AdjacentArrayCfg'
;
import
{
AdjacentArrayItemCtr
}
from
'./AdjacentArrayItemCtr'
;
const
{
ccclass
,
property
}
=
_decorator
;
...
...
@@ -18,6 +27,13 @@ export interface GridIfo {
clickNode
:
Node
,
}
enum
GAME_STATE
{
READY
=
10
,
PAUSE
=
20
,
END
=
30
,
RUN
=
40
,
}
@
ccclass
(
'AdjacentArrayCtr'
)
export
class
AdjacentArrayCtr
extends
Component
{
...
...
@@ -51,34 +67,112 @@ export class AdjacentArrayCtr extends Component {
private
row
=
5
;
private
column
=
6
;
private
gridIfoArr
:
GridIfo
[]
=
[];
private
levelData
:
number
[][]
=
[];
private
level
=
0
;
private
gameState
:
GAME_STATE
=
GAME_STATE
.
READY
;
private
costTime
=
0
;
private
isPlayCountdownMus
=
false
;
private
isShowGameDescViewOnce
=
false
;
showGameDescView
()
{
this
.
isShowGameDescViewOnce
=
true
;
viewMgr
.
openView
(
VIEW_DEF
.
GameDescView
,
(
node
)
=>
{
node
.
getComponent
(
GameDescView
)?.
setDesc
(
"点击两个数字中间的空格将两个数字合并成一个,
\
n当所有数字都两两组合完成时,没有重复的数字就算成功。
\
n注:点击两个已经组合的数字可以将其分开。"
);
});
}
onCloseGameDescView
()
{
this
.
gameState
=
GAME_STATE
.
RUN
;
}
setGameData
(
resData
:
object
)
{
//@ts-ignore
if
(
resData
.
totalTime
)
{
//@ts-ignore
this
.
totalTime
=
resData
.
totalTime
;
}
//@ts-ignore
if
(
resData
.
level
)
{
//@ts-ignore
this
.
level
=
resData
.
level
;
}
//@ts-ignore
if
(
resData
.
isShowGuide
)
{
//@ts-ignore
this
.
isShowGameDescViewOnce
=
false
;
}
else
{
this
.
isShowGameDescViewOnce
=
true
;
}
}
start
()
{
// [3]
director
.
on
(
"begin_countdown_end"
,
()
=>
{
//引导
if
(
!
this
.
isShowGameDescViewOnce
)
{
this
.
gameState
=
GAME_STATE
.
PAUSE
;
this
.
showGameDescView
();
}
else
{
this
.
gameState
=
GAME_STATE
.
RUN
;
}
},
this
);
director
.
on
(
"game_desc_close"
,
this
.
onCloseGameDescView
,
this
);
this
.
gameStart
();
}
onDestroy
()
{
director
.
off
(
"begin_countdown_end"
);
director
.
off
(
"game_desc_close"
,
this
.
onCloseGameDescView
,
this
);
}
gameStart
()
{
this
.
countdownLab
.
string
=
Utils
.
formatTime
(
Math
.
floor
(
this
.
totalTime
*
1000
));
this
.
gameState
=
GAME_STATE
.
READY
;
this
.
loadLevelData
();
this
.
itemPosArrNode
.
destroyAllChildren
();
this
.
gridArrNode
.
destroyAllChildren
();
this
.
creAllItem
();
this
.
setBgSprSize
();
this
.
creAllGrid
();
viewMgr
.
openView
(
VIEW_DEF
.
BeginCountdownView
,
(
node
)
=>
{
node
.
getComponent
(
BeginCountdownView
)?.
init
();
},
VIEW_INDEX
.
UPPER
);
// this.gameState = GAME_STATE.RUN;
}
gameEnd
(
isWin
:
boolean
)
{
this
.
gameState
=
GAME_STATE
.
END
;
if
(
isWin
)
{
viewMgr
.
openView
(
VIEW_DEF
.
ChallengeSuccView
,
(
node
)
=>
{
AudioMgr
.
playOneShot
(
succMus
);
node
?.
getComponent
(
ChallengeSuccView
)?.
init
();
},
VIEW_INDEX
.
TOP
);
}
else
{
viewMgr
.
openView
(
VIEW_DEF
.
ChallengeFailView
,
(
node
)
=>
{
AudioMgr
.
playOneShot
(
failMus
);
},
VIEW_INDEX
.
TOP
);
}
}
onGridClick
(
event
:
EventTouch
)
{
console
.
log
(
`grid被点击`
);
console
.
log
(
event
.
target
)
//
console.log(`grid被点击`);
//
console.log(event.target)
let
grid
=
this
.
findGridInGridArr
(
<
Node
>
event
.
target
)
!
;
grid
.
active
=
!
grid
.
active
;
if
(
grid
.
active
)
{
console
.
log
(
`选中格子`
);
console
.
log
(
grid
.
gridItem
);
//
console.log(`选中格子`);
//
console.log(grid.gridItem);
//先去掉
let
o_gridArr
=
this
.
findGridInGridArrWithItem
(
grid
.
pairItem
[
0
]);
o_gridArr
=
o_gridArr
.
concat
(
this
.
findGridInGridArrWithItem
(
grid
.
pairItem
[
1
]));
for
(
let
i
=
0
;
i
<
o_gridArr
.
length
;
++
i
)
{
if
(
!
o_gridArr
[
i
].
active
)
continue
;
if
(
!
o_gridArr
[
i
].
active
)
continue
;
o_gridArr
[
i
].
active
=
false
;
o_gridArr
[
i
].
gridItem
.
active
=
false
;
o_gridArr
[
i
].
pairItem
[
0
].
target
.
getComponent
(
AdjacentArrayItemCtr
)?.
setBgSprToNor
();
...
...
@@ -93,23 +187,58 @@ export class AdjacentArrayCtr extends Component {
else
{
grid
.
gridItem
.
active
=
false
;
grid
.
active
=
false
;
console
.
log
(
`选中格子`
);
console
.
log
(
grid
.
gridItem
);
//
console.log(`选中格子`);
//
console.log(grid.gridItem);
grid
.
pairItem
[
0
].
target
.
getComponent
(
AdjacentArrayItemCtr
)?.
setBgSprToNor
();
grid
.
pairItem
[
1
].
target
.
getComponent
(
AdjacentArrayItemCtr
)?.
setBgSprToNor
();
}
//检测是否成功
if
(
this
.
checkWin
())
{
console
.
log
(
`成功了`
);
this
.
gameEnd
(
true
);
}
else
{
console
.
log
(
`没有成功`
);
}
}
creAllItem
()
{
let
numArr
:
number
[]
=
[];
for
(
let
i
=
0
;
i
<
this
.
levelData
.
length
;
++
i
){
numArr
=
numArr
.
concat
(
this
.
levelData
[
i
]);
}
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
)
{
let
node
=
instantiate
(
this
.
itemPre
);
this
.
itemPosArrNode
.
addChild
(
node
);
node
.
setPosition
(
this
.
itemPosIfoArr
[
i
].
pos
);
this
.
itemPosIfoArr
[
i
].
target
=
node
;
node
.
getComponent
(
AdjacentArrayItemCtr
)?.
setNum
(
numArr
[
i
]);
}
}
checkWin
()
{
let
numStrArr
:
string
[]
=
[];
for
(
let
i
=
0
;
i
<
this
.
gridIfoArr
.
length
;
++
i
)
{
let
f_num
=
this
.
gridIfoArr
[
i
].
pairItem
[
0
].
target
.
getComponent
(
AdjacentArrayItemCtr
)
!
.
getNum
();
let
s_num
=
this
.
gridIfoArr
[
i
].
pairItem
[
1
].
target
.
getComponent
(
AdjacentArrayItemCtr
)
!
.
getNum
();
if
(
this
.
gridIfoArr
[
i
].
active
)
{
numStrArr
.
push
(
`
${
f_num
}${
s_num
}
`
);
}
}
if
(
numStrArr
.
length
<
this
.
row
*
this
.
column
/
2
)
return
false
;
let
repeatSet
:
Set
<
string
>
=
new
Set
<
string
>
();
for
(
let
i
=
0
;
i
<
numStrArr
.
length
;
++
i
)
{
if
(
repeatSet
.
has
(
numStrArr
[
i
]))
{
return
false
;
}
else
{
repeatSet
.
add
(
numStrArr
[
i
]);
}
}
return
true
;
}
setBgSprSize
()
{
let
minWidth
=
this
.
column
*
this
.
itemWidth
+
(
this
.
column
-
1
)
*
this
.
itemSpaceX
;
let
minHeight
=
this
.
row
*
this
.
itemHeight
+
(
this
.
row
-
1
)
*
this
.
itemSpaceY
;
...
...
@@ -233,7 +362,39 @@ export class AdjacentArrayCtr extends Component {
return
items
;
}
// update (deltaTime: number) {
// // [4]
// }
loadLevelData
()
{
switch
(
this
.
level
)
{
case
1
:
this
.
levelData
=
adjacentArrayLV_1
;
break
;
default
:
this
.
levelData
=
adjacentArrayLV_2
;
break
;
}
this
.
row
=
this
.
levelData
.
length
;
this
.
column
=
this
.
levelData
[
0
].
length
;
}
//倒计时
countdownTime
(
dt
:
number
)
{
if
(
this
.
gameState
==
GAME_STATE
.
READY
||
this
.
gameState
==
GAME_STATE
.
END
||
this
.
gameState
==
GAME_STATE
.
PAUSE
)
{
return
;
}
this
.
costTime
+=
dt
;
if
(
!
this
.
isPlayCountdownMus
&&
this
.
totalTime
-
this
.
costTime
<
3.5
)
{
this
.
isPlayCountdownMus
=
true
;
AudioMgr
.
playOneShot
(
countdownMus
);
}
if
(
this
.
totalTime
-
this
.
costTime
<=
0
)
{
console
.
log
(
`游戏时间到`
);
this
.
gameEnd
(
false
);
return
;
}
this
.
countdownLab
.
string
=
Utils
.
formatTime
(
Math
.
floor
((
this
.
totalTime
-
this
.
costTime
)
*
1000
));
}
update
(
deltaTime
:
number
)
{
// [4]
this
.
countdownTime
(
deltaTime
);
}
}
\ No newline at end of file
assets/sceneBundle/games/adjacentArray/script/AdjacentArrayItemCtr.ts
View file @
b930a813
...
...
@@ -11,6 +11,8 @@ export class AdjacentArrayItemCtr extends Component {
@
property
(
Label
)
numLab
:
Label
=
null
!
;
private
_showNum
=
0
;
start
()
{
// [3]
}
...
...
@@ -25,6 +27,11 @@ export class AdjacentArrayItemCtr extends Component {
setNum
(
value
:
number
)
{
this
.
numLab
.
string
=
value
.
toString
();
this
.
_showNum
=
value
;
}
getNum
(){
return
this
.
_showNum
;
}
// update (deltaTime: number) {
...
...
assets/startFolder/script/LevelCfg.ts
View file @
b930a813
...
...
@@ -1081,4 +1081,32 @@ export const levelCfg: OneVarLevelItf[] = [
}
]
}
,
{
gameIdHead
:
170
,
title
:
"邻接数组"
,
desc
:
"邻接数组,第一个版本"
,
levelArr
:
[{
gameId
:
17001
,
sceneUnitIfo
:
SCENE_DEF
.
AdjacentArray_1
,
comName
:
"AdjacentArrayCtr"
,
level
:
1
,
resData
:
{
totalTime
:
60
,
level
:
1
,
isShowGuide
:
true
}
}
,
{
gameId
:
17002
,
sceneUnitIfo
:
SCENE_DEF
.
AdjacentArray_1
,
comName
:
"AdjacentArrayCtr"
,
level
:
2
,
resData
:
{
totalTime
:
120
,
level
:
2
}
}
]
}
];
\ No newline at end of file
assets/startFolder/script/LevelHomeCtr.ts
View file @
b930a813
...
...
@@ -26,7 +26,7 @@ export class LevelHomeCtr extends Component {
// [3]
if
(
!
levelMgr
.
loadedOutData
)
{
levelMgr
.
loadedOutData
=
true
;
levelMgr
.
gameIdHead
=
10
;
levelMgr
.
gameIdHead
=
1
7
0
;
levelMgr
.
unLockCount
=
10
;
if
(
Utils
.
getValueFromHref
(
"gameIdHead"
))
{
levelMgr
.
gameIdHead
=
Number
(
Utils
.
getValueFromHref
(
"gameIdHead"
));
...
...
assets/startFolder/script/common/SceneDef.ts
View file @
b930a813
...
...
@@ -101,6 +101,8 @@ interface ScenePathItf {
LatticeBlockade_1
:
ScenePathUnitItf
,
//数字谜图
DigitalMysteryFigure_1
:
ScenePathUnitItf
,
//邻接数组
AdjacentArray_1
:
ScenePathUnitItf
,
}
export
const
SCENE_DEF
:
ScenePathItf
=
{
TestScene
:
{
...
...
@@ -438,4 +440,9 @@ export const SCENE_DEF: ScenePathItf = {
sceneName
:
"DigitalMysteryFigure_1"
,
desc
:
"数字谜图,第一个版本"
},
AdjacentArray_1
:
{
bundleName
:
"sceneBundle"
,
sceneName
:
"AdjacentArray_1"
,
desc
:
"邻接数组,第一个版本"
},
}
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