├── .gitignore
├── README.md
├── assets
├── BehaviorTree.js
├── BehaviorTree.js.meta
├── Scene.meta
├── Scene
│ ├── GameScene.fire
│ └── GameScene.fire.meta
├── Script.meta
├── Script
│ ├── ArmsCtl.ts
│ ├── ArmsCtl.ts.meta
│ ├── Attack.ts
│ ├── Attack.ts.meta
│ ├── Defense.ts
│ ├── Defense.ts.meta
│ ├── GameInterface.ts
│ ├── GameInterface.ts.meta
│ ├── GameScene.ts
│ ├── GameScene.ts.meta
│ ├── HeroSpriteClt.ts
│ ├── HeroSpriteClt.ts.meta
│ ├── Look.ts
│ ├── Look.ts.meta
│ ├── MonsterCtl.ts
│ ├── MonsterCtl.ts.meta
│ ├── Patrol.ts
│ ├── Patrol.ts.meta
│ ├── PlayerCtl.ts
│ ├── PlayerCtl.ts.meta
│ ├── ShieldCtl.ts
│ └── ShieldCtl.ts.meta
├── Texture.meta
├── Texture
│ ├── singleColor.png
│ └── singleColor.png.meta
├── b3core.0.1.0module.js
├── b3core.0.1.0module.js.meta
├── resources.meta
└── resources
│ ├── npc3-0001.png
│ ├── npc3-0001.png.meta
│ ├── player_stand1.png
│ └── player_stand1.png.meta
├── creator.d.ts
├── jsconfig.json
├── packages
└── behaviortree-editor
│ ├── b3core.0.1.0module.js
│ ├── bt-inspector.js
│ ├── main.js
│ ├── package.json
│ └── panel
│ ├── icon
│ ├── base.svg
│ ├── customaction.svg
│ ├── customcomposite.svg
│ ├── customcondition.svg
│ ├── customdecorator.svg
│ ├── error.svg
│ ├── failer.svg
│ ├── inverter.svg
│ ├── limit.svg
│ ├── maxtime.svg
│ ├── menpriority.svg
│ ├── mensequence.svg
│ ├── priority.svg
│ ├── repeat.svg
│ ├── repeatuntilfailure.svg
│ ├── repeatuntilsuccess.svg
│ ├── root.svg
│ ├── running.svg
│ ├── sequence.svg
│ ├── succeeder.svg
│ └── wait.svg
│ ├── img
│ └── jsoneditor-icons.svg
│ ├── index.html
│ ├── jsoneditor.css
│ ├── jsoneditor.js
│ └── node_modules
│ └── gojs
│ ├── README.md
│ ├── bower.json
│ ├── package.json
│ └── release
│ └── go.js
├── project.json
├── settings
├── builder.json
├── builder.panel.json
└── project.json
├── template-banner.png
├── template.json
└── tsconfig.json
/.gitignore:
--------------------------------------------------------------------------------
1 | #/////////////////////////////////////////////////////////////////////////////
2 | # Fireball Projects
3 | #/////////////////////////////////////////////////////////////////////////////
4 |
5 | library/
6 | temp/
7 | local/
8 | build/
9 |
10 | #/////////////////////////////////////////////////////////////////////////////
11 | # Logs and databases
12 | #/////////////////////////////////////////////////////////////////////////////
13 |
14 | *.log
15 | *.sql
16 | *.sqlite
17 |
18 | #/////////////////////////////////////////////////////////////////////////////
19 | # files for debugger
20 | #/////////////////////////////////////////////////////////////////////////////
21 |
22 | *.sln
23 | *.csproj
24 | *.pidb
25 | *.unityproj
26 | *.suo
27 |
28 | #/////////////////////////////////////////////////////////////////////////////
29 | # OS generated files
30 | #/////////////////////////////////////////////////////////////////////////////
31 |
32 | .DS_Store
33 | ehthumbs.db
34 | Thumbs.db
35 |
36 | #/////////////////////////////////////////////////////////////////////////////
37 | # exvim files
38 | #/////////////////////////////////////////////////////////////////////////////
39 |
40 | *UnityVS.meta
41 | *.err
42 | *.err.meta
43 | *.exvim
44 | *.exvim.meta
45 | *.vimentry
46 | *.vimentry.meta
47 | *.vimproject
48 | *.vimproject.meta
49 | .vimfiles.*/
50 | .exvim.*/
51 | quick_gen_project_*_autogen.bat
52 | quick_gen_project_*_autogen.bat.meta
53 | quick_gen_project_*_autogen.sh
54 | quick_gen_project_*_autogen.sh.meta
55 | .exvim.app
56 |
57 | #/////////////////////////////////////////////////////////////////////////////
58 | # webstorm files
59 | #/////////////////////////////////////////////////////////////////////////////
60 |
61 | .idea/
62 |
63 | #//////////////////////////
64 | # VS Code
65 | #//////////////////////////
66 |
67 | .vscode/
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # cocos creator 行为树
2 | 该仓库配合我的cocos creator中使用行为树教程
3 | 附链接 https://blog.csdn.net/kirikayakazu/article/details/88920730
4 |
5 | 联系方式QQ: 1099263878
--------------------------------------------------------------------------------
/assets/BehaviorTree.js:
--------------------------------------------------------------------------------
1 | //Don't modify this if you want to re-modify the behaviortree in the future
2 | //#########################################{"class":"go.TreeModel","nodeDataArray":[{"catagory":"Composite","color":"lightgreen","key":-1,"loc":"99.49999999999997 230.99999999999966","name":"Root","parameter":"{}","src":"icon/root.svg","textEditable":false,"type":"Root"},{"catagory":"Action","color":"lightcoral","key":-2,"loc":"684.4999999999986 270.64999999999964","name":"Attack","parameter":"{\"size\":30}","parent":-10,"src":"icon/customaction.svg","textEditable":true,"type":"Action"},{"catagory":"Condition","color":"palegoldenrod","key":-3,"loc":"433.50000000000057 191.64999999999998","name":"Look","parameter":"{\"radio\":300}","parent":-6,"src":"icon/customcondition.svg","textEditable":true,"type":"Condition"},{"catagory":"Action","color":"lightcoral","key":-4,"loc":"295.4999999999998 288.64999999999986","name":"Patrol","parameter":"{\"areaSize\":200}","parent":-7,"src":"icon/customaction.svg","textEditable":true,"type":"Action"},{"catagory":"Composite","color":"lightblue","key":-6,"loc":"292.4999999999998 215.3499999999998","name":"Sequence","parameter":"{}","parent":-7,"src":"icon/sequence.svg","textEditable":true,"type":"Sequence"},{"catagory":"Composite","color":"lightblue","key":-7,"loc":"194.4999999999999 229.34999999999997","name":"Priority","parameter":"{}","parent":-1,"src":"icon/priority.svg","textEditable":true,"type":"Priority"},{"catagory":"Composite","color":"lightblue","key":-8,"loc":"433.49999999999943 257.70000000000005","name":"Priority","parameter":"{}","parent":-6,"src":"icon/priority.svg","textEditable":true,"type":"Priority"},{"catagory":"Action","color":"lightcoral","key":-9,"loc":"559.4999999999997 316.6999999999997","name":"Defense","parameter":"{}","parent":-8,"src":"icon/customaction.svg","textEditable":true,"type":"Action"},{"catagory":"Composite","color":"lightblue","key":-10,"loc":"558.0000000000001 244.9999999999999","name":"Sequence","parameter":"{}","parent":-8,"src":"icon/sequence.svg","textEditable":true,"type":"Sequence"},{"catagory":"Condition","color":"palegoldenrod","key":-11,"loc":"680.5000000000003 195.64999999999986","name":"Look","parameter":"{\"radio\":150}","parent":-10,"src":"icon/customcondition.svg","textEditable":true,"type":"Condition"}]}#############################################
3 |
4 |
5 | cc.Class({
6 | extends: cc.Component,
7 | editor: {
8 | inspector: 'packages://behaviortree-editor/bt-inspector.js'
9 | },
10 | properties: {
11 | },
12 | onLoad: function () {
13 | let b3 = require('b3core.0.1.0module');
14 | let self = this;
15 | let Attack = b3.Class(b3.Action);
16 | Attack.prototype.name = 'Attack';
17 | Attack.prototype.__Action_initialize = Attack.prototype.initialize;
18 | Attack.prototype.initialize = function(settings){
19 | settings = settings || {};
20 | this.__Action_initialize();
21 | this.parameter = settings.parameter;
22 | }
23 | Attack.prototype.enter = function(tick){
24 | return self.getComponent('Attack').enter(tick,b3,this);
25 | }
26 | Attack.prototype.open = function(tick) {
27 | return self.getComponent('Attack').open(tick,b3,this);
28 | }
29 | Attack.prototype.tick = function(tick) {
30 | return self.getComponent('Attack').tick(tick,b3,this);
31 | }
32 | Attack.prototype.close = function(tick) {
33 | return self.getComponent('Attack').close(tick,b3,this);
34 | }
35 | Attack.prototype.exit = function(tick) {
36 | return self.getComponent('Attack').exit(tick,b3,this);
37 | }
38 | let Look = b3.Class(b3.Condition);
39 | Look.prototype.name = 'Look';
40 | Look.prototype.__Condition_initialize = Look.prototype.initialize;
41 | Look.prototype.initialize = function(settings){
42 | settings = settings || {};
43 | this.__Condition_initialize();
44 | this.parameter = settings.parameter;
45 | }
46 | Look.prototype.enter = function(tick){
47 | return self.getComponent('Look').enter(tick,b3,this);
48 | }
49 | Look.prototype.open = function(tick) {
50 | return self.getComponent('Look').open(tick,b3,this);
51 | }
52 | Look.prototype.tick = function(tick) {
53 | return self.getComponent('Look').tick(tick,b3,this);
54 | }
55 | Look.prototype.close = function(tick) {
56 | return self.getComponent('Look').close(tick,b3,this);
57 | }
58 | Look.prototype.exit = function(tick) {
59 | return self.getComponent('Look').exit(tick,b3,this);
60 | }
61 | let Patrol = b3.Class(b3.Action);
62 | Patrol.prototype.name = 'Patrol';
63 | Patrol.prototype.__Action_initialize = Patrol.prototype.initialize;
64 | Patrol.prototype.initialize = function(settings){
65 | settings = settings || {};
66 | this.__Action_initialize();
67 | this.parameter = settings.parameter;
68 | }
69 | Patrol.prototype.enter = function(tick){
70 | return self.getComponent('Patrol').enter(tick,b3,this);
71 | }
72 | Patrol.prototype.open = function(tick) {
73 | return self.getComponent('Patrol').open(tick,b3,this);
74 | }
75 | Patrol.prototype.tick = function(tick) {
76 | return self.getComponent('Patrol').tick(tick,b3,this);
77 | }
78 | Patrol.prototype.close = function(tick) {
79 | return self.getComponent('Patrol').close(tick,b3,this);
80 | }
81 | Patrol.prototype.exit = function(tick) {
82 | return self.getComponent('Patrol').exit(tick,b3,this);
83 | }
84 | let Defense = b3.Class(b3.Action);
85 | Defense.prototype.name = 'Defense';
86 | Defense.prototype.__Action_initialize = Defense.prototype.initialize;
87 | Defense.prototype.initialize = function(settings){
88 | settings = settings || {};
89 | this.__Action_initialize();
90 | this.parameter = settings.parameter;
91 | }
92 | Defense.prototype.enter = function(tick){
93 | return self.getComponent('Defense').enter(tick,b3,this);
94 | }
95 | Defense.prototype.open = function(tick) {
96 | return self.getComponent('Defense').open(tick,b3,this);
97 | }
98 | Defense.prototype.tick = function(tick) {
99 | return self.getComponent('Defense').tick(tick,b3,this);
100 | }
101 | Defense.prototype.close = function(tick) {
102 | return self.getComponent('Defense').close(tick,b3,this);
103 | }
104 | Defense.prototype.exit = function(tick) {
105 | return self.getComponent('Defense').exit(tick,b3,this);
106 | }
107 | let tree = new b3.BehaviorTree();
108 | tree.root = new b3.Sequence({parameter:{},children:[new b3.Priority({parameter:{},children:[new b3.Sequence({parameter:{},children:[new Look({parameter:{'radio':300}}),new b3.Priority({parameter:{},children:[new b3.Sequence({parameter:{},children:[new Look({parameter:{'radio':150}}),new Attack({parameter:{'size':30}})]}),new Defense({parameter:{}})]})]}),new Patrol({parameter:{'areaSize':200}})]})]});
109 | this.tree = tree;
110 | this.blackboard = new b3.Blackboard();
111 | this.b3 = b3;
112 | },
113 | tick: function(target){
114 | let t = {};
115 | if(target != undefined){t = target;}
116 | this.tree.tick(t,this.blackboard)
117 | }});
118 |
--------------------------------------------------------------------------------
/assets/BehaviorTree.js.meta:
--------------------------------------------------------------------------------
1 | {
2 | "ver": "1.0.5",
3 | "uuid": "ed4613a0-bcd8-4f91-8717-49e758cf69a2",
4 | "isPlugin": false,
5 | "loadPluginInWeb": true,
6 | "loadPluginInNative": true,
7 | "loadPluginInEditor": false,
8 | "subMetas": {}
9 | }
--------------------------------------------------------------------------------
/assets/Scene.meta:
--------------------------------------------------------------------------------
1 | {
2 | "ver": "1.0.1",
3 | "uuid": "29f52784-2fca-467b-92e7-8fd9ef8c57b7",
4 | "isGroup": false,
5 | "subMetas": {}
6 | }
--------------------------------------------------------------------------------
/assets/Scene/GameScene.fire:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "__type__": "cc.SceneAsset",
4 | "_name": "",
5 | "_objFlags": 0,
6 | "_native": "",
7 | "scene": {
8 | "__id__": 1
9 | }
10 | },
11 | {
12 | "__type__": "cc.Scene",
13 | "_objFlags": 0,
14 | "_parent": null,
15 | "_children": [
16 | {
17 | "__id__": 2
18 | }
19 | ],
20 | "_tag": -1,
21 | "_active": true,
22 | "_components": [],
23 | "_prefab": null,
24 | "_id": "2d2f792f-a40c-49bb-a189-ed176a246e49",
25 | "_opacity": 255,
26 | "_color": {
27 | "__type__": "cc.Color",
28 | "r": 255,
29 | "g": 255,
30 | "b": 255,
31 | "a": 255
32 | },
33 | "_cascadeOpacityEnabled": true,
34 | "_anchorPoint": {
35 | "__type__": "cc.Vec2",
36 | "x": 0,
37 | "y": 0
38 | },
39 | "_contentSize": {
40 | "__type__": "cc.Size",
41 | "width": 0,
42 | "height": 0
43 | },
44 | "_localZOrder": 0,
45 | "_globalZOrder": 0,
46 | "_opacityModifyRGB": false,
47 | "groupIndex": 0,
48 | "autoReleaseAssets": false
49 | },
50 | {
51 | "__type__": "cc.Node",
52 | "_name": "Canvas",
53 | "_objFlags": 0,
54 | "_parent": {
55 | "__id__": 1
56 | },
57 | "_children": [
58 | {
59 | "__id__": 3
60 | },
61 | {
62 | "__id__": 6
63 | },
64 | {
65 | "__id__": 20
66 | }
67 | ],
68 | "_tag": -1,
69 | "_active": true,
70 | "_components": [
71 | {
72 | "__id__": 36
73 | },
74 | {
75 | "__id__": 37
76 | }
77 | ],
78 | "_prefab": null,
79 | "_id": "a286bbGknJLZpRpxROV6M94",
80 | "_opacity": 255,
81 | "_color": {
82 | "__type__": "cc.Color",
83 | "r": 252,
84 | "g": 252,
85 | "b": 252,
86 | "a": 255
87 | },
88 | "_cascadeOpacityEnabled": true,
89 | "_anchorPoint": {
90 | "__type__": "cc.Vec2",
91 | "x": 0.5,
92 | "y": 0.5
93 | },
94 | "_contentSize": {
95 | "__type__": "cc.Size",
96 | "width": 1280,
97 | "height": 640
98 | },
99 | "_rotationX": 0,
100 | "_rotationY": 0,
101 | "_scaleX": 1,
102 | "_scaleY": 1,
103 | "_position": {
104 | "__type__": "cc.Vec2",
105 | "x": 640,
106 | "y": 320
107 | },
108 | "_skewX": 0,
109 | "_skewY": 0,
110 | "_localZOrder": 0,
111 | "_globalZOrder": 0,
112 | "_opacityModifyRGB": false,
113 | "groupIndex": 0
114 | },
115 | {
116 | "__type__": "cc.Node",
117 | "_name": "background",
118 | "_objFlags": 0,
119 | "_parent": {
120 | "__id__": 2
121 | },
122 | "_children": [],
123 | "_tag": -1,
124 | "_active": true,
125 | "_components": [
126 | {
127 | "__id__": 4
128 | },
129 | {
130 | "__id__": 5
131 | }
132 | ],
133 | "_prefab": null,
134 | "_id": "e2e0crkOLxGrpMxpbC4iQg1",
135 | "_opacity": 255,
136 | "_color": {
137 | "__type__": "cc.Color",
138 | "r": 27,
139 | "g": 38,
140 | "b": 46,
141 | "a": 255
142 | },
143 | "_cascadeOpacityEnabled": true,
144 | "_anchorPoint": {
145 | "__type__": "cc.Vec2",
146 | "x": 0.5,
147 | "y": 0.5
148 | },
149 | "_contentSize": {
150 | "__type__": "cc.Size",
151 | "width": 1280,
152 | "height": 640
153 | },
154 | "_rotationX": 0,
155 | "_rotationY": 0,
156 | "_scaleX": 1,
157 | "_scaleY": 1,
158 | "_position": {
159 | "__type__": "cc.Vec2",
160 | "x": 0,
161 | "y": 0
162 | },
163 | "_skewX": 0,
164 | "_skewY": 0,
165 | "_localZOrder": 0,
166 | "_globalZOrder": 0,
167 | "_opacityModifyRGB": false,
168 | "groupIndex": 0
169 | },
170 | {
171 | "__type__": "cc.Widget",
172 | "_name": "",
173 | "_objFlags": 0,
174 | "node": {
175 | "__id__": 3
176 | },
177 | "_enabled": true,
178 | "alignMode": 0,
179 | "_target": null,
180 | "_alignFlags": 45,
181 | "_left": 0,
182 | "_right": 0,
183 | "_top": 0,
184 | "_bottom": 0,
185 | "_verticalCenter": 0,
186 | "_horizontalCenter": 0,
187 | "_isAbsLeft": true,
188 | "_isAbsRight": true,
189 | "_isAbsTop": true,
190 | "_isAbsBottom": true,
191 | "_isAbsHorizontalCenter": true,
192 | "_isAbsVerticalCenter": true,
193 | "_originalWidth": 200,
194 | "_originalHeight": 150
195 | },
196 | {
197 | "__type__": "cc.Sprite",
198 | "_name": "",
199 | "_objFlags": 0,
200 | "node": {
201 | "__id__": 3
202 | },
203 | "_enabled": true,
204 | "_spriteFrame": {
205 | "__uuid__": "410fb916-8721-4663-bab8-34397391ace7"
206 | },
207 | "_type": 1,
208 | "_sizeMode": 0,
209 | "_fillType": 0,
210 | "_fillCenter": {
211 | "__type__": "cc.Vec2",
212 | "x": 0,
213 | "y": 0
214 | },
215 | "_fillStart": 0,
216 | "_fillRange": 0,
217 | "_isTrimmedMode": true,
218 | "_srcBlendFactor": 770,
219 | "_dstBlendFactor": 771,
220 | "_atlas": null
221 | },
222 | {
223 | "__type__": "cc.Node",
224 | "_name": "player",
225 | "_objFlags": 0,
226 | "_parent": {
227 | "__id__": 2
228 | },
229 | "_children": [
230 | {
231 | "__id__": 7
232 | },
233 | {
234 | "__id__": 11
235 | },
236 | {
237 | "__id__": 15
238 | }
239 | ],
240 | "_tag": -1,
241 | "_active": true,
242 | "_components": [
243 | {
244 | "__id__": 19
245 | }
246 | ],
247 | "_prefab": null,
248 | "_id": "bfDKHji6pMo755wE/u+UQY",
249 | "_opacity": 255,
250 | "_color": {
251 | "__type__": "cc.Color",
252 | "r": 255,
253 | "g": 255,
254 | "b": 255,
255 | "a": 255
256 | },
257 | "_cascadeOpacityEnabled": true,
258 | "_anchorPoint": {
259 | "__type__": "cc.Vec2",
260 | "x": 0.5,
261 | "y": 0.5
262 | },
263 | "_contentSize": {
264 | "__type__": "cc.Size",
265 | "width": 0,
266 | "height": 0
267 | },
268 | "_rotationX": 0,
269 | "_rotationY": 0,
270 | "_scaleX": 1,
271 | "_scaleY": 1,
272 | "_position": {
273 | "__type__": "cc.Vec2",
274 | "x": -378,
275 | "y": 0
276 | },
277 | "_skewX": 0,
278 | "_skewY": 0,
279 | "_localZOrder": 0,
280 | "_globalZOrder": 0,
281 | "_opacityModifyRGB": false,
282 | "groupIndex": 0
283 | },
284 | {
285 | "__type__": "cc.Node",
286 | "_name": "shield",
287 | "_objFlags": 0,
288 | "_parent": {
289 | "__id__": 6
290 | },
291 | "_children": [],
292 | "_tag": -1,
293 | "_active": false,
294 | "_components": [
295 | {
296 | "__id__": 8
297 | },
298 | {
299 | "__id__": 9
300 | },
301 | {
302 | "__id__": 10
303 | }
304 | ],
305 | "_prefab": null,
306 | "_id": "716R0xHr5L6LcUzHTlYpwc",
307 | "_opacity": 255,
308 | "_color": {
309 | "__type__": "cc.Color",
310 | "r": 0,
311 | "g": 0,
312 | "b": 255,
313 | "a": 255
314 | },
315 | "_cascadeOpacityEnabled": true,
316 | "_anchorPoint": {
317 | "__type__": "cc.Vec2",
318 | "x": 0.5,
319 | "y": 0.5
320 | },
321 | "_contentSize": {
322 | "__type__": "cc.Size",
323 | "width": 20,
324 | "height": 80
325 | },
326 | "_rotationX": 0,
327 | "_rotationY": 0,
328 | "_scaleX": 1,
329 | "_scaleY": 1,
330 | "_position": {
331 | "__type__": "cc.Vec2",
332 | "x": 40,
333 | "y": 0
334 | },
335 | "_skewX": 0,
336 | "_skewY": 0,
337 | "_localZOrder": 0,
338 | "_globalZOrder": 0,
339 | "_opacityModifyRGB": false,
340 | "groupIndex": 0
341 | },
342 | {
343 | "__type__": "cc.Sprite",
344 | "_name": "",
345 | "_objFlags": 0,
346 | "node": {
347 | "__id__": 7
348 | },
349 | "_enabled": true,
350 | "_spriteFrame": {
351 | "__uuid__": "a23235d1-15db-4b95-8439-a2e005bfff91"
352 | },
353 | "_type": 0,
354 | "_sizeMode": 0,
355 | "_fillType": 0,
356 | "_fillCenter": {
357 | "__type__": "cc.Vec2",
358 | "x": 0,
359 | "y": 0
360 | },
361 | "_fillStart": 0,
362 | "_fillRange": 0,
363 | "_isTrimmedMode": true,
364 | "_srcBlendFactor": 770,
365 | "_dstBlendFactor": 771,
366 | "_atlas": null
367 | },
368 | {
369 | "__type__": "4df13CWvXpCqYsWbDf5Rlqq",
370 | "_name": "",
371 | "_objFlags": 0,
372 | "node": {
373 | "__id__": 7
374 | },
375 | "_enabled": true
376 | },
377 | {
378 | "__type__": "cc.BoxCollider",
379 | "_name": "",
380 | "_objFlags": 0,
381 | "node": {
382 | "__id__": 7
383 | },
384 | "_enabled": true,
385 | "tag": 0,
386 | "_offset": {
387 | "__type__": "cc.Vec2",
388 | "x": 0,
389 | "y": 0
390 | },
391 | "_size": {
392 | "__type__": "cc.Size",
393 | "width": 20,
394 | "height": 80
395 | }
396 | },
397 | {
398 | "__type__": "cc.Node",
399 | "_name": "arms",
400 | "_objFlags": 0,
401 | "_parent": {
402 | "__id__": 6
403 | },
404 | "_children": [],
405 | "_tag": -1,
406 | "_active": false,
407 | "_components": [
408 | {
409 | "__id__": 12
410 | },
411 | {
412 | "__id__": 13
413 | },
414 | {
415 | "__id__": 14
416 | }
417 | ],
418 | "_prefab": null,
419 | "_id": "36E+GVWKFJSKvAtc20ND9y",
420 | "_opacity": 255,
421 | "_color": {
422 | "__type__": "cc.Color",
423 | "r": 255,
424 | "g": 0,
425 | "b": 0,
426 | "a": 255
427 | },
428 | "_cascadeOpacityEnabled": true,
429 | "_anchorPoint": {
430 | "__type__": "cc.Vec2",
431 | "x": 0,
432 | "y": 0.5
433 | },
434 | "_contentSize": {
435 | "__type__": "cc.Size",
436 | "width": 80,
437 | "height": 20
438 | },
439 | "_rotationX": 0,
440 | "_rotationY": 0,
441 | "_scaleX": 1,
442 | "_scaleY": 1,
443 | "_position": {
444 | "__type__": "cc.Vec2",
445 | "x": 0,
446 | "y": 40
447 | },
448 | "_skewX": 0,
449 | "_skewY": 0,
450 | "_localZOrder": 0,
451 | "_globalZOrder": 0,
452 | "_opacityModifyRGB": false,
453 | "groupIndex": 0
454 | },
455 | {
456 | "__type__": "cc.Sprite",
457 | "_name": "",
458 | "_objFlags": 0,
459 | "node": {
460 | "__id__": 11
461 | },
462 | "_enabled": true,
463 | "_spriteFrame": {
464 | "__uuid__": "a23235d1-15db-4b95-8439-a2e005bfff91"
465 | },
466 | "_type": 0,
467 | "_sizeMode": 0,
468 | "_fillType": 0,
469 | "_fillCenter": {
470 | "__type__": "cc.Vec2",
471 | "x": 0,
472 | "y": 0
473 | },
474 | "_fillStart": 0,
475 | "_fillRange": 0,
476 | "_isTrimmedMode": true,
477 | "_srcBlendFactor": 770,
478 | "_dstBlendFactor": 771,
479 | "_atlas": null
480 | },
481 | {
482 | "__type__": "eb3221gd0JN07JrrordQETu",
483 | "_name": "",
484 | "_objFlags": 0,
485 | "node": {
486 | "__id__": 11
487 | },
488 | "_enabled": true
489 | },
490 | {
491 | "__type__": "cc.BoxCollider",
492 | "_name": "",
493 | "_objFlags": 0,
494 | "node": {
495 | "__id__": 11
496 | },
497 | "_enabled": true,
498 | "tag": 0,
499 | "_offset": {
500 | "__type__": "cc.Vec2",
501 | "x": 40,
502 | "y": 0
503 | },
504 | "_size": {
505 | "__type__": "cc.Size",
506 | "width": 80,
507 | "height": 20
508 | }
509 | },
510 | {
511 | "__type__": "cc.Node",
512 | "_name": "sp",
513 | "_objFlags": 0,
514 | "_parent": {
515 | "__id__": 6
516 | },
517 | "_children": [],
518 | "_tag": -1,
519 | "_active": true,
520 | "_components": [
521 | {
522 | "__id__": 16
523 | },
524 | {
525 | "__id__": 17
526 | },
527 | {
528 | "__id__": 18
529 | }
530 | ],
531 | "_prefab": null,
532 | "_id": "5by8OXh4ZAj4LCIIzfxNnv",
533 | "_opacity": 255,
534 | "_color": {
535 | "__type__": "cc.Color",
536 | "r": 255,
537 | "g": 255,
538 | "b": 255,
539 | "a": 255
540 | },
541 | "_cascadeOpacityEnabled": true,
542 | "_anchorPoint": {
543 | "__type__": "cc.Vec2",
544 | "x": 0.5,
545 | "y": 0.5
546 | },
547 | "_contentSize": {
548 | "__type__": "cc.Size",
549 | "width": 80,
550 | "height": 100
551 | },
552 | "_rotationX": 0,
553 | "_rotationY": 0,
554 | "_scaleX": 1,
555 | "_scaleY": 1,
556 | "_position": {
557 | "__type__": "cc.Vec2",
558 | "x": 0,
559 | "y": 0
560 | },
561 | "_skewX": 0,
562 | "_skewY": 0,
563 | "_localZOrder": 0,
564 | "_globalZOrder": 0,
565 | "_opacityModifyRGB": false,
566 | "groupIndex": 0
567 | },
568 | {
569 | "__type__": "cc.Sprite",
570 | "_name": "",
571 | "_objFlags": 0,
572 | "node": {
573 | "__id__": 15
574 | },
575 | "_enabled": true,
576 | "_spriteFrame": {
577 | "__uuid__": "4b36b831-f88f-4bbc-8d8d-d48ec9b0e228"
578 | },
579 | "_type": 0,
580 | "_sizeMode": 0,
581 | "_fillType": 0,
582 | "_fillCenter": {
583 | "__type__": "cc.Vec2",
584 | "x": 0,
585 | "y": 0
586 | },
587 | "_fillStart": 0,
588 | "_fillRange": 0,
589 | "_isTrimmedMode": true,
590 | "_srcBlendFactor": 770,
591 | "_dstBlendFactor": 771,
592 | "_atlas": null
593 | },
594 | {
595 | "__type__": "9af0cN1pVxF6av7dtpWNzcG",
596 | "_name": "",
597 | "_objFlags": 0,
598 | "node": {
599 | "__id__": 15
600 | },
601 | "_enabled": true
602 | },
603 | {
604 | "__type__": "cc.BoxCollider",
605 | "_name": "",
606 | "_objFlags": 0,
607 | "node": {
608 | "__id__": 15
609 | },
610 | "_enabled": true,
611 | "tag": 0,
612 | "_offset": {
613 | "__type__": "cc.Vec2",
614 | "x": 0.2,
615 | "y": 0
616 | },
617 | "_size": {
618 | "__type__": "cc.Size",
619 | "width": 56.9,
620 | "height": 100
621 | }
622 | },
623 | {
624 | "__type__": "950b8ZtEvZOrJIJrD+C2iQW",
625 | "_name": "",
626 | "_objFlags": 0,
627 | "node": {
628 | "__id__": 6
629 | },
630 | "_enabled": true,
631 | "armsCtl": {
632 | "__id__": 13
633 | },
634 | "shieldCtl": {
635 | "__id__": 9
636 | },
637 | "HeroSpriteClt": {
638 | "__id__": 17
639 | }
640 | },
641 | {
642 | "__type__": "cc.Node",
643 | "_name": "monster",
644 | "_objFlags": 0,
645 | "_parent": {
646 | "__id__": 2
647 | },
648 | "_children": [
649 | {
650 | "__id__": 21
651 | },
652 | {
653 | "__id__": 24
654 | },
655 | {
656 | "__id__": 27
657 | }
658 | ],
659 | "_tag": -1,
660 | "_active": true,
661 | "_components": [
662 | {
663 | "__id__": 30
664 | },
665 | {
666 | "__id__": 31
667 | },
668 | {
669 | "__id__": 32
670 | },
671 | {
672 | "__id__": 33
673 | },
674 | {
675 | "__id__": 34
676 | },
677 | {
678 | "__id__": 35
679 | }
680 | ],
681 | "_prefab": null,
682 | "_id": "6bjGfY5c9N16rAAh3qfSJR",
683 | "_opacity": 255,
684 | "_color": {
685 | "__type__": "cc.Color",
686 | "r": 255,
687 | "g": 145,
688 | "b": 145,
689 | "a": 255
690 | },
691 | "_cascadeOpacityEnabled": true,
692 | "_anchorPoint": {
693 | "__type__": "cc.Vec2",
694 | "x": 0.5,
695 | "y": 0.5
696 | },
697 | "_contentSize": {
698 | "__type__": "cc.Size",
699 | "width": 100,
700 | "height": 100
701 | },
702 | "_rotationX": 0,
703 | "_rotationY": 0,
704 | "_scaleX": 1,
705 | "_scaleY": 1,
706 | "_position": {
707 | "__type__": "cc.Vec2",
708 | "x": -54,
709 | "y": 0
710 | },
711 | "_skewX": 0,
712 | "_skewY": 0,
713 | "_localZOrder": 0,
714 | "_globalZOrder": 0,
715 | "_opacityModifyRGB": false,
716 | "groupIndex": 0
717 | },
718 | {
719 | "__type__": "cc.Node",
720 | "_name": "shield",
721 | "_objFlags": 0,
722 | "_parent": {
723 | "__id__": 20
724 | },
725 | "_children": [],
726 | "_tag": -1,
727 | "_active": false,
728 | "_components": [
729 | {
730 | "__id__": 22
731 | },
732 | {
733 | "__id__": 23
734 | }
735 | ],
736 | "_prefab": null,
737 | "_id": "91ZlO8YFZA0bSBzIM9AevC",
738 | "_opacity": 255,
739 | "_color": {
740 | "__type__": "cc.Color",
741 | "r": 0,
742 | "g": 0,
743 | "b": 255,
744 | "a": 255
745 | },
746 | "_cascadeOpacityEnabled": true,
747 | "_anchorPoint": {
748 | "__type__": "cc.Vec2",
749 | "x": 0.5,
750 | "y": 0.5
751 | },
752 | "_contentSize": {
753 | "__type__": "cc.Size",
754 | "width": 20,
755 | "height": 80
756 | },
757 | "_rotationX": 0,
758 | "_rotationY": 0,
759 | "_scaleX": 1,
760 | "_scaleY": 1,
761 | "_position": {
762 | "__type__": "cc.Vec2",
763 | "x": 40,
764 | "y": 0
765 | },
766 | "_skewX": 0,
767 | "_skewY": 0,
768 | "_localZOrder": 0,
769 | "_globalZOrder": 0,
770 | "_opacityModifyRGB": false,
771 | "groupIndex": 0
772 | },
773 | {
774 | "__type__": "cc.Sprite",
775 | "_name": "",
776 | "_objFlags": 0,
777 | "node": {
778 | "__id__": 21
779 | },
780 | "_enabled": true,
781 | "_spriteFrame": {
782 | "__uuid__": "a23235d1-15db-4b95-8439-a2e005bfff91"
783 | },
784 | "_type": 0,
785 | "_sizeMode": 0,
786 | "_fillType": 0,
787 | "_fillCenter": {
788 | "__type__": "cc.Vec2",
789 | "x": 0,
790 | "y": 0
791 | },
792 | "_fillStart": 0,
793 | "_fillRange": 0,
794 | "_isTrimmedMode": true,
795 | "_srcBlendFactor": 770,
796 | "_dstBlendFactor": 771,
797 | "_atlas": null
798 | },
799 | {
800 | "__type__": "cc.BoxCollider",
801 | "_name": "",
802 | "_objFlags": 0,
803 | "node": {
804 | "__id__": 21
805 | },
806 | "_enabled": true,
807 | "tag": 0,
808 | "_offset": {
809 | "__type__": "cc.Vec2",
810 | "x": 0,
811 | "y": 0
812 | },
813 | "_size": {
814 | "__type__": "cc.Size",
815 | "width": 20,
816 | "height": 80
817 | }
818 | },
819 | {
820 | "__type__": "cc.Node",
821 | "_name": "arms",
822 | "_objFlags": 0,
823 | "_parent": {
824 | "__id__": 20
825 | },
826 | "_children": [],
827 | "_tag": -1,
828 | "_active": false,
829 | "_components": [
830 | {
831 | "__id__": 25
832 | },
833 | {
834 | "__id__": 26
835 | }
836 | ],
837 | "_prefab": null,
838 | "_id": "bbCgiaLZtN5YK6yg/PmPID",
839 | "_opacity": 255,
840 | "_color": {
841 | "__type__": "cc.Color",
842 | "r": 255,
843 | "g": 0,
844 | "b": 0,
845 | "a": 255
846 | },
847 | "_cascadeOpacityEnabled": true,
848 | "_anchorPoint": {
849 | "__type__": "cc.Vec2",
850 | "x": 0,
851 | "y": 0.5
852 | },
853 | "_contentSize": {
854 | "__type__": "cc.Size",
855 | "width": 80,
856 | "height": 20
857 | },
858 | "_rotationX": 0,
859 | "_rotationY": 0,
860 | "_scaleX": 1,
861 | "_scaleY": 1,
862 | "_position": {
863 | "__type__": "cc.Vec2",
864 | "x": 0,
865 | "y": 40
866 | },
867 | "_skewX": 0,
868 | "_skewY": 0,
869 | "_localZOrder": 0,
870 | "_globalZOrder": 0,
871 | "_opacityModifyRGB": false,
872 | "groupIndex": 0
873 | },
874 | {
875 | "__type__": "cc.Sprite",
876 | "_name": "",
877 | "_objFlags": 0,
878 | "node": {
879 | "__id__": 24
880 | },
881 | "_enabled": true,
882 | "_spriteFrame": {
883 | "__uuid__": "a23235d1-15db-4b95-8439-a2e005bfff91"
884 | },
885 | "_type": 0,
886 | "_sizeMode": 0,
887 | "_fillType": 0,
888 | "_fillCenter": {
889 | "__type__": "cc.Vec2",
890 | "x": 0,
891 | "y": 0
892 | },
893 | "_fillStart": 0,
894 | "_fillRange": 0,
895 | "_isTrimmedMode": true,
896 | "_srcBlendFactor": 770,
897 | "_dstBlendFactor": 771,
898 | "_atlas": null
899 | },
900 | {
901 | "__type__": "cc.BoxCollider",
902 | "_name": "",
903 | "_objFlags": 0,
904 | "node": {
905 | "__id__": 24
906 | },
907 | "_enabled": true,
908 | "tag": 0,
909 | "_offset": {
910 | "__type__": "cc.Vec2",
911 | "x": 40,
912 | "y": 0
913 | },
914 | "_size": {
915 | "__type__": "cc.Size",
916 | "width": 80,
917 | "height": 20
918 | }
919 | },
920 | {
921 | "__type__": "cc.Node",
922 | "_name": "sp",
923 | "_objFlags": 0,
924 | "_parent": {
925 | "__id__": 20
926 | },
927 | "_children": [],
928 | "_tag": -1,
929 | "_active": true,
930 | "_components": [
931 | {
932 | "__id__": 28
933 | },
934 | {
935 | "__id__": 29
936 | }
937 | ],
938 | "_prefab": null,
939 | "_id": "82HyEto6VOXauOvJmX7jqw",
940 | "_opacity": 255,
941 | "_color": {
942 | "__type__": "cc.Color",
943 | "r": 255,
944 | "g": 255,
945 | "b": 255,
946 | "a": 255
947 | },
948 | "_cascadeOpacityEnabled": true,
949 | "_anchorPoint": {
950 | "__type__": "cc.Vec2",
951 | "x": 0.5,
952 | "y": 0.5
953 | },
954 | "_contentSize": {
955 | "__type__": "cc.Size",
956 | "width": 80,
957 | "height": 100
958 | },
959 | "_rotationX": 0,
960 | "_rotationY": 0,
961 | "_scaleX": 1,
962 | "_scaleY": 1,
963 | "_position": {
964 | "__type__": "cc.Vec2",
965 | "x": 0,
966 | "y": 0
967 | },
968 | "_skewX": 0,
969 | "_skewY": 0,
970 | "_localZOrder": 0,
971 | "_globalZOrder": 0,
972 | "_opacityModifyRGB": false,
973 | "groupIndex": 0
974 | },
975 | {
976 | "__type__": "cc.Sprite",
977 | "_name": "",
978 | "_objFlags": 0,
979 | "node": {
980 | "__id__": 27
981 | },
982 | "_enabled": true,
983 | "_spriteFrame": {
984 | "__uuid__": "da9c4605-989f-4b31-9394-c26561cdb679"
985 | },
986 | "_type": 0,
987 | "_sizeMode": 0,
988 | "_fillType": 0,
989 | "_fillCenter": {
990 | "__type__": "cc.Vec2",
991 | "x": 0,
992 | "y": 0
993 | },
994 | "_fillStart": 0,
995 | "_fillRange": 0,
996 | "_isTrimmedMode": true,
997 | "_srcBlendFactor": 770,
998 | "_dstBlendFactor": 771,
999 | "_atlas": null
1000 | },
1001 | {
1002 | "__type__": "cc.BoxCollider",
1003 | "_name": "",
1004 | "_objFlags": 0,
1005 | "node": {
1006 | "__id__": 27
1007 | },
1008 | "_enabled": true,
1009 | "tag": 0,
1010 | "_offset": {
1011 | "__type__": "cc.Vec2",
1012 | "x": 0.2,
1013 | "y": 0
1014 | },
1015 | "_size": {
1016 | "__type__": "cc.Size",
1017 | "width": 56.9,
1018 | "height": 100
1019 | }
1020 | },
1021 | {
1022 | "__type__": "ed461OgvNhPkYcXSedYz2mi",
1023 | "_name": "",
1024 | "_objFlags": 0,
1025 | "node": {
1026 | "__id__": 20
1027 | },
1028 | "_enabled": true
1029 | },
1030 | {
1031 | "__type__": "b70a90+E+ZHR70VssaIV7CM",
1032 | "_name": "",
1033 | "_objFlags": 0,
1034 | "node": {
1035 | "__id__": 20
1036 | },
1037 | "_enabled": true
1038 | },
1039 | {
1040 | "__type__": "b692f5TPu5MZKPa7FGl9GNM",
1041 | "_name": "",
1042 | "_objFlags": 0,
1043 | "node": {
1044 | "__id__": 20
1045 | },
1046 | "_enabled": true
1047 | },
1048 | {
1049 | "__type__": "e48b2u5rW1OyageeYezCyHk",
1050 | "_name": "",
1051 | "_objFlags": 0,
1052 | "node": {
1053 | "__id__": 20
1054 | },
1055 | "_enabled": true
1056 | },
1057 | {
1058 | "__type__": "f3e68vrPzVMRZplNB+WUrmo",
1059 | "_name": "",
1060 | "_objFlags": 0,
1061 | "node": {
1062 | "__id__": 20
1063 | },
1064 | "_enabled": true
1065 | },
1066 | {
1067 | "__type__": "a7fb1KUKPpIaqunSeTYsUe4",
1068 | "_name": "",
1069 | "_objFlags": 0,
1070 | "node": {
1071 | "__id__": 20
1072 | },
1073 | "_enabled": true
1074 | },
1075 | {
1076 | "__type__": "cc.Canvas",
1077 | "_name": "",
1078 | "_objFlags": 0,
1079 | "node": {
1080 | "__id__": 2
1081 | },
1082 | "_enabled": true,
1083 | "_designResolution": {
1084 | "__type__": "cc.Size",
1085 | "width": 1280,
1086 | "height": 640
1087 | },
1088 | "_fitWidth": false,
1089 | "_fitHeight": true
1090 | },
1091 | {
1092 | "__type__": "e1b90/rohdEk4SdmmEZANaD",
1093 | "_name": "",
1094 | "_objFlags": 0,
1095 | "node": {
1096 | "__id__": 2
1097 | },
1098 | "_enabled": true,
1099 | "playerCtl": {
1100 | "__id__": 19
1101 | },
1102 | "monsterCtl": {
1103 | "__id__": 35
1104 | }
1105 | }
1106 | ]
--------------------------------------------------------------------------------
/assets/Scene/GameScene.fire.meta:
--------------------------------------------------------------------------------
1 | {
2 | "ver": "1.0.0",
3 | "uuid": "2d2f792f-a40c-49bb-a189-ed176a246e49",
4 | "asyncLoadAssets": false,
5 | "autoReleaseAssets": false,
6 | "subMetas": {}
7 | }
--------------------------------------------------------------------------------
/assets/Script.meta:
--------------------------------------------------------------------------------
1 | {
2 | "ver": "1.0.1",
3 | "uuid": "4734c20c-0db8-4eb2-92ea-e692f4d70934",
4 | "isGroup": false,
5 | "subMetas": {}
6 | }
--------------------------------------------------------------------------------
/assets/Script/ArmsCtl.ts:
--------------------------------------------------------------------------------
1 | import PlayerCtl from "./PlayerCtl"
2 | import { GameStatus } from "./GameInterface";
3 | const {ccclass, property} = cc._decorator;
4 |
5 | @ccclass
6 | export default class NewClass extends cc.Component {
7 |
8 | speed = 100;
9 | state = GameStatus.STOP;
10 | // LIFE-CYCLE CALLBACKS:
11 | playerCtl: PlayerCtl = null;
12 |
13 | // onLoad () {}
14 |
15 | init(playerCtl: PlayerCtl) {
16 | this.playerCtl = playerCtl;
17 | }
18 |
19 | setArmsState(state: number) {
20 | this.state = state;
21 | this.node.active = this.state == GameStatus.RUNNING ? true : false;
22 | }
23 |
24 | start () {
25 |
26 | }
27 |
28 | onCollisionEnter(other, self) {
29 | this.playerCtl.onCollisionEnter(other, self);
30 | }
31 |
32 | onCollisionStay(other, self) {
33 | this.playerCtl.onCollisionStay(other, self);
34 | }
35 |
36 | onCollisionExit(other, self) {
37 | this.playerCtl.onCollisionStay(other, self);
38 | }
39 |
40 | /**
41 | * 更新攻击
42 | */
43 | armsUpdate(dt: number) {
44 | if(this.state != GameStatus.RUNNING) {
45 | return ;
46 | }
47 | if(this.node.y <= -40) {
48 | this.node.y = 40;
49 | }
50 | this.node.y -= this.speed * dt;
51 | }
52 |
53 |
54 |
55 | // update (dt) {}
56 | }
57 |
58 |
59 |
--------------------------------------------------------------------------------
/assets/Script/ArmsCtl.ts.meta:
--------------------------------------------------------------------------------
1 | {
2 | "ver": "1.0.5",
3 | "uuid": "eb322d60-7742-4dd3-b26b-ae8add4044ee",
4 | "isPlugin": false,
5 | "loadPluginInWeb": true,
6 | "loadPluginInNative": true,
7 | "loadPluginInEditor": false,
8 | "subMetas": {}
9 | }
--------------------------------------------------------------------------------
/assets/Script/Attack.ts:
--------------------------------------------------------------------------------
1 |
2 | const {ccclass, property} = cc._decorator;
3 |
4 | @ccclass
5 | export default class NewClass extends cc.Component {
6 |
7 | speed = 100; // 移动的速度
8 |
9 | // onLoad () {}
10 |
11 | start () {
12 |
13 | }
14 |
15 | enter (tick,b3,treeNode){
16 | }
17 |
18 | open (tick,b3,treeNode){
19 | this.node.getChildByName("arms").active = true;
20 | }
21 | /**
22 | *
23 | * @param tick
24 | * @param b3
25 | * @param treeNode
26 | */
27 | tick (tick,b3,treeNode){
28 | let dt = tick.target.dt;
29 | if(this.node.getChildByName("arms").y <= -40) {
30 | this.node.getChildByName("arms").y = 40;
31 | return b3.SUCCESS;
32 | }else {
33 | this.node.getChildByName("arms").y -= this.speed * dt;
34 | }
35 | return b3.RUNNING;
36 | }
37 |
38 | close (tick,b3,treeNode){
39 | this.node.getChildByName("arms").active = false;
40 | }
41 |
42 | exit (tick,b3,treeNode){
43 | }
44 |
45 | // update (dt) {}
46 | }
47 |
--------------------------------------------------------------------------------
/assets/Script/Attack.ts.meta:
--------------------------------------------------------------------------------
1 | {
2 | "ver": "1.0.5",
3 | "uuid": "b70a9d3e-13e6-4747-bd15-b2c68857b08c",
4 | "isPlugin": false,
5 | "loadPluginInWeb": true,
6 | "loadPluginInNative": true,
7 | "loadPluginInEditor": false,
8 | "subMetas": {}
9 | }
--------------------------------------------------------------------------------
/assets/Script/Defense.ts:
--------------------------------------------------------------------------------
1 | import MonsterCtl from "./MonsterCtl"
2 | const {ccclass, property} = cc._decorator;
3 |
4 | @ccclass
5 | export default class NewClass extends cc.Component {
6 |
7 |
8 | // LIFE-CYCLE CALLBACKS:
9 |
10 | // onLoad () {}
11 |
12 | start () {
13 |
14 | }
15 |
16 | enter (tick,b3,treeNode){
17 |
18 | }
19 |
20 | open (tick,b3,treeNode){
21 |
22 | this.node.getChildByName("shield").active = true;
23 |
24 | }
25 |
26 | tick (tick,b3,treeNode){
27 | return b3.RUNNING;
28 | }
29 |
30 | close (tick,b3,treeNode){
31 | this.node.getChildByName("shield").active = false;
32 | }
33 |
34 | exit (tick,b3,treeNode){
35 | //
36 | }
37 |
38 | // update (dt) {}
39 | }
40 |
--------------------------------------------------------------------------------
/assets/Script/Defense.ts.meta:
--------------------------------------------------------------------------------
1 | {
2 | "ver": "1.0.5",
3 | "uuid": "f3e68beb-3f35-4c45-9a65-341f9652b9a8",
4 | "isPlugin": false,
5 | "loadPluginInWeb": true,
6 | "loadPluginInNative": true,
7 | "loadPluginInEditor": false,
8 | "subMetas": {}
9 | }
--------------------------------------------------------------------------------
/assets/Script/GameInterface.ts:
--------------------------------------------------------------------------------
1 | export enum PlayerDir {
2 | left = -1,
3 | right = 1,
4 | up = 2,
5 | down = -2,
6 | stop = 0,
7 | }
8 | export enum GameStatus {
9 | STOP = 1,
10 | RUNNING = 2,
11 | ATTACKING = 3,
12 | DEFENSING = 4,
13 | NOTHING = 5,
14 | DAZING = 6,
15 | }
--------------------------------------------------------------------------------
/assets/Script/GameInterface.ts.meta:
--------------------------------------------------------------------------------
1 | {
2 | "ver": "1.0.5",
3 | "uuid": "cd84af8e-2e66-48d1-84cf-8d6c31e3d8d4",
4 | "isPlugin": false,
5 | "loadPluginInWeb": true,
6 | "loadPluginInNative": true,
7 | "loadPluginInEditor": false,
8 | "subMetas": {}
9 | }
--------------------------------------------------------------------------------
/assets/Script/GameScene.ts:
--------------------------------------------------------------------------------
1 | import PlayerCtl from "./PlayerCtl";
2 | import MonsterCtl from "./MonsterCtl"
3 | import { PlayerDir } from "./GameInterface";
4 | import{GameStatus} from "./GameInterface"
5 | const {ccclass, property} = cc._decorator;
6 |
7 | /**
8 | * 一个简单的样例, 用于学习行为树AI
9 | * 怪物1, 默认在一段位置内巡逻, 一旦发现目标(玩家), 则发动攻击
10 | */
11 | @ccclass
12 | export default class GameScene extends cc.Component {
13 |
14 | @property(PlayerCtl)
15 | playerCtl: PlayerCtl = null;
16 |
17 | @property(MonsterCtl)
18 | monsterCtl: MonsterCtl = null;
19 |
20 | stepInterval = 60;
21 | restRunningSecond = 0;
22 | isRunning = false;
23 |
24 |
25 | onLoad() {
26 | cc.systemEvent.on(cc.SystemEvent.EventType.KEY_DOWN, this.onKeyDown, this);
27 | cc.systemEvent.on(cc.SystemEvent.EventType.KEY_UP, this.onKeyUp, this);
28 | }
29 |
30 |
31 | start () {
32 | this.playerCtl.init(this);
33 | this.monsterCtl.init(this);
34 | this.openCollisionManager();
35 | }
36 |
37 | /**
38 | * ----------------------------- 获取player的信息 -----------------------------
39 | */
40 | getPlayer() {
41 | return this.playerCtl;
42 | }
43 |
44 | getMonster() {
45 | return this.monsterCtl;
46 | }
47 |
48 |
49 |
50 |
51 | onKeyDown(event: any) {
52 | switch(event.keyCode) {
53 | case cc.KEY.left:
54 | case cc.KEY.a:
55 | this.playerCtl.setDirection(PlayerDir.left);
56 | break;
57 | case cc.KEY.right:
58 | case cc.KEY.d:
59 | this.playerCtl.setDirection(PlayerDir.right);
60 | break;
61 | case cc.KEY.j:
62 | this.playerCtl.setArmsState(GameStatus.RUNNING);
63 | break;
64 | case cc.KEY.k:
65 | this.playerCtl.setShieldState(GameStatus.RUNNING);
66 | break;
67 | }
68 | }
69 | onKeyUp(event: any) {
70 | switch(event.keyCode) {
71 | case cc.KEY.left:
72 | case cc.KEY.a:
73 | case cc.KEY.right:
74 | case cc.KEY.d:
75 | this.playerCtl.setDirection(PlayerDir.stop);
76 | break;
77 |
78 | case cc.KEY.j:
79 | this.playerCtl.setArmsState(GameStatus.STOP);
80 | break;
81 | case cc.KEY.k:
82 | this.playerCtl.setShieldState(GameStatus.STOP);
83 | break;
84 |
85 | }
86 | }
87 |
88 | onDestroy() {
89 | cc.systemEvent.off(cc.SystemEvent.EventType.KEY_DOWN, this.onKeyDown, this);
90 | cc.systemEvent.off(cc.SystemEvent.EventType.KEY_UP, this.onKeyUp, this);
91 | }
92 |
93 |
94 | update(dt: number) {
95 | let ms = dt;
96 | this.playerCtl.playerUpdate(ms);
97 |
98 | if(!this.isRunning) {
99 | this.restRunningSecond = this.stepInterval / 1000;
100 | this.isRunning = true;
101 | }
102 | this.restRunningSecond -= ms;
103 | if(this.restRunningSecond <= 0) {
104 | this.isRunning = false;
105 | this.runBehaviorTree(ms);
106 | }
107 | }
108 | /**
109 | * 执行行为树
110 | * @param ms
111 | */
112 | runBehaviorTree(ms: number) {
113 | let target = {
114 | dt: ms,
115 | };
116 | this.monsterCtl.getComponent("BehaviorTree").tick(target);
117 | }
118 |
119 |
120 |
121 |
122 | openCollisionManager() {
123 | var manager = cc.director.getCollisionManager();
124 | manager.enabled = true;
125 | }
126 | closeCollisionManager() {
127 | var manager = cc.director.getCollisionManager();
128 | manager.enabled = false;
129 | }
130 |
131 |
132 | }
133 |
--------------------------------------------------------------------------------
/assets/Script/GameScene.ts.meta:
--------------------------------------------------------------------------------
1 | {
2 | "ver": "1.0.5",
3 | "uuid": "e1b90feb-a217-4493-849d-9a611900d683",
4 | "isPlugin": false,
5 | "loadPluginInWeb": true,
6 | "loadPluginInNative": true,
7 | "loadPluginInEditor": false,
8 | "subMetas": {}
9 | }
--------------------------------------------------------------------------------
/assets/Script/HeroSpriteClt.ts:
--------------------------------------------------------------------------------
1 | import PlayerCtl from "./PlayerCtl"
2 | const {ccclass, property} = cc._decorator;
3 |
4 | @ccclass
5 | export default class NewClass extends cc.Component {
6 |
7 | // LIFE-CYCLE CALLBACKS:
8 |
9 | playerCtl: PlayerCtl = null;
10 | // onLoad () {}
11 |
12 | init(playerCtl: PlayerCtl) {
13 | this.playerCtl = playerCtl;
14 | }
15 |
16 | start () {
17 |
18 | }
19 |
20 | onCollisionEnter(other, self) {
21 | this.playerCtl.onCollisionEnter(other, self);
22 | }
23 |
24 | onCollisionStay(other, self) {
25 | this.playerCtl.onCollisionStay(other, self);
26 | }
27 |
28 | onCollisionExit(other, self) {
29 | this.playerCtl.onCollisionStay(other, self);
30 | }
31 |
32 | // update (dt) {}
33 | }
34 |
--------------------------------------------------------------------------------
/assets/Script/HeroSpriteClt.ts.meta:
--------------------------------------------------------------------------------
1 | {
2 | "ver": "1.0.5",
3 | "uuid": "9af0c375-a55c-45e9-abfb-76da56373706",
4 | "isPlugin": false,
5 | "loadPluginInWeb": true,
6 | "loadPluginInNative": true,
7 | "loadPluginInEditor": false,
8 | "subMetas": {}
9 | }
--------------------------------------------------------------------------------
/assets/Script/Look.ts:
--------------------------------------------------------------------------------
1 | import MonsterCtl from "./MonsterCtl"
2 | const {ccclass, property} = cc._decorator;
3 |
4 | @ccclass
5 | export default class NewClass extends cc.Component {
6 |
7 | // onLoad () {}
8 |
9 | start () {
10 |
11 | }
12 |
13 | enter (tick,b3,treeNode){
14 |
15 | }
16 |
17 | open (tick,b3,treeNode){
18 |
19 | }
20 |
21 | tick (tick,b3,treeNode){
22 | let radio = treeNode.parameter.radio;
23 | let playerX = this.getComponent(MonsterCtl).getPlayerPostion().x;
24 | if(Math.abs(playerX - this.node.x) < radio) {
25 | // 判断是不是 看见了
26 | let lookTurn = playerX - this.node.x > 0 ? 1 : -1;
27 | if(lookTurn == this.node.scaleX) {
28 | return b3.SUCCESS;
29 | }
30 | return b3.FAILURE;
31 |
32 | }else {
33 | return b3.FAILURE;
34 | }
35 | }
36 |
37 | close (tick,b3,treeNode){
38 |
39 | }
40 |
41 | exit (tick,b3,treeNode){
42 |
43 | }
44 |
45 |
46 | // update (dt) {}
47 | }
48 |
--------------------------------------------------------------------------------
/assets/Script/Look.ts.meta:
--------------------------------------------------------------------------------
1 | {
2 | "ver": "1.0.5",
3 | "uuid": "b692fe53-3eee-4c64-a3da-ec51a5f4634c",
4 | "isPlugin": false,
5 | "loadPluginInWeb": true,
6 | "loadPluginInNative": true,
7 | "loadPluginInEditor": false,
8 | "subMetas": {}
9 | }
--------------------------------------------------------------------------------
/assets/Script/MonsterCtl.ts:
--------------------------------------------------------------------------------
1 | import GameScene from "./GameScene"
2 | const {ccclass, property} = cc._decorator;
3 |
4 | @ccclass
5 | export default class NewClass extends cc.Component {
6 |
7 |
8 | gameCtl: GameScene = null;
9 |
10 | // onLoad () {}
11 |
12 | init(gameCtl: GameScene) {
13 | this.gameCtl = gameCtl;
14 | }
15 |
16 | getPlayerPostion() {
17 | return this.gameCtl.getPlayer().getPosition();
18 | }
19 |
20 |
21 | start () {
22 |
23 | }
24 |
25 |
26 |
27 | // update (dt) {}
28 | }
29 |
--------------------------------------------------------------------------------
/assets/Script/MonsterCtl.ts.meta:
--------------------------------------------------------------------------------
1 | {
2 | "ver": "1.0.5",
3 | "uuid": "a7fb1294-28fa-486a-aba7-49e4d8b147b8",
4 | "isPlugin": false,
5 | "loadPluginInWeb": true,
6 | "loadPluginInNative": true,
7 | "loadPluginInEditor": false,
8 | "subMetas": {}
9 | }
--------------------------------------------------------------------------------
/assets/Script/Patrol.ts:
--------------------------------------------------------------------------------
1 |
2 | const {ccclass, property} = cc._decorator;
3 |
4 | @ccclass
5 | export default class NewClass extends cc.Component {
6 |
7 |
8 | speed = 100;
9 | moveSize = 0;
10 | // LIFE-CYCLE CALLBACKS:
11 |
12 | // onLoad () {}
13 |
14 | start () {
15 |
16 | }
17 |
18 | enter (tick,b3,treeNode){
19 |
20 | }
21 |
22 | open (tick,b3,treeNode){
23 |
24 | }
25 | /**
26 | *
27 | * @param tick
28 | * @param b3
29 | * @param treeNode
30 | */
31 | tick (tick,b3,treeNode){
32 | let areaSize = treeNode.parameter.areaSize;
33 | let dt = tick.target.dt;
34 | this.node.x += dt * this.speed;
35 | this.moveSize += Math.abs(dt * this.speed)
36 | if(this.moveSize >= areaSize) {
37 | this.moveSize = 0;
38 | this.speed = -this.speed;
39 | this.node.scaleX = -this.node.scaleX;
40 | }
41 | return b3.SUCCESS;
42 |
43 | }
44 |
45 | close (tick,b3,treeNode){
46 |
47 | }
48 |
49 | exit (tick,b3,treeNode){
50 |
51 | }
52 |
53 | // update (dt) {}
54 | }
55 |
--------------------------------------------------------------------------------
/assets/Script/Patrol.ts.meta:
--------------------------------------------------------------------------------
1 | {
2 | "ver": "1.0.5",
3 | "uuid": "e48b2bb9-ad6d-4ec9-a81e-7987b30b21e4",
4 | "isPlugin": false,
5 | "loadPluginInWeb": true,
6 | "loadPluginInNative": true,
7 | "loadPluginInEditor": false,
8 | "subMetas": {}
9 | }
--------------------------------------------------------------------------------
/assets/Script/PlayerCtl.ts:
--------------------------------------------------------------------------------
1 | import GameScene from "./GameSCene"
2 | import ArmsCtl from "./ArmsCtl"
3 | import ShieldCtl from "./ShieldCtl"
4 | import HeroSpriteClt from "./HeroSpriteClt"
5 | import { GameStatus } from "./GameInterface";
6 | const {ccclass, property} = cc._decorator;
7 |
8 | @ccclass
9 | export default class NewClass extends cc.Component {
10 |
11 | direction = 0; // 当前状态 -1表示向左, 1表示向用, 0表示不动
12 | faceTo = 1; // 当前面向
13 | speed = 100;
14 | state = GameStatus.DAZING;
15 |
16 | gameCtl: GameScene = null;
17 |
18 | @property(ArmsCtl)
19 | armsCtl: ArmsCtl = null;
20 | @property(ShieldCtl)
21 | shieldCtl: ShieldCtl = null;
22 | @property(HeroSpriteClt)
23 | HeroSpriteClt: HeroSpriteClt = null;
24 |
25 | // onLoad () {}
26 | init(gameCtl: GameScene) {
27 | this.gameCtl = gameCtl;
28 | this.armsCtl.init(this);
29 | this.shieldCtl.init(this);
30 | this.HeroSpriteClt.init(this);
31 | }
32 |
33 | start () {
34 | }
35 |
36 | getPosition() {
37 | return this.node.position;
38 | }
39 | /**
40 | * 设置玩家方向
41 | * @param dir
42 | */
43 | setDirection(dir: number) {
44 | this.direction = dir;
45 | this.faceTo = dir == 0 ? this.faceTo : dir;
46 | this.node.scaleX = this.faceTo;
47 | }
48 | /**
49 | * 发起攻击
50 | */
51 | setArmsState(state: number) {
52 | if(this.state == GameStatus.DEFENSING) {
53 | return ;
54 | }
55 | this.armsCtl.setArmsState(state);
56 | this.state = state == GameStatus.RUNNING ? GameStatus.ATTACKING : GameStatus.STOP;
57 | }
58 | /**
59 | * 设置防御状态
60 | */
61 | setShieldState(state: number) {
62 | if(this.state == GameStatus.ATTACKING) {
63 | return ;
64 | }
65 | this.shieldCtl.setShieldState(state);
66 | this.state = state == GameStatus.RUNNING ? GameStatus.DEFENSING : GameStatus.STOP;
67 | }
68 | /**
69 | * 更新玩家位置
70 | * @param dt
71 | */
72 | playerUpdate(dt: number) {
73 | this.armsCtl.armsUpdate(dt);
74 | if(this.direction == 0) {
75 | return ;
76 | }
77 | this.node.x += this.direction * dt * this.speed;
78 | }
79 |
80 | /**
81 | * ---------------------------------- 碰撞回调 ---------------------------------------
82 | */
83 | onCollisionEnter(other, self) {
84 |
85 | }
86 |
87 | onCollisionStay(other, self) {
88 |
89 | }
90 |
91 | onCollisionExit(other, self) {
92 |
93 | }
94 |
95 | }
96 |
--------------------------------------------------------------------------------
/assets/Script/PlayerCtl.ts.meta:
--------------------------------------------------------------------------------
1 | {
2 | "ver": "1.0.5",
3 | "uuid": "950b866d-12f6-4eac-9209-ac3f82da2416",
4 | "isPlugin": false,
5 | "loadPluginInWeb": true,
6 | "loadPluginInNative": true,
7 | "loadPluginInEditor": false,
8 | "subMetas": {}
9 | }
--------------------------------------------------------------------------------
/assets/Script/ShieldCtl.ts:
--------------------------------------------------------------------------------
1 | import PlayerCtl from "./PlayerCtl"
2 | import { GameStatus } from "./GameInterface";
3 | const {ccclass, property} = cc._decorator;
4 |
5 | @ccclass
6 | export default class NewClass extends cc.Component {
7 |
8 | playerCtl: PlayerCtl = null;
9 | // onLoad () {}
10 |
11 | state = GameStatus.STOP;
12 |
13 | init(playerCtl: PlayerCtl) {
14 | this.playerCtl = playerCtl;
15 | }
16 |
17 | start () {
18 |
19 | }
20 | setShieldState(state: number) {
21 | this.state = state;
22 | this.node.active = this.state == GameStatus.RUNNING ? true : false;
23 | }
24 |
25 | onCollisionEnter(other, self) {
26 | this.playerCtl.onCollisionEnter(other, self);
27 | }
28 |
29 | onCollisionStay(other, self) {
30 | this.playerCtl.onCollisionStay(other, self);
31 | }
32 |
33 | onCollisionExit(other, self) {
34 | this.playerCtl.onCollisionStay(other, self);
35 | }
36 |
37 | // update (dt) {}
38 | }
39 |
--------------------------------------------------------------------------------
/assets/Script/ShieldCtl.ts.meta:
--------------------------------------------------------------------------------
1 | {
2 | "ver": "1.0.5",
3 | "uuid": "4df13096-bd7a-42a9-8b16-6c37f9465aaa",
4 | "isPlugin": false,
5 | "loadPluginInWeb": true,
6 | "loadPluginInNative": true,
7 | "loadPluginInEditor": false,
8 | "subMetas": {}
9 | }
--------------------------------------------------------------------------------
/assets/Texture.meta:
--------------------------------------------------------------------------------
1 | {
2 | "ver": "1.0.1",
3 | "uuid": "7b81d4e8-ec84-4716-968d-500ac1d78a54",
4 | "isGroup": false,
5 | "subMetas": {}
6 | }
--------------------------------------------------------------------------------
/assets/Texture/singleColor.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kirikayakazuto/BehaviorTreeGame/b12ae9c4b8f472e5b9185664d519175808009e35/assets/Texture/singleColor.png
--------------------------------------------------------------------------------
/assets/Texture/singleColor.png.meta:
--------------------------------------------------------------------------------
1 | {
2 | "ver": "2.0.0",
3 | "uuid": "a8027877-d8d6-4645-97a0-52d4a0123dba",
4 | "type": "sprite",
5 | "wrapMode": "clamp",
6 | "filterMode": "bilinear",
7 | "subMetas": {
8 | "singleColor": {
9 | "ver": "1.0.3",
10 | "uuid": "410fb916-8721-4663-bab8-34397391ace7",
11 | "rawTextureUuid": "a8027877-d8d6-4645-97a0-52d4a0123dba",
12 | "trimType": "auto",
13 | "trimThreshold": 1,
14 | "rotated": false,
15 | "offsetX": 0,
16 | "offsetY": 0,
17 | "trimX": 0,
18 | "trimY": 0,
19 | "width": 2,
20 | "height": 2,
21 | "rawWidth": 2,
22 | "rawHeight": 2,
23 | "borderTop": 0,
24 | "borderBottom": 0,
25 | "borderLeft": 0,
26 | "borderRight": 0,
27 | "subMetas": {}
28 | }
29 | }
30 | }
--------------------------------------------------------------------------------
/assets/b3core.0.1.0module.js.meta:
--------------------------------------------------------------------------------
1 | {
2 | "ver": "1.0.5",
3 | "uuid": "cfbfe809-a627-4cf2-857f-c6fcf3ec4d87",
4 | "isPlugin": false,
5 | "loadPluginInWeb": true,
6 | "loadPluginInNative": true,
7 | "loadPluginInEditor": false,
8 | "subMetas": {}
9 | }
--------------------------------------------------------------------------------
/assets/resources.meta:
--------------------------------------------------------------------------------
1 | {
2 | "ver": "1.0.1",
3 | "uuid": "e1df5259-1f98-4c9b-be51-026f39b797a9",
4 | "isSubpackage": false,
5 | "subpackageName": "",
6 | "subMetas": {}
7 | }
--------------------------------------------------------------------------------
/assets/resources/npc3-0001.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kirikayakazuto/BehaviorTreeGame/b12ae9c4b8f472e5b9185664d519175808009e35/assets/resources/npc3-0001.png
--------------------------------------------------------------------------------
/assets/resources/npc3-0001.png.meta:
--------------------------------------------------------------------------------
1 | {
2 | "ver": "2.0.0",
3 | "uuid": "d76441c4-2315-4915-b44d-84c14aa43822",
4 | "type": "sprite",
5 | "wrapMode": "clamp",
6 | "filterMode": "bilinear",
7 | "subMetas": {
8 | "npc3-0001": {
9 | "ver": "1.0.3",
10 | "uuid": "da9c4605-989f-4b31-9394-c26561cdb679",
11 | "rawTextureUuid": "d76441c4-2315-4915-b44d-84c14aa43822",
12 | "trimType": "auto",
13 | "trimThreshold": 1,
14 | "rotated": false,
15 | "offsetX": 1,
16 | "offsetY": -14.5,
17 | "trimX": 17,
18 | "trimY": 29,
19 | "width": 32,
20 | "height": 35,
21 | "rawWidth": 64,
22 | "rawHeight": 64,
23 | "borderTop": 0,
24 | "borderBottom": 0,
25 | "borderLeft": 0,
26 | "borderRight": 0,
27 | "subMetas": {}
28 | }
29 | }
30 | }
--------------------------------------------------------------------------------
/assets/resources/player_stand1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kirikayakazuto/BehaviorTreeGame/b12ae9c4b8f472e5b9185664d519175808009e35/assets/resources/player_stand1.png
--------------------------------------------------------------------------------
/assets/resources/player_stand1.png.meta:
--------------------------------------------------------------------------------
1 | {
2 | "ver": "2.0.0",
3 | "uuid": "089033af-e12a-46e7-bc05-d0dc68b25450",
4 | "type": "sprite",
5 | "wrapMode": "clamp",
6 | "filterMode": "bilinear",
7 | "subMetas": {
8 | "player_stand1": {
9 | "ver": "1.0.3",
10 | "uuid": "4b36b831-f88f-4bbc-8d8d-d48ec9b0e228",
11 | "rawTextureUuid": "089033af-e12a-46e7-bc05-d0dc68b25450",
12 | "trimType": "auto",
13 | "trimThreshold": 1,
14 | "rotated": false,
15 | "offsetX": -0.5,
16 | "offsetY": -14.5,
17 | "trimX": 12,
18 | "trimY": 29,
19 | "width": 55,
20 | "height": 71,
21 | "rawWidth": 80,
22 | "rawHeight": 100,
23 | "borderTop": 0,
24 | "borderBottom": 0,
25 | "borderLeft": 0,
26 | "borderRight": 0,
27 | "subMetas": {}
28 | }
29 | }
30 | }
--------------------------------------------------------------------------------
/jsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "es6",
4 | "module": "commonjs",
5 | "experimentalDecorators": true
6 | },
7 | "exclude": [
8 | "node_modules",
9 | ".vscode",
10 | "library",
11 | "local",
12 | "settings",
13 | "temp"
14 | ]
15 | }
--------------------------------------------------------------------------------
/packages/behaviortree-editor/bt-inspector.js:
--------------------------------------------------------------------------------
1 | Vue.component('foobar-inspector', {
2 | template: `
3 |