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
2f3de712
Commit
2f3de712
authored
Nov 08, 2021
by
unknown
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
数式接龙好了
parent
d87f860d
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
286 additions
and
19 deletions
+286
-19
时间框.png
assets/sceneBundle/games/formulaSolitaire/image/时间框.png
+0
-0
时间框.png.meta
assets/sceneBundle/games/formulaSolitaire/image/时间框.png.meta
+74
-0
FormulaSolitaire_1.scene
...dle/games/formulaSolitaire/scene/FormulaSolitaire_1.scene
+0
-0
FormulaSolitaire_1.scene.meta
...ames/formulaSolitaire/scene/FormulaSolitaire_1.scene.meta
+0
-0
FormulaSolitaireCfg.ts
...ndle/games/formulaSolitaire/script/FormulaSolitaireCfg.ts
+39
-0
FormulaSolitaireCfg.ts.meta
...games/formulaSolitaire/script/FormulaSolitaireCfg.ts.meta
+9
-0
FormulaSolitaireCtr.ts
...ndle/games/formulaSolitaire/script/FormulaSolitaireCtr.ts
+125
-16
FormulaSolitaireItem.ts
...dle/games/formulaSolitaire/script/FormulaSolitaireItem.ts
+1
-1
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
+8
-1
No files found.
assets/sceneBundle/games/formulaSolitaire/image/时间框.png
0 → 100644
View file @
2f3de712
1.98 KB
assets/sceneBundle/games/formulaSolitaire/image/时间框.png.meta
0 → 100644
View file @
2f3de712
{
"ver": "1.0.21",
"importer": "image",
"imported": true,
"uuid": "4ca08d57-ebb2-435a-910c-7b6c15aa85c8",
"files": [
".png",
".json"
],
"subMetas": {
"6c48a": {
"importer": "texture",
"uuid": "4ca08d57-ebb2-435a-910c-7b6c15aa85c8@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": "4ca08d57-ebb2-435a-910c-7b6c15aa85c8"
},
"ver": "1.0.21",
"imported": true,
"files": [
".json"
],
"subMetas": {}
},
"f9941": {
"importer": "sprite-frame",
"uuid": "4ca08d57-ebb2-435a-910c-7b6c15aa85c8@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": "4ca08d57-ebb2-435a-910c-7b6c15aa85c8@6c48a",
"atlasUuid": ""
},
"ver": "1.0.9",
"imported": true,
"files": [
".json"
],
"subMetas": {}
}
},
"userData": {
"hasAlpha": true,
"type": "sprite-frame",
"redirect": "4ca08d57-ebb2-435a-910c-7b6c15aa85c8@f9941"
}
}
assets/sceneBundle/games/formulaSolitaire/scene/FormulaSolitaire.scene
→
assets/sceneBundle/games/formulaSolitaire/scene/FormulaSolitaire
_1
.scene
View file @
2f3de712
This diff is collapsed.
Click to expand it.
assets/sceneBundle/games/formulaSolitaire/scene/FormulaSolitaire.scene.meta
→
assets/sceneBundle/games/formulaSolitaire/scene/FormulaSolitaire
_1
.scene.meta
View file @
2f3de712
File moved
assets/sceneBundle/games/formulaSolitaire/script/FormulaSolitaireCfg.ts
0 → 100644
View file @
2f3de712
import
{
_decorator
,
Component
,
Node
}
from
'cc'
;
const
{
ccclass
,
property
}
=
_decorator
;
export
interface
FormulaSolitaireCfg
{
row
:
number
,
column
:
number
,
result
:
number
,
resultCount
:
number
,
formulaArr
:
string
[][]
}
//÷ ×
export
const
FS_LV_1
:
FormulaSolitaireCfg
=
{
row
:
4
,
column
:
4
,
result
:
8
,
resultCount
:
2
,
formulaArr
:
[
[
"5"
,
"6"
,
"+"
,
"-"
],
[
"×"
,
"4"
,
"2"
,
"5"
],
[
"8"
,
"+"
,
"1"
,
"-"
],
[
"÷"
,
"2"
,
"-"
,
"11"
]
]
}
export
const
FS_LV_2
:
FormulaSolitaireCfg
=
{
row
:
4
,
column
:
4
,
result
:
12
,
resultCount
:
2
,
formulaArr
:
[
[
"4"
,
"6"
,
"+"
,
"0"
],
[
"×"
,
"÷"
,
"3"
,
"-"
],
[
"2"
,
"6"
,
"×"
,
"1"
],
[
"+"
,
"4"
,
"8"
,
"+"
]
]
}
assets/sceneBundle/games/formulaSolitaire/script/FormulaSolitaireCfg.ts.meta
0 → 100644
View file @
2f3de712
{
"ver": "4.0.22",
"importer": "typescript",
"imported": true,
"uuid": "96e3c939-105b-4aa8-9224-6410ab56497e",
"files": [],
"subMetas": {},
"userData": {}
}
assets/sceneBundle/games/formulaSolitaire/script/FormulaSolitaireCtr.ts
View file @
2f3de712
import
{
_decorator
,
Component
,
Node
,
Sprite
,
Vec3
,
Prefab
,
Label
,
CCFloat
,
instantiate
,
UITransform
,
v3
,
director
,
EventTouch
,
v2
,
Color
}
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
}
from
'../../../../startFolder/script/common/ViewMgr'
;
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
{
FormulaSolitaireCfg
,
FS_LV_1
,
FS_LV_2
}
from
'./FormulaSolitaireCfg'
;
import
{
FormulaSolitaireItem
,
FS_ITEM_STATE
}
from
'./FormulaSolitaireItem'
;
const
{
ccclass
,
property
}
=
_decorator
;
...
...
@@ -61,6 +67,9 @@ export class FormulaSolitaireCtr extends Component {
@
property
(
CCFloat
)
totalTime
:
number
=
0
;
@
property
(
Label
)
resultLab
:
Label
=
null
!
;
private
itemWidth
=
100
;
private
itemHeight
=
100
;
private
itemSpaceX
=
2
;
...
...
@@ -80,10 +89,13 @@ export class FormulaSolitaireCtr extends Component {
private
curLinePointArr
:
ItemPosIfo
[]
=
[];
private
allLinePointArr
:
ItemPosIfo
[][]
=
[];
private
level
=
2
;
private
levelData
:
FormulaSolitaireCfg
=
null
!
;
showGameDescView
()
{
this
.
isShowGameDescViewOnce
=
true
;
viewMgr
.
openView
(
VIEW_DEF
.
GameDescView
,
(
node
)
=>
{
node
.
getComponent
(
GameDescView
)?.
setDesc
(
"
把算式连接在一起。
"
);
node
.
getComponent
(
GameDescView
)?.
setDesc
(
"
划过图中的数字和算式运算符,把它们连接在一起组成一个式子,
\
n得到上方的结果。
\
n成功条件:尽可能多的组合能得到正确答案的式子。
\
n注意:再次划过已经组合完成的式子可以拆散还原。
\
n有些数字和运算符可能不会用到
"
);
});
}
...
...
@@ -114,6 +126,17 @@ export class FormulaSolitaireCtr extends Component {
start
()
{
// [3]
director
.
on
(
"begin_countdown_end"
,
()
=>
{
//引导
if
(
!
this
.
isShowGameDescViewOnce
)
{
this
.
gameState
=
GAME_STATE
.
PAUSE
;
this
.
showGameDescView
();
}
else
{
this
.
gameState
=
GAME_STATE
.
IDLE
;
}
},
this
);
director
.
on
(
"game_desc_close"
,
this
.
onCloseGameDescView
,
this
);
this
.
posArrNode
.
on
(
Node
.
EventType
.
TOUCH_START
,
this
.
onTouchStart
,
this
);
this
.
posArrNode
.
on
(
Node
.
EventType
.
TOUCH_MOVE
,
this
.
onTouchMove
,
this
);
this
.
posArrNode
.
on
(
Node
.
EventType
.
TOUCH_END
,
this
.
onTouchEnd
,
this
);
...
...
@@ -195,6 +218,12 @@ export class FormulaSolitaireCtr extends Component {
selPoint
.
target
.
getComponent
(
FormulaSolitaireItem
)?.
setColor
(
Color
.
fromHEX
(
new
Color
(),
colorStr
));
}
this
.
paintPaths
();
if
(
this
.
checkWin
())
{
this
.
gameEnd
(
true
);
}
else
{
}
}
paintPaths
()
{
...
...
@@ -224,30 +253,64 @@ export class FormulaSolitaireCtr extends Component {
}
}
}
}
console
.
log
(
`线段集合`
);
console
.
log
(
this
.
allLinePointArr
);
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
);
}
}
getResult
(
numStrArr
:
string
[]){
checkWin
()
{
if
(
this
.
allLinePointArr
.
length
<
this
.
levelData
.
resultCount
)
return
false
;
let
retArr
:
number
[][]
=
[];
for
(
let
i
=
0
;
i
<
this
.
allLinePointArr
.
length
;
++
i
)
{
let
numAtrArr
:
string
[]
=
[];
for
(
let
j
=
0
;
j
<
this
.
allLinePointArr
[
i
].
length
;
++
j
)
{
numAtrArr
.
push
(
this
.
allLinePointArr
[
i
][
j
].
target
.
getComponent
(
FormulaSolitaireItem
)
!
.
getText
());
}
console
.
log
(
`检测一个算式`
);
console
.
log
(
numAtrArr
);
retArr
.
push
(
this
.
getResult
(
numAtrArr
));
}
let
count
=
0
;
for
(
let
i
=
0
;
i
<
retArr
.
length
;
++
i
)
{
if
(
retArr
[
i
].
indexOf
(
this
.
levelData
.
result
)
!=
-
1
)
count
+=
1
;
}
console
.
log
(
`所有结果`
);
console
.
log
(
retArr
);
if
(
count
>=
this
.
levelData
.
resultCount
)
return
true
;
return
false
;
}
getResult
(
numStrArr
:
string
[])
{
let
ret
:
any
[]
=
[];
try
{
try
{
let
tempArr
:
string
[]
=
[];
tempArr
=
tempArr
.
concat
(
numStrArr
);
ret
.
push
(
this
.
calculator
(
tempArr
));
}
catch
{
catch
{
console
.
log
(
`错误的算式1`
);
ret
.
push
(
null
);
}
try
{
try
{
let
tempArr
:
string
[]
=
[];
tempArr
=
tempArr
.
concat
(
numStrArr
);
tempArr
=
tempArr
.
reverse
();
ret
.
push
(
this
.
calculator
(
tempArr
));
}
catch
{
catch
{
console
.
log
(
`错误的算式2`
);
ret
.
push
(
null
);
}
...
...
@@ -257,7 +320,7 @@ export class FormulaSolitaireCtr extends Component {
findLineWithPoint
(
point
:
ItemPosIfo
)
{
for
(
let
i
=
0
;
i
<
this
.
allLinePointArr
.
length
;
++
i
)
{
for
(
let
j
=
0
;
j
<
this
.
allLinePointArr
[
i
].
length
;
++
j
)
{
if
(
point
.
id
==
this
.
allLinePointArr
[
i
][
j
].
id
)
{
if
(
point
.
id
==
this
.
allLinePointArr
[
i
][
j
].
id
)
{
return
this
.
allLinePointArr
[
i
];
}
}
...
...
@@ -267,12 +330,17 @@ export class FormulaSolitaireCtr extends Component {
gameStart
()
{
this
.
gameState
=
GAME_STATE
.
READY
;
this
.
countdownLab
.
string
=
Utils
.
formatTime
(
Math
.
floor
(
this
.
totalTime
*
1000
));
this
.
usedColorArr
=
[];
this
.
curLinePointArr
=
[];
this
.
allLinePointArr
=
[];
this
.
loadLevelData
();
this
.
resultLab
.
string
=
`正确答案:`
+
this
.
levelData
.
result
;
this
.
creAllItem
();
this
.
setBgSprSize
();
this
.
gameState
=
GAME_STATE
.
IDLE
;
viewMgr
.
openView
(
VIEW_DEF
.
BeginCountdownView
,
(
node
)
=>
{
node
.
getComponent
(
BeginCountdownView
)?.
init
();
},
VIEW_INDEX
.
UPPER
);
}
getRandomItemColor
()
{
...
...
@@ -295,6 +363,7 @@ export class FormulaSolitaireCtr extends Component {
this
.
itemPosIfoArr
[
i
].
target
=
node
;
node
.
getComponent
(
FormulaSolitaireItem
)?.
setItemState
(
FS_ITEM_STATE
.
CENTER
);
node
.
getComponent
(
FormulaSolitaireItem
)?.
setColor
(
Color
.
fromHEX
(
new
Color
(),
this
.
orgColor
));
node
.
getComponent
(
FormulaSolitaireItem
)?.
setText
(
this
.
levelData
.
formulaArr
[
this
.
itemPosIfoArr
[
i
].
yIdx
][
this
.
itemPosIfoArr
[
i
].
xIdx
]);
}
}
...
...
@@ -352,9 +421,12 @@ export class FormulaSolitaireCtr extends Component {
}
}
if
(
operatorIdx
==
0
||
operatorIdx
==
numStrArr
.
length
-
1
)
{
throw
new
Error
(
`传入的算式不符合规则`
);
throw
new
Error
(
`传入的算式不符合规则1`
);
}
if
(
operatorIdx
==
-
1
)
{
if
(
numStrArr
.
length
==
1
)
return
Number
(
numStrArr
[
0
]);
else
throw
new
Error
(
`传入的算式不符合规则2`
);
}
if
(
operatorIdx
==
-
1
)
return
Number
(
numStrArr
[
0
]);
let
num_1
=
Number
(
numStrArr
[
operatorIdx
-
1
]);
let
num_2
=
Number
(
numStrArr
[
operatorIdx
+
1
]);
let
num_ret
=
0
;
...
...
@@ -415,7 +487,43 @@ export class FormulaSolitaireCtr extends Component {
return
FS_ITEM_STATE
.
LEFT
;
}
}
// update (deltaTime: number) {
// // [4]
// }
loadLevelData
()
{
switch
(
this
.
level
)
{
case
1
:
this
.
levelData
=
FS_LV_1
;
break
;
case
2
:
this
.
levelData
=
FS_LV_2
;
break
;
default
:
this
.
levelData
=
FS_LV_1
;
break
;
}
this
.
row
=
this
.
levelData
.
row
;
this
.
column
=
this
.
levelData
.
column
;
}
//倒计时
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/formulaSolitaire/script/FormulaSolitaireItem.ts
View file @
2f3de712
...
...
@@ -55,7 +55,7 @@ export class FormulaSolitaireItem extends Component {
setText
(
text
:
string
){
this
.
textLab
.
string
=
text
;
this
.
textLab
.
string
=
text
;
this
.
_text
=
text
;
}
getText
(){
...
...
assets/startFolder/script/LevelCfg.ts
View file @
2f3de712
...
...
@@ -1137,4 +1137,32 @@ export const levelCfg: OneVarLevelItf[] = [
}
]
}
,
{
gameIdHead
:
190
,
title
:
"数式接龙"
,
desc
:
"数式接龙,第一个版本"
,
levelArr
:
[{
gameId
:
19001
,
sceneUnitIfo
:
SCENE_DEF
.
FormulaSolitaire_1
,
comName
:
"FormulaSolitaireCtr"
,
level
:
1
,
resData
:
{
totalTime
:
60
,
level
:
1
,
isShowGuide
:
true
}
}
,
{
gameId
:
19002
,
sceneUnitIfo
:
SCENE_DEF
.
FormulaSolitaire_1
,
comName
:
"FormulaSolitaireCtr"
,
level
:
2
,
resData
:
{
totalTime
:
120
,
level
:
2
}
}
]
}
];
\ No newline at end of file
assets/startFolder/script/LevelHomeCtr.ts
View file @
2f3de712
...
...
@@ -26,7 +26,7 @@ export class LevelHomeCtr extends Component {
// [3]
if
(
!
levelMgr
.
loadedOutData
)
{
levelMgr
.
loadedOutData
=
true
;
levelMgr
.
gameIdHead
=
1
8
0
;
levelMgr
.
gameIdHead
=
1
9
0
;
levelMgr
.
unLockCount
=
10
;
if
(
Utils
.
getValueFromHref
(
"gameIdHead"
))
{
levelMgr
.
gameIdHead
=
Number
(
Utils
.
getValueFromHref
(
"gameIdHead"
));
...
...
assets/startFolder/script/common/SceneDef.ts
View file @
2f3de712
...
...
@@ -105,6 +105,8 @@ interface ScenePathItf {
AdjacentArray_1
:
ScenePathUnitItf
,
//纵横填数
VHFillNum_1
:
ScenePathUnitItf
,
//数式接龙
FormulaSolitaire_1
:
ScenePathUnitItf
,
}
export
const
SCENE_DEF
:
ScenePathItf
=
{
TestScene
:
{
...
...
@@ -447,9 +449,14 @@ export const SCENE_DEF: ScenePathItf = {
sceneName
:
"AdjacentArray_1"
,
desc
:
"邻接数组,第一个版本"
},
VHFillNum_1
:
{
VHFillNum_1
:
{
bundleName
:
"sceneBundle"
,
sceneName
:
"VHFillNum_1"
,
desc
:
"纵横填数,第一个版本"
},
FormulaSolitaire_1
:
{
bundleName
:
"sceneBundle"
,
sceneName
:
"FormulaSolitaire_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