Best JavaScript code snippet using storybook-root
enemySpawner.js
Source:enemySpawner.js
1class EnemySpawner {2 /**3 * Can be used to spawn enemy units along either a predefined path or a manual path. Useful for debugging.4 * Can also be inserted into the game engine's gameEntities to spawn waves of enemies.5 */6 constructor(game, mapNum) {7 Object.assign(this, { game, mapNum });8 this.priority = MISCELLANEOUSPRIORITY;9 this.spawnedWanderingZombies = false;10 //An array where each index represents whether that wave has spawned in (boolean value)11 this.spawnedWaveFlags = [];12 this.paths = [];13 this.initializePaths();14 }15 //Nothing needs to be drawn for the spawner16 draw() {17 }18 drawMinimap(ctx, mmX, mmY) {19 20 }21 update() {22 //Initial zombies wandering the map23 if(!this.spawnedWanderingZombies && this.game.elapsedHour >= 0) {24 this.spawnWanderingZombies();25 this.spawnedWanderingZombies = true;26 }27 switch(this.mapNum) {28 //Map 129 case 1:30 this.initializeZombieWaveFlags(4);31 this.map1ZombieSpawn();32 break;33 case 2:34 this.initializeZombieWaveFlags(5);35 this.map2ZombieSpawn();36 break;37 case 3:38 this.initializeZombieWaveFlags(6);39 this.map3ZombieSpawn();40 break;41 }42 }43 initializeZombieWaveFlags(numWaves) {44 for(let i = 0; i < numWaves; i++) {45 this.spawnedWaveFlags.push(false);46 }47 }48 initializePaths() {49 switch(this.mapNum) {50 case 1:51 //0 Upper path52 this.paths.push({ 53 startX : 39, startY : -1, path : [54 { x: 39, y: 7 }, 55 { x: 33, y: 7 }, 56 { x: 33, y: 16 },57 { x: 36, y: 16 }, 58 { x: 36, y: 22 }, 59 { x: 18, y: 22 },60 { x: 18, y: 35 },61 { x: 28, y: 35 }62 ]63 });64 //1 lower path65 this.paths.push({ 66 startX : 25, startY : 51, path : [67 { x: 25, y: 48 },68 { x: 22, y: 48 },69 { x: 22, y: 42 },70 { x: 28, y: 42 },71 { x: 28, y: 35 }72 ]});73 break;74 case 2:75 //0 Upper left76 this.paths.push({ 77 startX : 7, startY : -1, path : [78 { x: 7, y: 14 }, 79 { x: 10, y: 14 }, 80 { x: 10, y: 30 },81 { x: 21, y: 30 }82 ]83 });84 //1 Upper right85 this.paths.push({ 86 startX : 39, startY : -1, path : [87 { x: 39, y: 9 }, 88 { x: 36, y: 9 }, 89 { x: 36, y: 20 },90 { x: 33, y: 20 },91 { x: 33, y: 34 },92 { x: 21, y: 34 },93 { x: 21, y: 30 },94 ]95 });96 //2 Right up97 this.paths.push({ 98 startX : 50, startY : 14, path : [99 { x: 30, y: 14 }, 100 { x: 30, y: 11 }, 101 { x: 21, y: 11 },102 { x: 21, y: 30 }103 ]104 });105 //3 Right down106 this.paths.push({ 107 startX : 50, startY : 31, path : [108 { x: 33, y: 31 }, 109 { x: 33, y: 34 }, 110 { x: 21, y: 34 },111 { x: 21, y: 30 }112 ]113 });114 //4 Bottom right115 this.paths.push({ 116 startX : 30, startY : 50, path : [117 { x: 30, y: 40 }, 118 { x: 27, y: 40 }, 119 { x: 27, y: 34 },120 { x: 21, y: 34 },121 { x: 21, y: 30 }122 ]123 });124 //5 Bottom left125 this.paths.push({ 126 startX : 13, startY : 50, path : [127 { x: 13, y: 39 }, 128 { x: 16, y: 39 }, 129 { x: 16, y: 30 },130 { x: 21, y: 30 }131 ]132 });133 //6 Left down134 this.paths.push({ 135 startX : -1, startY : 28, path : [136 { x: 10, y: 28 }, 137 { x: 10, y: 30 }, 138 { x: 21, y: 30 }139 ]140 });141 break;142 case 3:143 //0 Far left144 this.paths.push({ 145 startX : 18, startY : -1, path : [146 { x: 18, y: 10 }, 147 { x: 12, y: 10 }, 148 { x: 12, y: 21 },149 { x: 3, y: 21 },150 { x: 3, y: 35 },151 { x: 21, y: 35 },152 { x: 21, y: 26 },153 { x: 24, y: 26 },154 { x: 24, y: 21 }155 ]156 });157 //1 Middle left158 this.paths.push({ 159 startX : 21, startY : -1, path : [160 { x: 21, y: 10 }, 161 { x: 12, y: 10 }, 162 { x: 12, y: 21 },163 { x: 24, y: 21 }164 ]165 });166 //2 Middle167 this.paths.push({ 168 startX : 24, startY : -1, path : [169 { x: 24, y: 10 }, 170 { x: 33, y: 10 }, 171 { x: 33, y: 16 },172 { x: 43, y: 16 },173 { x: 43, y: 19 },174 { x: 46, y: 19 },175 { x: 46, y: 26 },176 { x: 35, y: 26 },177 { x: 35, y: 21 },178 { x: 24, y: 21 },179 ]180 });181 //3 Middle right182 this.paths.push({ 183 startX : 27, startY : -1, path : [184 { x: 27, y: 10 }, 185 { x: 33, y: 10 }, 186 { x: 33, y: 16 },187 { x: 43, y: 16 },188 { x: 43, y: 19 },189 { x: 46, y: 19 },190 { x: 46, y: 26 },191 { x: 24, y: 26 },192 { x: 24, y: 21 },193 ]194 });195 //4 Far right196 this.paths.push({ 197 startX : 30, startY : -1, path : [198 { x: 30, y: 10 }, 199 { x: 33, y: 10 }, 200 { x: 33, y: 16 },201 { x: 43, y: 16 },202 { x: 43, y: 19 },203 { x: 46, y: 19 },204 { x: 46, y: 29 },205 { x: 33, y: 29 },206 { x: 33, y: 35 },207 { x: 21, y: 35 },208 { x: 21, y: 26 },209 { x: 24, y: 26 },210 { x: 24, y: 21 }211 ]212 });213 break;214 }215 }216 spawnWanderingZombies() {217 switch(this.mapNum) {218 case 1:219 //Open space upper left corner220 this.spawnEnemy(INFECTEDUNIT, 12, 5, [{ x: 12, y: 6 }])221 this.spawnEnemy(INFECTEDUNIT, 15, 4, [{ x: 16, y: 4 }])222 //Spawn zombies near upper left mine223 this.spawnEnemy(INFECTEDUNIT, 10, 16, [{ x: 10, y: 17 }])224 this.spawnEnemy(INFECTEDUNIT, 9, 14, [{ x: 9, y: 15 }])225 this.spawnEnemy(INFECTEDUNIT, 6, 16, [{ x: 6, y: 17 }])226 //Spawn zombies near upper middle part of map227 this.spawnEnemy(INFECTEDUNIT, 25, 14, [{ x: 25, y: 15 }])228 //Spawn zombies near upper right part of map229 this.spawnEnemy(INFECTEDUNIT, 42, 11, [{ x: 43, y: 11 }])230 //Spawn zombies near middle right mine231 this.spawnEnemy(INFECTEDUNIT, 40, 19, [{ x: 40, y: 20 }])232 this.spawnEnemy(INFECTEDUNIT, 43, 21, [{ x: 43, y: 22 }])233 this.spawnEnemy(INFECTEDUNIT, 43, 21, [{ x: 43, y: 22 }])234 //Spawn zombies near bottom left mine235 // this.spawnEnemy(INFECTEDUNIT, 10, 40, [{ x: 10, y: 41 }])236 // this.spawnEnemy(INFECTEDUNIT, 9, 39, [{ x: 8, y: 38 }])237 this.spawnEnemy(INFECTEDHARPY, 4, 44, [{ x: 5, y: 44 }])238 this.spawnEnemy(INFECTEDHARPY, 4, 42, [{ x: 5, y: 42 }])239 this.spawnEnemy(INFECTEDVENOM, 4, 43, [{ x: 5, y: 43 }])240 // this.spawnEnemy(INFECTEDUNIT, 10, 32, [{ x: 11, y: 32 }])241 // this.spawnEnemy(INFECTEDUNIT, 12, 29, [{ x: 12, y: 28 }])242 // Testing:243 /*this.spawnEnemy(INFECTEDUNIT, 18, 40, [{x: 19, y:40}])244 this.spawnEnemy(INFECTEDVENOM, 18, 36, [{x: 19, y:36}])245 this.spawnEnemy(INFECTEDHARPY, 18, 32, [{x: 19, y:32}])246 this.spawnEnemy(INFECTEDCHUBBY, 18, 28, [{x: 19, y:28}])*/247 //Location for test zombies248 this.spawnEnemy(INFECTEDUNIT, 23, 23, [{ x: 23, y: 24 }])249 break;250 case 2:251 //Upper left corner252 this.spawnEnemy(INFECTEDUNIT, 5, 6, [{ x: 5, y: 7 }])253 //Upper left corner near ores254 this.spawnEnemy(INFECTEDVENOM, 11, 13, [{ x: 11, y: 14 }])255 this.spawnEnemy(INFECTEDVENOM, 13, 13, [{ x: 13, y: 14 }])256 //Middle upper left corner near ores257 this.spawnEnemy(INFECTEDUNIT, 6, 20, [{ x: 7, y: 20 }])258 this.spawnEnemy(INFECTEDUNIT, 4, 24, [{ x: 4, y: 25 }])259 //Center upper woods260 this.spawnEnemy(INFECTEDVENOM, 24, 5, [{ x: 24, y: 6 }])261 this.spawnEnemy(INFECTEDCHUBBY, 24, 6, [{ x: 24, y: 7 }])262 //Center ore deposit263 this.spawnEnemy(INFECTEDUNIT, 20, 19, [{ x: 20, y: 20 }])264 this.spawnEnemy(INFECTEDUNIT, 25, 20, [{ x: 25, y: 21 }])265 //Bottom left266 this.spawnEnemy(INFECTEDUNIT, 4, 30, [{ x: 5, y: 30 }])267 this.spawnEnemy(INFECTEDUNIT, 7, 33, [{ x: 7, y: 34 }])268 this.spawnEnemy(INFECTEDUNIT, 7, 38, [{ x: 8, y: 38 }])269 this.spawnEnemy(INFECTEDVENOM, 7, 39, [{ x: 8, y: 39 }])270 //Bottom right (ores)271 this.spawnEnemy(INFECTEDCHUBBY, 41, 28, [{ x: 40, y: 28 }])272 this.spawnEnemy(INFECTEDUNIT, 42, 29, [{ x: 42, y: 30 }])273 this.spawnEnemy(INFECTEDUNIT, 37, 26, [{ x: 37, y: 25 }])274 //Upper right275 this.spawnEnemy(INFECTEDUNIT, 37, 10, [{ x: 38, y: 10 }])276 this.spawnEnemy(INFECTEDUNIT, 38, 12, [{ x: 38, y: 13 }])277 this.spawnEnemy(INFECTEDUNIT, 42, 13, [{ x: 42, y: 14 }])278 this.spawnEnemy(INFECTEDUNIT, 40, 18, [{ x: 41, y: 17 }])279 break;280 case 3:281 //Upper left282 this.spawnEnemy(INFECTEDHARPY, 5, 13, [{ x: 5, y: 14 }])283 this.spawnEnemy(INFECTEDHARPY, 6, 12, [{ x: 6, y: 13 }])284 this.spawnEnemy(INFECTEDHARPY, 6, 13, [{ x: 6, y: 14 }])285 this.spawnEnemy(INFECTEDHARPY, 7, 12, [{ x: 7, y: 13 }])286 this.spawnEnemy(INFECTEDHARPY, 7, 13, [{ x: 7, y: 14 }])287 //Left ore deposit288 this.spawnEnemy(INFECTEDUNIT, 5, 23, [{ x: 5, y: 22 }]) 289 this.spawnEnemy(INFECTEDUNIT, 12, 31, [{ x: 13, y: 32 }]) 290 this.spawnEnemy(INFECTEDVENOM, 7, 32, [{ x: 8, y: 32 }])291 this.spawnEnemy(INFECTEDVENOM, 7, 33, [{ x: 8, y: 33 }]) 292 //Scattered throughout bottom (called from left to right)293 this.spawnEnemy(INFECTEDUNIT, 3, 39, [{ x: 4, y: 39 }])294 this.spawnEnemy(INFECTEDUNIT, 7, 40, [{ x: 8, y: 39 }])295 this.spawnEnemy(INFECTEDVENOM, 10, 42, [{ x: 10, y: 41 }])296 this.spawnEnemy(INFECTEDUNIT, 12, 40, [{ x: 12, y: 39 }])297 this.spawnEnemy(INFECTEDCHUBBY, 14, 42, [{ x: 13, y: 41 }])298 this.spawnEnemy(INFECTEDUNIT, 15, 37, [{ x: 15, y: 38 }])299 this.spawnEnemy(INFECTEDUNIT, 21, 40, [{ x: 20, y: 40 }])300 this.spawnEnemy(INFECTEDUNIT, 25, 39, [{ x: 26, y: 38 }])301 this.spawnEnemy(INFECTEDVENOM, 29, 43, [{ x: 29, y: 42 }])302 this.spawnEnemy(INFECTEDUNIT, 33, 38, [{ x: 33, y: 39 }])303 //Right ore deposit304 this.spawnEnemy(INFECTEDUNIT, 42, 22, [{ x: 42, y: 23 }]) 305 this.spawnEnemy(INFECTEDVENOM, 43, 22, [{ x: 43, y: 23 }]) 306 this.spawnEnemy(INFECTEDUNIT, 44, 22, [{ x: 44, y: 23 }]) 307 //Bottom right brown square308 this.spawnEnemy(INFECTEDCHUBBY, 41, 35, [{ x: 41, y: 36 }]) 309 this.spawnEnemy(INFECTEDVENOM, 41, 36, [{ x: 42, y: 36 }]) 310 this.spawnEnemy(INFECTEDVENOM, 41, 36, [{ x: 41, y: 37 }]) 311 this.spawnEnemy(INFECTEDVENOM, 41, 36, [{ x: 40, y: 36 }]) 312 this.spawnEnemy(INFECTEDVENOM, 41, 36, [{ x: 41, y: 35 }]) 313 //Upper right314 this.spawnEnemy(INFECTEDHARPY, 35, 10, [{ x: 35, y: 11 }])315 this.spawnEnemy(INFECTEDHARPY, 36, 10, [{ x: 36, y: 11 }])316 this.spawnEnemy(INFECTEDHARPY, 37, 10, [{ x: 37, y: 11 }])317 }318 }319 320 /**321 * Spawns an Enemy on a random path along the railroads.322 * @param {entity} id The type of you unit you want to spawn. ENTITIES.INFECTEDUNIT = InfectedUnit, etc.323 */324 spawnEnemyPrewrittenPath(id) {325 let roll = Math.random(); 326 let step = roll / this.paths.length;327 for(let i = 1; i <= this.paths.length; i++) {328 if(roll < i * step) {329 this.spawnEnemyPrewrittenPath(id, i);330 return;331 }332 }333 //In case of weird rounding issues334 this.spawnEnemyPrewrittenPath(id, this.paths.length);335 }336 /**337 * Spawns an Enemy that travels a prewritten path specified by the pathNum parameter.338 * @param {entity} id The type of you unit you want to spawn. ENTITIES.INFECTEDUNIT = InfectedUnit, etc.339 * @param {integer} pathNum Path to travel on this map. 1 = Path goes from TOP towards town center, 2 = Path goes from BOTTOM towards town center340 */341 spawnEnemyPrewrittenPath(id, pathNum) {342 if(pathNum < 0 || pathNum > this.paths.length - 1) {343 console.log("Invalid path length.")344 }345 this.spawnEnemy(id, this.paths[pathNum].startX, this.paths[pathNum].startY, this.copyPath(this.paths[pathNum].path));346 }347 /**348 * Spawns an Enemy that travels along a manual path provided.349 * @param {entity} id The type of you unit you want to spawn. ENTITIES.INFECTEDUNIT = InfectedUnit, etc.350 * @param {integer} pathStartX X spawn coordinate.351 * @param {integer} pathStartY Y spawn coordinate.352 * @param {array} path A manual path to travel. ex. [ { x: 28, y: 42 }, { x: 22, y: 42 } ]353 */354 spawnEnemy(id, pathStartX, pathStartY, path) {355 this.game.addEntity(new ENTITIES[id](this.game, pathStartX, pathStartY, path));356 // switch(id) {357 // case INFECTEDUNIT:358 // this.game.addEntity(new InfectedUnit(this.game, pathStartX, pathStartY, path));359 // break;360 // case INFECTEDVENOM:361 // this.game.addEntity(new InfectedVenom(this.game, pathStartX, pathStartY, path));362 // break;363 // case INFECTEDHARPY:364 // this.game.addEntity(new InfectedHarpy(this.game, pathStartX, pathStartY, path));365 // break;366 // case INFECTEDCHUBBY:367 // this.game.addEntity(new InfectedChubby(this.game, pathStartX, pathStartY, path));368 // break;369 // default:370 // console.log("Id doesn't match any existing unit.");371 // }372 }373 map1ZombieSpawn() {374 switch(true) {375 //Wave 1376 case !this.spawnedWaveFlags[0] && this.game.elapsedDay >= 1:377 //Path 1378 for (var i = 0; i < 2; i++) {379 this.game.addEntity(new InfectedUnit(this.game, this.paths[0].startX, this.paths[0].startY + (i * -1), this.copyPath(this.paths[0].path)));380 }381 //Path 2382 for (var i = 0; i < 3; i++) {383 this.game.addEntity(new InfectedUnit(this.game, this.paths[1].startX, this.paths[1].startY + (i * 1), this.copyPath(this.paths[1].path)));384 }385 this.spawnedWaveFlags[0] = true;386 break;387 //Wave 2388 case !this.spawnedWaveFlags[1] && this.game.elapsedDay >= 2 && this.game.elapsedHour >= 12:389 //Path 1390 for (var i = 0; i < 4; i++) {391 this.game.addEntity(new InfectedUnit(this.game, this.paths[0].startX, this.paths[0].startY + (i * -1), this.copyPath(this.paths[0].path)));392 }393 this.game.addEntity(new InfectedVenom(this.game, this.paths[0].startX, this.paths[0].startY - 4, this.copyPath(this.paths[0].path)));394 //Path 2395 for (var i = 0; i < 2; i++) {396 this.game.addEntity(new InfectedUnit(this.game, this.paths[1].startX, this.paths[1].startY + (i * 1), this.copyPath(this.paths[1].path)));397 }398 //this.game.addEntity(new InfectedVenom(this.game, this.paths[1].startX, this.paths[1].startY + 4, this.copyPath(this.paths[1].path)));399 //this.game.addEntity(new InfectedVenom(this.game, this.paths[1].startX, this.paths[1].startY + 5, this.copyPath(this.paths[1].path)));400 this.spawnedWaveFlags[1] = true;401 break;402 //Wave 3403 case !this.spawnedWaveFlags[2] && this.game.elapsedDay >= 4:404 //Path 1405 for (var i = 0; i < 7; i++) {406 this.game.addEntity(new InfectedUnit(this.game, this.paths[0].startX, this.paths[0].startY + (i * -1), this.copyPath(this.paths[0].path)));407 }408 for (var i = 0; i < 2; i++) {409 this.game.addEntity(new InfectedVenom(this.game, this.paths[0].startX, this.paths[0].startY + (i * -2 - 3), this.copyPath(this.paths[0].path)));410 }411 for (var i = 0; i < 5; i++) {412 this.game.addEntity(new InfectedHarpy(this.game, this.paths[0].startX, this.paths[0].startY + (i * -1.5 - 0.2), this.copyPath(this.paths[0].path)));413 }414 for (var i = 0; i < 2; i++) {415 this.game.addEntity(new InfectedChubby(this.game, this.paths[0].startX, this.paths[0].startY + (i * -5), this.copyPath(this.paths[0].path)));416 }417 //Path 2418 for (var i = 0; i < 9; i++) {419 this.game.addEntity(new InfectedUnit(this.game, this.paths[1].startX, this.paths[1].startY + (i * 1), this.copyPath(this.paths[1].path)));420 }421 for (var i = 0; i < 1; i++) {422 this.game.addEntity(new InfectedVenom(this.game, this.paths[1].startX, this.paths[1].startY + (i * 2 + 1), this.copyPath(this.paths[1].path)));423 }424 for (var i = 0; i < 4; i++) {425 this.game.addEntity(new InfectedHarpy(this.game, this.paths[1].startX, this.paths[1].startY + (i * 1.5), this.copyPath(this.paths[1].path)));426 }427 for (var i = 0; i < 1; i++) {428 this.game.addEntity(new InfectedChubby(this.game, this.paths[1].startX, this.paths[1].startY + (i * 5), this.copyPath(this.paths[1].path)));429 }430 this.spawnedWaveFlags[2] = true;431 break;432 //Wave 4 433 case !this.spawnedWaveFlags[3] && this.game.elapsedDay >= 6 && this.game.elapsedHour >= 12:434 //Path 1435 for (var i = 0; i < 11; i++) {436 this.game.addEntity(new InfectedUnit(this.game, this.paths[0].startX, this.paths[0].startY + (i * -1), this.copyPath(this.paths[0].path)));437 }438 for (var i = 0; i < 4; i++) {439 this.game.addEntity(new InfectedVenom(this.game, this.paths[0].startX, this.paths[0].startY + (i * -2 - 3), this.copyPath(this.paths[0].path)));440 }441 for (var i = 0; i < 5; i++) {442 this.game.addEntity(new InfectedHarpy(this.game, this.paths[0].startX, this.paths[0].startY + (i * -2.5 - 0.5), this.copyPath(this.paths[0].path)));443 }444 for (var i = 0; i < 3; i++) {445 this.game.addEntity(new InfectedChubby(this.game, this.paths[1].startX, this.paths[1].startY + (i), this.copyPath(this.paths[1].path)));446 }447 //Path 2448 for (var i = 0; i < 6; i++) {449 this.game.addEntity(new InfectedUnit(this.game, this.paths[1].startX, this.paths[1].startY + (i * 1), this.copyPath(this.paths[1].path)));450 }451 for (var i = 0; i < 3; i++) {452 this.game.addEntity(new InfectedVenom(this.game, this.paths[1].startX, this.paths[1].startY + (i * 2 + 1), this.copyPath(this.paths[1].path)));453 }454 for (var i = 0; i < 4; i++) {455 this.game.addEntity(new InfectedHarpy(this.game, this.paths[1].startX, this.paths[1].startY + (i * 2.5 + 0.5), this.copyPath(this.paths[1].path)));456 }457 // for (var i = 0; i < 2; i++) {458 // this.game.addEntity(new InfectedChubby(this.game, this.paths[1].startX, this.paths[1].startY + (i * 32 + 5), this.copyPath(this.paths[1].path)));459 // }460 this.spawnedWaveFlags[3] = true;461 break; 462 }463 }464 map2ZombieSpawn() {465 let currentPath;466 switch(true) {467 //Wave 1468 case !this.spawnedWaveFlags[0] && this.game.elapsedDay >= 1:469 currentPath = 3;470 for (var i = 0; i < 2; i++) {471 this.game.addEntity(new InfectedUnit(this.game, this.paths[currentPath].startX + (i * 1), this.paths[currentPath].startY, this.copyPath(this.paths[currentPath].path)));472 }473 currentPath = 6;474 for (var i = 0; i < 3; i++) {475 this.game.addEntity(new InfectedUnit(this.game, this.paths[currentPath].startX + (i * -1), this.paths[currentPath].startY, this.copyPath(this.paths[currentPath].path)));476 }477 this.spawnedWaveFlags[0] = true;478 break;479 //Wave 2480 case !this.spawnedWaveFlags[1] && this.game.elapsedDay >= 2 && this.game.elapsedHour >= 12:481 currentPath = 3;482 for (var i = 0; i < 4; i++) {483 this.game.addEntity(new InfectedUnit(this.game, this.paths[currentPath].startX + (i * 1), this.paths[currentPath].startY, this.copyPath(this.paths[currentPath].path)));484 }485 for (var i = 0; i < 2; i++) {486 this.game.addEntity(new InfectedVenom(this.game, this.paths[currentPath].startX + (i * 1.5), this.paths[currentPath].startY, this.copyPath(this.paths[currentPath].path)));487 }488 currentPath = 6;489 for (var i = 0; i < 5; i++) {490 this.game.addEntity(new InfectedUnit(this.game, this.paths[currentPath].startX + (i * -1), this.paths[currentPath].startY, this.copyPath(this.paths[currentPath].path)));491 }492 for (var i = 0; i < 4; i++) {493 this.game.addEntity(new InfectedHarpy(this.game, this.paths[currentPath].startX + (i * -1), this.paths[currentPath].startY, this.copyPath(this.paths[currentPath].path)));494 }495 this.spawnedWaveFlags[1] = true;496 break;497 //Wave 3498 case !this.spawnedWaveFlags[2] && this.game.elapsedDay >= 4:499 currentPath = 0;500 for (var i = 0; i < 8; i++) {501 this.game.addEntity(new InfectedVenom(this.game, this.paths[currentPath].startX, this.paths[currentPath].startY + (i * -1), this.copyPath(this.paths[currentPath].path)));502 }503 currentPath = 3;504 for (var i = 0; i < 6; i++) {505 this.game.addEntity(new InfectedUnit(this.game, this.paths[currentPath].startX + (i * 1), this.paths[currentPath].startY, this.copyPath(this.paths[currentPath].path)));506 }507 for (var i = 0; i < 2; i++) {508 this.game.addEntity(new InfectedVenom(this.game, this.paths[currentPath].startX + (i * 1 + 0.5), this.paths[currentPath].startY, this.copyPath(this.paths[currentPath].path)));509 }510 currentPath = 4;511 for (var i = 0; i < 8; i++) {512 this.game.addEntity(new InfectedVenom(this.game, this.paths[currentPath].startX, this.paths[currentPath].startY + (i * 1.5), this.copyPath(this.paths[currentPath].path)));513 }514 currentPath = 6;515 for (var i = 0; i < 5; i++) {516 this.game.addEntity(new InfectedUnit(this.game, this.paths[currentPath].startX + (i * -1), this.paths[currentPath].startY, this.copyPath(this.paths[currentPath].path)));517 }518 for (var i = 0; i < 4; i++) {519 this.game.addEntity(new InfectedVenom(this.game, this.paths[currentPath].startX + (i * -1), this.paths[currentPath].startY, this.copyPath(this.paths[currentPath].path)));520 }521 this.spawnedWaveFlags[2] = true;522 break;523 //Wave 4 524 case !this.spawnedWaveFlags[3] && this.game.elapsedDay >= 6 && this.game.elapsedHour >= 12:525 currentPath = 0;526 for (var i = 0; i < 4; i++) {527 this.game.addEntity(new InfectedVenom(this.game, this.paths[currentPath].startX, this.paths[currentPath].startY + (i * -1 - 0.5), this.copyPath(this.paths[currentPath].path)));528 }529 for (var i = 0; i < 8; i++) {530 this.game.addEntity(new InfectedHarpy(this.game, this.paths[currentPath].startX, this.paths[currentPath].startY + (i * -1), this.copyPath(this.paths[currentPath].path)));531 }532 currentPath = 3;533 for (var i = 0; i < 4; i++) {534 this.game.addEntity(new InfectedUnit(this.game, this.paths[currentPath].startX + (i * 1), this.paths[currentPath].startY, this.copyPath(this.paths[currentPath].path)));535 }536 for (var i = 0; i < 7; i++) {537 this.game.addEntity(new InfectedVenom(this.game, this.paths[currentPath].startX + (i * 1 + 0.5), this.paths[currentPath].startY, this.copyPath(this.paths[currentPath].path)));538 }539 for (var i = 0; i < 2; i++) {540 this.game.addEntity(new InfectedChubby(this.game, this.paths[currentPath].startX + (i * 1 + 0.5), this.paths[currentPath].startY, this.copyPath(this.paths[currentPath].path)));541 }542 currentPath = 4;543 for (var i = 0; i < 8; i++) {544 this.game.addEntity(new InfectedVenom(this.game, this.paths[currentPath].startX, this.paths[currentPath].startY + (i * 1.5), this.copyPath(this.paths[currentPath].path)));545 }546 currentPath = 6;547 for (var i = 0; i < 12; i++) {548 this.game.addEntity(new InfectedUnit(this.game, this.paths[currentPath].startX + (i * -1), this.paths[currentPath].startY, this.copyPath(this.paths[currentPath].path)));549 }550 for (var i = 0; i < 5; i++) {551 this.game.addEntity(new InfectedHarpy(this.game, this.paths[currentPath].startX + (i * -1), this.paths[currentPath].startY, this.copyPath(this.paths[currentPath].path)));552 }553 for (var i = 0; i < 1; i++) {554 this.game.addEntity(new InfectedChubby(this.game, this.paths[currentPath].startX + (i * -1 - 0.5), this.paths[currentPath].startY, this.copyPath(this.paths[currentPath].path)));555 }556 this.spawnedWaveFlags[3] = true;557 break; 558 //Wave 5 559 case !this.spawnedWaveFlags[4] && this.game.elapsedDay >= 9 && this.game.elapsedHour >= 12:560 currentPath = 0;561 for (var i = 0; i < 3; i++) {562 this.game.addEntity(new InfectedUnit(this.game, this.paths[currentPath].startX, this.paths[currentPath].startY + (i * -1 - 0.5), this.copyPath(this.paths[currentPath].path)));563 }564 for (var i = 0; i < 4; i++) {565 this.game.addEntity(new InfectedVenom(this.game, this.paths[currentPath].startX, this.paths[currentPath].startY + (i * -1 - 0.5), this.copyPath(this.paths[currentPath].path)));566 }567 for (var i = 0; i < 8; i++) {568 this.game.addEntity(new InfectedHarpy(this.game, this.paths[currentPath].startX, this.paths[currentPath].startY + (i * -1), this.copyPath(this.paths[currentPath].path)));569 }570 currentPath = 1;571 for (var i = 0; i < 6; i++) {572 this.game.addEntity(new InfectedVenom(this.game, this.paths[currentPath].startX, this.paths[currentPath].startY + (i * -1 - 0.5), this.copyPath(this.paths[currentPath].path)));573 }574 currentPath = 2;575 for (var i = 0; i < 4; i++) {576 this.game.addEntity(new InfectedChubby(this.game, this.paths[currentPath].startX + (i * 1 + 0.5), this.paths[currentPath].startY, this.copyPath(this.paths[currentPath].path)));577 }578 currentPath = 3;579 for (var i = 0; i < 4; i++) {580 this.game.addEntity(new InfectedUnit(this.game, this.paths[currentPath].startX + (i * 1), this.paths[currentPath].startY, this.copyPath(this.paths[currentPath].path)));581 }582 for (var i = 0; i < 7; i++) {583 this.game.addEntity(new InfectedVenom(this.game, this.paths[currentPath].startX + (i * 1 + 0.5), this.paths[currentPath].startY, this.copyPath(this.paths[currentPath].path)));584 }585 for (var i = 0; i < 10; i++) {586 this.game.addEntity(new InfectedHarpy(this.game, this.paths[currentPath].startX + (i * 1 + 0.5), this.paths[currentPath].startY, this.copyPath(this.paths[currentPath].path)));587 }588 currentPath = 4;589 for (var i = 0; i < 6; i++) {590 this.game.addEntity(new InfectedVenom(this.game, this.paths[currentPath].startX, this.paths[currentPath].startY + (i * 1), this.copyPath(this.paths[currentPath].path)));591 }592 for (var i = 0; i < 6; i++) {593 this.game.addEntity(new InfectedVenom(this.game, this.paths[currentPath].startX, this.paths[currentPath].startY + (i * 1 + 0.5), this.copyPath(this.paths[currentPath].path)));594 }595 currentPath = 5;596 for (var i = 0; i < 8; i++) {597 this.game.addEntity(new InfectedUnit(this.game, this.paths[currentPath].startX, this.paths[currentPath].startY + (i * 1), this.copyPath(this.paths[currentPath].path)));598 }599 for (var i = 0; i < 2; i++) {600 this.game.addEntity(new InfectedVenom(this.game, this.paths[currentPath].startX, this.paths[currentPath].startY + (i * 1 + 0.5), this.copyPath(this.paths[currentPath].path)));601 }602 currentPath = 6;603 for (var i = 0; i < 7; i++) {604 this.game.addEntity(new InfectedUnit(this.game, this.paths[currentPath].startX + (i * -1), this.paths[currentPath].startY, this.copyPath(this.paths[currentPath].path)));605 }606 for (var i = 0; i < 3; i++) {607 this.game.addEntity(new InfectedChubby(this.game, this.paths[currentPath].startX + (i * -1 - 0.5), this.paths[currentPath].startY, this.copyPath(this.paths[currentPath].path)));608 }609 this.spawnedWaveFlags[4] = true;610 break; 611 }612 }613 map3ZombieSpawn() {614 let currentPath;615 switch(true) {616 //Wave 1617 case !this.spawnedWaveFlags[0] && this.game.elapsedDay >= 1 && this.game.elapsedHour >= 12:618 currentPath = 1;619 for (var i = 0; i < 3; i++) {620 this.game.addEntity(new InfectedUnit(this.game, this.paths[currentPath].startX, this.paths[currentPath].startY + (i * -1), this.copyPath(this.paths[currentPath].path)));621 }622 currentPath = 3;623 for (var i = 0; i < 2; i++) {624 this.game.addEntity(new InfectedUnit(this.game, this.paths[currentPath].startX, this.paths[currentPath].startY + (i * -1), this.copyPath(this.paths[currentPath].path)));625 }626 this.spawnedWaveFlags[0] = true;627 break;628 //Wave 2629 case !this.spawnedWaveFlags[1] && this.game.elapsedDay >= 3 && this.game.elapsedHour >= 12:630 currentPath = 0;631 for (var i = 0; i < 4; i++) {632 this.game.addEntity(new InfectedHarpy(this.game, this.paths[currentPath].startX, this.paths[currentPath].startY + (i * -1), this.copyPath(this.paths[currentPath].path)));633 }634 currentPath = 1;635 for (var i = 0; i < 4; i++) {636 this.game.addEntity(new InfectedHarpy(this.game, this.paths[currentPath].startX, this.paths[currentPath].startY + (i * -1), this.copyPath(this.paths[currentPath].path)));637 }638 currentPath = 3;639 for (var i = 0; i < 4; i++) {640 this.game.addEntity(new InfectedHarpy(this.game, this.paths[currentPath].startX, this.paths[currentPath].startY + (i * -1), this.copyPath(this.paths[currentPath].path)));641 }642 currentPath = 4;643 for (var i = 0; i < 4; i++) {644 this.game.addEntity(new InfectedHarpy(this.game, this.paths[currentPath].startX, this.paths[currentPath].startY + (i * -1), this.copyPath(this.paths[currentPath].path)));645 }646 this.spawnedWaveFlags[1] = true;647 break;648 //Wave 3649 case !this.spawnedWaveFlags[2] && this.game.elapsedDay >= 6 && this.game.elapsedHour >= 0:650 currentPath = 0;651 for (var i = 0; i < 6; i++) {652 this.game.addEntity(new InfectedUnit(this.game, this.paths[currentPath].startX, this.paths[currentPath].startY + (i * -1), this.copyPath(this.paths[currentPath].path)));653 }654 for (var i = 0; i < 3; i++) {655 this.game.addEntity(new InfectedHarpy(this.game, this.paths[currentPath].startX, this.paths[currentPath].startY + (i * -1 - 0.5), this.copyPath(this.paths[currentPath].path)));656 }657 currentPath = 1;658 for (var i = 0; i < 6; i++) {659 this.game.addEntity(new InfectedUnit(this.game, this.paths[currentPath].startX, this.paths[currentPath].startY + (i * -1), this.copyPath(this.paths[currentPath].path)));660 }661 for (var i = 0; i < 3; i++) {662 this.game.addEntity(new InfectedVenom(this.game, this.paths[currentPath].startX, this.paths[currentPath].startY + (i * -1 - 0.5), this.copyPath(this.paths[currentPath].path)));663 }664 currentPath = 2;665 for (var i = 0; i < 6; i++) {666 this.game.addEntity(new InfectedUnit(this.game, this.paths[currentPath].startX, this.paths[currentPath].startY + (i * -1), this.copyPath(this.paths[currentPath].path)));667 }668 for (var i = 0; i < 6; i++) {669 this.game.addEntity(new InfectedVenom(this.game, this.paths[currentPath].startX, this.paths[currentPath].startY + (i * -1 - 0.5), this.copyPath(this.paths[currentPath].path)));670 }671 currentPath = 3;672 for (var i = 0; i < 2; i++) {673 this.game.addEntity(new InfectedChubby(this.game, this.paths[currentPath].startX, this.paths[currentPath].startY + (i * -1), this.copyPath(this.paths[currentPath].path)));674 }675 for (var i = 0; i < 4; i++) {676 this.game.addEntity(new InfectedHarpy(this.game, this.paths[currentPath].startX, this.paths[currentPath].startY + (i * -1 - 0.5), this.copyPath(this.paths[currentPath].path)));677 }678 currentPath = 4;679 for (var i = 0; i < 12; i++) {680 this.game.addEntity(new InfectedUnit(this.game, this.paths[currentPath].startX, this.paths[currentPath].startY + (i * -1), this.copyPath(this.paths[currentPath].path)));681 }682 this.spawnedWaveFlags[2] = true;683 break;684 //Wave 4 685 case !this.spawnedWaveFlags[3] && this.game.elapsedDay >= 9 && this.game.elapsedHour >= 12:686 currentPath = 0;687 for (var i = 0; i < 8; i++) {688 this.game.addEntity(new InfectedUnit(this.game, this.paths[currentPath].startX, this.paths[currentPath].startY + (i * -1), this.copyPath(this.paths[currentPath].path)));689 }690 for (var i = 0; i < 3; i++) {691 this.game.addEntity(new InfectedVenom(this.game, this.paths[currentPath].startX, this.paths[currentPath].startY + (i * -1 - 0.5), this.copyPath(this.paths[currentPath].path)));692 }693 for (var i = 0; i < 2; i++) {694 this.game.addEntity(new InfectedChubby(this.game, this.paths[currentPath].startX, this.paths[currentPath].startY + (i * -1 - 0.5), this.copyPath(this.paths[currentPath].path)));695 }696 currentPath = 1;697 for (var i = 0; i < 8; i++) {698 this.game.addEntity(new InfectedUnit(this.game, this.paths[currentPath].startX, this.paths[currentPath].startY + (i * -1), this.copyPath(this.paths[currentPath].path)));699 }700 for (var i = 0; i < 6; i++) {701 this.game.addEntity(new InfectedHarpy(this.game, this.paths[currentPath].startX, this.paths[currentPath].startY + (i * -1 - 0.5), this.copyPath(this.paths[currentPath].path)));702 }703 currentPath = 2;704 for (var i = 0; i < 9; i++) {705 this.game.addEntity(new InfectedUnit(this.game, this.paths[currentPath].startX, this.paths[currentPath].startY + (i * -1), this.copyPath(this.paths[currentPath].path)));706 }707 for (var i = 0; i < 8; i++) {708 this.game.addEntity(new InfectedVenom(this.game, this.paths[currentPath].startX, this.paths[currentPath].startY + (i * -1 - 0.5), this.copyPath(this.paths[currentPath].path)));709 }710 currentPath = 3;711 for (var i = 0; i < 4; i++) {712 this.game.addEntity(new InfectedVenom(this.game, this.paths[currentPath].startX, this.paths[currentPath].startY + (i * -1), this.copyPath(this.paths[currentPath].path)));713 }714 for (var i = 0; i < 8; i++) {715 this.game.addEntity(new InfectedHarpy(this.game, this.paths[currentPath].startX, this.paths[currentPath].startY + (i * -1 - 0.5), this.copyPath(this.paths[currentPath].path)));716 }717 currentPath = 4;718 for (var i = 0; i < 16; i++) {719 this.game.addEntity(new InfectedUnit(this.game, this.paths[currentPath].startX, this.paths[currentPath].startY + (i * -1), this.copyPath(this.paths[currentPath].path)));720 }721 this.spawnedWaveFlags[3] = true;722 break; 723 //Wave 5 724 case !this.spawnedWaveFlags[4] && this.game.elapsedDay >= 13 && this.game.elapsedHour >= 0:725 currentPath = 0;726 for (var i = 0; i < 10; i++) {727 this.game.addEntity(new InfectedUnit(this.game, this.paths[currentPath].startX, this.paths[currentPath].startY + (i * -1), this.copyPath(this.paths[currentPath].path)));728 }729 for (var i = 0; i < 5; i++) {730 this.game.addEntity(new InfectedVenom(this.game, this.paths[currentPath].startX, this.paths[currentPath].startY + (i * -1 - 0.5), this.copyPath(this.paths[currentPath].path)));731 }732 for (var i = 0; i < 4; i++) {733 this.game.addEntity(new InfectedHarpy(this.game, this.paths[currentPath].startX, this.paths[currentPath].startY + (i * -1 - 0.5), this.copyPath(this.paths[currentPath].path)));734 }735 for (var i = 0; i < 1; i++) {736 this.game.addEntity(new InfectedChubby(this.game, this.paths[currentPath].startX, this.paths[currentPath].startY + (i * -1 - 0.5), this.copyPath(this.paths[currentPath].path)));737 }738 currentPath = 1;739 for (var i = 0; i < 8; i++) {740 this.game.addEntity(new InfectedUnit(this.game, this.paths[currentPath].startX, this.paths[currentPath].startY + (i * -1), this.copyPath(this.paths[currentPath].path)));741 }742 for (var i = 0; i < 4; i++) {743 this.game.addEntity(new InfectedVenom(this.game, this.paths[currentPath].startX, this.paths[currentPath].startY + (i * -1 - 0.5), this.copyPath(this.paths[currentPath].path)));744 }745 for (var i = 0; i < 7; i++) {746 this.game.addEntity(new InfectedHarpy(this.game, this.paths[currentPath].startX, this.paths[currentPath].startY + (i * -1 - 0.5), this.copyPath(this.paths[currentPath].path)));747 }748 for (var i = 0; i < 0; i++) {749 this.game.addEntity(new InfectedChubby(this.game, this.paths[currentPath].startX, this.paths[currentPath].startY + (i * -1 - 0.5), this.copyPath(this.paths[currentPath].path)));750 }751 currentPath = 2;752 for (var i = 0; i < 3; i++) {753 this.game.addEntity(new InfectedUnit(this.game, this.paths[currentPath].startX, this.paths[currentPath].startY + (i * -1), this.copyPath(this.paths[currentPath].path)));754 }755 for (var i = 0; i < 10; i++) {756 this.game.addEntity(new InfectedVenom(this.game, this.paths[currentPath].startX, this.paths[currentPath].startY + (i * -1 - 0.5), this.copyPath(this.paths[currentPath].path)));757 }758 for (var i = 0; i < 4; i++) {759 this.game.addEntity(new InfectedHarpy(this.game, this.paths[currentPath].startX, this.paths[currentPath].startY + (i * -1 - 0.5), this.copyPath(this.paths[currentPath].path)));760 }761 for (var i = 0; i < 2; i++) {762 this.game.addEntity(new InfectedChubby(this.game, this.paths[currentPath].startX, this.paths[currentPath].startY + (i * -1 - 0.5), this.copyPath(this.paths[currentPath].path)));763 }764 currentPath = 3;765 for (var i = 0; i < 6; i++) {766 this.game.addEntity(new InfectedUnit(this.game, this.paths[currentPath].startX, this.paths[currentPath].startY + (i * -1), this.copyPath(this.paths[currentPath].path)));767 }768 for (var i = 0; i < 6; i++) {769 this.game.addEntity(new InfectedVenom(this.game, this.paths[currentPath].startX, this.paths[currentPath].startY + (i * -1 - 0.5), this.copyPath(this.paths[currentPath].path)));770 }771 for (var i = 0; i < 0; i++) {772 this.game.addEntity(new InfectedHarpy(this.game, this.paths[currentPath].startX, this.paths[currentPath].startY + (i * -1 - 0.5), this.copyPath(this.paths[currentPath].path)));773 }774 for (var i = 0; i < 0; i++) {775 this.game.addEntity(new InfectedChubby(this.game, this.paths[currentPath].startX, this.paths[currentPath].startY + (i * -1 - 0.5), this.copyPath(this.paths[currentPath].path)));776 }777 currentPath = 4;778 for (var i = 0; i < 8; i++) {779 this.game.addEntity(new InfectedUnit(this.game, this.paths[currentPath].startX, this.paths[currentPath].startY + (i * -1), this.copyPath(this.paths[currentPath].path)));780 }781 for (var i = 0; i < 5; i++) {782 this.game.addEntity(new InfectedVenom(this.game, this.paths[currentPath].startX, this.paths[currentPath].startY + (i * -1 - 0.5), this.copyPath(this.paths[currentPath].path)));783 }784 for (var i = 0; i < 8; i++) {785 this.game.addEntity(new InfectedHarpy(this.game, this.paths[currentPath].startX, this.paths[currentPath].startY + (i * -1 - 0.5), this.copyPath(this.paths[currentPath].path)));786 }787 for (var i = 0; i < 1; i++) {788 this.game.addEntity(new InfectedChubby(this.game, this.paths[currentPath].startX, this.paths[currentPath].startY + (i * -1 - 0.5), this.copyPath(this.paths[currentPath].path)));789 }790 this.spawnedWaveFlags[4] = true;791 break; 792 //Wave 6 793 case !this.spawnedWaveFlags[5] && this.game.elapsedDay >= 16 && this.game.elapsedHour >= 12:794 currentPath = 0;795 for (var i = 0; i < 0; i++) {796 this.game.addEntity(new InfectedUnit(this.game, this.paths[currentPath].startX, this.paths[currentPath].startY + (i * -1), this.copyPath(this.paths[currentPath].path)));797 }798 for (var i = 0; i < 12; i++) {799 this.game.addEntity(new InfectedVenom(this.game, this.paths[currentPath].startX, this.paths[currentPath].startY + (i * -1 - 0.5), this.copyPath(this.paths[currentPath].path)));800 }801 for (var i = 0; i < 10; i++) {802 this.game.addEntity(new InfectedHarpy(this.game, this.paths[currentPath].startX, this.paths[currentPath].startY + (i * -1 - 0.5), this.copyPath(this.paths[currentPath].path)));803 }804 for (var i = 0; i < 3; i++) {805 this.game.addEntity(new InfectedChubby(this.game, this.paths[currentPath].startX, this.paths[currentPath].startY + (i * -1 - 0.5), this.copyPath(this.paths[currentPath].path)));806 }807 currentPath = 1;808 for (var i = 0; i < 4; i++) {809 this.game.addEntity(new InfectedUnit(this.game, this.paths[currentPath].startX, this.paths[currentPath].startY + (i * -1), this.copyPath(this.paths[currentPath].path)));810 }811 for (var i = 0; i < 12; i++) {812 this.game.addEntity(new InfectedVenom(this.game, this.paths[currentPath].startX, this.paths[currentPath].startY + (i * -1 - 0.5), this.copyPath(this.paths[currentPath].path)));813 }814 for (var i = 0; i < 10; i++) {815 this.game.addEntity(new InfectedHarpy(this.game, this.paths[currentPath].startX, this.paths[currentPath].startY + (i * -1 - 0.5), this.copyPath(this.paths[currentPath].path)));816 }817 for (var i = 0; i < 2; i++) {818 this.game.addEntity(new InfectedChubby(this.game, this.paths[currentPath].startX, this.paths[currentPath].startY + (i * -1 - 0.5), this.copyPath(this.paths[currentPath].path)));819 }820 currentPath = 2;821 for (var i = 0; i < 5; i++) {822 this.game.addEntity(new InfectedUnit(this.game, this.paths[currentPath].startX, this.paths[currentPath].startY + (i * -1), this.copyPath(this.paths[currentPath].path)));823 }824 for (var i = 0; i < 14; i++) {825 this.game.addEntity(new InfectedVenom(this.game, this.paths[currentPath].startX, this.paths[currentPath].startY + (i * -1 - 0.5), this.copyPath(this.paths[currentPath].path)));826 }827 for (var i = 0; i < 8; i++) {828 this.game.addEntity(new InfectedHarpy(this.game, this.paths[currentPath].startX, this.paths[currentPath].startY + (i * -1 - 0.5), this.copyPath(this.paths[currentPath].path)));829 }830 for (var i = 0; i < 1; i++) {831 this.game.addEntity(new InfectedChubby(this.game, this.paths[currentPath].startX, this.paths[currentPath].startY + (i * -1 - 0.5), this.copyPath(this.paths[currentPath].path)));832 }833 currentPath = 3;834 for (var i = 0; i < 6; i++) {835 this.game.addEntity(new InfectedUnit(this.game, this.paths[currentPath].startX, this.paths[currentPath].startY + (i * -1), this.copyPath(this.paths[currentPath].path)));836 }837 for (var i = 0; i < 10; i++) {838 this.game.addEntity(new InfectedVenom(this.game, this.paths[currentPath].startX, this.paths[currentPath].startY + (i * -1 - 0.5), this.copyPath(this.paths[currentPath].path)));839 }840 for (var i = 0; i < 10; i++) {841 this.game.addEntity(new InfectedHarpy(this.game, this.paths[currentPath].startX, this.paths[currentPath].startY + (i * -1 - 0.5), this.copyPath(this.paths[currentPath].path)));842 }843 for (var i = 0; i < 0; i++) {844 this.game.addEntity(new InfectedChubby(this.game, this.paths[currentPath].startX, this.paths[currentPath].startY + (i * -1 - 0.5), this.copyPath(this.paths[currentPath].path)));845 }846 currentPath = 4;847 for (var i = 0; i < 2; i++) {848 this.game.addEntity(new InfectedUnit(this.game, this.paths[currentPath].startX, this.paths[currentPath].startY + (i * -1), this.copyPath(this.paths[currentPath].path)));849 }850 for (var i = 0; i < 7; i++) {851 this.game.addEntity(new InfectedVenom(this.game, this.paths[currentPath].startX, this.paths[currentPath].startY + (i * -1 - 0.5), this.copyPath(this.paths[currentPath].path)));852 }853 for (var i = 0; i < 15; i++) {854 this.game.addEntity(new InfectedHarpy(this.game, this.paths[currentPath].startX, this.paths[currentPath].startY + (i * -1 - 0.5), this.copyPath(this.paths[currentPath].path)));855 }856 for (var i = 0; i < 1; i++) {857 this.game.addEntity(new InfectedChubby(this.game, this.paths[currentPath].startX, this.paths[currentPath].startY + (i * -1 - 0.5), this.copyPath(this.paths[currentPath].path)));858 }859 this.spawnedWaveFlags[5] = true;860 break; 861 }862 }863 //Helper function to deep copy paths864 copyPath(originalPath) {865 let copiedPath = [];866 for(let i = 0; i < originalPath.length; i++) {867 copiedPath[i] = { x : originalPath[i].x, y : originalPath[i].y }868 }869 return copiedPath;870 }...
mainws.js
Source:mainws.js
1let app = new Vue({2 el: '#app',3 data: {4 rootfolder: "/media",5 directories: [],6 files: [],7 currentPath: "/media",8 state: {},9 heartbeat: null,10 progressTicker: null,11 tabDir: true,12 tabFiles: false,13 tabPlaylist: false,14 playlist: [],15 ws: null16 },17 filters: {18 pretty: function(value) {19 return JSON.stringify(value, null, 2);20 }21 },22 mounted () {23 this.ws = new WebSocket("ws://" + window.location.host + "/test");24 this.ws.addEventListener("open", this.onWSOpen);25 this.ws.addEventListener("message", this.onMessage);26 this.loadfolder(this.currentPath);27 this.progressTicker = window.setInterval(this.updateProgressBar,100);28 //this.heartbeat = window.setInterval(this.sendHeartbeat,3000);29 this.sendHeartbeat();30 this.getPlaylist();31 //window.setInterval(this.getPlaylist, 10000);32 },33 methods: {34 onWSOpen: function() {35 this.ws.send(JSON.stringify({list: this.currentPath, status}));36 },37 loadfolder: async function (path) {38 if(path.startsWith("#")) path = path.substring(1);39 if(this.currentPath === undefined) this.currentPath = "";40 this.currentPath=path;41 let resp = await fetch("/list" + (this.currentPath.startsWith("/") ? "" : "/") + this.currentPath);42 const respObj = await resp.json();43 this.directories = respObj["directories"];44 this.files = respObj["files"];45 this.currentPath = respObj["path"];46 },47 onFolderClick: function(event) {48 this.loadfolder(this.currentPath + '/' + event.target.textContent);49 },50 onPlaySongClick: async function(event) {51 let resp = await fetch("/playsong" + (this.currentPath.startsWith("/") ? "" : "/") 52 + encodeURIComponent(this.currentPath + "/" 53 + event.target.textContent.trim()));54 app.state = await resp.json();55 },56 onPlayFolderClick: async function(event) {57 const resp = await fetch("/playfolder" + (this.currentPath.startsWith("/") ? "" : "/") 58 + encodeURIComponent(this.currentPath + "/" 59 + event.target.nextElementSibling.nextElementSibling.textContent.trim()));60 app.state = await resp.json();61 },62 onCurrentFolderPlay: async function(event) {63 const resp = await fetch("/playfolder" + (this.currentPath.startsWith("/") ? "" : "/") 64 + encodeURIComponent(this.currentPath));65 app.state = await resp.json();66 },67 pause: async function(event) {68 const resp = await fetch("/pause");69 app.state = await resp.json();70 },71 sendHeartbeat: async function() {72 if(document.hidden) return;73 const resp = await fetch("/heartbeat");74 const respObj = await resp.json();75 app.state = respObj;76 },77 getPlaylist: async function() {78 if(document.hidden) return;79 const resp = await fetch("/playlist");80 const respObj = await resp.json();81 app.playlist = respObj;82 },83 next: async function(event) {84 const resp = await fetch("/next");85 app.state = await resp.json();86 },87 prev: async function(event) {88 const resp = await fetch("/prev");89 app.state = await resp.json();90 },91 stop: async function(event) {92 const resp = await fetch("/stop");93 app.state = await resp.json();94 },95 onProgressClick: async function(event) {96 const targetProgress = Math.round(((event.pageX - event.target.offsetLeft) / event.target.offsetWidth)*100);97 const resp = await fetch("/seek/" + targetProgress);98 app.state = await resp.json();99 },100 onGoUpClick: async function(event) {101 this.loadfolder(String(app.currentPath).slice(0,app.currentPath.lastIndexOf("/")));102 }, 103 onAddFolderClick: async function(event) {104 const resp = await fetch("/appendfolder" + (this.currentPath.startsWith("/") ? "" : "/") 105 + encodeURIComponent(this.currentPath + "/" 106 + event.target.nextElementSibling.textContent.trim()));107 app.state = await resp.json();108 } , 109 onAddSongClick: async function(event) {110 const resp = await fetch("/appendsong" + (this.currentPath.startsWith("/") ? "" : "/") 111 + encodeURIComponent(this.currentPath + "/" 112 + event.target.nextElementSibling.textContent.trim()));113 app.state = await resp.json();114 },115 onAddCurrentFolderClick: async function(event) {116 const resp = await fetch("/appendfolder" + (this.currentPath.startsWith("/") ? "" : "/") 117 + encodeURIComponent(this.currentPath));118 app.state = await resp.json();119 },120 updateProgressBar: function() {121 if(!app.state.paused) {122 app.state.current += .100;123 }124 }, 125 showDirectories: function(event) {126 app.tabDir = true;127 app.tabFiles = false;128 app.tabPlaylist = false;129 },130 showFiles: function(event) {131 app.tabDir = false;132 app.tabFiles = true;133 app.tabPlaylist = false;134 },135 showPlaylist: function(event) {136 app.tabDir = false;137 app.tabFiles = false;138 app.tabPlaylist = true;139 },140 breadcrumbClick: function(event) {141 console.log(event.target.dataset.pathindex);142 const finalIndex = String(app.currentPath).split("/",parseInt(event.target.dataset.pathindex)+2).join("/").length;143 console.log(String(this.currentPath).slice(0,finalIndex));144 this.loadfolder(String(this.currentPath).slice(0,finalIndex));145 }146 },...
get-path.js
Source:get-path.js
1const { borders, centroids, getLatLong, setOriginDirection, getDirection, makeSortFn } = require('./helpers');2const args = process.argv.slice(2);3const origin = args[0];4const destination = args[1];5const originalDirectionData = getDirection(origin, destination);6const borderingSort = makeSortFn(originalDirectionData);7setOriginDirection(origin);8var paths = [];9var pathCoords = [];10var currentPath = 0;11paths.push([]);12pathCoords.push([]);13paths[currentPath].push(origin);14pathCoords[currentPath].push({ origin, coords: getLatLong(origin) });15var minPathLength = 14;16var SAFETY_NET = 1000000;17var safety = 0;18function getBorders(currentCountry) {19 safety++;20 if (safety > SAFETY_NET) return;21 var countryData = borders.find(b => b.country === currentCountry);22 var borderingCountries = countryData.borders;23// borderingCountries.sort(borderingSort);24 for (let i = 0, j = borderingCountries.length; i < j; i++) {25 // Processing for "Destination included in current path."26 // If the destination is already in the path...27 if (paths[currentPath].indexOf(destination) !== -1) {28 // If this is now the shortest path found, retain it.29 if (paths[currentPath].length < minPathLength) {30 minPathLength = paths[currentPath].length;31 paths[currentPath + 1] = paths[currentPath].slice(0, paths[currentPath].length - 1);32console.log(`Right destination and shortest path ${currentPath}. paths so far`, paths);33 pathCoords[currentPath + 1] = pathCoords[currentPath].slice(0, pathCoords[currentPath].length - 1);34 return ++currentPath;35 // Else, if this is not the shortest path found, prepare to reuse it.36 } else {37console.log('Right destination but not shortest path; prepare to reuse', paths[currentPath]);38 paths[currentPath] = paths[currentPath].slice(0, paths[currentPath].length - 1);39 pathCoords[currentPath] = pathCoords[currentPath].slice(0, pathCoords[currentPath].length - 1);40 return currentPath; 41 }42 }43 // Done with processing for "Destination included in current path."44 // Processing for "Current path length exceeds length of shortest path found so far."45 // If current path length exceeds shortest path length so far, prepare to reuse it.46 if (paths[currentPath].length > minPathLength) { 47console.log('Path length exceeds length of shortest; prepare to reuse', paths[currentPath]);48 paths[currentPath] = paths[currentPath].slice(0, paths[currentPath].length - 1);49 pathCoords[currentPath] = pathCoords[currentPath].slice(0, pathCoords[currentPath].length - 1);50 return currentPath; 51 }52 // Done with processing for "Current path length exceeds length of shortest path found so far."53 // Current path is neither longer than the shortest found, nor does it contain the destination.54 // Get the next current country's next bordering country (bc), and check for it in the current path.55 let bc = borderingCountries[i];56 // If the bordering country isn't the destination, don't add it unless the current path is at least 2 shorter than the minimum.57 if (bc === destination || paths[currentPath].length + 1 < minPathLength) {58 // Bordering country not in current path, so add it.59 if (paths[currentPath].indexOf(bc) === -1) {60 paths[currentPath].push(bc);61console.log('Adding country', bc, 'to path', paths[currentPath], pathCoords[currentPath]);62 pathCoords[currentPath].push({ country: bc, coords: getLatLong(bc) });63 // Then, call getBorders to get the borders for the country just added to the path.64 let p = getBorders(bc);65 }66 }67 // If the above condition failed, it means that:68 // a) the current bordering country is already in the path, and69 // b) the current country is not the destination.70 }71 // If we reached here, we've gone through all the bordering countries and haven't reached the destination.72 // This means backing up a country.73console.log('End of getPaths function; about to add', paths[currentPath].slice(0, paths[currentPath].length - 1));74 paths[currentPath] = paths[currentPath].slice(0, paths[currentPath].length - 1);75 pathCoords[currentPath] = pathCoords[currentPath].slice(0, pathCoords[currentPath].length - 1);76 return currentPath;77}78getBorders(origin);79var shortestPath = { path: [], length: 100 };80var reachedDest = paths.filter(p => p[p.length-1] === destination);81console.log('Paths', paths);82for (let i = 0; i < paths.length; i++) {83 let path = paths[i];84 if (path.length < shortestPath.length) {85 shortestPath.path = path;86 shortestPath.length = path.length;87 shortestPath.pathCoords = pathCoords[i];88 } 89}90console.log('Shortest path', shortestPath);91console.log(`Mission accomplished (border visits ${safety}):`);92reachedDest.forEach(path => {93 console.log(path.join(' - '));...
Using AI Code Generation
1import { currentPath } from 'storybook-root';2const currentPath = require('storybook-root').currentPath;3const currentPath = require('storybook-root').currentPath;4import { currentPath } from 'storybook-root';5const currentPath = require('storybook-root').currentPath;6const currentPath = require('storybook-root').currentPath;7import { currentPath } from 'storybook-root';8const currentPath = require('storybook-root').currentPath;9const currentPath = require('storybook-root').currentPath;10import { currentPath } from 'storybook-root';11const currentPath = require('storybook-root').currentPath;12const currentPath = require('storybook-root').currentPath;13import { currentPath } from 'storybook-root';14const currentPath = require('storybook-root').currentPath;15const currentPath = require('storybook-root').currentPath;16import { currentPath } from 'storybook-root';17const currentPath = require('storybook-root').currentPath;18const currentPath = require('storybook-root').currentPath;19import { currentPath } from 'storybook-root';20const currentPath = require('storybook-root').currentPath;
Using AI Code Generation
1storiesOf('test', module)2 .add('test', () => {3 const path = currentPath();4 return (5 {path}6 );7 });
Using AI Code Generation
1var root = require('storybook-root');2var path = root.currentPath();3var root = require('storybook-root');4var path = root.currentPath();5var root = require('storybook-root');6var path = root.currentPath();7var root = require('storybook-root');8var path = root.currentPath();9var root = require('storybook-root');10var path = root.currentPath();11var root = require('storybook-root');12var path = root.currentPath();13var root = require('storybook-root');14var path = root.currentPath();15var root = require('storybook-root');16var path = root.currentPath();17var root = require('storybook-root');18var path = root.currentPath();19var root = require('storybook-root');20var path = root.currentPath();21var root = require('storybook-root');22var path = root.currentPath();23var root = require('storybook-root');
Using AI Code Generation
1import { currentPath } from 'storybook-root';2export default {3};4export const App = () => {5 return <h1>Current path is: {currentPath()}</h1>;6};7import { storiesOf } from '@storybook/react';8import App from '../test';9storiesOf('App', module).add('App', () => <App />);10import { addDecorator } from '@storybook/react';11import { withRoot } from 'storybook-root';12addDecorator(withRoot);13import { configure } from '@storybook/react';14const req = require.context('../stories', true, /\.stories\.js$/);15function loadStories() {16 req.keys().forEach(filename => req(filename));17}18configure(loadStories, module);19import { currentPath } from 'storybook-root';20console.log(currentPath());
Using AI Code Generation
1var currentPath = require('storybook-root').currentPath;2console.log(currentPath);3var currentPath = require('storybook-root').currentPath;4console.log(currentPath);5var currentPath = require('storybook-root').currentPath;6console.log(currentPath);7var currentPath = require('storybook-root').currentPath;8console.log(currentPath);9var currentPath = require('storybook-root').currentPath;10console.log(currentPath);11var currentPath = require('storybook-root').currentPath;12console.log(currentPath);13var currentPath = require('storybook-root').currentPath;14console.log(currentPath);15var currentPath = require('storybook-root').currentPath;16console.log(currentPath);17var currentPath = require('storybook-root').currentPath;18console.log(currentPath);19var currentPath = require('storybook-root').currentPath;20console.log(currentPath);21var currentPath = require('storybook-root').currentPath;22console.log(currentPath);23var currentPath = require('storybook-root').currentPath;24console.log(currentPath);
Using AI Code Generation
1import { currentPath } from 'storybook-root';2const path = currentPath();3console.log(path);4import { currentPath } from 'storybook-root';5const path = currentPath();6console.log(path);7import { currentPath } from 'storybook-root';8const path = currentPath();9console.log(path);10import { currentPath } from 'storybook-root';11const path = currentPath();12console.log(path);13import { currentPath } from 'storybook-root';
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!