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
8fc77e6c
Commit
8fc77e6c
authored
Nov 28, 2024
by
haiyoucuv
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
init
parent
0dd09263
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
4 deletions
+25
-4
Enums.ts
assets/Scripts/Scenes/MainGame/Common/Enums.ts
+3
-0
Card.ts
assets/Scripts/Scenes/MainGame/Props/Card.ts
+5
-4
Snake.ts
assets/Scripts/Scenes/MainGame/Snake.ts
+17
-0
No files found.
assets/Scripts/Scenes/MainGame/Common/Enums.ts
View file @
8fc77e6c
...
@@ -18,6 +18,9 @@ export enum EPropType {
...
@@ -18,6 +18,9 @@ export enum EPropType {
ccenum
(
EPropType
);
ccenum
(
EPropType
);
export
type
ECard
=
EPropType
.
CARD_A
|
EPropType
.
CARD_B
|
EPropType
.
CARD_C
;
// 移动方向枚举
// 移动方向枚举
export
enum
DirectionType
{
export
enum
DirectionType
{
DEFAULT
=
0
,
// 默认方向
DEFAULT
=
0
,
// 默认方向
...
...
assets/Scripts/Scenes/MainGame/Props/Card.ts
View file @
8fc77e6c
import
{
_decorator
}
from
"cc"
;
import
{
_decorator
,
Collider2D
}
from
"cc"
;
import
{
PropBase
}
from
"./PropBase"
;
import
{
PropBase
}
from
"./PropBase"
;
import
{
Snake
}
from
"db://assets/Scripts/Scenes/MainGame/Snake"
;
import
{
Snake
}
from
"db://assets/Scripts/Scenes/MainGame/Snake"
;
import
{
EPropType
}
from
"../Common/Enums"
;
import
{
E
Card
,
E
PropType
}
from
"../Common/Enums"
;
import
{
CardManager
}
from
"../Manager/CardManager"
;
import
{
CardManager
}
from
"../Manager/CardManager"
;
const
{
ccclass
,
property
}
=
_decorator
;
const
{
ccclass
,
property
}
=
_decorator
;
...
@@ -10,13 +10,14 @@ const { ccclass, property } = _decorator;
...
@@ -10,13 +10,14 @@ const { ccclass, property } = _decorator;
export
class
Card
extends
PropBase
{
export
class
Card
extends
PropBase
{
@
property
({
type
:
EPropType
})
@
property
({
type
:
EPropType
})
tag
:
E
PropType
=
EPropType
.
CARD_A
;
tag
:
E
Card
=
EPropType
.
CARD_A
;
onLoad
()
{
onLoad
()
{
this
.
getComponent
(
Collider2D
).
tag
=
this
.
tag
;
}
}
beEaten
=
(
target
:
Snake
)
=>
{
beEaten
=
(
target
:
Snake
)
=>
{
target
.
addCard
(
this
.
tag
);
};
};
recycle
()
{
recycle
()
{
...
...
assets/Scripts/Scenes/MainGame/Snake.ts
View file @
8fc77e6c
...
@@ -18,6 +18,7 @@ import { isIntersect, loadSkin } from "./utils/uitl";
...
@@ -18,6 +18,7 @@ import { isIntersect, loadSkin } from "./utils/uitl";
import
{
bodyPool
}
from
"./Manager/CommonPool"
;
import
{
bodyPool
}
from
"./Manager/CommonPool"
;
import
{
PropBase
}
from
"./Props/PropBase"
;
import
{
PropBase
}
from
"./Props/PropBase"
;
import
{
FoodManger
}
from
"./Manager/FoodManger"
;
import
{
FoodManger
}
from
"./Manager/FoodManger"
;
import
{
ECard
,
EPropType
}
from
"./Common/Enums"
;
const
{
ccclass
,
property
}
=
_decorator
;
const
{
ccclass
,
property
}
=
_decorator
;
...
@@ -46,6 +47,8 @@ export class Snake extends Component {
...
@@ -46,6 +47,8 @@ export class Snake extends Component {
@
property
(
Prefab
)
bodyPrefab
:
Prefab
=
null
;
@
property
(
Prefab
)
bodyPrefab
:
Prefab
=
null
;
cardMap
:
Map
<
ECard
,
number
>
=
new
Map
<
ECard
,
number
>
();
// 私有成员变量
// 私有成员变量
bodyArr
:
Node
[]
=
[];
bodyArr
:
Node
[]
=
[];
private
imgHead
:
SpriteFrame
=
null
;
private
imgHead
:
SpriteFrame
=
null
;
...
@@ -208,6 +211,18 @@ export class Snake extends Component {
...
@@ -208,6 +211,18 @@ export class Snake extends Component {
}
}
}
}
addCard
(
type
:
ECard
)
{
if
(
!
this
.
cardMap
.
has
(
type
))
{
this
.
cardMap
.
set
(
type
,
0
);
}
this
.
cardMap
.
set
(
type
,
this
.
cardMap
.
get
(
type
)
+
1
);
this
.
checkCard
();
}
checkCard
()
{
}
// 能量与成长
// 能量与成长
private
lastRemaining
=
0
;
private
lastRemaining
=
0
;
...
@@ -368,6 +383,8 @@ export class Snake extends Component {
...
@@ -368,6 +383,8 @@ export class Snake extends Component {
this
.
isLife
=
false
;
this
.
isLife
=
false
;
this
.
node
.
active
=
false
;
this
.
node
.
active
=
false
;
this
.
cardMap
.
clear
();
this
.
clearInvincible
();
const
len
=
this
.
bodyArr
.
length
;
const
len
=
this
.
bodyArr
.
length
;
const
foodArr
=
this
.
bodyArr
.
map
((
body
)
=>
{
const
foodArr
=
this
.
bodyArr
.
map
((
body
)
=>
{
...
...
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