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
a1720fd6
Commit
a1720fd6
authored
Oct 09, 2021
by
unknown
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
食物派对数量加了限制
parent
93b5e5b9
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
138 additions
and
69 deletions
+138
-69
FoodForThePartyCtr.ts
...Bundle/games/foodForTheParty/script/FoodForThePartyCtr.ts
+35
-4
MagicSpells_1.scene
...s/sceneBundle/games/magicSpells/scene/MagicSpells_1.scene
+53
-25
MagicSpellsCtr.ts
...ts/sceneBundle/games/magicSpells/script/MagicSpellsCtr.ts
+16
-17
LevelCfg.ts
assets/startFolder/script/LevelCfg.ts
+33
-22
LevelHomeCtr.ts
assets/startFolder/script/LevelHomeCtr.ts
+1
-1
No files found.
assets/sceneBundle/games/foodForTheParty/script/FoodForThePartyCtr.ts
View file @
a1720fd6
...
@@ -65,7 +65,10 @@ export class FoodForThePartyCtr extends Component {
...
@@ -65,7 +65,10 @@ export class FoodForThePartyCtr extends Component {
succScore
:
number
=
0
;
succScore
:
number
=
0
;
@
property
(
CCInteger
)
@
property
(
CCInteger
)
foodCount
:
number
=
0
;
foodVarCount
:
number
=
0
;
@
property
(
CCInteger
)
foodNumCount
:
number
=
0
;
@
property
(
CCFloat
)
@
property
(
CCFloat
)
totalTime
:
number
=
10
;
totalTime
:
number
=
10
;
...
@@ -93,9 +96,14 @@ export class FoodForThePartyCtr extends Component {
...
@@ -93,9 +96,14 @@ export class FoodForThePartyCtr extends Component {
this
.
totalTime
=
resData
.
totalTime
;
this
.
totalTime
=
resData
.
totalTime
;
}
}
//@ts-ignore
//@ts-ignore
if
(
resData
.
foodCount
)
{
if
(
resData
.
foodVarCount
)
{
//@ts-ignore
this
.
foodVarCount
=
resData
.
foodVarCount
;
}
//@ts-ignore
if
(
resData
.
foodNumCount
)
{
//@ts-ignore
//@ts-ignore
this
.
food
Count
=
resData
.
food
Count
;
this
.
food
NumCount
=
resData
.
foodNum
Count
;
}
}
//@ts-ignore
//@ts-ignore
if
(
resData
.
succScore
)
{
if
(
resData
.
succScore
)
{
...
@@ -268,7 +276,7 @@ export class FoodForThePartyCtr extends Component {
...
@@ -268,7 +276,7 @@ export class FoodForThePartyCtr extends Component {
this
.
clearPips
();
this
.
clearPips
();
for
(
let
i
=
0
;
i
<
this
.
pips
.
length
;
++
i
)
{
for
(
let
i
=
0
;
i
<
this
.
pips
.
length
;
++
i
)
{
// let maxCount = Math.floor(Math.random() * 5) + 1;
// let maxCount = Math.floor(Math.random() * 5) + 1;
let
maxCount
=
this
.
foodCount
;
let
maxCount
=
this
.
food
Var
Count
;
let
names
:
string
[]
=
[];
let
names
:
string
[]
=
[];
while
(
names
.
length
<
maxCount
)
{
while
(
names
.
length
<
maxCount
)
{
let
name
=
foodNameArr
[
Math
.
floor
(
Math
.
random
()
*
foodNameArr
.
length
)];
let
name
=
foodNameArr
[
Math
.
floor
(
Math
.
random
()
*
foodNameArr
.
length
)];
...
@@ -276,12 +284,35 @@ export class FoodForThePartyCtr extends Component {
...
@@ -276,12 +284,35 @@ export class FoodForThePartyCtr extends Component {
}
}
names
=
this
.
randomCopyNameToNameArr
(
names
);
names
=
this
.
randomCopyNameToNameArr
(
names
);
names
=
this
.
disorderArr
(
names
);
names
=
this
.
disorderArr
(
names
);
names
=
this
.
excludeMoreFood
(
names
);
console
.
log
(
`
${
this
.
pips
[
i
].
getPipName
()}
管道的物品`
);
console
.
log
(
`
${
this
.
pips
[
i
].
getPipName
()}
管道的物品`
);
console
.
log
(
names
);
console
.
log
(
names
);
this
.
pips
[
i
].
setFoodsImgNames
(
this
.
imgHead
,
names
);
this
.
pips
[
i
].
setFoodsImgNames
(
this
.
imgHead
,
names
);
}
}
}
}
excludeMoreFood
(
names
:
string
[]):
string
[]
{
if
(
this
.
foodVarCount
>=
this
.
foodNumCount
)
{
throw
new
Error
(
"食物种类大于食物数量限制"
);
}
let
outCount
=
0
;
while
(
names
.
length
>
this
.
foodNumCount
&&
outCount
<
10000
)
{
let
foodName
=
names
[
Math
.
floor
(
Math
.
random
()
*
names
.
length
)];
let
nameIdxs
:
number
[]
=
[];
for
(
let
i
=
0
;
i
<
names
.
length
;
++
i
)
{
if
(
names
[
i
]
==
foodName
)
nameIdxs
.
push
(
i
);
}
if
(
nameIdxs
.
length
>
1
)
{
names
.
splice
(
nameIdxs
[
Math
.
floor
(
Math
.
random
()
*
nameIdxs
.
length
)],
1
);
}
outCount
+=
1
;
}
if
(
outCount
>=
10000
){
console
.
log
(
`食物数量限制可能发生死循环`
);
}
return
names
;
}
disorderArr
<
T
>
(
arr
:
T
[])
{
disorderArr
<
T
>
(
arr
:
T
[])
{
for
(
let
i
=
0
;
i
<
arr
.
length
;
++
i
)
{
for
(
let
i
=
0
;
i
<
arr
.
length
;
++
i
)
{
let
idx
=
Math
.
floor
(
Math
.
random
()
*
arr
.
length
);
let
idx
=
Math
.
floor
(
Math
.
random
()
*
arr
.
length
);
...
...
assets/sceneBundle/games/magicSpells/scene/MagicSpells_1.scene
View file @
a1720fd6
...
@@ -24,7 +24,7 @@
...
@@ -24,7 +24,7 @@
"__id__": 7
"__id__": 7
},
},
{
{
"__id__": 7
0
"__id__": 7
5
}
}
],
],
"_active": true,
"_active": true,
...
@@ -32,7 +32,7 @@
...
@@ -32,7 +32,7 @@
"_prefab": null,
"_prefab": null,
"autoReleaseAssets": false,
"autoReleaseAssets": false,
"_globals": {
"_globals": {
"__id__": 7
3
"__id__": 7
8
},
},
"_id": "31b6bf24-7062-4edc-ba09-5fd282192579"
"_id": "31b6bf24-7062-4edc-ba09-5fd282192579"
},
},
...
@@ -1737,23 +1737,51 @@
...
@@ -1737,23 +1737,51 @@
"countdownLab": {
"countdownLab": {
"__id__": 52
"__id__": 52
},
},
"imageNameArr": [
"索命咒",
"夺魂咒",
"遗忘咒",
"护卫咒",
"昏迷咒"
],
"mgcNameArr": [
"啊啊啊",
"哒哒哒",
"溜溜溜",
"哈哈哈",
"呀呀呀"
],
"quesIfoCount": 5,
"quesIfoCount": 5,
"quesIfoPool": [
{
"__id__": 70
},
{
"__id__": 71
},
{
"__id__": 72
},
{
"__id__": 73
},
{
"__id__": 74
}
],
"_id": "78ClK1kytPYZ7ZnlrSEX1M"
"_id": "78ClK1kytPYZ7ZnlrSEX1M"
},
},
{
"__type__": "MgcItemItf",
"imgName": "夺魂咒",
"mgcName": "依帕力欧"
},
{
"__type__": "MgcItemItf",
"imgName": "护卫咒",
"mgcName": "一克斯派替欧"
},
{
"__type__": "MgcItemItf",
"imgName": "昏迷咒",
"mgcName": "思丢普录"
},
{
"__type__": "MgcItemItf",
"imgName": "索命咒",
"mgcName": "阿瓦达索命"
},
{
"__type__": "MgcItemItf",
"imgName": "遗忘咒",
"mgcName": "欧不力维特"
},
{
{
"__type__": "cc.Node",
"__type__": "cc.Node",
"_name": "Audio",
"_name": "Audio",
...
@@ -1765,10 +1793,10 @@
...
@@ -1765,10 +1793,10 @@
"_active": true,
"_active": true,
"_components": [
"_components": [
{
{
"__id__": 7
1
"__id__": 7
6
},
},
{
{
"__id__": 7
2
"__id__": 7
7
}
}
],
],
"_prefab": null,
"_prefab": null,
...
@@ -1805,7 +1833,7 @@
...
@@ -1805,7 +1833,7 @@
"_name": "",
"_name": "",
"_objFlags": 0,
"_objFlags": 0,
"node": {
"node": {
"__id__": 7
0
"__id__": 7
5
},
},
"_enabled": true,
"_enabled": true,
"__prefab": null,
"__prefab": null,
...
@@ -1820,28 +1848,28 @@
...
@@ -1820,28 +1848,28 @@
"_name": "",
"_name": "",
"_objFlags": 0,
"_objFlags": 0,
"node": {
"node": {
"__id__": 7
0
"__id__": 7
5
},
},
"_enabled": true,
"_enabled": true,
"__prefab": null,
"__prefab": null,
"audioSource": {
"audioSource": {
"__id__": 7
1
"__id__": 7
6
},
},
"_id": "acebgi7bZMsYJe6NAYG6Ez"
"_id": "acebgi7bZMsYJe6NAYG6Ez"
},
},
{
{
"__type__": "cc.SceneGlobals",
"__type__": "cc.SceneGlobals",
"ambient": {
"ambient": {
"__id__": 7
4
"__id__": 7
9
},
},
"shadows": {
"shadows": {
"__id__":
75
"__id__":
80
},
},
"_skybox": {
"_skybox": {
"__id__":
76
"__id__":
81
},
},
"fog": {
"fog": {
"__id__":
77
"__id__":
82
}
}
},
},
{
{
...
...
assets/sceneBundle/games/magicSpells/script/MagicSpellsCtr.ts
View file @
a1720fd6
...
@@ -15,9 +15,13 @@ import { MgcSpAswTwoView } from './MgcSpAswTwoView';
...
@@ -15,9 +15,13 @@ import { MgcSpAswTwoView } from './MgcSpAswTwoView';
import
{
MgcSpQueView
}
from
'./MgcSpQueView'
;
import
{
MgcSpQueView
}
from
'./MgcSpQueView'
;
const
{
ccclass
,
property
}
=
_decorator
;
const
{
ccclass
,
property
}
=
_decorator
;
export
interface
MgcItemItf
{
@
ccclass
(
'MgcItemItf'
)
imgName
:
string
,
class
MgcItemItf
{
mgcName
:
string
@
property
(
CCString
)
imgName
:
string
=
""
;
@
property
(
CCString
)
mgcName
:
string
=
""
;
}
}
enum
GAME_STATE
{
enum
GAME_STATE
{
...
@@ -51,18 +55,15 @@ export class MagicSpellsCtr extends Component {
...
@@ -51,18 +55,15 @@ export class MagicSpellsCtr extends Component {
@
property
(
Label
)
@
property
(
Label
)
countdownLab
:
Label
=
null
!
;
countdownLab
:
Label
=
null
!
;
@
property
([
CCString
])
imageNameArr
:
string
[]
=
[];
@
property
([
CCString
])
mgcNameArr
:
string
[]
=
[];
@
property
(
CCInteger
)
@
property
(
CCInteger
)
quesIfoCount
:
number
=
0
;
quesIfoCount
:
number
=
0
;
@
property
(
MgcItemItf
)
private
quesIfoPool
:
MgcItemItf
[]
=
[];
private
gameState
:
GAME_STATE
=
GAME_STATE
.
READY
;
private
gameState
:
GAME_STATE
=
GAME_STATE
.
READY
;
private
quesIfos
:
MgcItemItf
[]
=
[];
private
rightIfo
:
MgcItemItf
|
null
=
null
;
private
rightIfo
:
MgcItemItf
|
null
=
null
;
private
quesIfos
:
MgcItemItf
[]
=
[];
private
curScore
=
0
;
private
curScore
=
0
;
private
costTime
=
0
;
private
costTime
=
0
;
...
@@ -102,6 +103,7 @@ export class MagicSpellsCtr extends Component {
...
@@ -102,6 +103,7 @@ export class MagicSpellsCtr extends Component {
director
.
off
(
"quesone_asw"
,
this
.
onAswOneCall
,
this
);
director
.
off
(
"quesone_asw"
,
this
.
onAswOneCall
,
this
);
director
.
off
(
"questwo_asw"
,
this
.
onAswTwoCall
,
this
);
director
.
off
(
"questwo_asw"
,
this
.
onAswTwoCall
,
this
);
director
.
off
(
"go_answer"
,
this
.
aswOneStart
,
this
);
director
.
off
(
"go_answer"
,
this
.
aswOneStart
,
this
);
director
.
off
(
"begin_countdown_end"
);
}
}
gameStart
()
{
gameStart
()
{
...
@@ -261,11 +263,8 @@ export class MagicSpellsCtr extends Component {
...
@@ -261,11 +263,8 @@ export class MagicSpellsCtr extends Component {
this
.
countdownLab
.
string
=
Utils
.
formatTime
(
Math
.
floor
((
this
.
totalTime
-
this
.
costTime
)
*
1000
));
this
.
countdownLab
.
string
=
Utils
.
formatTime
(
Math
.
floor
((
this
.
totalTime
-
this
.
costTime
)
*
1000
));
}
}
creRandomItemIfo
():
MgcItemItf
{
getRandomItemIfo
():
MgcItemItf
{
return
{
return
this
.
quesIfoPool
[
Math
.
floor
(
Math
.
random
()
*
this
.
quesIfoPool
.
length
)];
imgName
:
this
.
imageNameArr
[
Math
.
floor
(
Math
.
random
()
*
this
.
imageNameArr
.
length
)],
mgcName
:
this
.
mgcNameArr
[
Math
.
floor
(
Math
.
random
()
*
this
.
mgcNameArr
.
length
)]
}
}
}
isSameItemIfo
(
a
:
MgcItemItf
,
b
:
MgcItemItf
)
{
isSameItemIfo
(
a
:
MgcItemItf
,
b
:
MgcItemItf
)
{
...
@@ -273,12 +272,12 @@ export class MagicSpellsCtr extends Component {
...
@@ -273,12 +272,12 @@ export class MagicSpellsCtr extends Component {
}
}
creQuesIfos
()
{
creQuesIfos
()
{
if
(
this
.
imageNameArr
.
length
<
this
.
quesIfoCount
||
this
.
mgcNameArr
.
length
<
this
.
quesIfoCount
)
{
if
(
this
.
quesIfoPool
.
length
<
this
.
quesIfoCount
)
{
throw
new
Error
(
"咒语数量少于展示咒语数量"
);
throw
new
Error
(
"咒语数量少于展示咒语数量"
);
}
}
this
.
quesIfos
=
[];
this
.
quesIfos
=
[];
while
(
this
.
quesIfos
.
length
<
this
.
quesIfoCount
)
{
while
(
this
.
quesIfos
.
length
<
this
.
quesIfoCount
)
{
let
tempIfo
=
this
.
cre
RandomItemIfo
();
let
tempIfo
=
this
.
get
RandomItemIfo
();
let
isOnly
=
true
;
let
isOnly
=
true
;
for
(
let
i
=
0
;
i
<
this
.
quesIfos
.
length
;
++
i
)
{
for
(
let
i
=
0
;
i
<
this
.
quesIfos
.
length
;
++
i
)
{
if
(
this
.
isSameItemIfo
(
tempIfo
,
this
.
quesIfos
[
i
]))
{
if
(
this
.
isSameItemIfo
(
tempIfo
,
this
.
quesIfos
[
i
]))
{
...
...
assets/startFolder/script/LevelCfg.ts
View file @
a1720fd6
...
@@ -676,9 +676,10 @@ export const levelCfg: OneVarLevelItf[] = [
...
@@ -676,9 +676,10 @@ export const levelCfg: OneVarLevelItf[] = [
level
:
1
,
level
:
1
,
resData
:
{
resData
:
{
totalTime
:
90
,
totalTime
:
90
,
foodCount
:
2
,
food
Var
Count
:
2
,
succScore
:
5
,
succScore
:
5
,
oneScore
:
1
oneScore
:
1
,
foodNumCount
:
6
}
}
}
}
,
{
,
{
...
@@ -688,9 +689,10 @@ export const levelCfg: OneVarLevelItf[] = [
...
@@ -688,9 +689,10 @@ export const levelCfg: OneVarLevelItf[] = [
level
:
2
,
level
:
2
,
resData
:
{
resData
:
{
totalTime
:
120
,
totalTime
:
120
,
foodCount
:
3
,
food
Var
Count
:
3
,
succScore
:
5
,
succScore
:
5
,
oneScore
:
1
oneScore
:
1
,
foodNumCount
:
7
}
}
}
}
,
{
,
{
...
@@ -700,9 +702,10 @@ export const levelCfg: OneVarLevelItf[] = [
...
@@ -700,9 +702,10 @@ export const levelCfg: OneVarLevelItf[] = [
level
:
3
,
level
:
3
,
resData
:
{
resData
:
{
totalTime
:
100
,
totalTime
:
100
,
foodCount
:
3
,
food
Var
Count
:
3
,
succScore
:
5
,
succScore
:
5
,
oneScore
:
1
oneScore
:
1
,
foodNumCount
:
7
}
}
}
}
,
{
,
{
...
@@ -712,9 +715,10 @@ export const levelCfg: OneVarLevelItf[] = [
...
@@ -712,9 +715,10 @@ export const levelCfg: OneVarLevelItf[] = [
level
:
4
,
level
:
4
,
resData
:
{
resData
:
{
totalTime
:
150
,
totalTime
:
150
,
foodCount
:
4
,
food
Var
Count
:
4
,
succScore
:
5
,
succScore
:
5
,
oneScore
:
1
oneScore
:
1
,
foodNumCount
:
8
}
}
}
}
,
{
,
{
...
@@ -724,9 +728,10 @@ export const levelCfg: OneVarLevelItf[] = [
...
@@ -724,9 +728,10 @@ export const levelCfg: OneVarLevelItf[] = [
level
:
5
,
level
:
5
,
resData
:
{
resData
:
{
totalTime
:
180
,
totalTime
:
180
,
foodCount
:
4
,
food
Var
Count
:
4
,
succScore
:
6
,
succScore
:
6
,
oneScore
:
1
oneScore
:
1
,
foodNumCount
:
9
}
}
}
}
]
]
...
@@ -742,9 +747,10 @@ export const levelCfg: OneVarLevelItf[] = [
...
@@ -742,9 +747,10 @@ export const levelCfg: OneVarLevelItf[] = [
level
:
1
,
level
:
1
,
resData
:
{
resData
:
{
totalTime
:
90
,
totalTime
:
90
,
foodCount
:
1
,
food
Var
Count
:
1
,
succScore
:
5
,
succScore
:
5
,
oneScore
:
1
oneScore
:
1
,
foodNumCount
:
3
}
}
}
}
,
{
,
{
...
@@ -754,9 +760,10 @@ export const levelCfg: OneVarLevelItf[] = [
...
@@ -754,9 +760,10 @@ export const levelCfg: OneVarLevelItf[] = [
level
:
2
,
level
:
2
,
resData
:
{
resData
:
{
totalTime
:
120
,
totalTime
:
120
,
foodCount
:
2
,
food
Var
Count
:
2
,
succScore
:
5
,
succScore
:
5
,
oneScore
:
1
oneScore
:
1
,
foodNumCount
:
6
}
}
}
}
,
{
,
{
...
@@ -766,9 +773,10 @@ export const levelCfg: OneVarLevelItf[] = [
...
@@ -766,9 +773,10 @@ export const levelCfg: OneVarLevelItf[] = [
level
:
3
,
level
:
3
,
resData
:
{
resData
:
{
totalTime
:
100
,
totalTime
:
100
,
foodCount
:
2
,
food
Var
Count
:
2
,
succScore
:
5
,
succScore
:
5
,
oneScore
:
1
oneScore
:
1
,
foodNumCount
:
6
}
}
}
}
,
{
,
{
...
@@ -778,9 +786,10 @@ export const levelCfg: OneVarLevelItf[] = [
...
@@ -778,9 +786,10 @@ export const levelCfg: OneVarLevelItf[] = [
level
:
4
,
level
:
4
,
resData
:
{
resData
:
{
totalTime
:
90
,
totalTime
:
90
,
foodCount
:
2
,
food
Var
Count
:
2
,
succScore
:
5
,
succScore
:
5
,
oneScore
:
1
oneScore
:
1
,
foodNumCount
:
7
}
}
}
}
,
{
,
{
...
@@ -790,9 +799,10 @@ export const levelCfg: OneVarLevelItf[] = [
...
@@ -790,9 +799,10 @@ export const levelCfg: OneVarLevelItf[] = [
level
:
5
,
level
:
5
,
resData
:
{
resData
:
{
totalTime
:
150
,
totalTime
:
150
,
foodCount
:
3
,
food
Var
Count
:
3
,
succScore
:
5
,
succScore
:
5
,
oneScore
:
1
oneScore
:
1
,
foodNumCount
:
8
}
}
}
}
,
{
,
{
...
@@ -802,9 +812,10 @@ export const levelCfg: OneVarLevelItf[] = [
...
@@ -802,9 +812,10 @@ export const levelCfg: OneVarLevelItf[] = [
level
:
6
,
level
:
6
,
resData
:
{
resData
:
{
totalTime
:
180
,
totalTime
:
180
,
foodCount
:
3
,
food
Var
Count
:
3
,
succScore
:
6
,
succScore
:
6
,
oneScore
:
1
oneScore
:
1
,
foodNumCount
:
10
}
}
}
}
]
]
...
...
assets/startFolder/script/LevelHomeCtr.ts
View file @
a1720fd6
...
@@ -23,7 +23,7 @@ export class LevelHomeCtr extends Component {
...
@@ -23,7 +23,7 @@ export class LevelHomeCtr extends Component {
// [3]
// [3]
if
(
!
levelMgr
.
loadedOutData
)
{
if
(
!
levelMgr
.
loadedOutData
)
{
levelMgr
.
loadedOutData
=
true
;
levelMgr
.
loadedOutData
=
true
;
levelMgr
.
gameIdHead
=
30
;
levelMgr
.
gameIdHead
=
101
;
levelMgr
.
unLockCount
=
10
;
levelMgr
.
unLockCount
=
10
;
if
(
Utils
.
getValueFromHref
(
"gameIdHead"
)){
if
(
Utils
.
getValueFromHref
(
"gameIdHead"
)){
levelMgr
.
gameIdHead
=
Number
(
Utils
.
getValueFromHref
(
"gameIdHead"
));
levelMgr
.
gameIdHead
=
Number
(
Utils
.
getValueFromHref
(
"gameIdHead"
));
...
...
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