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
614da85d
Commit
614da85d
authored
Nov 19, 2024
by
haiyoucuv
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
init
parent
d82fcdb5
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
213 additions
and
78 deletions
+213
-78
aaa.txt
aaa.txt
+111
-0
MainGame.scene
assets/Bundles/MainGame/MainGame.scene
+10
-13
Enums.ts
assets/Scripts/Scenes/MainGame/Enums.ts
+4
-0
FondManger.ts
assets/Scripts/Scenes/MainGame/FondManger.ts
+21
-56
MainGame.ts
assets/Scripts/Scenes/MainGame/MainGame.ts
+3
-3
Snake.ts
assets/Scripts/Scenes/MainGame/Snake.ts
+4
-4
ExecutePreFrame.ts
assets/Scripts/Utils/ExecutePreFrame.ts
+45
-0
ExecutePreFrame.ts.meta
assets/Scripts/Utils/ExecutePreFrame.ts.meta
+9
-0
project.json
settings/v2/packages/project.json
+2
-2
tsconfig.json
tsconfig.json
+4
-0
No files found.
aaa.txt
0 → 100644
View file @
614da85d
设计可能第三方做&终评无设计稿&无详细动画列表
七日签到+签到成功弹窗 6h
活动首页&活动限制 6h
我的背包(奖品+道具,去领取,装扮等)6h
蛇皮肤提醒弹窗 2h
游戏玩法介绍 0.5h
积分明细页 2h
游戏内:
UI 2h
UI-排行榜部分 3h
开始倒计时 1h
蛇:
摇杆 4h
蛇操行走 12h
蛇支持换肤 12h
吃零食、击杀、拖尾动效 12h
生成:
食物生成 2h
零食卡生成 1h
福袋生成 1h
道具生成 4h
道具生成-难度可控 8h
内部道具:
护盾效果&逻辑 4h
吸铁石效果&逻辑 4h
增长效果&逻辑 3h
移速道具效果&逻辑 3h
外部道具:
护盾卡
加速卡 3h
双倍卡 2h
加长卡 2h
道具栏&开合、使用逻辑 2h
道具栏道具冷却动画 6h
零食卡:
零食卡拾取&合成逻辑 12h
加速叠加效果 3h
AI蛇:
AI蛇的AI 16h
AI难度可控 24h
阶段一/二目标展示动画 2h
阶段一 8h
阶段一倒计时闪烁抖动 2h
阶段二 4h
阶段二倒计时破碎 4h
阶段三(无尽模式) 8h
死亡生成食物 4h
复活-无复活卡面板&复活逻辑 6h
复活-有复活卡 2h
结算逻辑 2h
游戏基础防作弊处理(加密,计数等) 12h
分享海报 4h
排行榜:
切换 2h
省榜&激励展示&倒计时 4h
个人榜&激励展示&倒计时 4h
好友榜 2h
排行榜奖励 1h
首页弹窗排列 1h
道具兑换:
道具页 3h
商品详情 2h
兑换&兑换成功弹窗 2h
福袋抽奖:
福袋页 8h
福袋开启&弹窗 2h
福袋五连+弹窗 4h
五连动画 4h
福袋任务 6h
邀请&助力 8h
福袋兑换&弹窗 4h
其他动画效果预估 32h
埋点 6h
自测联调 30h
351.5h = 43.9375d
assets/Bundles/MainGame/MainGame.scene
View file @
614da85d
...
...
@@ -104,8 +104,8 @@
"_prefab": null,
"_lpos": {
"__type__": "cc.Vec3",
"x":
375
,
"y":
812
,
"x":
812
,
"y":
375
,
"z": 0
},
"_lrot": {
...
...
@@ -860,7 +860,7 @@
},
"_enabled": true,
"__prefab": null,
"
F
oods": [
"
f
oods": [
{
"__id__": 23
}
...
...
@@ -875,7 +875,7 @@
"__type__": "Item",
"type": 0,
"sp": {
"__uuid__": "
ad97e5f2-485d-4ebb-a1ef-a63c1c32115a@f9941
",
"__uuid__": "
8f21f897-8cb9-448d-a674-e0574c83e228@da8cd
",
"__expectedType__": "cc.SpriteFrame"
}
},
...
...
@@ -1218,8 +1218,8 @@
"__prefab": null,
"_contentSize": {
"__type__": "cc.Size",
"width":
750
,
"height":
1624
"width":
1624
,
"height":
750
},
"_anchorPoint": {
"__type__": "cc.Vec2",
...
...
@@ -1326,9 +1326,6 @@
},
"_enabled": true,
"__prefab": null,
"uiCamera": {
"__id__": 42
},
"handle": {
"__id__": 53
},
...
...
@@ -1426,8 +1423,8 @@
"_prefab": null,
"_lpos": {
"__type__": "cc.Vec3",
"x":
375
,
"y":
812
,
"x":
812
,
"y":
375
,
"z": 0
},
"_lrot": {
...
...
@@ -1815,8 +1812,8 @@
"__prefab": null,
"_contentSize": {
"__type__": "cc.Size",
"width":
750
,
"height":
1624
"width":
1624
,
"height":
750
},
"_anchorPoint": {
"__type__": "cc.Vec2",
...
...
assets/Scripts/Scenes/MainGame/Enums.ts
View file @
614da85d
// 事件名称定义
import
{
ccenum
}
from
"cc"
;
export
const
Events
=
{
changeSkinId
:
"changeSkinId"
,
// 更换皮肤事件
setGameState
:
"setGameState"
,
// 设置游戏状态事件
...
...
@@ -10,6 +12,8 @@ export enum FoodType {
FOOD
=
0
,
// 普通食物
MONEY
=
1
// 金币
}
ccenum
(
FoodType
)
// 移动方向枚举
export
enum
DirectionType
{
...
...
assets/Scripts/Scenes/MainGame/FondManger.ts
View file @
614da85d
import
{
_decorator
,
Enum
,
SpriteFrame
,
math
,
v3
,
Sprite
,
Collider2D
,
Component
,
Prefab
}
from
"cc"
;
import
{
_decorator
,
Enum
,
SpriteFrame
,
math
,
v3
,
Sprite
,
Collider2D
,
Component
,
Prefab
,
ccenum
}
from
"cc"
;
import
{
PoolManager
}
from
"./PoolManager"
;
import
{
FoodType
}
from
"./Enums"
;
import
{
Global
}
from
"./Global"
;
import
{
MainGame
}
from
"./MainGame"
;
const
{
ccclass
,
property
}
=
_decorator
;
...
...
@@ -10,9 +11,7 @@ const { ccclass, property } = _decorator;
*/
@
ccclass
(
"Item"
)
class
Item
{
@
property
({
type
:
FoodType
})
@
property
({
type
:
FoodType
})
type
:
FoodType
=
FoodType
.
FOOD
;
@
property
(
SpriteFrame
)
...
...
@@ -24,8 +23,9 @@ class Item {
*/
@
ccclass
(
"FondManger"
)
export
class
FondManger
extends
Component
{
@
property
([
Item
])
private
Foods
:
Item
[]
=
[];
@
property
({
type
:
[
Item
]
})
private
foods
:
Item
[]
=
[];
@
property
(
Prefab
)
private
foodPrefab
:
Prefab
=
null
;
...
...
@@ -48,22 +48,18 @@ export class FondManger extends Component {
* 设置食物
*/
setFood
(
x
?:
number
,
y
?:
number
)
{
// 如果没有指定位置,随机生成位置
if
(
!
x
)
{
x
=
math
.
randomRangeInt
(
-
(
Global
.
MAP_WIDTH
/
2
-
50
),
Global
.
MAP_WIDTH
/
2
-
50
);
x
=
math
.
randomRangeInt
(
-
(
Global
.
MAP_WIDTH
/
2
-
50
),
Global
.
MAP_WIDTH
/
2
-
50
);
}
if
(
!
y
)
{
y
=
math
.
randomRangeInt
(
-
(
Global
.
MAP_HIGHT
/
2
-
50
),
Global
.
MAP_HIGHT
/
2
-
50
);
y
=
math
.
randomRangeInt
(
-
(
Global
.
MAP_HIGHT
/
2
-
50
),
Global
.
MAP_HIGHT
/
2
-
50
);
}
// 随机选择食物类型
const
index
=
math
.
randomRangeInt
(
0
,
this
.
F
oods
.
length
);
const
index
=
math
.
randomRangeInt
(
0
,
this
.
f
oods
.
length
);
// 从对象池获取食物节点
const
node
=
PoolManager
.
instance
.
getNode
(
...
...
@@ -75,26 +71,17 @@ export class FondManger extends Component {
// 设置食物属性
node
.
angle
=
0
;
node
.
setScale
(
1
,
1
);
node
.
getComponent
(
Sprite
).
spriteFrame
=
this
.
F
oods
[
index
].
sp
;
node
.
getComponent
(
Sprite
).
spriteFrame
=
this
.
f
oods
[
index
].
sp
;
// 设置碰撞类型
const
collider
=
node
.
getComponent
(
Collider2D
);
if
(
collider
)
{
collider
.
tag
=
this
.
F
oods
[
index
].
type
;
collider
.
tag
=
this
.
f
oods
[
index
].
type
;
}
node
.
active
=
true
;
}
/**
* 生成食物迭代器
*/
private
*
_getItemGenerator
(
count
:
number
)
{
for
(
let
i
=
0
;
i
<
count
;
i
++
)
{
yield
this
.
_initItem
(
i
);
}
}
/**
* 初始化单个食物
*/
...
...
@@ -107,18 +94,18 @@ export class FondManger extends Component {
const
y
=
math
.
randomRangeInt
(
-
(
Global
.
MAP_HIGHT
/
2
-
50
),
Global
.
MAP_HIGHT
/
2
-
50
);
// 随机选择食物类型
index
=
math
.
randomRangeInt
(
0
,
this
.
F
oods
.
length
);
index
=
math
.
randomRangeInt
(
0
,
this
.
f
oods
.
length
);
// 设置食物属性
node
.
angle
=
0
;
node
.
setScale
(
1
,
1
);
node
.
setPosition
(
x
,
y
,
0
);
node
.
getComponent
(
Sprite
).
spriteFrame
=
this
.
F
oods
[
index
].
sp
;
node
.
getComponent
(
Sprite
).
spriteFrame
=
this
.
f
oods
[
index
].
sp
;
// 设置碰撞类型
const
collider
=
node
.
getComponent
(
Collider2D
);
if
(
collider
)
{
collider
.
tag
=
this
.
F
oods
[
index
].
type
;
collider
.
tag
=
this
.
f
oods
[
index
].
type
;
}
node
.
active
=
true
;
...
...
@@ -127,32 +114,10 @@ export class FondManger extends Component {
/**
* 初始化食物
*/
async
initFond
(
count
:
number
)
{
await
this
.
executePreFrame
(
this
.
_getItemGenerator
(
count
),
1
);
initFond
(
count
:
number
)
{
for
(
let
i
=
0
;
i
<
count
;
i
++
)
{
this
.
_initItem
(
i
);
}
}
/**
* 分帧执行
*/
executePreFrame
(
generator
:
Generator
,
frameTime
:
number
):
Promise
<
boolean
>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
const
iter
=
generator
;
const
next
=
()
=>
{
const
startTime
=
new
Date
().
getTime
();
for
(
let
result
=
iter
.
next
();
;
result
=
iter
.
next
())
{
if
(
!
result
||
result
.
done
)
{
resolve
(
true
);
return
;
}
if
(
new
Date
().
getTime
()
-
startTime
>
frameTime
)
{
this
.
scheduleOnce
(()
=>
{
next
();
});
return
;
}
}
};
next
();
});
}
}
\ No newline at end of file
}
assets/Scripts/Scenes/MainGame/MainGame.ts
View file @
614da85d
...
...
@@ -130,7 +130,7 @@ export class MainGame extends Scene {
if
(
this
.
state
==
GameState
.
READY
)
return
;
// 更新UI提示
this
.
LTips
.
string
=
`长度:
${
this
.
snake
.
getSnakeLen
()}
金币:
${
this
.
snake
.
get
m
oneySum
()}
`
;
this
.
LTips
.
string
=
`长度:
${
this
.
snake
.
getSnakeLen
()}
金币:
${
this
.
snake
.
get
M
oneySum
()}
`
;
// 更新蛇的移动
this
.
snake
.
setAngle
((
360
-
this
.
joystick
.
angle
)
%
360
);
...
...
@@ -169,7 +169,7 @@ export class MainGame extends Scene {
break
;
case
GameState
.
WIN
:
director
.
pause
();
console
.
log
(
"win"
,
this
.
snake
.
getSnakeLen
(),
this
.
snake
.
get
m
oneySum
());
console
.
log
(
"win"
,
this
.
snake
.
getSnakeLen
(),
this
.
snake
.
get
M
oneySum
());
break
;
case
GameState
.
QUIT
:
director
.
resume
();
...
...
@@ -193,7 +193,7 @@ export class MainGame extends Scene {
}
showGOver
()
{
console
.
log
(
"showGOver"
,
this
.
snake
.
getSnakeLen
(),
this
.
snake
.
get
m
oneySum
());
console
.
log
(
"showGOver"
,
this
.
snake
.
getSnakeLen
(),
this
.
snake
.
get
M
oneySum
());
}
private
*
_getItemGenerator
(
count
:
number
)
{
...
...
assets/Scripts/Scenes/MainGame/Snake.ts
View file @
614da85d
...
...
@@ -8,9 +8,9 @@ import {
v2
,
v3
,
Vec3
,
Node
,
Contact2DType
,
tween
,
Prefab
,
PhysicsGroup
,
Node
,
Contact2DType
,
tween
,
Prefab
,
PhysicsGroup
,
director
,
}
from
"cc"
;
import
{
FoodTyp
e
}
from
"./Enums"
;
import
{
Events
,
FoodType
,
GameStat
e
}
from
"./Enums"
;
import
{
Global
}
from
"./Global"
;
import
{
PoolManager
}
from
"./PoolManager"
;
import
{
isIntersect
}
from
"./uitl"
;
...
...
@@ -335,7 +335,7 @@ export class Snake extends Component {
return
this
.
Bodys
.
length
;
}
get
m
oneySum
()
{
get
M
oneySum
()
{
return
this
.
moneySum
;
}
...
...
@@ -360,7 +360,7 @@ export class Snake extends Component {
this
.
node
.
active
=
false
;
// 发送游戏结束事件
//
director.emit(Events.setGameState, GameState.OVER);
director
.
emit
(
Events
.
setGameState
,
GameState
.
OVER
);
}
// 工具方法 - 计算新位置
...
...
assets/Scripts/Utils/ExecutePreFrame.ts
0 → 100644
View file @
614da85d
function
*
_getItemGenerator
(
length
:
number
)
{
for
(
let
i
=
0
;
i
<
length
;
i
++
)
{
yield
this
.
_initItem
(
i
);
}
this
.
ready
=
true
;
}
function
executePreFrame
(
generator
:
Generator
,
duration
:
number
)
{
return
new
Promise
<
void
>
((
resolve
,
reject
)
=>
{
let
gen
=
generator
;
// 创建执行函数
let
execute
=
()
=>
{
// 执行之前,先记录开始时间戳
let
startTime
=
new
Date
().
getTime
();
// 然后一直从 Generator 中获取已经拆分好的代码段出来执行
for
(
let
iter
=
gen
.
next
();
;
iter
=
gen
.
next
())
{
// 判断是否已经执行完所有 Generator 的小代码段
// 如果是的话,那么就表示任务完成
if
(
iter
==
null
||
iter
.
done
)
{
resolve
();
return
;
}
// 每执行完一段小代码段,都检查一下是否
// 已经超过我们分配给本帧,这些小代码端的最大可执行时间
if
(
new
Date
().
getTime
()
-
startTime
>
duration
)
{
// 如果超过了,那么本帧就不在执行,开定时器,让下一帧再执行
this
.
scheduleOnce
(()
=>
{
execute
();
});
return
;
}
}
};
// 运行执行函数
execute
();
});
}
assets/Scripts/Utils/ExecutePreFrame.ts.meta
0 → 100644
View file @
614da85d
{
"ver": "4.0.24",
"importer": "typescript",
"imported": true,
"uuid": "020d28d5-d3d5-44c3-ae46-9c83b35f5f7d",
"files": [],
"subMetas": {},
"userData": {}
}
settings/v2/packages/project.json
View file @
614da85d
...
...
@@ -2,8 +2,8 @@
"__version__"
:
"1.0.6"
,
"general"
:
{
"designResolution"
:
{
"width"
:
750
,
"height"
:
1624
"width"
:
1624
,
"height"
:
750
},
"downloadMaxConcurrency"
:
20
,
"renderPipeline"
:
"c7e748e8-be82-4f6f-b2c0-085b604e40e5"
...
...
tsconfig.json
View file @
614da85d
...
...
@@ -3,6 +3,10 @@
"extends"
:
"./temp/tsconfig.cocos.json"
,
/*
Add
your
custom
configuration
here.
*/
"compilerOptions"
:
{
"lib"
:
[
"es2015"
,
"dom"
],
"strict"
:
false
,
"allowSyntheticDefaultImports"
:
true
,
"moduleResolution"
:
"bundler"
,
...
...
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