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
0dd09263
Commit
0dd09263
authored
Nov 28, 2024
by
haiyoucuv
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
init
parent
842d0321
Changes
15
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
1387 additions
and
385 deletions
+1387
-385
MainGame.scene
assets/Bundles/MainGame/MainGame.scene
+442
-343
卡A.prefab
assets/Bundles/MainGame/prefab/卡A.prefab
+244
-0
卡A.prefab.meta
assets/Bundles/MainGame/prefab/卡A.prefab.meta
+13
-0
卡B.prefab
assets/Bundles/MainGame/prefab/卡B.prefab
+244
-0
卡B.prefab.meta
assets/Bundles/MainGame/prefab/卡B.prefab.meta
+13
-0
卡C.prefab
assets/Bundles/MainGame/prefab/卡C.prefab
+244
-0
卡C.prefab.meta
assets/Bundles/MainGame/prefab/卡C.prefab.meta
+13
-0
Enums.ts
assets/Scripts/Scenes/MainGame/Common/Enums.ts
+4
-1
Global.ts
assets/Scripts/Scenes/MainGame/Global.ts
+18
-6
CardManager.ts
assets/Scripts/Scenes/MainGame/Manager/CardManager.ts
+94
-0
CardManager.ts.meta
assets/Scripts/Scenes/MainGame/Manager/CardManager.ts.meta
+9
-0
FoodManger.ts
assets/Scripts/Scenes/MainGame/Manager/FoodManger.ts
+4
-9
Card.ts
assets/Scripts/Scenes/MainGame/Props/Card.ts
+29
-0
Card.ts.meta
assets/Scripts/Scenes/MainGame/Props/Card.ts.meta
+9
-0
uitl.ts
assets/Scripts/Scenes/MainGame/utils/uitl.ts
+7
-26
No files found.
assets/Bundles/MainGame/MainGame.scene
View file @
0dd09263
This diff is collapsed.
Click to expand it.
assets/Bundles/MainGame/prefab/卡A.prefab
0 → 100644
View file @
0dd09263
[
{
"__type__": "cc.Prefab",
"_name": "卡A",
"_objFlags": 0,
"__editorExtras__": {},
"_native": "",
"data": {
"__id__": 1
},
"optimizationPolicy": 0,
"persistent": false
},
{
"__type__": "cc.Node",
"_name": "卡A",
"_objFlags": 0,
"__editorExtras__": {},
"_parent": null,
"_children": [],
"_active": true,
"_components": [
{
"__id__": 2
},
{
"__id__": 4
},
{
"__id__": 6
},
{
"__id__": 8
},
{
"__id__": 10
}
],
"_prefab": {
"__id__": 12
},
"_lpos": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_lrot": {
"__type__": "cc.Quat",
"x": 0,
"y": 0,
"z": 0,
"w": 1
},
"_lscale": {
"__type__": "cc.Vec3",
"x": 1,
"y": 1,
"z": 1
},
"_mobility": 0,
"_layer": 1,
"_euler": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_id": ""
},
{
"__type__": "cc.UITransform",
"_name": "",
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 1
},
"_enabled": true,
"__prefab": {
"__id__": 3
},
"_contentSize": {
"__type__": "cc.Size",
"width": 32,
"height": 42
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "f36Gjr/cxA5bosiEnf90lC"
},
{
"__type__": "cc.Sprite",
"_name": "",
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 1
},
"_enabled": true,
"__prefab": {
"__id__": 5
},
"_customMaterial": null,
"_srcBlendFactor": 2,
"_dstBlendFactor": 4,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_spriteFrame": {
"__uuid__": "04c4c3c6-c6a2-4ffb-98af-169280fb26f6@f9941",
"__expectedType__": "cc.SpriteFrame"
},
"_type": 0,
"_fillType": 0,
"_sizeMode": 1,
"_fillCenter": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"_fillStart": 0,
"_fillRange": 0,
"_isTrimmedMode": true,
"_useGrayscale": false,
"_atlas": null,
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "79U2Z8PihDCKpj25KchRMz"
},
{
"__type__": "cc.RigidBody2D",
"_name": "",
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 1
},
"_enabled": true,
"__prefab": {
"__id__": 7
},
"enabledContactListener": true,
"bullet": false,
"awakeOnLoad": true,
"_group": 4,
"_type": 1,
"_allowSleep": true,
"_gravityScale": 1,
"_linearDamping": 0,
"_angularDamping": 0,
"_linearVelocity": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"_angularVelocity": 0,
"_fixedRotation": false,
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "97wTw+gGFFXqhX9+0L8n3z"
},
{
"__type__": "cc.BoxCollider2D",
"_name": "",
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 1
},
"_enabled": true,
"__prefab": {
"__id__": 9
},
"tag": 0,
"_group": 4,
"_density": 1,
"_sensor": true,
"_friction": 0.2,
"_restitution": 0,
"_offset": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"_size": {
"__type__": "cc.Size",
"width": 32,
"height": 42
},
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "03SReFoi1MyblTtnOqjaHw"
},
{
"__type__": "ff08cSpRqFAubppBaJ7tYho",
"_name": "",
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 1
},
"_enabled": true,
"__prefab": {
"__id__": 11
},
"tag": 2,
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "96Vnnh5RpGZ52WY8R4AzOS"
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__id__": 0
},
"fileId": "cbAXFUcl9AyYAN+i9Mo+C6",
"instance": null,
"targetOverrides": null
}
]
\ No newline at end of file
assets/Bundles/MainGame/prefab/卡A.prefab.meta
0 → 100644
View file @
0dd09263
{
"ver": "1.1.50",
"importer": "prefab",
"imported": true,
"uuid": "efbb3e39-0a47-481d-a9a2-27f449ab881d",
"files": [
".json"
],
"subMetas": {},
"userData": {
"syncNodeName": "卡A"
}
}
assets/Bundles/MainGame/prefab/卡B.prefab
0 → 100644
View file @
0dd09263
[
{
"__type__": "cc.Prefab",
"_name": "卡B",
"_objFlags": 0,
"__editorExtras__": {},
"_native": "",
"data": {
"__id__": 1
},
"optimizationPolicy": 0,
"persistent": false
},
{
"__type__": "cc.Node",
"_name": "卡B",
"_objFlags": 0,
"__editorExtras__": {},
"_parent": null,
"_children": [],
"_active": true,
"_components": [
{
"__id__": 2
},
{
"__id__": 4
},
{
"__id__": 6
},
{
"__id__": 8
},
{
"__id__": 10
}
],
"_prefab": {
"__id__": 12
},
"_lpos": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_lrot": {
"__type__": "cc.Quat",
"x": 0,
"y": 0,
"z": 0,
"w": 1
},
"_lscale": {
"__type__": "cc.Vec3",
"x": 1,
"y": 1,
"z": 1
},
"_mobility": 0,
"_layer": 1,
"_euler": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_id": ""
},
{
"__type__": "cc.UITransform",
"_name": "",
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 1
},
"_enabled": true,
"__prefab": {
"__id__": 3
},
"_contentSize": {
"__type__": "cc.Size",
"width": 32,
"height": 42
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "f36Gjr/cxA5bosiEnf90lC"
},
{
"__type__": "cc.Sprite",
"_name": "",
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 1
},
"_enabled": true,
"__prefab": {
"__id__": 5
},
"_customMaterial": null,
"_srcBlendFactor": 2,
"_dstBlendFactor": 4,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_spriteFrame": {
"__uuid__": "e37fb195-9aa5-43ba-9720-93366607f675@f9941",
"__expectedType__": "cc.SpriteFrame"
},
"_type": 0,
"_fillType": 0,
"_sizeMode": 1,
"_fillCenter": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"_fillStart": 0,
"_fillRange": 0,
"_isTrimmedMode": true,
"_useGrayscale": false,
"_atlas": null,
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "79U2Z8PihDCKpj25KchRMz"
},
{
"__type__": "cc.RigidBody2D",
"_name": "",
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 1
},
"_enabled": true,
"__prefab": {
"__id__": 7
},
"enabledContactListener": true,
"bullet": false,
"awakeOnLoad": true,
"_group": 4,
"_type": 1,
"_allowSleep": true,
"_gravityScale": 1,
"_linearDamping": 0,
"_angularDamping": 0,
"_linearVelocity": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"_angularVelocity": 0,
"_fixedRotation": false,
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "97wTw+gGFFXqhX9+0L8n3z"
},
{
"__type__": "cc.BoxCollider2D",
"_name": "",
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 1
},
"_enabled": true,
"__prefab": {
"__id__": 9
},
"tag": 0,
"_group": 4,
"_density": 1,
"_sensor": true,
"_friction": 0.2,
"_restitution": 0,
"_offset": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"_size": {
"__type__": "cc.Size",
"width": 32,
"height": 42
},
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "03SReFoi1MyblTtnOqjaHw"
},
{
"__type__": "ff08cSpRqFAubppBaJ7tYho",
"_name": "",
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 1
},
"_enabled": true,
"__prefab": {
"__id__": 11
},
"tag": 3,
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "6d2fdXQtZG5oyCopoKcs1R"
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__id__": 0
},
"fileId": "cbAXFUcl9AyYAN+i9Mo+C6",
"instance": null,
"targetOverrides": null
}
]
\ No newline at end of file
assets/Bundles/MainGame/prefab/卡B.prefab.meta
0 → 100644
View file @
0dd09263
{
"ver": "1.1.50",
"importer": "prefab",
"imported": true,
"uuid": "5b9810de-f810-45a7-8d79-b3fc1152bfc9",
"files": [
".json"
],
"subMetas": {},
"userData": {
"syncNodeName": "卡B"
}
}
assets/Bundles/MainGame/prefab/卡C.prefab
0 → 100644
View file @
0dd09263
[
{
"__type__": "cc.Prefab",
"_name": "卡C",
"_objFlags": 0,
"__editorExtras__": {},
"_native": "",
"data": {
"__id__": 1
},
"optimizationPolicy": 0,
"persistent": false
},
{
"__type__": "cc.Node",
"_name": "卡C",
"_objFlags": 0,
"__editorExtras__": {},
"_parent": null,
"_children": [],
"_active": true,
"_components": [
{
"__id__": 2
},
{
"__id__": 4
},
{
"__id__": 6
},
{
"__id__": 8
},
{
"__id__": 10
}
],
"_prefab": {
"__id__": 12
},
"_lpos": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_lrot": {
"__type__": "cc.Quat",
"x": 0,
"y": 0,
"z": 0,
"w": 1
},
"_lscale": {
"__type__": "cc.Vec3",
"x": 1,
"y": 1,
"z": 1
},
"_mobility": 0,
"_layer": 1,
"_euler": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_id": ""
},
{
"__type__": "cc.UITransform",
"_name": "",
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 1
},
"_enabled": true,
"__prefab": {
"__id__": 3
},
"_contentSize": {
"__type__": "cc.Size",
"width": 32,
"height": 42
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "f36Gjr/cxA5bosiEnf90lC"
},
{
"__type__": "cc.Sprite",
"_name": "",
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 1
},
"_enabled": true,
"__prefab": {
"__id__": 5
},
"_customMaterial": null,
"_srcBlendFactor": 2,
"_dstBlendFactor": 4,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_spriteFrame": {
"__uuid__": "af6adb06-7b7a-4c99-9a3a-93f00d63e5c7@f9941",
"__expectedType__": "cc.SpriteFrame"
},
"_type": 0,
"_fillType": 0,
"_sizeMode": 1,
"_fillCenter": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"_fillStart": 0,
"_fillRange": 0,
"_isTrimmedMode": true,
"_useGrayscale": false,
"_atlas": null,
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "79U2Z8PihDCKpj25KchRMz"
},
{
"__type__": "cc.RigidBody2D",
"_name": "",
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 1
},
"_enabled": true,
"__prefab": {
"__id__": 7
},
"enabledContactListener": true,
"bullet": false,
"awakeOnLoad": true,
"_group": 4,
"_type": 1,
"_allowSleep": true,
"_gravityScale": 1,
"_linearDamping": 0,
"_angularDamping": 0,
"_linearVelocity": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"_angularVelocity": 0,
"_fixedRotation": false,
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "97wTw+gGFFXqhX9+0L8n3z"
},
{
"__type__": "cc.BoxCollider2D",
"_name": "",
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 1
},
"_enabled": true,
"__prefab": {
"__id__": 9
},
"tag": 0,
"_group": 4,
"_density": 1,
"_sensor": true,
"_friction": 0.2,
"_restitution": 0,
"_offset": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"_size": {
"__type__": "cc.Size",
"width": 32,
"height": 42
},
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "03SReFoi1MyblTtnOqjaHw"
},
{
"__type__": "ff08cSpRqFAubppBaJ7tYho",
"_name": "",
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 1
},
"_enabled": true,
"__prefab": {
"__id__": 11
},
"tag": 4,
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "6d2fdXQtZG5oyCopoKcs1R"
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__id__": 0
},
"fileId": "cbAXFUcl9AyYAN+i9Mo+C6",
"instance": null,
"targetOverrides": null
}
]
\ No newline at end of file
assets/Bundles/MainGame/prefab/卡C.prefab.meta
0 → 100644
View file @
0dd09263
{
"ver": "1.1.50",
"importer": "prefab",
"imported": true,
"uuid": "e47a3402-261d-4da0-942c-c672159c078b",
"files": [
".json"
],
"subMetas": {},
"userData": {
"syncNodeName": "卡C"
}
}
assets/Scripts/Scenes/MainGame/Common/Enums.ts
View file @
0dd09263
...
...
@@ -10,7 +10,10 @@ export const Events = {
// 食物类型枚举
export
enum
EPropType
{
FOOD
=
0
,
// 普通食物
LUCK_BAG
=
1
// 福袋
LUCK_BAG
=
1
,
// 福袋
CARD_A
=
2
,
CARD_B
=
3
,
CARD_C
=
4
,
}
ccenum
(
EPropType
);
...
...
assets/Scripts/Scenes/MainGame/Global.ts
View file @
0dd09263
import
{
_decorator
,
View
}
from
'cc'
;
import
{
_decorator
,
IVec2Like
,
math
,
View
}
from
"cc"
;
const
{
ccclass
}
=
_decorator
;
/**
* 全局配置类
*/
@
ccclass
(
'Global'
)
@
ccclass
(
"Global"
)
export
class
Global
{
/** 地图宽度 */
public
static
MAP_WIDTH
:
number
=
6000
;
/** 地图宽度 */
static
MAP_WIDTH
:
number
=
6000
;
/** 地图高度 */
static
MAP_HEIGHT
:
number
=
4200
;
static
getRandomPosition
(
padding
:
number
=
0
):
IVec2Like
{
const
maxW
=
Global
.
MAP_WIDTH
/
2
-
padding
;
const
maxH
=
Global
.
MAP_HEIGHT
/
2
-
padding
;
const
x
=
math
.
randomRange
(
-
maxW
,
maxW
);
const
y
=
math
.
randomRange
(
-
maxH
,
maxH
);
/** 地图高度 */
public
static
MAP_HEIGHT
:
number
=
4200
;
return
{
x
,
y
};
}
}
\ No newline at end of file
assets/Scripts/Scenes/MainGame/Manager/CardManager.ts
0 → 100644
View file @
0dd09263
import
{
_decorator
,
math
,
Component
,
Prefab
,
instantiate
,
}
from
"cc"
;
import
{
Global
}
from
"db://assets/Scripts/Scenes/MainGame/Global"
;
import
{
executePreFrame
,
getItemGenerator
}
from
"db://assets/Scripts/Utils/ExecutePreFrame"
;
const
{
ccclass
,
property
}
=
_decorator
;
/**
* 食物管理器
*/
@
ccclass
(
"CardManager"
)
export
class
CardManager
extends
Component
{
private
static
_ins
:
CardManager
=
null
;
static
get
ins
()
{
return
this
.
_ins
;
}
@
property
({
type
:
[
Prefab
]
})
private
cardPrefabs
:
Prefab
[]
=
[];
maxCard
:
number
=
10
;
onLoad
()
{
CardManager
.
_ins
=
this
;
}
onDestroy
()
{
CardManager
.
_ins
=
null
;
}
start
()
{
this
.
init
(
10
);
}
/**
* 获取当前食物数量
*/
getCardSum
()
{
return
this
.
node
.
children
.
length
||
0
;
}
/**
* 初始化食物
*/
async
init
(
maxCard
:
number
=
10
)
{
this
.
maxCard
=
maxCard
;
await
executePreFrame
(
getItemGenerator
(
maxCard
,
this
.
initItem
),
1
,
this
);
}
/**
* 检查食物
*/
checkCard
()
{
for
(
let
i
=
this
.
getCardSum
();
i
<
this
.
maxCard
;
i
++
)
{
this
.
addCard
();
}
}
/**
* 设置食物
*/
addCard
(
x
?:
number
,
y
?:
number
)
{
// 如果没有指定位置,随机生成位置
if
(
!
x
)
{
const
{
x
:
_x
,
y
:
_y
}
=
Global
.
getRandomPosition
(
100
);
x
=
_x
;
y
=
_y
;
}
const
index
=
math
.
randomRangeInt
(
0
,
this
.
cardPrefabs
.
length
);
const
card
=
instantiate
(
this
.
cardPrefabs
[
index
]);
// 设置食物属性
card
.
setPosition
(
x
,
y
);
this
.
node
.
addChild
(
card
);
card
.
active
=
true
;
}
/**
* 初始化单个食物
*/
initItem
=
(
_
:
number
)
=>
{
this
.
checkCard
();
};
}
assets/Scripts/Scenes/MainGame/Manager/CardManager.ts.meta
0 → 100644
View file @
0dd09263
{
"ver": "4.0.24",
"importer": "typescript",
"imported": true,
"uuid": "aad38637-15a2-4fcb-b087-b702d39b404f",
"files": [],
"subMetas": {},
"userData": {}
}
assets/Scripts/Scenes/MainGame/Manager/FoodManger.ts
View file @
0dd09263
...
...
@@ -28,7 +28,7 @@ export class FoodManger extends Component {
}
@
property
({
type
:
[
SpriteFrame
]
})
private
foods
:
SpriteFrame
[]
=
[];
foods
:
SpriteFrame
[]
=
[];
@
property
(
Prefab
)
private
foodPrefab
:
Prefab
=
null
;
...
...
@@ -73,16 +73,11 @@ export class FoodManger extends Component {
*/
addFood
(
x
?:
number
,
y
?:
number
,
energy
:
number
=
1
)
{
const
maxW
=
Global
.
MAP_WIDTH
/
2
-
100
;
const
maxH
=
Global
.
MAP_HEIGHT
/
2
-
100
;
// 如果没有指定位置,随机生成位置
if
(
!
x
)
{
x
=
math
.
randomRange
(
-
maxW
,
maxW
);
}
if
(
!
y
)
{
y
=
math
.
randomRange
(
-
maxH
,
maxH
);
const
{
x
:
_x
,
y
:
_y
}
=
Global
.
getRandomPosition
(
100
);
x
=
_x
;
y
=
_y
;
}
const
food
=
foodPool
.
get
()
||
instantiate
(
this
.
foodPrefab
);
...
...
assets/Scripts/Scenes/MainGame/Props/Card.ts
0 → 100644
View file @
0dd09263
import
{
_decorator
}
from
"cc"
;
import
{
PropBase
}
from
"./PropBase"
;
import
{
Snake
}
from
"db://assets/Scripts/Scenes/MainGame/Snake"
;
import
{
EPropType
}
from
"../Common/Enums"
;
import
{
CardManager
}
from
"../Manager/CardManager"
;
const
{
ccclass
,
property
}
=
_decorator
;
@
ccclass
(
"Card"
)
export
class
Card
extends
PropBase
{
@
property
({
type
:
EPropType
})
tag
:
EPropType
=
EPropType
.
CARD_A
;
onLoad
()
{
}
beEaten
=
(
target
:
Snake
)
=>
{
};
recycle
()
{
CardManager
.
ins
.
checkCard
();
this
.
node
.
removeFromParent
();
this
.
node
.
destroy
();
// propPool.put(this.node);
}
}
\ No newline at end of file
assets/Scripts/Scenes/MainGame/Props/Card.ts.meta
0 → 100644
View file @
0dd09263
{
"ver": "4.0.24",
"importer": "typescript",
"imported": true,
"uuid": "ff08c4a9-46a1-40b9-ba69-05a27bb58868",
"files": [],
"subMetas": {},
"userData": {}
}
assets/Scripts/Scenes/MainGame/utils/uitl.ts
View file @
0dd09263
import
{
Vec2
,
Vec3
,
Size
,
assetManager
,
SpriteFrame
,
SpriteAtlas
}
from
"cc"
;
import
{
Vec2
,
Vec3
,
Size
,
assetManager
,
SpriteFrame
,
SpriteAtlas
,
math
,
IVec2Like
}
from
"cc"
;
import
{
Global
}
from
"../Global"
;
/**
* 判断两点是否在指定范围内相交
...
...
@@ -9,7 +10,7 @@ import { Vec2, Vec3, Size, assetManager, SpriteFrame, SpriteAtlas } from "cc";
* @returns 是否相交
*/
export
function
isIntersect
(
pos1
:
Vec3
,
pos2
:
Vec3
,
rangeW
:
number
,
rangeH
:
number
):
boolean
{
return
rangeW
>
Math
.
abs
(
pos1
.
x
-
pos2
.
x
)
&&
rangeH
>
Math
.
abs
(
pos1
.
y
-
pos2
.
y
);
return
rangeW
>
Math
.
abs
(
pos1
.
x
-
pos2
.
x
)
&&
rangeH
>
Math
.
abs
(
pos1
.
y
-
pos2
.
y
);
}
/**
...
...
@@ -19,33 +20,13 @@ export function isIntersect(pos1: Vec3, pos2: Vec3, rangeW: number, rangeH: numb
* @returns 随机浮点数
*/
export
function
getRandomFloat
(
min
:
number
,
max
:
number
):
number
{
return
Math
.
random
()
*
(
max
-
min
)
+
min
;
return
Math
.
random
()
*
(
max
-
min
)
+
min
;
}
/**
* 获取随机位置
* @param viewSize 视图大小
* @param padding 边距
* @returns 随机位置
*/
export
function
getRandomPosition
(
viewSize
:
Size
,
padding
:
number
=
0
):
Vec2
{
const
x
=
getRandomFloat
(
-
viewSize
.
width
/
2
+
padding
,
viewSize
.
width
/
2
-
padding
);
const
y
=
getRandomFloat
(
-
viewSize
.
height
/
2
+
padding
,
viewSize
.
height
/
2
-
padding
);
return
new
Vec2
(
x
,
y
);
}
export
function
formatTime
(
seconds
:
number
):
string
{
const
mins
=
Math
.
floor
(
seconds
/
60
);
const
secs
=
Math
.
floor
(
seconds
%
60
);
return
`
${
mins
.
toString
().
padStart
(
2
,
"0"
)}
:
${
secs
.
toString
().
padStart
(
2
,
"0"
)}
`
;
const
mins
=
Math
.
floor
(
seconds
/
60
);
const
secs
=
Math
.
floor
(
seconds
%
60
);
return
`
${
mins
.
toString
().
padStart
(
2
,
"0"
)}
:
${
secs
.
toString
().
padStart
(
2
,
"0"
)}
`
;
}
export
function
loadSkin
(
skinName
:
string
,
bundleName
:
string
=
"MainGame"
):
Promise
<
SpriteAtlas
>
{
...
...
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