Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
E
elephant
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
template admin
elephant
Commits
2aaf7c55
Commit
2aaf7c55
authored
Dec 12, 2021
by
Tt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
第一版
parent
9462ca1c
Changes
12
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
11070 additions
and
2273 deletions
+11070
-2273
cocos_generator.fire
assets/cocos_generator/scene/cocos_generator.fire
+10436
-2080
cocos_generator.ts
assets/cocos_generator/scene/cocos_generator.ts
+405
-167
config.ts
assets/cocos_generator/scene/config/config.ts
+106
-6
item.ts
assets/cocos_generator/scene/model/item.ts
+4
-0
kitchen.ts
assets/cocos_generator/scene/model/kitchen.ts
+32
-0
kitchen.ts.meta
assets/cocos_generator/scene/model/kitchen.ts.meta
+9
-0
user.ts
assets/cocos_generator/scene/model/user.ts
+28
-2
api.ts
assets/cocos_generator/scene/net/api.ts
+39
-0
api.ts.meta
assets/cocos_generator/scene/net/api.ts.meta
+0
-0
http.ts
assets/cocos_generator/scene/net/http.ts
+0
-16
pg.ts
assets/cocos_generator/scene/pg.ts
+9
-0
bg_progress.png.meta
assets/cocos_generator/textures/home/bg_progress.png.meta
+2
-2
No files found.
assets/cocos_generator/scene/cocos_generator.fire
View file @
2aaf7c55
This diff is collapsed.
Click to expand it.
assets/cocos_generator/scene/cocos_generator.ts
View file @
2aaf7c55
This diff is collapsed.
Click to expand it.
assets/cocos_generator/scene/config/config.ts
View file @
2aaf7c55
const
I
tems
=
[
const
I
TEMS
=
[
{
{
id
:
1001
,
id
:
1001
,
name
:
"
西瓜
"
type
:
1
,
//食物
name
:
"
苹果
"
,
icon
:
"
icon_1
"
,
growthValue
:
10
,
cost
:
100
,
discount
:
0.8
,
num
:
3
,
levelLimite
:
1
,
},
{
id
:
1002
,
type
:
1
,
//食物
name
:
"
香蕉
"
,
icon
:
"
icon_2
"
,
growthValue
:
15
,
cost
:
120
,
discount
:
1
,
num
:
5
,
levelLimite
:
2
,
},
{
id
:
1003
,
type
:
1
,
//食物
name
:
"
面包
"
,
icon
:
"
icon_3
"
,
growthValue
:
20
,
cost
:
150
,
discount
:
1
,
num
:
8
,
levelLimite
:
1
,
},
{
id
:
1004
,
type
:
1
,
//食物
name
:
"
胡萝卜
"
,
icon
:
"
icon_4
"
,
growthValue
:
30
,
cost
:
200
,
discount
:
1
,
num
:
9
,
levelLimite
:
1
,
},
{
id
:
1005
,
type
:
1
,
//食物
name
:
"
奶酪
"
,
icon
:
"
icon_5
"
,
growthValue
:
40
,
cost
:
230
,
discount
:
1
,
num
:
13
,
levelLimite
:
1
,
},
{
id
:
1006
,
type
:
1
,
//食物
name
:
"
橙子
"
,
icon
:
"
icon_6
"
,
growthValue
:
50
,
cost
:
270
,
discount
:
1
,
num
:
1
,
levelLimite
:
1
,
},
{
id
:
1007
,
type
:
1
,
//食物
name
:
"
披萨
"
,
icon
:
"
icon_7
"
,
growthValue
:
90
,
cost
:
400
,
discount
:
1
,
num
:
0
,
levelLimite
:
1
,
},
{
id
:
1008
,
type
:
1
,
//食物
name
:
"
西红柿
"
,
icon
:
"
icon_8
"
,
growthValue
:
100
,
cost
:
600
,
discount
:
1
,
num
:
0
,
levelLimite
:
1
,
}
}
]
]
const
Shops
=
[];
const
LEVEL
=
{
const
Kitchen
=
[];
level_1
:
{
growth
:
100
,
},
level_2
:
{
growth
:
300
,
},
level_3
:
{
growth
:
600
,
},
level_4
:
{
growth
:
1000
,
},
level_5
:
{
growth
:
1500
,
},
level_6
:
{
growth
:
2100
,
}
}
const
USER
=
{
const
USER
=
{
name
:
"
小小香香
"
,
name
:
"
小小香香
"
,
coin
:
100023
,
coin
:
100023
,
...
@@ -19,4 +114,9 @@ const USER = {
...
@@ -19,4 +114,9 @@ const USER = {
useClothes
:
[],
useClothes
:
[],
mood
:
"
开心
"
mood
:
"
开心
"
}
}
export
{
USER
}
enum
ITEM_TYPE
{
\ No newline at end of file
FOOD
=
1
,
HOUSE
=
2
,
CLOTHES
=
3
}
export
{
USER
,
LEVEL
,
ITEMS
,
ITEM_TYPE
}
\ No newline at end of file
assets/cocos_generator/scene/model/item.ts
View file @
2aaf7c55
class
Item
{
class
Item
{
public
id
:
number
;
//id
public
type
:
number
;
//商品类型
public
type
:
number
;
//商品类型
public
name
:
string
;
//商品名称
public
name
:
string
;
//商品名称
public
icon
:
string
;
//商品图片--可用type生成
public
icon
:
string
;
//商品图片--可用type生成
...
@@ -8,12 +9,15 @@ class Item {
...
@@ -8,12 +9,15 @@ class Item {
public
num
:
number
;
//拥有数量
public
num
:
number
;
//拥有数量
public
levelLimite
:
number
;
//等级限制
public
levelLimite
:
number
;
//等级限制
constructor
(
obj
:
any
)
{
constructor
(
obj
:
any
)
{
this
.
id
=
obj
.
id
;
this
.
type
=
obj
.
type
;
this
.
type
=
obj
.
type
;
this
.
name
=
obj
.
name
;
this
.
name
=
obj
.
name
;
this
.
icon
=
obj
.
icon
;
this
.
icon
=
obj
.
icon
;
this
.
growthValue
=
obj
.
growthValue
;
this
.
growthValue
=
obj
.
growthValue
;
this
.
cost
=
obj
.
cost
;
this
.
cost
=
obj
.
cost
;
this
.
discount
=
obj
.
discount
;
this
.
discount
=
obj
.
discount
;
this
.
num
=
obj
.
num
;
this
.
levelLimite
=
obj
.
levelLimite
;
}
}
}
}
...
...
assets/cocos_generator/scene/model/kitchen.ts
0 → 100644
View file @
2aaf7c55
import
Item
from
"
./item
"
class
Kitchen
{
private
_list
:
Array
<
Item
>
constructor
()
{
this
.
_list
=
[];
}
use
(
id
)
{
this
.
_list
=
this
.
_list
.
map
(
li
=>
{
if
(
li
.
id
==
id
)
li
.
num
-=
1
;
return
li
;
})
}
buy
(
id
)
{
this
.
_list
=
this
.
_list
.
map
(
li
=>
{
if
(
li
.
id
==
id
)
li
.
num
+=
1
;
return
li
;
})
}
getListByType
(
type
:
number
)
{
return
this
.
_list
.
filter
(
li
=>
li
.
type
==
type
)
}
parse
(
list
:
any
)
{
if
(
!
list
)
return
;
this
.
_list
=
list
.
map
(
li
=>
{
return
new
Item
(
li
);
})
}
get
list
()
{
return
this
.
_list
;
}
}
let
kitchen
=
new
Kitchen
();
export
default
kitchen
;
assets/cocos_generator/scene/model/kitchen.ts.meta
0 → 100644
View file @
2aaf7c55
{
"ver": "1.0.8",
"uuid": "1ab727dc-af13-4539-a98a-4ec85d8981c9",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}
\ No newline at end of file
assets/cocos_generator/scene/model/user.ts
View file @
2aaf7c55
import
{
LEVEL
}
from
"
../config/config
"
;
class
User
{
class
User
{
public
name
:
string
;
public
name
:
string
;
public
coin
:
number
;
public
coin
:
number
;
public
level
:
number
;
public
level
:
number
;
public
growth
:
number
;
public
growth
:
number
;
//当前成长值
public
growthDaily
:
number
;
public
growthDaily
:
number
;
public
growthDailyMax
:
number
;
public
growthDailyMax
:
number
;
public
eatTime
:
number
;
public
eatTime
:
number
;
public
useFurniture
:
Array
<
number
>
;
public
useFurniture
:
Array
<
number
>
;
public
useClothes
:
Array
<
number
>
;
public
useClothes
:
Array
<
number
>
;
public
mood
:
string
;
public
mood
:
number
;
//0开心 1不开心
constructor
()
{
constructor
()
{
}
}
...
@@ -23,6 +25,30 @@ class User {
...
@@ -23,6 +25,30 @@ class User {
this
.
eatTime
=
data
.
eatTime
;
this
.
eatTime
=
data
.
eatTime
;
this
.
useFurniture
=
data
.
useFurniture
;
this
.
useFurniture
=
data
.
useFurniture
;
this
.
useClothes
=
data
.
useClothes
;
this
.
useClothes
=
data
.
useClothes
;
this
.
mood
=
1
;
}
isDailyMax
()
{
return
this
.
growthDailyMax
>=
this
.
growthDaily
}
addGrowth
(
val
)
{
this
.
growth
+=
val
;
this
.
growthDaily
+=
val
;
user
.
mood
=
0
;
}
useCoin
(
val
)
{
this
.
coin
-=
val
;
}
//当前等级成长值最大值
public
get
growthLevel
():
number
{
let
max
=
1
;
for
(
let
i
=
1
;
i
<
100
;
i
++
)
{
let
val
=
LEVEL
[
`level_
${
i
}
`
].
growth
;
if
(
this
.
growth
<
val
)
{
max
=
val
break
;
}
}
return
max
}
}
}
}
let
user
=
new
User
();
let
user
=
new
User
();
...
...
assets/cocos_generator/scene/net/api.ts
0 → 100644
View file @
2aaf7c55
import
pg
from
"
../pg
"
;
import
{
ITEMS
,
USER
}
from
"
../config/config
"
import
user
from
"
../model/user
"
;
import
kitchen
from
"
../model/kitchen
"
;
//获取信息,购买物品,使用物品(吃东西),穿戴衣服/更换家具
class
Api
{
static
askUser
()
{
return
new
Promise
((
resolve
,
reject
)
=>
{
pg
.
http
.
send
(
"
GET
"
,
"
http://www.baidu.com
"
,
{}).
then
((
data
:
any
)
=>
{
let
userInfo
=
USER
;
user
.
parse
(
userInfo
);
let
kitchenInfo
=
ITEMS
;
kitchen
.
parse
(
kitchenInfo
);
resolve
(
''
);
})
});
}
static
askUseItem
(
data
)
{
return
new
Promise
((
resolve
,
reject
)
=>
{
pg
.
http
.
send
(
"
GET
"
,
"
http://www.baidu.com
"
,
{}).
then
((
data
:
any
)
=>
{
user
.
addGrowth
(
data
.
growthValue
);
kitchen
.
use
(
data
.
id
);
resolve
(
''
);
})
});
}
static
askBuyItem
(
data
)
{
return
new
Promise
((
resolve
,
reject
)
=>
{
data
.
id
;
data
.
type
;
pg
.
http
.
send
(
"
GET
"
,
"
http://www.baidu.com
"
,
{}).
then
((
data
:
any
)
=>
{
user
.
useCoin
(
data
.
cost
*
data
.
discount
);
kitchen
.
buy
(
data
.
id
);
resolve
(
''
);
})
});
}
}
export
default
Api
;
\ No newline at end of file
assets/cocos_generator/scene/net/
http
.ts.meta
→
assets/cocos_generator/scene/net/
api
.ts.meta
View file @
2aaf7c55
File moved
assets/cocos_generator/scene/net/http.ts
deleted
100644 → 0
View file @
9462ca1c
import
pg
from
"
../pg
"
;
import
{
USER
}
from
"
../config/config
"
import
user
from
"
../model/user
"
;
//获取信息,购买物品,使用物品(吃东西),穿戴衣服/更换家具
class
Api
{
static
askUser
()
{
return
new
Promise
((
resolve
,
reject
)
=>
{
pg
.
http
.
send
(
"
GET
"
,
"
http://www.baidu.com
"
,
{}).
then
((
data
:
any
)
=>
{
let
info
=
USER
;
user
.
parse
(
info
);
resolve
(
''
);
})
});
}
}
export
default
Api
;
\ No newline at end of file
assets/cocos_generator/scene/pg.ts
View file @
2aaf7c55
...
@@ -245,6 +245,15 @@ let pg = {
...
@@ -245,6 +245,15 @@ let pg = {
skl
.
setAnimation
(
0
,
aniName
,
loop
);
skl
.
setAnimation
(
0
,
aniName
,
loop
);
return
skl
;
return
skl
;
},
},
playDBAnimation
(
item
:
any
,
aniName
:
string
,
loop
?:
number
)
{
if
(
!
item
||
!
cc
.
isValid
(
item
))
return
pg
.
logger
.
w
(
"
动画播放失败,传入了错误的item
"
);
if
(
!
aniName
)
return
pg
.
logger
.
w
(
"
动画播放失败,传入了错误的aniName
"
);
let
node
=
item
.
node
?
item
.
node
:
item
;
if
(
!
cc
.
isValid
(
node
))
return
pg
.
logger
.
w
(
"
节点已销毁
"
);
let
skl
:
dragonBones
.
ArmatureDisplay
=
node
.
getComponent
(
dragonBones
.
ArmatureDisplay
);
skl
.
playAnimation
(
aniName
,
loop
);
return
skl
;
},
},
},
load
:
{
load
:
{
//资源加载
//资源加载
...
...
assets/cocos_generator/textures/home/bg_progress.png.meta
View file @
2aaf7c55
...
@@ -28,8 +28,8 @@
...
@@ -28,8 +28,8 @@
"rawHeight": 20,
"rawHeight": 20,
"borderTop": 0,
"borderTop": 0,
"borderBottom": 0,
"borderBottom": 0,
"borderLeft":
0
,
"borderLeft":
6.5
,
"borderRight":
0
,
"borderRight":
8.5
,
"subMetas": {}
"subMetas": {}
}
}
}
}
...
...
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