Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
MingSnake_241120
Project
Project
Details
Activity
Releases
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
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
SparkProjects
MingSnake_241120
Commits
910da6a4
Commit
910da6a4
authored
Nov 26, 2024
by
haiyoucuv
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
init
parent
69ead5e9
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
14 additions
and
5 deletions
+14
-5
FoodManger.ts
assets/Scripts/Scenes/MainGame/Manager/FoodManger.ts
+1
-1
LuckyBagManager.ts
assets/Scripts/Scenes/MainGame/Manager/LuckyBagManager.ts
+11
-4
LuckyBag.ts
assets/Scripts/Scenes/MainGame/Props/LuckyBag.ts
+2
-0
No files found.
assets/Scripts/Scenes/MainGame/Manager/FoodManger.ts
View file @
910da6a4
...
...
@@ -73,7 +73,7 @@ export class FoodManger extends Component {
*/
addFood
(
x
?:
number
,
y
?:
number
,
energy
:
number
=
1
)
{
const
maxW
=
Global
.
MAP_
HEIGHT
/
2
-
100
;
const
maxW
=
Global
.
MAP_
WIDTH
/
2
-
100
;
const
maxH
=
Global
.
MAP_HEIGHT
/
2
-
100
;
// 如果没有指定位置,随机生成位置
...
...
assets/Scripts/Scenes/MainGame/Manager/LuckyBagManager.ts
View file @
910da6a4
...
...
@@ -35,10 +35,16 @@ export class LuckyBagManager extends Component {
}
start
()
{
this
.
flush
Items
();
this
.
flush
();
}
flushItems
()
{
check
()
{
if
(
this
.
node
.
children
.
length
<=
0
)
{
this
.
flush
();
}
}
flush
()
{
const
{
luckNum
}
=
gameStore
.
gameInfo
||
{};
const
{
currentAcquireNum
}
=
gameStore
.
startInfo
||
{};
...
...
@@ -48,9 +54,10 @@ export class LuckyBagManager extends Component {
}
add
(
num
:
number
=
1
)
{
if
(
!
num
||
num
<=
0
)
return
;
const
maxW
=
Global
.
MAP_
HEIGHT
/
2
-
100
;
const
maxH
=
(
Global
.
MAP_HEIGHT
/
2
-
100
)
;
const
maxW
=
Global
.
MAP_
WIDTH
/
2
-
100
;
const
maxH
=
Global
.
MAP_HEIGHT
/
2
-
100
;
for
(
let
i
=
1
;
i
<=
num
;
i
++
)
{
const
x
=
math
.
randomRange
(
-
maxW
,
maxW
);
...
...
assets/Scripts/Scenes/MainGame/Props/LuckyBag.ts
View file @
910da6a4
import
{
_decorator
}
from
"cc"
;
import
{
PropBase
}
from
"./PropBase"
;
import
{
Snake
}
from
"../Snake"
;
import
{
LuckyBagManager
}
from
"../Manager/LuckyBagManager"
;
const
{
ccclass
,
property
}
=
_decorator
;
...
...
@@ -12,6 +13,7 @@ export class LuckyBag extends PropBase {
};
recycle
()
{
LuckyBagManager
.
ins
.
check
();
this
.
node
.
removeFromParent
();
this
.
node
.
destroy
();
// propPool.put(this.node);
...
...
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