├── .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 | 编辑 4 | `, 5 | 6 | props: { 7 | target: { 8 | twoWay: true, 9 | type: Object, 10 | }, 11 | }, 12 | 13 | methods: { 14 | openBTEditor:function(){ 15 | Editor.Ipc.sendToMain('behaviortree-editor:re-open-by-comp',{uuid:this.target.__scriptAsset.value.uuid,name:this.target.name.value}); 16 | } 17 | } 18 | }); -------------------------------------------------------------------------------- /packages/behaviortree-editor/main.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | let reEditing = false; 3 | let reSaving = false; 4 | let reEditingModelString = null; 5 | let reEditingUuid = null; 6 | let reEditingName = null; 7 | 8 | module.exports = { 9 | load () { 10 | // 当 package 被正确加载的时候执行 11 | //console.log("behaviortree-editor loaded"); 12 | }, 13 | 14 | unload () { 15 | // 当 package 被正确卸载的时候执行 16 | //console.log("behaviortree-editor unloaded"); 17 | }, 18 | 19 | messages: { 20 | 'test' (e,arg){ 21 | Editor.log(arg); 22 | Editor.log(Editor.metas); 23 | }, 24 | 25 | 're-open-by-comp' (e,arg) { 26 | if(reEditing){ 27 | Editor.Dialog.messageBox ({ 28 | type:"none", 29 | buttons: ["shut up"], 30 | title:"tips", 31 | message: "you are locked in re-editing mode.", 32 | detail:"leave the re-editing mode and try again. maybe you should save first." 33 | },function(){}); 34 | 35 | return}; 36 | reEditing = true; 37 | Editor.Panel.open("behaviortree-editor"); 38 | //Editor.Ipc.sendToPanel('behaviortree-editor','load-data',); 39 | //Editor.log(arg.uuid); 40 | Editor.Ipc.sendToMain("asset-db:query-path-by-uuid",arg.uuid,function(e,result){ 41 | //Editor.log(e); 42 | //Editor.log(result); 43 | let fs_handler = require('fs'); 44 | fs_handler.readFile(result, "utf-8", function(err, data) { 45 | //Editor.log(data); 46 | let modelString= data.match(/\/\/#########################################.*#############################################/)[0].replace(/#*/g,"").replace(/^\/\//,""); 47 | reEditingModelString = modelString; 48 | reEditingUuid = arg.uuid; 49 | reEditingName = arg.name; 50 | //Editor.log(reEditingName); 51 | //Editor.log(modelData); 52 | //Editor.Ipc.sendToPanel("behaviortree-editor","re-modify-by-comp",{modelString:modelString,uuid:arg.uuid}); 53 | //require('electron').ipcMain.send('behaviortree-editor:re-modify-by-comp',{modelString:modelString,uuid:arg.uuid}); 54 | //Editor.log(Editor.Ipc); 55 | }); 56 | }); 57 | }, 58 | 'load-data-of-comp' (e,arg){ 59 | if(!reEditing){Editor.Dialog.messageBox ({ 60 | type:"none", 61 | buttons: ["shut up"], 62 | title:"tips", 63 | message: "you are not in re-editing mode", 64 | detail:"you can enter the re-editing mode from behaviortree-Component." 65 | },function(){}); 66 | e.reply(null,{error: true}); 67 | }else{ 68 | if(reSaving){Editor.log(Editor.Dialog.messageBox ({ 69 | type:"none", 70 | buttons: ["shut up"], 71 | title:"tips", 72 | message: "please wait the temp saving", 73 | detail:"after saving, you can load from lasteat saved data if in re-editing mode." 74 | },function(){}));e.reply(null,{error:true})} 75 | else{ 76 | e.reply(null,{error: false, reEditingModelString:reEditingModelString, reEditingName: reEditingName}); 77 | } 78 | } 79 | 80 | }, 81 | 'leave-re-editing-mode' (e){ 82 | reEditing = false; 83 | Editor.log(Editor.Dialog.messageBox ({ 84 | type:"none", 85 | buttons: ["shut up"], 86 | title:"tips", 87 | message: "you leave re-editing mode", 88 | detail:"in new mode the file would saved as default way.and just close the edit-panel would not leave re-editing mode." 89 | },function(){}));e.reply(null,{error:true}) 90 | e.reply(null,{}); 91 | }, 92 | 93 | 'open' () { 94 | Editor.Panel.open("behaviortree-editor"); 95 | }, 96 | 'receive-json' (e,arg) { 97 | let modelAsObj = arg; 98 | //console.log(modelAsObj); 99 | let nodeDataArray = modelAsObj.nodeDataArray; 100 | 101 | let getNodeByType = function(type){ 102 | for(let node of nodeDataArray){ 103 | if(node.type == type){ 104 | return node; 105 | } 106 | } 107 | }; 108 | 109 | let getNodesByParentKey = function(key){ 110 | let nodes = []; 111 | for(let node of nodeDataArray){ 112 | if(node.parent!== undefined && node.parent == key){ 113 | nodes.push(node); 114 | } 115 | } 116 | return nodes; 117 | }; 118 | 119 | let orderFromTopToDown = function(a,b){ 120 | let ay = a.loc.split(" ")[1]; 121 | let by = b.loc.split(" ")[1]; 122 | //Editor.log(ay,by,(ay - by) | 0); 123 | return (ay - by) | 0; 124 | } 125 | 126 | let rootNode = getNodeByType("Root"); 127 | 128 | let generateTreeLayerString = function(parentNode,childNodes){ 129 | let children = []; 130 | for(let childNode of childNodes){ 131 | if(childNode.name == childNode.type){ 132 | children.push("new b3." + childNode.type + "(" + "##key" + childNode.key +"##" +")"); 133 | }else{ 134 | children.push("new " + childNode.name + "(" +"##key" + childNode.key +"##"+ ")"); 135 | } 136 | // if(childNode.parameter){ 137 | // console.log(childNode.parameter.replace(/\"/g,"'")); 138 | // } 139 | } 140 | let tempParameter = JSON.parse(parentNode.parameter); 141 | let resultObj = {}; 142 | resultObj.parameter = parentNode.parameter.replace(/"/g,"'"); 143 | switch(parentNode.type){ 144 | case 'Limiter': 145 | case 'RepeaterUntilFailure': 146 | case 'RepeaterUntilSuccess': 147 | case 'Repeater':{resultObj.maxLoop = tempParameter.maxLoop; break;} 148 | } 149 | switch(parentNode.type){ 150 | case 'MaxTime': {resultObj.maxTime = rtempParameter.maxTime; break;} 151 | } 152 | switch(parentNode.type){ 153 | case 'Wait': {resultObj.milliseconds = tempParameter.milliseconds; break;} 154 | } 155 | switch(parentNode.catagory){ 156 | case 'Composite': {resultObj.children = children; break;} 157 | } 158 | switch(parentNode.catagory){ 159 | case 'Decorator': {resultObj.child = children[0]; break;} 160 | } 161 | 162 | return JSON.stringify(resultObj); 163 | } 164 | 165 | 166 | 167 | let nodeQuene = []; 168 | nodeQuene.push(rootNode); 169 | let finalString = "new b3.Sequence(##key" + rootNode.key +"##)"; 170 | while(nodeQuene.length != 0){ 171 | let node = nodeQuene.shift(); 172 | let childNodes = getNodesByParentKey(node.key); 173 | let orderedChildNodes = childNodes.sort(orderFromTopToDown); 174 | nodeQuene = nodeQuene.concat(orderedChildNodes); 175 | let gString = generateTreeLayerString(node,orderedChildNodes); 176 | finalString = finalString.replace("##key"+node.key+"##",gString); 177 | } 178 | //console.log(finalString); 179 | 180 | let customNodeString = "let self = this;\n"; 181 | let hasGeneratedNodes = []; 182 | for(let node of nodeDataArray){ 183 | if(hasGeneratedNodes[node.name] != undefined){continue;} 184 | if(node.name != node.type || node.type == 'Action' || node.type == 'Condition' || node.type == 'Composite' || node.type == 'Decorator'){ 185 | hasGeneratedNodes[node.name] = true; 186 | customNodeString += "let "+node.name+" = b3.Class(b3."+node.type+");\n" + 187 | node.name+".prototype.name = '"+node.name+"';\n" + 188 | node.name+".prototype.__"+node.catagory+"_initialize = "+node.name+".prototype.initialize;\n" + 189 | node.name+".prototype.initialize = function(settings){\n" + 190 | " settings = settings || {};\n" + 191 | " this.__"+node.catagory+"_initialize();\n" + 192 | " this.parameter = settings.parameter;\n"; 193 | switch(node.type){ 194 | case 'Limiter': 195 | case 'RepeaterUntilFailure': 196 | case 'RepeaterUntilSuccess': 197 | case 'Repeater':{customNodeString += "this.maxLoop = settings.maxLoop;\n";break;} 198 | } 199 | switch(node.type){ 200 | case 'MaxTime': {customNodeString += "this.maxTime = settings.maxTime;\n";break;} 201 | } 202 | switch(node.type){ 203 | case 'Wait': {customNodeString += "this.milliseconds = settings.milliseconds;\n";break;} 204 | } 205 | switch(node.catagory){ 206 | case 'Composite': {customNodeString += "this.children = settings.children;\n";break;} 207 | } 208 | switch(node.catagory){ 209 | case 'Decorator': {customNodeString += "this.child = settings.child;\n";break;} 210 | } 211 | customNodeString += "}\n" + 212 | node.name+".prototype.enter = function(tick){\n" + 213 | " return self.getComponent('"+node.name+"').enter(tick,b3,this);\n" + 214 | "}\n" + 215 | node.name+".prototype.open = function(tick) {\n" + 216 | " return self.getComponent('"+node.name+"').open(tick,b3,this);\n" + 217 | "}\n" + 218 | node.name+".prototype.tick = function(tick) {\n" + 219 | " return self.getComponent('"+node.name+"').tick(tick,b3,this);\n" + 220 | "}\n" + 221 | node.name+".prototype.close = function(tick) {\n" + 222 | " return self.getComponent('"+node.name+"').close(tick,b3,this);\n" + 223 | "}\n" + 224 | node.name+".prototype.exit = function(tick) {\n" + 225 | " return self.getComponent('"+node.name+"').exit(tick,b3,this);\n" + 226 | "}\n"; 227 | } 228 | } 229 | let tipsString = "//Don't modify this if you want to re-modify the behaviortree in the future\n"; 230 | let modelString = "//#########################################" + JSON.stringify(modelAsObj) + "#############################################\n"; 231 | 232 | let mainString = tipsString + 233 | modelString + 234 | "\n" + 235 | "\n" + 236 | "cc.Class({\n" + 237 | "extends: cc.Component,\n" + 238 | "editor: {\n" + 239 | "inspector: 'packages://behaviortree-editor/bt-inspector.js'\n"+ 240 | "},\n" + 241 | "properties: {\n" + 242 | "},\n" + 243 | "onLoad: function () {\n" + 244 | "let b3 = require('b3core.0.1.0module');\n"+ 245 | customNodeString + 246 | "let tree = new b3.BehaviorTree();\n"+ 247 | "tree.root = " + finalString.replace(/"/g,"") + ";\n"+ 248 | "this.tree = tree;\n"+ 249 | "this.blackboard = new b3.Blackboard();\n" + 250 | "this.b3 = b3;\n" + 251 | "},\n" + 252 | "tick: function(target){\n"+ 253 | "let t = {};\n" + 254 | "if(target != undefined){t = target;}\n" + 255 | "this.tree.tick(t,this.blackboard)\n" + 256 | "}" + 257 | "});\n"; 258 | 259 | //console.log(mainString); 260 | let fs_handler = require("fs"); 261 | if(reEditing){ 262 | Editor.Ipc.sendToMain("asset-db:query-url-by-uuid",reEditingUuid,function(e,result){ 263 | fs_handler.writeFileSync(Editor.url(result),mainString); 264 | Editor.Ipc.sendToMain("asset-db:refresh",result,function(err,results){ 265 | reSaving = true; 266 | fs_handler.readFile(Editor.url(result), "utf-8", function(err, data) { 267 | 268 | let modelString= data.match(/\/\/#########################################.*#############################################/)[0].replace(/#*/g,"").replace(/^\/\//,""); 269 | reEditingModelString = modelString; 270 | reSaving = false; 271 | Editor.log(Editor.Dialog.messageBox ({ 272 | type:"none", 273 | buttons: ["shut up"], 274 | title:"tips", 275 | message: "file of re-edit saved", 276 | detail:"you could see something blink blink in assetdb. take care of the component name." 277 | },function(){})); 278 | }); 279 | }); 280 | }); 281 | } 282 | else{ 283 | //生成行为树组件脚本 284 | fs_handler.writeFileSync(Editor.url("db://assets/BehaviorTree.js"),mainString); 285 | Editor.Ipc.sendToMain("asset-db:refresh","db://assets/BehaviorTree.js",function(err,results){ 286 | Editor.log(Editor.Dialog.messageBox ({ 287 | type:"none", 288 | buttons: ["shut up"], 289 | title:"tips", 290 | message: "file of new saved", 291 | detail:"you could see something new(maybe) in assetdb. take care of the component name." 292 | },function(){})); 293 | }); 294 | } 295 | 296 | }, 297 | 298 | 'add-lib' () { 299 | let fs_handler = require("fs"); 300 | fs_handler.writeFileSync(Editor.url("db://assets/b3core.0.1.0module.js"), fs_handler.readFileSync(Editor.url("packages://behaviortree-editor/b3core.0.1.0module.js"))); 301 | Editor.Ipc.sendToMain("asset-db:refresh","db://assets/b3core.0.1.0module.js",function(err,results){ 302 | Editor.log(Editor.Dialog.messageBox ({ 303 | type:"none", 304 | buttons: ["shut up"], 305 | title:"tips", 306 | message: "behaviortree lib added", 307 | detail:"even though the lib name is ugly, but don't modify it please." 308 | },function(){})); 309 | }); 310 | }, 311 | 312 | 'generate-tree-node-template' (){ 313 | let mainString = "cc.Class({\n" + 314 | "extends: cc.Component,\n" + 315 | "\n" + 316 | "properties: {\n" + 317 | "\n" + 318 | "},\n" + 319 | "\n" + 320 | "\n" + 321 | "onLoad: function () {\n" + 322 | "\n" + 323 | "},\n" + 324 | "enter: function(tick,b3,treeNode){\n" + 325 | "\n" + 326 | "},\n"+ 327 | "open: function(tick,b3,treeNode){\n" + 328 | "\n"+ 329 | "},\n" + 330 | "tick: function(tick,b3,treeNode){\n" + 331 | "\n"+ 332 | "},\n" + 333 | "close: function(tick,b3,treeNode){\n" + 334 | "\n" + 335 | "},\n" + 336 | "exit: function(tick,b3,treeNode){\n" + 337 | "\n" + 338 | "},\n" + 339 | "\n" + 340 | "});\n"; 341 | 342 | let fs_handler = require("fs"); 343 | fs_handler.writeFileSync(Editor.url("db://assets/TreeNodeTemplate.js"), mainString); 344 | Editor.Ipc.sendToMain("asset-db:refresh","db://assets/TreeNodeTemplate.js",function(err,results){ 345 | Editor.log(Editor.Dialog.messageBox ({ 346 | type:"none", 347 | buttons: ["shut up"], 348 | title:"tips", 349 | message: "treenode code template generated", 350 | detail:"look more about the code and the src in behaviortree lib to get more tips" 351 | },function(){})); 352 | }); 353 | }, 354 | 355 | }, 356 | 357 | }; -------------------------------------------------------------------------------- /packages/behaviortree-editor/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "behaviortree-editor", 3 | "version": "0.0.1", 4 | "description": "行为树可视化编辑器", 5 | "author": "Cocos Creator", 6 | "main": "main.js", 7 | "main-menu": { 8 | "bt-editor/open": { 9 | "message": "behaviortree-editor:open" 10 | } 11 | }, 12 | "panel": { 13 | "main": "panel/index.html", 14 | "type": "simple", 15 | "title": "behaviortree-editor", 16 | "width": "100%", 17 | "height": "100%" 18 | } 19 | } -------------------------------------------------------------------------------- /packages/behaviortree-editor/panel/icon/base.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /packages/behaviortree-editor/panel/icon/customaction.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /packages/behaviortree-editor/panel/icon/customcomposite.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /packages/behaviortree-editor/panel/icon/customcondition.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /packages/behaviortree-editor/panel/icon/customdecorator.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /packages/behaviortree-editor/panel/icon/error.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /packages/behaviortree-editor/panel/icon/failer.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /packages/behaviortree-editor/panel/icon/inverter.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /packages/behaviortree-editor/panel/icon/limit.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /packages/behaviortree-editor/panel/icon/maxtime.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /packages/behaviortree-editor/panel/icon/menpriority.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /packages/behaviortree-editor/panel/icon/mensequence.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /packages/behaviortree-editor/panel/icon/priority.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /packages/behaviortree-editor/panel/icon/repeat.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /packages/behaviortree-editor/panel/icon/repeatuntilfailure.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /packages/behaviortree-editor/panel/icon/repeatuntilsuccess.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /packages/behaviortree-editor/panel/icon/root.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /packages/behaviortree-editor/panel/icon/running.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /packages/behaviortree-editor/panel/icon/sequence.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /packages/behaviortree-editor/panel/icon/succeeder.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /packages/behaviortree-editor/panel/icon/wait.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /packages/behaviortree-editor/panel/img/jsoneditor-icons.svg: -------------------------------------------------------------------------------- 1 | 2 | 16 | JSON Editor Icons 18 | 20 | 21 | 23 | image/svg+xml 24 | 26 | JSON Editor Icons 27 | 28 | 29 | 30 | 32 | 56 | 60 | 61 | 62 | 64 | 71 | 78 | 85 | 92 | 99 | 102 | 109 | 116 | 117 | 121 | 128 | 135 | 136 | 143 | 150 | 157 | 159 | 166 | 173 | 180 | 181 | 184 | 191 | 198 | 205 | 206 | 213 | 219 | 225 | 232 | 237 | 242 | 249 | 255 | 260 | 267 | 273 | 279 | 280 | 287 | 294 | 301 | 308 | 315 | 319 | 326 | 333 | 334 | 338 | 345 | 352 | 353 | 360 | 367 | 374 | 377 | 384 | 391 | 398 | 399 | 402 | 409 | 416 | 423 | 424 | 431 | 437 | 443 | 450 | 455 | 460 | 467 | 473 | 478 | 485 | 491 | 497 | 504 | 511 | 518 | 525 | 532 | 539 | 546 | 552 | 560 | 566 | 572 | 579 | 587 | 595 | 602 | 609 | 616 | 623 | 630 | 637 | 644 | 651 | 657 | 665 | 671 | 677 | 684 | 692 | 700 | 707 | 714 | 721 | 728 | 735 | 742 | 749 | 756 | 761 | 766 | 771 | 777 | 783 | 788 | 793 | 798 | 803 | 808 | 824 | 841 | 858 | 875 | 881 | 887 | 893 | 894 | -------------------------------------------------------------------------------- /packages/behaviortree-editor/panel/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |

5 |
6 |
7 |
8 |
9 | 10 | 11 | 12 | 13 | 14 |
15 |
16 | 17 | 18 | 19 | 269 | 270 | -------------------------------------------------------------------------------- /packages/behaviortree-editor/panel/jsoneditor.css: -------------------------------------------------------------------------------- 1 | /* reset styling (prevent conflicts with bootstrap, materialize.css, etc.) */ 2 | 3 | div.jsoneditor .jsoneditor-search input { 4 | height: auto; 5 | border: inherit; 6 | } 7 | 8 | div.jsoneditor .jsoneditor-search input:focus { 9 | border: none !important; 10 | box-shadow: none !important; 11 | } 12 | 13 | div.jsoneditor table { 14 | border-collapse: collapse; 15 | width: auto; 16 | } 17 | 18 | div.jsoneditor td, 19 | div.jsoneditor th { 20 | padding: 0; 21 | display: table-cell; 22 | text-align: left; 23 | vertical-align: inherit; 24 | border-radius: inherit; 25 | } 26 | 27 | 28 | div.jsoneditor-field, 29 | div.jsoneditor-value, 30 | div.jsoneditor-readonly { 31 | border: 1px solid transparent; 32 | min-height: 16px; 33 | min-width: 32px; 34 | padding: 2px; 35 | margin: 1px; 36 | word-wrap: break-word; 37 | float: left; 38 | } 39 | 40 | /* adjust margin of p elements inside editable divs, needed for Opera, IE */ 41 | 42 | div.jsoneditor-field p, 43 | div.jsoneditor-value p { 44 | margin: 0; 45 | } 46 | 47 | div.jsoneditor-value { 48 | word-break: break-word; 49 | } 50 | 51 | div.jsoneditor-readonly { 52 | min-width: 16px; 53 | color: gray; 54 | } 55 | 56 | div.jsoneditor-empty { 57 | border-color: lightgray; 58 | border-style: dashed; 59 | border-radius: 2px; 60 | } 61 | 62 | div.jsoneditor-field.jsoneditor-empty::after, 63 | div.jsoneditor-value.jsoneditor-empty::after { 64 | pointer-events: none; 65 | color: lightgray; 66 | font-size: 8pt; 67 | } 68 | 69 | div.jsoneditor-field.jsoneditor-empty::after { 70 | content: "field"; 71 | } 72 | 73 | div.jsoneditor-value.jsoneditor-empty::after { 74 | content: "value"; 75 | } 76 | 77 | div.jsoneditor-value.jsoneditor-url, 78 | a.jsoneditor-value.jsoneditor-url { 79 | color: green; 80 | text-decoration: underline; 81 | } 82 | 83 | a.jsoneditor-value.jsoneditor-url { 84 | display: inline-block; 85 | padding: 2px; 86 | margin: 2px; 87 | } 88 | 89 | a.jsoneditor-value.jsoneditor-url:hover, 90 | a.jsoneditor-value.jsoneditor-url:focus { 91 | color: #ee422e; 92 | } 93 | 94 | div.jsoneditor td.jsoneditor-separator { 95 | padding: 3px 0; 96 | vertical-align: top; 97 | color: gray; 98 | } 99 | 100 | div.jsoneditor-field[contenteditable=true]:focus, 101 | div.jsoneditor-field[contenteditable=true]:hover, 102 | div.jsoneditor-value[contenteditable=true]:focus, 103 | div.jsoneditor-value[contenteditable=true]:hover, 104 | div.jsoneditor-field.jsoneditor-highlight, 105 | div.jsoneditor-value.jsoneditor-highlight { 106 | background-color: #FFFFAB; 107 | border: 1px solid yellow; 108 | border-radius: 2px; 109 | } 110 | 111 | div.jsoneditor-field.jsoneditor-highlight-active, 112 | div.jsoneditor-field.jsoneditor-highlight-active:focus, 113 | div.jsoneditor-field.jsoneditor-highlight-active:hover, 114 | div.jsoneditor-value.jsoneditor-highlight-active, 115 | div.jsoneditor-value.jsoneditor-highlight-active:focus, 116 | div.jsoneditor-value.jsoneditor-highlight-active:hover { 117 | background-color: #ffee00; 118 | border: 1px solid #ffc700; 119 | border-radius: 2px; 120 | } 121 | 122 | div.jsoneditor-value.jsoneditor-string { 123 | color: #008000; 124 | } 125 | 126 | div.jsoneditor-value.jsoneditor-object, 127 | div.jsoneditor-value.jsoneditor-array { 128 | min-width: 16px; 129 | color: #808080; 130 | } 131 | 132 | div.jsoneditor-value.jsoneditor-number { 133 | color: #ee422e; 134 | } 135 | 136 | div.jsoneditor-value.jsoneditor-boolean { 137 | color: #ff8c00; 138 | } 139 | 140 | div.jsoneditor-value.jsoneditor-null { 141 | color: #004ED0; 142 | } 143 | 144 | div.jsoneditor-value.jsoneditor-invalid { 145 | color: #000000; 146 | } 147 | 148 | div.jsoneditor-tree button { 149 | width: 24px; 150 | height: 24px; 151 | padding: 0; 152 | margin: 0; 153 | border: none; 154 | cursor: pointer; 155 | background: transparent url("img/jsoneditor-icons.svg"); 156 | } 157 | 158 | div.jsoneditor-mode-view tr.jsoneditor-expandable td.jsoneditor-tree, 159 | div.jsoneditor-mode-form tr.jsoneditor-expandable td.jsoneditor-tree { 160 | cursor: pointer; 161 | } 162 | 163 | div.jsoneditor-tree button.jsoneditor-collapsed { 164 | background-position: 0 -48px; 165 | } 166 | 167 | div.jsoneditor-tree button.jsoneditor-expanded { 168 | background-position: 0 -72px; 169 | } 170 | 171 | div.jsoneditor-tree button.jsoneditor-contextmenu { 172 | background-position: -48px -72px; 173 | } 174 | 175 | div.jsoneditor-tree button.jsoneditor-contextmenu:hover, 176 | div.jsoneditor-tree button.jsoneditor-contextmenu:focus, 177 | div.jsoneditor-tree button.jsoneditor-contextmenu.jsoneditor-selected, 178 | tr.jsoneditor-selected.jsoneditor-first button.jsoneditor-contextmenu { 179 | background-position: -48px -48px; 180 | } 181 | 182 | div.jsoneditor-tree *:focus { 183 | outline: none; 184 | } 185 | 186 | div.jsoneditor-tree button:focus { 187 | /* TODO: nice outline for buttons with focus 188 | outline: #97B0F8 solid 2px; 189 | box-shadow: 0 0 8px #97B0F8; 190 | */ 191 | background-color: #f5f5f5; 192 | outline: #e5e5e5 solid 1px; 193 | } 194 | 195 | div.jsoneditor-tree button.jsoneditor-invisible { 196 | visibility: hidden; 197 | background: none; 198 | } 199 | 200 | div.jsoneditor { 201 | color: #1A1A1A; 202 | border: 1px solid #3883fa; 203 | -moz-box-sizing: border-box; 204 | -webkit-box-sizing: border-box; 205 | box-sizing: border-box; 206 | width: 100%; 207 | height: 100%; 208 | overflow: hidden; 209 | position: relative; 210 | padding: 0; 211 | line-height: 100%; 212 | } 213 | 214 | div.jsoneditor-tree table.jsoneditor-tree { 215 | border-collapse: collapse; 216 | border-spacing: 0; 217 | width: 100%; 218 | margin: 0; 219 | } 220 | 221 | div.jsoneditor-outer { 222 | position: static; 223 | width: 100%; 224 | height: 100%; 225 | margin: -35px 0 0 0; 226 | padding: 35px 0 0 0; 227 | -moz-box-sizing: border-box; 228 | -webkit-box-sizing: border-box; 229 | box-sizing: border-box; 230 | } 231 | 232 | textarea.jsoneditor-text, 233 | .ace-jsoneditor { 234 | min-height: 150px; 235 | } 236 | 237 | div.jsoneditor-tree { 238 | width: 100%; 239 | height: 100%; 240 | position: relative; 241 | overflow: auto; 242 | } 243 | 244 | textarea.jsoneditor-text { 245 | width: 100%; 246 | height: 100%; 247 | margin: 0; 248 | -moz-box-sizing: border-box; 249 | -webkit-box-sizing: border-box; 250 | box-sizing: border-box; 251 | outline-width: 0; 252 | border: none; 253 | background-color: white; 254 | resize: none; 255 | } 256 | 257 | tr.jsoneditor-highlight, 258 | tr.jsoneditor-selected { 259 | background-color: #e6e6e6; 260 | } 261 | 262 | tr.jsoneditor-selected button.jsoneditor-dragarea, 263 | tr.jsoneditor-selected button.jsoneditor-contextmenu { 264 | visibility: hidden; 265 | } 266 | 267 | tr.jsoneditor-selected.jsoneditor-first button.jsoneditor-dragarea, 268 | tr.jsoneditor-selected.jsoneditor-first button.jsoneditor-contextmenu { 269 | visibility: visible; 270 | } 271 | 272 | div.jsoneditor-tree button.jsoneditor-dragarea { 273 | background: url("img/jsoneditor-icons.svg") -72px -72px; 274 | cursor: move; 275 | } 276 | 277 | div.jsoneditor-tree button.jsoneditor-dragarea:hover, 278 | div.jsoneditor-tree button.jsoneditor-dragarea:focus, 279 | tr.jsoneditor-selected.jsoneditor-first button.jsoneditor-dragarea { 280 | background-position: -72px -48px; 281 | } 282 | 283 | div.jsoneditor tr, 284 | div.jsoneditor th, 285 | div.jsoneditor td { 286 | padding: 0; 287 | margin: 0; 288 | } 289 | 290 | div.jsoneditor td { 291 | vertical-align: top; 292 | } 293 | 294 | div.jsoneditor td.jsoneditor-tree { 295 | vertical-align: top; 296 | } 297 | 298 | div.jsoneditor-field, 299 | div.jsoneditor-value, 300 | div.jsoneditor td, 301 | div.jsoneditor th, 302 | div.jsoneditor textarea, 303 | .jsoneditor-schema-error { 304 | font-family: droid sans mono, consolas, monospace, courier new, courier, sans-serif; 305 | font-size: 10pt; 306 | color: #1A1A1A; 307 | } 308 | 309 | /* popover */ 310 | 311 | .jsoneditor-schema-error { 312 | cursor: default; 313 | display: inline-block; 314 | /*font-family: arial, sans-serif;*/ 315 | height: 24px; 316 | line-height: 24px; 317 | position: relative; 318 | text-align: center; 319 | width: 24px; 320 | } 321 | 322 | div.jsoneditor-tree .jsoneditor-schema-error { 323 | width: 24px; 324 | height: 24px; 325 | padding: 0; 326 | margin: 0 4px 0 0; 327 | background: url("img/jsoneditor-icons.svg") -168px -48px; 328 | } 329 | 330 | .jsoneditor-schema-error .jsoneditor-popover { 331 | background-color: #4c4c4c; 332 | border-radius: 3px; 333 | box-shadow: 0 0 5px rgba(0,0,0,0.4); 334 | color: #fff; 335 | display: none; 336 | padding: 7px 10px; 337 | position: absolute; 338 | width: 200px; 339 | z-index: 4; 340 | } 341 | 342 | .jsoneditor-schema-error .jsoneditor-popover.jsoneditor-above { 343 | bottom: 32px; 344 | left: -98px; 345 | } 346 | 347 | .jsoneditor-schema-error .jsoneditor-popover.jsoneditor-below { 348 | top: 32px; 349 | left: -98px; 350 | } 351 | 352 | .jsoneditor-schema-error .jsoneditor-popover.jsoneditor-left { 353 | top: -7px; 354 | right: 32px; 355 | } 356 | 357 | .jsoneditor-schema-error .jsoneditor-popover.jsoneditor-right { 358 | top: -7px; 359 | left: 32px; 360 | } 361 | 362 | .jsoneditor-schema-error .jsoneditor-popover:before { 363 | border-right: 7px solid transparent; 364 | border-left: 7px solid transparent; 365 | content: ''; 366 | display: block; 367 | left: 50%; 368 | margin-left: -7px; 369 | position: absolute; 370 | } 371 | 372 | .jsoneditor-schema-error .jsoneditor-popover.jsoneditor-above:before { 373 | border-top: 7px solid #4c4c4c; 374 | bottom: -7px; 375 | } 376 | 377 | .jsoneditor-schema-error .jsoneditor-popover.jsoneditor-below:before { 378 | border-bottom: 7px solid #4c4c4c; 379 | top: -7px; 380 | } 381 | 382 | .jsoneditor-schema-error .jsoneditor-popover.jsoneditor-left:before { 383 | border-left: 7px solid #4c4c4c; 384 | border-top: 7px solid transparent; 385 | border-bottom: 7px solid transparent; 386 | content: ''; 387 | top: 19px; 388 | right: -14px; 389 | left: inherit; 390 | margin-left: inherit; 391 | margin-top: -7px; 392 | position: absolute; 393 | } 394 | 395 | .jsoneditor-schema-error .jsoneditor-popover.jsoneditor-right:before { 396 | border-right: 7px solid #4c4c4c; 397 | border-top: 7px solid transparent; 398 | border-bottom: 7px solid transparent; 399 | content: ''; 400 | top: 19px; 401 | left: -14px; 402 | margin-left: inherit; 403 | margin-top: -7px; 404 | position: absolute; 405 | } 406 | 407 | .jsoneditor-schema-error:hover .jsoneditor-popover, 408 | .jsoneditor-schema-error:focus .jsoneditor-popover { 409 | display: block; 410 | -webkit-animation: fade-in .3s linear 1, move-up .3s linear 1; 411 | -moz-animation: fade-in .3s linear 1, move-up .3s linear 1; 412 | -ms-animation: fade-in .3s linear 1, move-up .3s linear 1; 413 | } 414 | 415 | @-webkit-keyframes fade-in { 416 | from { 417 | opacity: 0; 418 | } 419 | 420 | to { 421 | opacity: 1; 422 | } 423 | } 424 | 425 | @-moz-keyframes fade-in { 426 | from { 427 | opacity: 0; 428 | } 429 | 430 | to { 431 | opacity: 1; 432 | } 433 | } 434 | 435 | @-ms-keyframes fade-in { 436 | from { 437 | opacity: 0; 438 | } 439 | 440 | to { 441 | opacity: 1; 442 | } 443 | } 444 | 445 | /*@-webkit-keyframes move-up {*/ 446 | 447 | /*from { bottom: 24px; }*/ 448 | 449 | /*to { bottom: 32px; }*/ 450 | 451 | /*}*/ 452 | 453 | /*@-moz-keyframes move-up {*/ 454 | 455 | /*from { bottom: 24px; }*/ 456 | 457 | /*to { bottom: 32px; }*/ 458 | 459 | /*}*/ 460 | 461 | /*@-ms-keyframes move-up {*/ 462 | 463 | /*from { bottom: 24px; }*/ 464 | 465 | /*to { bottom: 32px; }*/ 466 | 467 | /*}*/ 468 | 469 | /* JSON schema errors displayed at the bottom of the editor in mode text and code */ 470 | 471 | .jsoneditor .jsoneditor-text-errors { 472 | width: 100%; 473 | border-collapse: collapse; 474 | background-color: #ffef8b; 475 | border-top: 1px solid #ffd700; 476 | } 477 | 478 | .jsoneditor .jsoneditor-text-errors td { 479 | padding: 3px 6px; 480 | vertical-align: middle; 481 | } 482 | 483 | .jsoneditor-text-errors .jsoneditor-schema-error { 484 | border: none; 485 | width: 24px; 486 | height: 24px; 487 | padding: 0; 488 | margin: 0 4px 0 0; 489 | background: url("img/jsoneditor-icons.svg") -168px -48px; 490 | } 491 | /* ContextMenu - main menu */ 492 | 493 | div.jsoneditor-contextmenu-root { 494 | position: relative; 495 | width: 0; 496 | height: 0; 497 | } 498 | 499 | div.jsoneditor-contextmenu { 500 | position: absolute; 501 | box-sizing: content-box; 502 | z-index: 99999; 503 | } 504 | 505 | div.jsoneditor-contextmenu ul, 506 | div.jsoneditor-contextmenu li { 507 | box-sizing: content-box; 508 | } 509 | 510 | div.jsoneditor-contextmenu ul { 511 | position: relative; 512 | left: 0; 513 | top: 0; 514 | width: 124px; 515 | background: white; 516 | border: 1px solid #d3d3d3; 517 | box-shadow: 2px 2px 12px rgba(128, 128, 128, 0.3); 518 | list-style: none; 519 | margin: 0; 520 | padding: 0; 521 | } 522 | 523 | div.jsoneditor-contextmenu ul li button { 524 | padding: 0; 525 | margin: 0; 526 | width: 124px; 527 | height: 24px; 528 | border: none; 529 | cursor: pointer; 530 | color: #4d4d4d; 531 | background: transparent; 532 | font-size: 10pt; 533 | font-family: arial, sans-serif; 534 | box-sizing: border-box; 535 | line-height: 26px; 536 | text-align: left; 537 | } 538 | 539 | /* Fix button padding in firefox */ 540 | 541 | div.jsoneditor-contextmenu ul li button::-moz-focus-inner { 542 | padding: 0; 543 | border: 0; 544 | } 545 | 546 | div.jsoneditor-contextmenu ul li button:hover, 547 | div.jsoneditor-contextmenu ul li button:focus { 548 | color: #1a1a1a; 549 | background-color: #f5f5f5; 550 | outline: none; 551 | } 552 | 553 | div.jsoneditor-contextmenu ul li button.jsoneditor-default { 554 | width: 92px; 555 | } 556 | 557 | div.jsoneditor-contextmenu ul li button.jsoneditor-expand { 558 | float: right; 559 | width: 32px; 560 | height: 24px; 561 | border-left: 1px solid #e5e5e5; 562 | } 563 | 564 | div.jsoneditor-contextmenu div.jsoneditor-icon { 565 | float: left; 566 | width: 24px; 567 | height: 24px; 568 | border: none; 569 | padding: 0; 570 | margin: 0; 571 | background-image: url("img/jsoneditor-icons.svg"); 572 | } 573 | 574 | div.jsoneditor-contextmenu ul li button div.jsoneditor-expand { 575 | float: right; 576 | width: 24px; 577 | height: 24px; 578 | padding: 0; 579 | margin: 0 4px 0 0; 580 | background: url("img/jsoneditor-icons.svg") 0 -72px; 581 | opacity: 0.4; 582 | } 583 | 584 | div.jsoneditor-contextmenu ul li button:hover div.jsoneditor-expand, 585 | div.jsoneditor-contextmenu ul li button:focus div.jsoneditor-expand, 586 | div.jsoneditor-contextmenu ul li.jsoneditor-selected div.jsoneditor-expand, 587 | div.jsoneditor-contextmenu ul li button.jsoneditor-expand:hover div.jsoneditor-expand, 588 | div.jsoneditor-contextmenu ul li button.jsoneditor-expand:focus div.jsoneditor-expand { 589 | opacity: 1; 590 | } 591 | 592 | div.jsoneditor-contextmenu div.jsoneditor-separator { 593 | height: 0; 594 | border-top: 1px solid #e5e5e5; 595 | padding-top: 5px; 596 | margin-top: 5px; 597 | } 598 | 599 | div.jsoneditor-contextmenu button.jsoneditor-remove > div.jsoneditor-icon { 600 | background-position: -24px -24px; 601 | } 602 | 603 | div.jsoneditor-contextmenu button.jsoneditor-remove:hover > div.jsoneditor-icon, 604 | div.jsoneditor-contextmenu button.jsoneditor-remove:focus > div.jsoneditor-icon { 605 | background-position: -24px 0; 606 | } 607 | 608 | div.jsoneditor-contextmenu button.jsoneditor-append > div.jsoneditor-icon { 609 | background-position: 0 -24px; 610 | } 611 | 612 | div.jsoneditor-contextmenu button.jsoneditor-append:hover > div.jsoneditor-icon, 613 | div.jsoneditor-contextmenu button.jsoneditor-append:focus > div.jsoneditor-icon { 614 | background-position: 0 0; 615 | } 616 | 617 | div.jsoneditor-contextmenu button.jsoneditor-insert > div.jsoneditor-icon { 618 | background-position: 0 -24px; 619 | } 620 | 621 | div.jsoneditor-contextmenu button.jsoneditor-insert:hover > div.jsoneditor-icon, 622 | div.jsoneditor-contextmenu button.jsoneditor-insert:focus > div.jsoneditor-icon { 623 | background-position: 0 0; 624 | } 625 | 626 | div.jsoneditor-contextmenu button.jsoneditor-duplicate > div.jsoneditor-icon { 627 | background-position: -48px -24px; 628 | } 629 | 630 | div.jsoneditor-contextmenu button.jsoneditor-duplicate:hover > div.jsoneditor-icon, 631 | div.jsoneditor-contextmenu button.jsoneditor-duplicate:focus > div.jsoneditor-icon { 632 | background-position: -48px 0; 633 | } 634 | 635 | div.jsoneditor-contextmenu button.jsoneditor-sort-asc > div.jsoneditor-icon { 636 | background-position: -168px -24px; 637 | } 638 | 639 | div.jsoneditor-contextmenu button.jsoneditor-sort-asc:hover > div.jsoneditor-icon, 640 | div.jsoneditor-contextmenu button.jsoneditor-sort-asc:focus > div.jsoneditor-icon { 641 | background-position: -168px 0; 642 | } 643 | 644 | div.jsoneditor-contextmenu button.jsoneditor-sort-desc > div.jsoneditor-icon { 645 | background-position: -192px -24px; 646 | } 647 | 648 | div.jsoneditor-contextmenu button.jsoneditor-sort-desc:hover > div.jsoneditor-icon, 649 | div.jsoneditor-contextmenu button.jsoneditor-sort-desc:focus > div.jsoneditor-icon { 650 | background-position: -192px 0; 651 | } 652 | 653 | /* ContextMenu - sub menu */ 654 | 655 | div.jsoneditor-contextmenu ul li button.jsoneditor-selected, 656 | div.jsoneditor-contextmenu ul li button.jsoneditor-selected:hover, 657 | div.jsoneditor-contextmenu ul li button.jsoneditor-selected:focus { 658 | color: white; 659 | background-color: #ee422e; 660 | } 661 | 662 | div.jsoneditor-contextmenu ul li { 663 | overflow: hidden; 664 | } 665 | 666 | div.jsoneditor-contextmenu ul li ul { 667 | display: none; 668 | position: relative; 669 | left: -10px; 670 | top: 0; 671 | border: none; 672 | box-shadow: inset 0 0 10px rgba(128, 128, 128, 0.5); 673 | padding: 0 10px; 674 | /* TODO: transition is not supported on IE8-9 */ 675 | -webkit-transition: all 0.3s ease-out; 676 | -moz-transition: all 0.3s ease-out; 677 | -o-transition: all 0.3s ease-out; 678 | transition: all 0.3s ease-out; 679 | } 680 | 681 | 682 | 683 | div.jsoneditor-contextmenu ul li ul li button { 684 | padding-left: 24px; 685 | animation: all ease-in-out 1s; 686 | } 687 | 688 | div.jsoneditor-contextmenu ul li ul li button:hover, 689 | div.jsoneditor-contextmenu ul li ul li button:focus { 690 | background-color: #f5f5f5; 691 | } 692 | 693 | div.jsoneditor-contextmenu button.jsoneditor-type-string > div.jsoneditor-icon { 694 | background-position: -144px -24px; 695 | } 696 | 697 | div.jsoneditor-contextmenu button.jsoneditor-type-string:hover > div.jsoneditor-icon, 698 | div.jsoneditor-contextmenu button.jsoneditor-type-string:focus > div.jsoneditor-icon, 699 | div.jsoneditor-contextmenu button.jsoneditor-type-string.jsoneditor-selected > div.jsoneditor-icon { 700 | background-position: -144px 0; 701 | } 702 | 703 | div.jsoneditor-contextmenu button.jsoneditor-type-auto > div.jsoneditor-icon { 704 | background-position: -120px -24px; 705 | } 706 | 707 | div.jsoneditor-contextmenu button.jsoneditor-type-auto:hover > div.jsoneditor-icon, 708 | div.jsoneditor-contextmenu button.jsoneditor-type-auto:focus > div.jsoneditor-icon, 709 | div.jsoneditor-contextmenu button.jsoneditor-type-auto.jsoneditor-selected > div.jsoneditor-icon { 710 | background-position: -120px 0; 711 | } 712 | 713 | div.jsoneditor-contextmenu button.jsoneditor-type-object > div.jsoneditor-icon { 714 | background-position: -72px -24px; 715 | } 716 | 717 | div.jsoneditor-contextmenu button.jsoneditor-type-object:hover > div.jsoneditor-icon, 718 | div.jsoneditor-contextmenu button.jsoneditor-type-object:focus > div.jsoneditor-icon, 719 | div.jsoneditor-contextmenu button.jsoneditor-type-object.jsoneditor-selected > div.jsoneditor-icon { 720 | background-position: -72px 0; 721 | } 722 | 723 | div.jsoneditor-contextmenu button.jsoneditor-type-array > div.jsoneditor-icon { 724 | background-position: -96px -24px; 725 | } 726 | 727 | div.jsoneditor-contextmenu button.jsoneditor-type-array:hover > div.jsoneditor-icon, 728 | div.jsoneditor-contextmenu button.jsoneditor-type-array:focus > div.jsoneditor-icon, 729 | div.jsoneditor-contextmenu button.jsoneditor-type-array.jsoneditor-selected > div.jsoneditor-icon { 730 | background-position: -96px 0; 731 | } 732 | 733 | div.jsoneditor-contextmenu button.jsoneditor-type-modes > div.jsoneditor-icon { 734 | background-image: none; 735 | width: 6px; 736 | } 737 | div.jsoneditor-menu { 738 | width: 100%; 739 | height: 35px; 740 | padding: 2px; 741 | margin: 0; 742 | -moz-box-sizing: border-box; 743 | -webkit-box-sizing: border-box; 744 | box-sizing: border-box; 745 | color: white; 746 | background-color: #CCCCCC; 747 | border-bottom: 1px solid #CCCCCC; 748 | } 749 | 750 | div.jsoneditor-menu > button, 751 | div.jsoneditor-menu > div.jsoneditor-modes > button { 752 | width: 26px; 753 | height: 26px; 754 | margin: 2px; 755 | padding: 0; 756 | border-radius: 2px; 757 | border: 1px solid transparent; 758 | background: transparent url("img/jsoneditor-icons.svg"); 759 | color: white; 760 | opacity: 0.8; 761 | font-family: arial, sans-serif; 762 | font-size: 10pt; 763 | float: left; 764 | } 765 | 766 | div.jsoneditor-menu > button:hover, 767 | div.jsoneditor-menu > div.jsoneditor-modes > button:hover { 768 | background-color: rgba(255,255,255,0.2); 769 | border: 1px solid rgba(255,255,255,0.4); 770 | } 771 | 772 | div.jsoneditor-menu > button:focus, 773 | div.jsoneditor-menu > button:active, 774 | div.jsoneditor-menu > div.jsoneditor-modes > button:focus, 775 | div.jsoneditor-menu > div.jsoneditor-modes > button:active { 776 | background-color: rgba(255,255,255,0.3); 777 | } 778 | 779 | div.jsoneditor-menu > button:disabled, 780 | div.jsoneditor-menu > div.jsoneditor-modes > button:disabled { 781 | opacity: 0.5; 782 | } 783 | 784 | div.jsoneditor-menu > button.jsoneditor-collapse-all { 785 | background-position: 0 -96px; 786 | } 787 | 788 | div.jsoneditor-menu > button.jsoneditor-expand-all { 789 | background-position: 0 -120px; 790 | } 791 | 792 | div.jsoneditor-menu > button.jsoneditor-undo { 793 | background-position: -24px -96px; 794 | } 795 | 796 | div.jsoneditor-menu > button.jsoneditor-undo:disabled { 797 | background-position: -24px -120px; 798 | } 799 | 800 | div.jsoneditor-menu > button.jsoneditor-redo { 801 | background-position: -48px -96px; 802 | } 803 | 804 | div.jsoneditor-menu > button.jsoneditor-redo:disabled { 805 | background-position: -48px -120px; 806 | } 807 | 808 | div.jsoneditor-menu > button.jsoneditor-compact { 809 | background-position: -72px -96px; 810 | } 811 | 812 | div.jsoneditor-menu > button.jsoneditor-format { 813 | background-position: -72px -120px; 814 | } 815 | 816 | div.jsoneditor-menu > div.jsoneditor-modes { 817 | display: inline-block; 818 | float: left; 819 | } 820 | 821 | div.jsoneditor-menu > div.jsoneditor-modes > button { 822 | background-image: none; 823 | width: auto; 824 | padding-left: 6px; 825 | padding-right: 6px; 826 | } 827 | 828 | div.jsoneditor-menu > button.jsoneditor-separator, 829 | div.jsoneditor-menu > div.jsoneditor-modes > button.jsoneditor-separator { 830 | margin-left: 10px; 831 | } 832 | 833 | div.jsoneditor-menu a { 834 | font-family: arial, sans-serif; 835 | font-size: 10pt; 836 | color: white; 837 | opacity: 0.8; 838 | vertical-align: middle; 839 | } 840 | 841 | div.jsoneditor-menu a:hover { 842 | opacity: 1; 843 | } 844 | 845 | div.jsoneditor-menu a.jsoneditor-poweredBy { 846 | font-size: 8pt; 847 | position: absolute; 848 | right: 0; 849 | top: 0; 850 | padding: 10px; 851 | } 852 | table.jsoneditor-search input, 853 | table.jsoneditor-search div.jsoneditor-results { 854 | font-family: arial, sans-serif; 855 | font-size: 10pt; 856 | color: #1A1A1A; 857 | background: transparent; 858 | /* For Firefox */ 859 | } 860 | 861 | table.jsoneditor-search div.jsoneditor-results { 862 | color: white; 863 | padding-right: 5px; 864 | line-height: 24px; 865 | } 866 | 867 | table.jsoneditor-search { 868 | position: absolute; 869 | right: 4px; 870 | top: 4px; 871 | border-collapse: collapse; 872 | border-spacing: 0; 873 | } 874 | 875 | table.jsoneditor-search div.jsoneditor-frame { 876 | border: 1px solid transparent; 877 | background-color: white; 878 | padding: 0 2px; 879 | margin: 0; 880 | } 881 | 882 | table.jsoneditor-search div.jsoneditor-frame table { 883 | border-collapse: collapse; 884 | } 885 | 886 | table.jsoneditor-search input { 887 | width: 120px; 888 | border: none; 889 | outline: none; 890 | margin: 1px; 891 | line-height: 20px; 892 | } 893 | 894 | table.jsoneditor-search button { 895 | width: 16px; 896 | height: 24px; 897 | padding: 0; 898 | margin: 0; 899 | border: none; 900 | background: url("img/jsoneditor-icons.svg"); 901 | vertical-align: top; 902 | } 903 | 904 | table.jsoneditor-search button:hover { 905 | background-color: transparent; 906 | } 907 | 908 | table.jsoneditor-search button.jsoneditor-refresh { 909 | width: 18px; 910 | background-position: -99px -73px; 911 | } 912 | 913 | table.jsoneditor-search button.jsoneditor-next { 914 | cursor: pointer; 915 | background-position: -124px -73px; 916 | } 917 | 918 | table.jsoneditor-search button.jsoneditor-next:hover { 919 | background-position: -124px -49px; 920 | } 921 | 922 | table.jsoneditor-search button.jsoneditor-previous { 923 | cursor: pointer; 924 | background-position: -148px -73px; 925 | margin-right: 2px; 926 | } 927 | 928 | table.jsoneditor-search button.jsoneditor-previous:hover { 929 | background-position: -148px -49px; 930 | } -------------------------------------------------------------------------------- /packages/behaviortree-editor/panel/node_modules/gojs/README.md: -------------------------------------------------------------------------------- 1 | GoJS, a JavaScript Library for HTML Diagrams 2 | ============================================ 3 | 4 | 5 | 6 | [GoJS](https://gojs.net) is a JavaScript and HTML5 library for creating interactive diagrams, charts, and graphs. 7 | 8 | [See GoJS Samples](https://gojs.net/latest/samples). 9 | 10 | [Get Started with GoJS](https://gojs.net/latest/learn) 11 | 12 | Read more about GoJS at [gojs.net](https://gojs.net) 13 | 14 | This repository contains both the library and the sources for all samples, extensions, and documentation. 15 | You can use the GitHub repository to quickly [search through all of the sources](https://github.com/NorthwoodsSoftware/GoJS-Samples/search?q=setDataProperty&type=Code). 16 | 17 | 18 |

Support

19 | 20 | Northwoods Software offers a month of free developer-to-developer support for GoJS to help you get started on your project. 21 | 22 | Read and search the official GoJS forum for any topics related to your questions. 23 | 24 | Posting in the forum is the fastest and most effective way of obtaining support for any GoJS related inquiries. 25 | Please register for support at Northwoods Software's registration form before posting in the forum. 26 | 27 | For any nontechnical questions about GoJS, such as about sales or licensing, 28 | please visit Northwoods Software's contact form. 29 | 30 | 31 |

License

32 | 33 | The GoJS software license. 34 | 35 | Copyright (c) Northwoods Software Corporation -------------------------------------------------------------------------------- /packages/behaviortree-editor/panel/node_modules/gojs/bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "gojs", 3 | "description": "Interactive diagrams, charts, and graphs, such as trees, flowcharts, orgcharts, UML, BPMN, or business diagrams", 4 | "main": "release/go.js", 5 | "moduleType": [ "globals", "amd", "node" ], 6 | "license": "https://gojs.net/latest/doc/license.html", 7 | "ignore": [ "**/.*" ], 8 | "keywords": [ "diagram", "chart", "tree", "flowchart", "orgchart", "uml", "bpmn", "graphics", "editor", "inspector", "drawing", "canvas", "shape", "svg", "hierarchy", "node", "link", "group", "vertex", "edge", "connection", "port", "label", "arrowhead", "family-tree", "decision-tree", "mindmap", "tournament", "treeview", "pipe-tree", "genogram", "ivr-tree", "parse-tree", "concept-map", "euler", "visualization", "entity-relationship", "er-diagram", "friend-wheel", "radial", "graph-distances", "graph-paths", "sankey", "pert", "gantt", "timeline", "monitor", "layer", "swimlane", "spreadsheet", "virtualization", "flow", "process", "state", "sequential-function", "grafcet", "sequence", "circuit", "record", "field", "table", "dataflow", "data-flow", "planogram", "seating", "pipes", "overview", "palette", "comment", "layout", "grid-layout", "tree-layout", "force-directed", "layered", "hierarchical", "circular", "fishbone", "ishikawa", "parallel", "serpentine", "treemap", "tree-map", "freehand", "polygon", "polyline", "bezier", "panel", "view", "model", "databinding", "data-binding", "binding", "transaction", "coordinates", "subgraph", "selection", "highlight", "tooltip", "context-menu", "tool", "command", "validation", "button", "template", "legend", "grid", "printing" ], 9 | "authors": [ "Northwoods Software" ], 10 | "homepage": "https://gojs.net" 11 | } -------------------------------------------------------------------------------- /packages/behaviortree-editor/panel/node_modules/gojs/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "_args": [ 3 | [ 4 | { 5 | "raw": "gojs", 6 | "scope": null, 7 | "escapedName": "gojs", 8 | "name": "gojs", 9 | "rawSpec": "", 10 | "spec": "latest", 11 | "type": "tag" 12 | }, 13 | "C:\\Users\\Administrator\\Desktop\\test_behaviour_tree" 14 | ] 15 | ], 16 | "_cnpm_publish_time": 1487779127170, 17 | "_from": "gojs@latest", 18 | "_id": "gojs@1.7.0", 19 | "_inCache": true, 20 | "_location": "/gojs", 21 | "_nodeVersion": "5.10.1", 22 | "_npmOperationalInternal": { 23 | "host": "packages-12-west.internal.npmjs.com", 24 | "tmp": "tmp/gojs-1.7.0.tgz_1487779123549_0.9793568486347795" 25 | }, 26 | "_npmUser": { 27 | "name": "gojs", 28 | "email": "gojs@nwoods.com" 29 | }, 30 | "_npmVersion": "3.8.3", 31 | "_phantomChildren": {}, 32 | "_requested": { 33 | "raw": "gojs", 34 | "scope": null, 35 | "escapedName": "gojs", 36 | "name": "gojs", 37 | "rawSpec": "", 38 | "spec": "latest", 39 | "type": "tag" 40 | }, 41 | "_requiredBy": [ 42 | "#USER" 43 | ], 44 | "_resolved": "https://registry.npm.taobao.org/gojs/download/gojs-1.7.0.tgz", 45 | "_shasum": "78a1b2de2978fe69afe16a369e1262692ead3393", 46 | "_shrinkwrap": null, 47 | "_spec": "gojs", 48 | "_where": "C:\\Users\\Administrator\\Desktop\\test_behaviour_tree", 49 | "author": { 50 | "name": "Northwoods Software" 51 | }, 52 | "bugs": { 53 | "url": "https://forum.nwoods.com/c/gojs", 54 | "email": "gojs@nwoods.com" 55 | }, 56 | "dependencies": {}, 57 | "description": "Interactive diagrams, charts, and graphs, such as trees, flowcharts, orgcharts, UML, BPMN, or business diagrams", 58 | "devDependencies": {}, 59 | "directories": {}, 60 | "dist": { 61 | "shasum": "78a1b2de2978fe69afe16a369e1262692ead3393", 62 | "size": 6631621, 63 | "noattachment": false, 64 | "tarball": "http://registry.npm.taobao.org/gojs/download/gojs-1.7.0.tgz" 65 | }, 66 | "files": [ 67 | "package.json", 68 | "bower.json", 69 | "index.html", 70 | "README.md", 71 | "api", 72 | "assets", 73 | "doc/changelog.html", 74 | "doc/download.html", 75 | "doc/license.html", 76 | "extensions", 77 | "intro", 78 | "learn", 79 | "projects", 80 | "release/go.js", 81 | "release/go-debug.js", 82 | "release/go.d.ts", 83 | "samples" 84 | ], 85 | "homepage": "https://gojs.net", 86 | "keywords": [ 87 | "diagram", 88 | "chart", 89 | "tree", 90 | "flowchart", 91 | "orgchart", 92 | "uml", 93 | "bpmn", 94 | "graphics", 95 | "editor", 96 | "inspector", 97 | "drawing", 98 | "canvas", 99 | "shape", 100 | "svg", 101 | "hierarchy", 102 | "node", 103 | "link", 104 | "group", 105 | "vertex", 106 | "edge", 107 | "connection", 108 | "port", 109 | "label", 110 | "arrowhead", 111 | "family-tree", 112 | "decision-tree", 113 | "mindmap", 114 | "tournament", 115 | "treeview", 116 | "pipe-tree", 117 | "genogram", 118 | "ivr-tree", 119 | "parse-tree", 120 | "concept-map", 121 | "euler", 122 | "visualization", 123 | "entity-relationship", 124 | "er-diagram", 125 | "friend-wheel", 126 | "radial", 127 | "graph-distances", 128 | "graph-paths", 129 | "sankey", 130 | "pert", 131 | "gantt", 132 | "timeline", 133 | "monitor", 134 | "layer", 135 | "swimlane", 136 | "spreadsheet", 137 | "virtualization", 138 | "flow", 139 | "process", 140 | "state", 141 | "sequential-function", 142 | "grafcet", 143 | "sequence", 144 | "circuit", 145 | "record", 146 | "field", 147 | "table", 148 | "dataflow", 149 | "data-flow", 150 | "planogram", 151 | "seating", 152 | "pipes", 153 | "overview", 154 | "palette", 155 | "comment", 156 | "layout", 157 | "grid-layout", 158 | "tree-layout", 159 | "force-directed", 160 | "layered", 161 | "hierarchical", 162 | "circular", 163 | "fishbone", 164 | "ishikawa", 165 | "parallel", 166 | "serpentine", 167 | "treemap", 168 | "tree-map", 169 | "freehand", 170 | "polygon", 171 | "polyline", 172 | "bezier", 173 | "panel", 174 | "view", 175 | "model", 176 | "databinding", 177 | "data-binding", 178 | "binding", 179 | "transaction", 180 | "coordinates", 181 | "subgraph", 182 | "selection", 183 | "highlight", 184 | "tooltip", 185 | "context-menu", 186 | "tool", 187 | "command", 188 | "validation", 189 | "button", 190 | "template", 191 | "legend", 192 | "grid", 193 | "printing" 194 | ], 195 | "license": "SEE LICENSE AT https://gojs.net/latest/doc/license.html", 196 | "main": "release/go.js", 197 | "maintainers": [ 198 | { 199 | "name": "gojs", 200 | "email": "gojs@nwoods.com" 201 | }, 202 | { 203 | "name": "simonsarris", 204 | "email": "simon@nwoods.com" 205 | } 206 | ], 207 | "name": "gojs", 208 | "optionalDependencies": {}, 209 | "publish_time": 1487779127170, 210 | "readme": "ERROR: No README data found!", 211 | "repository": { 212 | "type": "git", 213 | "url": "git+https://github.com/NorthwoodsSoftware/GoJS.git" 214 | }, 215 | "scripts": {}, 216 | "typings": "release/go.d.ts", 217 | "version": "1.7.0" 218 | } 219 | -------------------------------------------------------------------------------- /project.json: -------------------------------------------------------------------------------- 1 | { 2 | "engine": "cocos2d-html5", 3 | "packages": "packages" 4 | } -------------------------------------------------------------------------------- /settings/builder.json: -------------------------------------------------------------------------------- 1 | { 2 | "excludeScenes": [], 3 | "orientation": { 4 | "landscapeLeft": true, 5 | "landscapeRight": true, 6 | "portrait": false, 7 | "upsideDown": false 8 | }, 9 | "packageName": "org.cocos2d.helloworld", 10 | "startScene": "2d2f792f-a40c-49bb-a189-ed176a246e49", 11 | "title": "hello_world", 12 | "webOrientation": "auto" 13 | } -------------------------------------------------------------------------------- /settings/builder.panel.json: -------------------------------------------------------------------------------- 1 | { 2 | "excludeScenes": [], 3 | "packageName": "org.cocos2d.helloworld", 4 | "platform": "web-mobile", 5 | "startScene": "2d2f792f-a40c-49bb-a189-ed176a246e49", 6 | "title": "HelloWorld" 7 | } -------------------------------------------------------------------------------- /settings/project.json: -------------------------------------------------------------------------------- 1 | { 2 | "collision-matrix": [ 3 | [ 4 | true 5 | ] 6 | ], 7 | "excluded-modules": [], 8 | "group-list": [ 9 | "default" 10 | ], 11 | "start-scene": "current", 12 | "design-resolution-width": 960, 13 | "design-resolution-height": 640, 14 | "fit-width": false, 15 | "fit-height": true, 16 | "use-project-simulator-setting": false, 17 | "simulator-orientation": false, 18 | "use-customize-simulator": false, 19 | "simulator-resolution": { 20 | "width": 960, 21 | "height": 640 22 | }, 23 | "cocos-analytics": { 24 | "enable": false, 25 | "appID": "13798", 26 | "appSecret": "959b3ac0037d0f3c2fdce94f8421a9b2" 27 | } 28 | } -------------------------------------------------------------------------------- /template-banner.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kirikayakazuto/BehaviorTreeGame/b12ae9c4b8f472e5b9185664d519175808009e35/template-banner.png -------------------------------------------------------------------------------- /template.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "TEMPLATES.helloworld-ts.name", 3 | "desc": "TEMPLATES.helloworld-ts.desc", 4 | "banner": "template-banner.png" 5 | } -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "module": "commonjs", 4 | "lib": [ "dom", "es5", "es2015.promise" ], 5 | "target": "es5", 6 | "allowJs": true, 7 | "experimentalDecorators": true, 8 | "skipLibCheck": true 9 | }, 10 | "exclude": [ 11 | "node_modules", 12 | "library", 13 | "local", 14 | "temp", 15 | "build", 16 | "settings" 17 | ] 18 | } 19 | --------------------------------------------------------------------------------