Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Z
zeroing-libs
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
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
劳工
zeroing-libs
Commits
af3ba169
Commit
af3ba169
authored
Mar 27, 2020
by
13732208043
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ddddd
parent
f0684238
Changes
15
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
1747 additions
and
0 deletions
+1747
-0
app.js
src/custom/pick-tea/debug/app.js
+85
-0
index.html
src/custom/pick-tea/debug/index.html
+47
-0
load-assets.js
src/custom/pick-tea/debug/load-assets.js
+109
-0
main.js
src/custom/pick-tea/debug/main.js
+503
-0
main.js.map
src/custom/pick-tea/debug/main.js.map
+1
-0
props.js
src/custom/pick-tea/debug/props.js
+7
-0
meta.json
src/custom/pick-tea/meta.json
+213
-0
GameView.ts
src/custom/pick-tea/src/game/GameView.ts
+513
-0
GameWrapper.ts
src/custom/pick-tea/src/game/GameWrapper.ts
+96
-0
Goods.ts
src/custom/pick-tea/src/game/Goods.ts
+83
-0
Tealeaf.ts
src/custom/pick-tea/src/game/Tealeaf.ts
+27
-0
object-pool-init.ts
src/custom/pick-tea/src/game/object-pool-init.ts
+14
-0
utils.ts
src/custom/pick-tea/src/game/utils.ts
+20
-0
index.ts
src/custom/pick-tea/src/index.ts
+14
-0
props.ts
src/custom/pick-tea/src/props.ts
+15
-0
No files found.
src/custom/pick-tea/debug/app.js
0 → 100644
View file @
af3ba169
/**
* Created by renjianfeng on 2020-03-13.
*/
const
customId
=
'pick-tea'
;
(
async
function
()
{
let
customModule
=
await
fetch
(
`../meta.json`
);
customModule
=
await
customModule
.
json
();
console
.
log
(
customModule
);
await
loadAssets
(
customModule
.
assets
);
launchWithCustomModule
(
customModule
);
})();
function
launchWithCustomModule
(
customModule
)
{
//engine.registerCustomCodeModule(customModule);
engine
.
registerCustomModule
(
customId
,
window
[
customId
]);
const
{
props
:
propsOption
,
assets
}
=
customModule
;
let
props
=
engine
.
computeProps
(
customModuleProps
,
propsOption
);
const
customModuleIns
=
{
id
:
customId
,
props
,
assets
,
};
engine
.
registerCustomModules
([
customModuleIns
]);
engine
.
launchWithConfig
({
options
:
{
entrySceneView
:
'entry'
,
},
assets
:
[],
views
:
[{
name
:
'entry'
,
type
:
'node'
,
properties
:
{
x
:
0
,
y
:
0
,
}
}],
},
null
,
function
()
{
setTimeout
(()
=>
{
engine
.
addCustomModule
(
customId
,
engine
.
gameStage
.
sceneContainer
.
getChildAt
(
0
));
},
100
);
//先抛出初始化消息
setTimeout
(()
=>
{
engine
.
globalEvent
.
dispatchEvent
(
'event-pickTeaGame-init'
);
//获得引用端的篮子类型event-setBasket-Type event-setchange-TeaNum
engine
.
globalEvent
.
dispatchEvent
(
'event-setBasket-Type'
);
engine
.
globalEvent
.
dispatchEvent
(
'event-setchange-TeaNum'
);
},
500
);
});
// +1显示
engine
.
globalEvent
.
addEventListener
(
'event-add-oneScore'
,
(
e
)
=>
{
console
.
log
(
e
.
type
,
e
.
data
);
});
// 收集茶叶
engine
.
globalEvent
.
addEventListener
(
'event-pick-tea'
,
(
e
)
=>
{
console
.
log
(
e
.
type
,
e
.
data
);
});
// 茶叶散开
engine
.
globalEvent
.
addEventListener
(
'event-tea-skyup'
,
(
e
)
=>
{
console
.
log
(
e
.
type
,
e
.
data
);
});
// 茶叶上升
engine
.
globalEvent
.
addEventListener
(
'event-hand-grasp'
,
(
e
)
=>
{
console
.
log
(
e
.
type
,
e
.
data
);
});
// 改变篮子里的茶叶
engine
.
globalEvent
.
addEventListener
(
'event-change-TeaNum'
,
(
e
)
=>
{
console
.
log
(
e
.
type
,
e
.
data
);
});
}
function
getAssetByUUID
(
uuid
)
{
return
engine
.
resolveCustomAsset
(
customId
,
uuid
);
}
function
getProps
()
{
return
engine
.
getProps
(
customId
);
}
src/custom/pick-tea/debug/index.html
0 → 100644
View file @
af3ba169
<!DOCTYPE html>
<html
lang=
"en"
>
<head>
<meta
charset=
"UTF-8"
>
<title>
采茶叶
</title>
<meta
name=
"viewport"
content=
"width=device-width,initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable=no"
/>
<meta
name=
"apple-mobile-web-app-capable"
content=
"yes"
/>
<meta
name=
"full-screen"
content=
"true"
/>
<meta
name=
"screen-orientation"
content=
"portrait"
/>
<meta
name=
"x5-fullscreen"
content=
"true"
/>
<meta
name=
"360-fullscreen"
content=
"true"
/>
<style>
html
,
body
{
padding
:
0
;
margin
:
0
;
border
:
0
;
width
:
100%
;
height
:
100%
;
overflow
:
hidden
;
position
:
absolute
;
background-color
:
transparent
;
}
</style>
</head>
<body>
<div
id=
"game-container"
style=
"line-height:0;font-size:0"
></div>
<script
crossorigin=
"anonymous"
src=
"//yun.duiba.com.cn/editor/zeroing/libs/engine.50cdcef6ebe4e8c0fbc624f9d4fbf225102c5750.js"
></script>
<script
crossorigin=
"anonymous"
src=
"//yun.duiba.com.cn/editor/zeroing/libs/svga.fd3923ae6e664251ca7981801a65809cc5f36bc3.js"
></script>
<!-- <script src="//yun.duiba.com.cn/editor/zeroing/libs/engine.ebc906f6b50b8da0a669f77027981d5f3cb560ce.js"></script> -->
<!-- <script src="http://localhost:4002/debug/engine.js"></script>
<script src="http://localhost:4003/debug/engine-svga.js"></script> -->
<!--<script src="//yun.duiba.com.cn/editor/zeroing/libs/engine.9a9dbfda4cb2dd5508ecddfe3d95dfd88063f7b5.js"></script>-->
<script
src=
"app.js"
></script>
<script
src=
"props.js"
></script>
<script
src=
"load-assets.js"
></script>
<script
src=
"main.js"
></script>
<script>
</script>
</body>
\ No newline at end of file
src/custom/pick-tea/debug/load-assets.js
0 → 100644
View file @
af3ba169
/**
* Created by rockyl on 2020-01-21.
*/
const
assets
=
[
{
"name"
:
"进度条底框"
,
"url"
:
"//yun.duiba.com.cn/aurora/assets/e394fce3576ddeed52fa4dceededc98820318f15.png"
,
"uuid"
:
"7436ffbc-8906-4cdc-9e9a-80a3f7126e30"
,
"ext"
:
".png"
},
{
"name"
:
"进度"
,
"url"
:
"//yun.duiba.com.cn/aurora/assets/047218962662ed238192f211719c109fa107e8e1.png"
,
"uuid"
:
"23e7861c-75a9-46bd-93f8-2825d4810d31"
,
"ext"
:
".png"
},
{
"name"
:
"茶叶进度缺"
,
"url"
:
"//yun.duiba.com.cn/aurora/assets/a99ad1582f44237f9391aeffa53b72c316a8ea83.png"
,
"uuid"
:
"cc4f6b6c-0542-4b8d-b83d-1ee31e9c0e39"
,
"ext"
:
".png"
},
{
"name"
:
"茶叶进度满"
,
"url"
:
"//yun.duiba.com.cn/aurora/assets/7b1ac4e33309adfde360c92c1cdc8299a3e1efd0.png"
,
"uuid"
:
"81728f22-c616-4133-8c78-c041cde68b79"
,
"ext"
:
".png"
},
{
"name"
:
"小茶叶"
,
"url"
:
"//yun.duiba.com.cn/aurora/assets/e938df1513919985c573128e1ed8074c9cc19dd5.png"
,
"uuid"
:
"b30b3093-6097-4cc5-9364-ad1050f86c6e"
,
"ext"
:
".png"
},
{
"name"
:
"茶叶-满"
,
"url"
:
"//yun.duiba.com.cn/aurora/assets/acd219c8c8d472a3469183ba8d32568372e75797.png"
,
"uuid"
:
"41431fe5-523c-4e21-a2bc-9dc4641d27e8"
,
"ext"
:
".png"
},
{
"name"
:
"茶叶-少"
,
"url"
:
"//yun.duiba.com.cn/aurora/assets/38f1874d0688fb8b621dfb1d3028d6f8ac61374d.png"
,
"uuid"
:
"5765bb2b-3e7b-48fe-9e06-3c76a78c92dc"
,
"ext"
:
".png"
},
{
"name"
:
"采茶童-纸篮子"
,
"url"
:
"//yun.duiba.com.cn/aurora/assets/52f24f84d31709faea0fc35193692b134fe2e40d.svga"
,
"uuid"
:
"8a7801dd-b802-4571-9f8e-e9acfb9c4527"
,
"ext"
:
".svga"
},
{
"name"
:
"采茶童-布篮子"
,
"url"
:
"//yun.duiba.com.cn/aurora/assets/7ca607d0fd5471d33a4bb58c0d92122fe4ae425f.svga"
,
"uuid"
:
"ba183e10-4059-4c3e-b9ec-c78192d5e980"
,
"ext"
:
".svga"
},
{
"name"
:
"采茶童-竹编篮"
,
"url"
:
"//yun.duiba.com.cn/aurora/assets/91b8f35ce06b9c65cb504c59ac6c3961f625fb2e.svga"
,
"uuid"
:
"c7414e60-5312-4586-984a-d8b45a614621"
,
"ext"
:
".svga"
},
{
"name"
:
"采茶童-木篮子"
,
"url"
:
"//yun.duiba.com.cn/aurora/assets/de210099641d4d4fb2d323cc9da17f2f4e48a038.svga"
,
"uuid"
:
"c492cbd4-aa42-4425-846f-86a91fd3f198"
,
"ext"
:
".svga"
},
{
"name"
:
"待升级"
,
"url"
:
"//yun.duiba.com.cn/aurora/assets/80834a2a25aca30b79dae655003fb7d6b8dc1b49.svga"
,
"uuid"
:
"eb1f7929-f812-4b88-8345-5d61977fce39"
,
"ext"
:
".svga"
},
{
"name"
:
"+1"
,
"url"
:
"//yun.duiba.com.cn/aurora/assets/72c631a1da7b7969b7995fa16ccc1f435b9b57db.svga"
,
"uuid"
:
"16a57950-0201-4904-8c65-6378fab65f59"
,
"ext"
:
".svga"
},
{
"name"
:
"采茶叶"
,
"url"
:
"//yun.duiba.com.cn/aurora/assets/6b89b11a26d0f91f1dad9e14b2d099e0d8450032.svga"
,
"uuid"
:
" 81428208-0274-4e73-9f5e-27bb4a57f80a"
,
"ext"
:
".svga"
},
{
"name"
:
"茶叶向上飞"
,
"url"
:
"//yun.duiba.com.cn/aurora/assets/676ff9aabe60a49ca92f6ade26e62c6bb76be922.svga"
,
"uuid"
:
"de7273ab-41be-4248-9f05-cdf8a7e3585b"
,
"ext"
:
".svga"
},
{
"name"
:
"手抓去"
,
"url"
:
"//yun.duiba.com.cn/aurora/assets/6b774da91be08d1c9f773d88ace4927c3c5de583.svga"
,
"uuid"
:
"f1e7a7cf-95c7-4c91-a30b-935e31ea0084"
,
"ext"
:
".svga"
}
];
function
loadAssets
(
customModuleAssets
,
onProgress
,
onComplete
)
{
return
engine
.
loadAssets
(
assets
.
concat
(...
customModuleAssets
),
onProgress
,
onComplete
);
}
src/custom/pick-tea/debug/main.js
0 → 100644
View file @
af3ba169
This diff is collapsed.
Click to expand it.
src/custom/pick-tea/debug/main.js.map
0 → 100644
View file @
af3ba169
This diff is collapsed.
Click to expand it.
src/custom/pick-tea/debug/props.js
0 → 100644
View file @
af3ba169
/**
* Created by rockyl on 2020-01-21.
*/
let
customModuleProps
=
{
};
src/custom/pick-tea/meta.json
0 → 100644
View file @
af3ba169
{
"name"
:
"采茶叶"
,
"desc"
:
"采茶叶模块"
,
"props"
:
{
"versePos"
:
{
"alias"
:
"诗句的起始位置"
,
"type"
:
"array<number>"
,
"default"
:
"160,360"
},
"verses"
:
{
"alias"
:
"诗句"
,
"type"
:
"array<string>"
,
"default"
:
"今朝有酒今朝醉,今宵更有湘江月,找出霏霏满碗花,雨过林霏清石气,秋将山翠入诗心,生怕芳丛鹰嘴芽,老郎封寄谪仙家"
},
"verseLabel"
:
{
"alias"
:
"提示语框xys"
,
"type"
:
"array<number>"
,
"default"
:
"396,50,22"
},
"verseColor"
:
{
"alias"
:
"颜色描边"
,
"type"
:
"array<string>"
,
"default"
:
"#33628b,#99b1c5"
},
"pickTeaSpeed"
:
{
"alias"
:
"采集茶叶的速度ms"
,
"type"
:
"number"
,
"default"
:
1000
},
"basketSvgaPos"
:
{
"alias"
:
"人物的位置"
,
"type"
:
"array<number>"
,
"default"
:
"110,420"
},
"addOneSvgaPos"
:
{
"alias"
:
"+1SVGA的位置"
,
"type"
:
"array<number>"
,
"default"
:
"70,720"
},
"pickTeaSvgaPos"
:
{
"alias"
:
"采茶叶SVGA的位置"
,
"type"
:
"array<number>"
,
"default"
:
"377,530"
},
"teaSkyUpSvgaPos"
:
{
"alias"
:
"收集茶叶SVGA的位置"
,
"type"
:
"array<number>"
,
"default"
:
"320,192"
},
"handGraspSvgaPos"
:
{
"alias"
:
"手点击SVGA的位置"
,
"type"
:
"array<number>"
,
"default"
:
"543,791"
},
"handGraspMovePos"
:
{
"alias"
:
"手点击移动的位置"
,
"type"
:
"array<number>"
,
"default"
:
"460,700"
},
"progressbarBgImgPos"
:
{
"alias"
:
"进度条底图的位置"
,
"type"
:
"array<number>"
,
"default"
:
"69,818"
},
"progressbarImgPos"
:
{
"alias"
:
"进度条的位置"
,
"type"
:
"array<number>"
,
"default"
:
"-443,4"
},
"teaStarImgPos"
:
{
"alias"
:
"小茶叶的位置"
,
"type"
:
"array<number>"
,
"default"
:
"9,7"
},
"teaHalfFlagImgPos"
:
{
"alias"
:
"满缺的位置"
,
"type"
:
"array<number>"
,
"default"
:
"-15,-15"
},
"pickTeaCountPos"
:
{
"alias"
:
"文本进度的位置"
,
"type"
:
"array<number>"
,
"default"
:
"180,10"
}
},
"assets"
:
[
{
"name"
:
"气泡框"
,
"url"
:
"//yun.duiba.com.cn/aurora/assets/585743f25262b6992ac97015e22d91054d506821.png"
,
"uuid"
:
"1e6c4615-e1f4-43fe-b5de-9bfdaa27888c"
,
"ext"
:
".png"
},
{
"name"
:
"进度条底框"
,
"url"
:
"//yun.duiba.com.cn/aurora/assets/e394fce3576ddeed52fa4dceededc98820318f15.png"
,
"uuid"
:
"7436ffbc-8906-4cdc-9e9a-80a3f7126e30"
,
"ext"
:
".png"
},
{
"name"
:
"进度"
,
"url"
:
"//yun.duiba.com.cn/aurora/assets/047218962662ed238192f211719c109fa107e8e1.png"
,
"uuid"
:
"23e7861c-75a9-46bd-93f8-2825d4810d31"
,
"ext"
:
".png"
},
{
"name"
:
"茶叶进度缺"
,
"url"
:
"//yun.duiba.com.cn/aurora/assets/a99ad1582f44237f9391aeffa53b72c316a8ea83.png"
,
"uuid"
:
"cc4f6b6c-0542-4b8d-b83d-1ee31e9c0e39"
,
"ext"
:
".png"
},
{
"name"
:
"茶叶进度满"
,
"url"
:
"//yun.duiba.com.cn/aurora/assets/7b1ac4e33309adfde360c92c1cdc8299a3e1efd0.png"
,
"uuid"
:
"81728f22-c616-4133-8c78-c041cde68b79"
,
"ext"
:
".png"
},
{
"name"
:
"小茶叶"
,
"url"
:
"//yun.duiba.com.cn/aurora/assets/e938df1513919985c573128e1ed8074c9cc19dd5.png"
,
"uuid"
:
"b30b3093-6097-4cc5-9364-ad1050f86c6e"
,
"ext"
:
".png"
},
{
"name"
:
"茶叶-满"
,
"url"
:
"//yun.duiba.com.cn/aurora/assets/acd219c8c8d472a3469183ba8d32568372e75797.png"
,
"uuid"
:
"41431fe5-523c-4e21-a2bc-9dc4641d27e8"
,
"ext"
:
".png"
},
{
"name"
:
"茶叶-少"
,
"url"
:
"//yun.duiba.com.cn/aurora/assets/38f1874d0688fb8b621dfb1d3028d6f8ac61374d.png"
,
"uuid"
:
"5765bb2b-3e7b-48fe-9e06-3c76a78c92dc"
,
"ext"
:
".png"
},
{
"name"
:
"采茶童-纸篮子"
,
"url"
:
"//yun.duiba.com.cn/aurora/assets/52f24f84d31709faea0fc35193692b134fe2e40d.svga"
,
"uuid"
:
"8a7801dd-b802-4571-9f8e-e9acfb9c4527"
,
"ext"
:
".svga"
},
{
"name"
:
"采茶童-布篮子"
,
"url"
:
"//yun.duiba.com.cn/aurora/assets/7ca607d0fd5471d33a4bb58c0d92122fe4ae425f.svga"
,
"uuid"
:
"ba183e10-4059-4c3e-b9ec-c78192d5e980"
,
"ext"
:
".svga"
},
{
"name"
:
"采茶童-竹编篮"
,
"url"
:
"//yun.duiba.com.cn/aurora/assets/91b8f35ce06b9c65cb504c59ac6c3961f625fb2e.svga"
,
"uuid"
:
"c7414e60-5312-4586-984a-d8b45a614621"
,
"ext"
:
".svga"
},
{
"name"
:
"采茶童-木篮子"
,
"url"
:
"//yun.duiba.com.cn/aurora/assets/de210099641d4d4fb2d323cc9da17f2f4e48a038.svga"
,
"uuid"
:
"c492cbd4-aa42-4425-846f-86a91fd3f198"
,
"ext"
:
".svga"
},
{
"name"
:
"待升级"
,
"url"
:
"//yun.duiba.com.cn/aurora/assets/80834a2a25aca30b79dae655003fb7d6b8dc1b49.svga"
,
"uuid"
:
"eb1f7929-f812-4b88-8345-5d61977fce39"
,
"ext"
:
".svga"
},
{
"name"
:
"+1"
,
"url"
:
"//yun.duiba.com.cn/aurora/assets/72c631a1da7b7969b7995fa16ccc1f435b9b57db.svga"
,
"uuid"
:
"16a57950-0201-4904-8c65-6378fab65f59"
,
"ext"
:
".svga"
},
{
"name"
:
"采茶叶"
,
"url"
:
"//yun.duiba.com.cn/aurora/assets/6b89b11a26d0f91f1dad9e14b2d099e0d8450032.svga"
,
"uuid"
:
" 81428208-0274-4e73-9f5e-27bb4a57f80a"
,
"ext"
:
".svga"
},
{
"name"
:
"茶叶向上飞"
,
"url"
:
"//yun.duiba.com.cn/aurora/assets/676ff9aabe60a49ca92f6ade26e62c6bb76be922.svga"
,
"uuid"
:
"de7273ab-41be-4248-9f05-cdf8a7e3585b"
,
"ext"
:
".svga"
},
{
"name"
:
"手抓去"
,
"url"
:
"//yun.duiba.com.cn/aurora/assets/6b774da91be08d1c9f773d88ace4927c3c5de583.svga"
,
"uuid"
:
"f1e7a7cf-95c7-4c91-a30b-935e31ea0084"
,
"ext"
:
".svga"
}
],
"events"
:
{
"in"
:
{
"event-getchange-TeaNum"
:
{
"alias"
:
"茶叶数量{初始值totalNum,总量nowNum} "
},
"event-getBasket-Type"
:
{
"alias"
:
"获得篮子类型"
},
"event-hand-grasp"
:
{
"alias"
:
"手抓去"
}
},
"out"
:
{
"event-setchange-TeaNum"
:
{
"alias"
:
""
,
"data"
:
{}
},
"event-setBasket-Typ"
:
{
"alias"
:
""
,
"data"
:
{}
}
}
}
}
\ No newline at end of file
src/custom/pick-tea/src/game/GameView.ts
0 → 100644
View file @
af3ba169
This diff is collapsed.
Click to expand it.
src/custom/pick-tea/src/game/GameWrapper.ts
0 → 100644
View file @
af3ba169
/**
* Created by rockyl on 2020-01-09.
*/
import
GameView
from
"./GameView"
;
import
{
injectProps
}
from
"../props"
;
export
class
GameWrapper
extends
engine
.
Container
{
private
_status
;
private
_gameView
:
GameView
;
constructor
()
{
super
();
/*
event-pickTeaGame-init //游戏初始化
//event-wait-uplevel //待升级
event-add-oneScore //+1
event-pick-tea //采茶叶
event-tea-skyup //茶叶向上飞
event-hand-grasp //手抓去
event-change-TeaNum //茶叶数量 改变svga动画
event-getBasket-Type //获得篮子类型
event-setBasket-Type //设置篮子类型
*/
// event-getchange-TeaNum //茶叶数量{初始值totalNum,总量nowNum} 改变svga动画
// event-getBasket-Type //获得篮子类型
// event-hand-grasp //手抓去
//event-pickTeaGame-init 游戏初始化
engine
.
globalEvent
.
addEventListener
(
'event-pickTeaGame-init'
,
this
.
reset
,
this
);
engine
.
globalEvent
.
addEventListener
(
'event-hand-grasp'
,
this
.
handGrasp
,
this
);
engine
.
globalEvent
.
addEventListener
(
'event-getchange-TeaNum'
,
this
.
setTeaNum
,
this
);
engine
.
globalEvent
.
addEventListener
(
'event-getBasket-Type'
,
this
.
setPickTeaLevel
,
this
);
let
gameView
=
this
.
_gameView
=
new
GameView
();
this
.
addChild
(
gameView
);
}
//设置茶叶数量
setTeaNum
(
event
:
engine
.
Event
)
{
injectProps
(
event
.
data
);
this
.
_gameView
.
setTeaNum
(
event
.
data
);
}
//设置茶蓝等级
setPickTeaLevel
(
event
:
engine
.
Event
)
{
injectProps
(
event
.
data
);
this
.
_gameView
.
setPickTeaLevel
(
event
.
data
);
}
reset
(
event
:
engine
.
Event
)
{
injectProps
(
event
.
data
);
this
.
_gameView
.
visible
=
true
;
this
.
_gameView
.
reset
();
}
start
(
event
:
engine
.
Event
)
{
injectProps
(
event
.
data
);
this
.
_status
=
1
;
this
.
_gameView
.
start
();
}
pause
()
{
this
.
_gameView
.
pause
();
}
resume
()
{
this
.
_gameView
.
resume
();
}
revive
()
{
this
.
_gameView
.
revive
();
}
clear
()
{
this
.
_gameView
.
visible
=
false
;
}
handGrasp
()
{
this
.
_gameView
.
handGrasp
();
}
private
onTap
(
event
)
{
// this._gameView.tap(event);
}
}
src/custom/pick-tea/src/game/Goods.ts
0 → 100644
View file @
af3ba169
/**
* Created by rockyl on 2020-02-02.
*
* 掉落物品
*/
import
{
getTextureByName
}
from
"./utils"
;
import
{
props
}
from
"../props"
;
export
class
Goods
extends
engine
.
Container
{
private
_body
:
engine
.
Rect
private
_toY
;
constructor
()
{
super
();
let
body
body
=
this
.
_body
=
new
engine
.
Rect
()
let
rain
=
new
engine
.
Sprite
(
getTextureByName
(
'雨滴'
));
rain
[
"npcType"
]
=
"rain"
let
stone
=
new
engine
.
Sprite
(
getTextureByName
(
'石块'
));
stone
[
"npcType"
]
=
"stone"
let
boom
=
new
engine
.
Sprite
(
getTextureByName
(
'炸弹'
));
boom
[
"npcType"
]
=
"boom"
rain
.
visible
=
false
;
stone
.
visible
=
false
;
boom
.
visible
=
false
;
body
.
addChild
(
rain
)
body
.
addChild
(
stone
)
body
.
addChild
(
boom
)
this
.
addChild
(
body
);
body
.
width
=
.
0001
;
body
.
height
=
.
0001
;
body
.
mouseEnabled
=
false
;
}
getRandomNumberByRange
(
start
,
end
)
{
return
Math
.
floor
(
Math
.
random
()
*
(
end
-
start
)
+
start
)
}
reset
()
{
this
.
visible
=
true
;
this
.
rotation
=
0
;
this
.
anchorOffsetY
=
0
;
this
.
y
=
0
;
this
.
x
=
(
750
-
120
)
*
Math
.
random
()
+
30
;
this
.
rotation
=
0
;
let
random
=
Math
.
random
()
if
(
random
<
props
.
goodsProbability
[
0
]){
this
.
showNpc
(
"rain"
)
}
else
if
(
random
>=
props
.
goodsProbability
[
0
]
&&
random
<=
(
props
.
goodsProbability
[
0
]
+
props
.
goodsProbability
[
1
])){
this
.
showNpc
(
"stone"
)
}
else
if
(
random
>
(
props
.
goodsProbability
[
0
]
+
props
.
goodsProbability
[
1
])){
this
.
showNpc
(
"boom"
)
}
}
showNpc
(
type
){
for
(
let
i
=
0
;
i
<
this
.
_body
.
children
.
length
;
i
++
){
this
.
_body
.
children
[
i
].
visible
=
false
;
this
.
_body
.
children
[
i
].
mouseEnabled
=
false
;
}
for
(
let
i
=
0
;
i
<
this
.
_body
.
children
.
length
;
i
++
){
if
(
this
.
_body
.
children
[
i
][
"npcType"
]
==
type
){
this
[
"npcType"
]
=
type
this
.
_body
.
children
[
i
].
visible
=
true
;
this
.
_body
.
children
[
i
].
mouseEnabled
=
false
;
}
}
}
set
anchorOffsetY
(
v
)
{
this
.
_body
.
y
=
v
;
}
}
src/custom/pick-tea/src/game/Tealeaf.ts
0 → 100644
View file @
af3ba169
import
{
getTextureByName
}
from
"./utils"
;
export
class
Tealeaf
extends
engine
.
Container
{
private
_teaFull
:
engine
.
Image
;
private
_teaHalfFull
:
engine
.
Image
;
private
_teaImages
:
any
constructor
()
{
super
();
this
.
_teaFull
=
new
engine
.
Image
(
getTextureByName
(
'茶叶-满'
));
this
.
_teaHalfFull
=
new
engine
.
Image
(
getTextureByName
(
'茶叶-少'
));
this
.
_teaImages
=
[
this
.
_teaFull
,
this
.
_teaHalfFull
]
this
.
addChild
(
this
.
_teaFull
);
this
.
addChild
(
this
.
_teaHalfFull
);
}
reset
()
{
this
.
visible
=
true
;
}
getSpriteUrl
(
index
)
{
let
url
=
this
.
_teaImages
[
index
].
url
;
return
url
;
}
}
src/custom/pick-tea/src/game/object-pool-init.ts
0 → 100644
View file @
af3ba169
/**
* Created by rockyl on 2020-02-03.
*/
import
{
Goods
}
from
"./Goods"
;
import
ObjectPool
=
engine
.
ObjectPool
;
export
const
PoolName
:
string
=
'goods'
;
ObjectPool
.
registerPool
(
PoolName
,
function
()
{
return
new
Goods
();
},
function
(
item
:
Goods
,
data
)
{
item
.
reset
();
});
src/custom/pick-tea/src/game/utils.ts
0 → 100644
View file @
af3ba169
/**
* Created by rockyl on 2020-01-21.
*/
export
function
getTexture
(
uuid
)
{
return
engine
.
Texture
.
from
(
getAssetByUUID
(
uuid
).
uuid
);
}
export
function
getTextureByName
(
name
)
{
return
getTexture
(
engine
.
getAssetByName
(
name
).
uuid
);
}
export
function
playSound
(
name
)
{
engine
.
playSound
(
engine
.
getAssetByName
(
name
).
uuid
,
{
keep
:
true
});
}
export
function
createSvga
(
name
,
anchorName
?)
{
let
inst
=
new
svga
.
Svga
();
inst
.
source
=
'asset://'
+
engine
.
getAssetByName
(
name
).
uuid
;
return
inst
;
}
\ No newline at end of file
src/custom/pick-tea/src/index.ts
0 → 100644
View file @
af3ba169
/**
* Created by rockyl on 2019-11-20.
*/
import
{
GameWrapper
}
from
"./game/GameWrapper"
;
import
{
injectProps
,
prepareProps
}
from
"./props"
;
export
default
function
(
props
)
{
prepareProps
();
injectProps
(
props
);
let
instance
=
new
GameWrapper
();
return
instance
;
}
src/custom/pick-tea/src/props.ts
0 → 100644
View file @
af3ba169
/**
* Created by rockyl on 2020-01-21.
*/
export
let
props
:
any
=
{};
export
function
prepareProps
()
{
let
metaProps
=
getProps
();
engine
.
injectProp
(
props
,
metaProps
);
}
export
function
injectProps
(
p
)
{
engine
.
injectProp
(
props
,
p
);
}
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