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
a1a04361
Commit
a1a04361
authored
Nov 26, 2024
by
haiyoucuv
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
init
parent
1b520c6e
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
109 additions
and
25 deletions
+109
-25
codeStyleConfig.xml
.idea/codeStyles/codeStyleConfig.xml
+5
-0
道具.prefab
assets/Bundles/MainGame/prefab/道具.prefab
+24
-3
CommonPool.ts
assets/Scripts/Scenes/MainGame/Manager/CommonPool.ts
+2
-0
Food.ts
assets/Scripts/Scenes/MainGame/Props/Food.ts
+7
-4
LuckyBag.ts
assets/Scripts/Scenes/MainGame/Props/LuckyBag.ts
+20
-0
LuckyBag.ts.meta
assets/Scripts/Scenes/MainGame/Props/LuckyBag.ts.meta
+9
-0
PropBase.ts
assets/Scripts/Scenes/MainGame/Props/PropBase.ts
+19
-0
PropBase.ts.meta
assets/Scripts/Scenes/MainGame/Props/PropBase.ts.meta
+9
-0
Snake.ts
assets/Scripts/Scenes/MainGame/Snake.ts
+11
-11
project.json
settings/v2/packages/project.json
+3
-7
No files found.
.idea/codeStyles/codeStyleConfig.xml
0 → 100644
View file @
a1a04361
<component
name=
"ProjectCodeStyleConfiguration"
>
<state>
<option
name=
"PREFERRED_PROJECT_CODE_STYLE"
value=
"Default"
/>
</state>
</component>
\ No newline at end of file
assets/Bundles/MainGame/prefab/道具.prefab
View file @
a1a04361
...
...
@@ -35,10 +35,13 @@
},
{
"__id__": 20
},
{
"__id__": 22
}
],
"_prefab": {
"__id__": 2
2
"__id__": 2
4
},
"_lpos": {
"__type__": "cc.Vec3",
...
...
@@ -416,7 +419,7 @@
"enabledContactListener": true,
"bullet": false,
"awakeOnLoad": true,
"_group":
32
,
"_group":
4
,
"_type": 2,
"_allowSleep": true,
"_gravityScale": 1,
...
...
@@ -448,7 +451,7 @@
"__id__": 21
},
"tag": 0,
"_group":
32
,
"_group":
4
,
"_density": 1,
"_sensor": true,
"_friction": 0.2,
...
...
@@ -465,6 +468,24 @@
"__type__": "cc.CompPrefabInfo",
"fileId": "d4nguP1hRPj6hmP9ugayLT"
},
{
"__type__": "5da8aSqHYxAvaSUEz+0fvlM",
"_name": "",
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 1
},
"_enabled": true,
"__prefab": {
"__id__": 23
},
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "3e5kK27VpPMblCs9d+jIA3"
},
{
"__type__": "cc.PrefabInfo",
"root": {
...
...
assets/Scripts/Scenes/MainGame/Manager/CommonPool.ts
View file @
a1a04361
...
...
@@ -3,10 +3,12 @@ import { NodePool } from "cc";
export
const
foodPool
=
new
NodePool
();
export
const
bodyPool
=
new
NodePool
();
export
const
aiPool
=
new
NodePool
();
export
const
propPool
=
new
NodePool
();
export
function
clearAllPool
()
{
foodPool
.
clear
();
bodyPool
.
clear
();
aiPool
.
clear
();
propPool
.
clear
();
}
\ No newline at end of file
assets/Scripts/Scenes/MainGame/Props/Food.ts
View file @
a1a04361
import
{
_decorator
,
Component
}
from
"cc"
;
import
{
_decorator
}
from
"cc"
;
import
{
foodPool
}
from
"../Manager/CommonPool"
;
import
{
PropBase
}
from
"./PropBase"
;
import
{
Snake
}
from
"../Snake"
;
const
{
ccclass
,
property
}
=
_decorator
;
@
ccclass
(
"Food"
)
export
class
Food
extends
Component
{
export
class
Food
extends
PropBase
{
_energy
:
number
=
1
;
...
...
@@ -23,8 +26,8 @@ export class Food extends Component {
this
.
energy
=
energy
;
}
protected
start
()
{
beEaten
=
(
target
:
Snake
)
=>
{
target
.
addEnergy
(
this
.
energy
);
}
recycle
()
{
...
...
assets/Scripts/Scenes/MainGame/Props/LuckyBag.ts
0 → 100644
View file @
a1a04361
import
{
_decorator
}
from
"cc"
;
import
{
propPool
}
from
"../Manager/CommonPool"
;
import
{
PropBase
}
from
"./PropBase"
;
import
{
Snake
}
from
"../Snake"
;
const
{
ccclass
,
property
}
=
_decorator
;
@
ccclass
(
"LuckyBag"
)
export
class
LuckyBag
extends
PropBase
{
beEaten
=
(
target
:
Snake
)
=>
{
};
recycle
()
{
this
.
node
.
removeFromParent
();
propPool
.
put
(
this
.
node
);
}
}
\ No newline at end of file
assets/Scripts/Scenes/MainGame/Props/LuckyBag.ts.meta
0 → 100644
View file @
a1a04361
{
"ver": "4.0.24",
"importer": "typescript",
"imported": true,
"uuid": "5da8a4aa-1d8c-40bd-a494-133fb47ef94c",
"files": [],
"subMetas": {},
"userData": {}
}
assets/Scripts/Scenes/MainGame/Props/PropBase.ts
0 → 100644
View file @
a1a04361
import
{
_decorator
,
Component
}
from
"cc"
;
import
{
Snake
}
from
"../Snake"
;
const
{
ccclass
,
property
}
=
_decorator
;
@
ccclass
(
"PropBase"
)
export
class
PropBase
extends
Component
{
beEaten
(
target
:
Snake
)
{
};
recycle
()
{
};
}
assets/Scripts/Scenes/MainGame/Props/PropBase.ts.meta
0 → 100644
View file @
a1a04361
{
"ver": "4.0.24",
"importer": "typescript",
"imported": true,
"uuid": "343401ae-5e08-4311-8747-216116496283",
"files": [],
"subMetas": {},
"userData": {}
}
assets/Scripts/Scenes/MainGame/Snake.ts
View file @
a1a04361
...
...
@@ -2,8 +2,7 @@ import {
_decorator
,
Collider2D
,
Component
,
Contact2DType
,
instantiate
,
IVec2Like
,
math
,
Contact2DType
,
instantiate
,
Node
,
PhysicsGroup
,
Prefab
,
...
...
@@ -11,15 +10,15 @@ import {
SpriteFrame
,
tween
,
UITransform
,
v2
,
v3
,
Vec2
,
v3
,
Vec3
,
}
from
"cc"
;
import
{
FoodType
}
from
"./Common/Enums"
;
import
{
Global
}
from
"./Global"
;
import
{
isIntersect
,
loadSkin
}
from
"./utils/uitl"
;
import
{
MainGame
}
from
"./MainGame"
;
import
{
bodyPool
}
from
"./Manager/CommonPool"
;
import
{
Food
}
from
"./Props/Food"
;
import
{
PropBase
}
from
"./Props/PropBase"
;
const
{
ccclass
,
property
}
=
_decorator
;
...
...
@@ -173,8 +172,7 @@ export class Snake extends Component {
}
onBeginEye
(
selfCollider
:
Collider2D
,
otherCollider
:
Collider2D
)
{
if
(
otherCollider
.
group
===
PhysicsGroup
[
"Food"
])
{
const
foodType
=
otherCollider
.
tag
;
if
(
otherCollider
.
group
===
PhysicsGroup
[
"Prop"
])
{
// 食物吃掉的动画
tween
(
otherCollider
.
node
)
...
...
@@ -184,17 +182,19 @@ export class Snake extends Component {
})
.
call
(()
=>
{
if
(
!
this
.
isLife
)
return
;
const
foodTs
=
otherCollider
.
getComponent
(
Food
);
this
.
addEnergy
(
foodTs
.
energy
);
foodTs
.
recycle
();
const
propTs
=
otherCollider
.
getComponent
(
PropBase
);
propTs
.
beEaten
(
this
);
propTs
.
recycle
();
})
.
start
();
}
}
// 能量与成长
lastRemaining
=
0
;
private
addEnergy
(
value
:
number
)
{
private
lastRemaining
=
0
;
addEnergy
(
value
:
number
)
{
this
.
energy
+=
value
;
const
growthThreshold
=
Math
.
floor
(
4
*
this
.
scale
);
...
...
settings/v2/packages/project.json
View file @
a1a04361
...
...
@@ -19,7 +19,7 @@
},
{
"index"
:
2
,
"name"
:
"
Food
"
"name"
:
"
Prop
"
},
{
"index"
:
3
,
...
...
@@ -28,10 +28,6 @@
{
"index"
:
4
,
"name"
:
"Body"
},
{
"index"
:
5
,
"name"
:
"Prop"
}
],
"collisionMatrix"
:
{
...
...
@@ -39,8 +35,8 @@
"1"
:
52
,
"2"
:
10
,
"3"
:
116
,
"4"
:
42
,
"5"
:
90
,
"4"
:
10
,
"5"
:
74
,
"6"
:
40
},
"maxSubSteps"
:
1
,
...
...
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