UNPKG

bp-prism-game

Version:
1 lines 549 kB
{"version":3,"file":"bp-prism-game.mjs","sources":["../../../projects/prism/src/lib/text/display-dialog/display-dialog.component.ts","../../../projects/prism/src/lib/text/display-dialog/display-dialog.component.html","../../../projects/prism/src/lib/service/display-dialog.service.ts","../../../projects/prism/src/lib/service/game-cookie.service.ts","../../../projects/prism/src/lib/gameboard/gameboard-constants.ts","../../../projects/prism/src/lib/enum/observable-type.enum.ts","../../../projects/prism/src/lib/asset/enum/asset-align.enum.ts","../../../projects/prism/src/lib/asset/enum/asset-align-vertical.enum.ts","../../../projects/prism/src/lib/asset/asset.class.ts","../../../projects/prism/src/lib/base/base.class.ts","../../../projects/prism/src/lib/enum/image-loaded.enum.ts","../../../projects/prism/src/lib/base/prism-base/prism-base.class.ts","../../../projects/prism/src/lib/base/alien-base/alien-base.class.ts","../../../projects/prism/src/lib/enum/asset-direction.enum.ts","../../../projects/prism/src/lib/aliens/alien/alien.class.ts","../../../projects/prism/src/lib/aliens/alien-1/alien-1.class.ts","../../../projects/prism/src/lib/aliens/alien-2/alien-2.class.ts","../../../projects/prism/src/lib/enum/alien-path.enum.ts","../../../projects/prism/src/lib/enum/alien-path-direction.enum.ts","../../../projects/prism/src/lib/service/path.service.ts","../../../projects/prism/src/lib/aliens/alien-dropship/alien-dropship.class.ts","../../../projects/prism/src/lib/service/invasion.service.ts","../../../projects/prism/src/lib/gunner/gunner.class.ts","../../../projects/prism/src/lib/gunner/main-gunner/main-gunner.class.ts","../../../projects/prism/src/lib/missile/missile.class.ts","../../../projects/prism/src/lib/service/missile.service.ts","../../../projects/prism/src/lib/text/character.class.ts","../../../projects/prism/src/lib/text/number/number.class.ts","../../../projects/prism/src/lib/enum/text-type.enum.ts","../../../projects/prism/src/lib/text/letter/letter.class.ts","../../../projects/prism/src/lib/service/text.service.ts","../../../projects/prism/src/lib/prism/prism-blast/prism-blast-constants.ts","../../../projects/prism/src/lib/prism/prism-blast/prism-blast.class.ts","../../../projects/prism/src/lib/prism/prism-blast-icon/prism-blast-icon.class.ts","../../../projects/prism/src/lib/service/prism-blast.service.ts","../../../projects/prism/src/lib/scenery/scenery.class.ts","../../../projects/prism/src/lib/enum/game-assets.enum.ts","../../../projects/prism/src/lib/scenery/water/water.class.ts","../../../projects/prism/src/lib/enum/asset-type.enum.ts","../../../projects/prism/src/lib/scenery/tree/tree.class.ts","../../../projects/prism/src/lib/scenery/lava/lava.class.ts","../../../projects/prism/src/lib/scenery/rock/rock.class.ts","../../../projects/prism/src/lib/scenery/grass/grass.class.ts","../../../projects/prism/src/lib/scenery/slime/slime.class.ts","../../../projects/prism/src/lib/service/scenery.service.ts","../../../projects/prism/src/lib/level/level.class.ts","../../../projects/prism/src/lib/level/bridge/bridge.class.ts","../../../projects/prism/src/lib/level/level-one/level-one.class.ts","../../../projects/prism/src/lib/level/path/path.class.ts","../../../projects/prism/src/lib/service/gameboard.service.ts","../../../projects/prism/src/lib/images/main-gunner/main-gunner.base64.ts","../../../projects/prism/src/lib/images/prism-base/prism-base.base64.ts","../../../projects/prism/src/lib/images/alien/alien-1/alien-one-right.base64.ts","../../../projects/prism/src/lib/images/alien/alien-2/alien-2-animate-west-1.base64.ts","../../../projects/prism/src/lib/images/prism-blast-icon/prism-blast-icon.base64.ts","../../../projects/prism/src/lib/game-instruction/game-instruction.component.ts","../../../projects/prism/src/lib/game-instruction/game-instruction.component.html","../../../projects/prism/src/lib/service/water.service.ts","../../../projects/prism/src/lib/images/scenery/tree/tree.base64.ts","../../../projects/prism/src/lib/images/scenery/water/water-zero.base64.ts","../../../projects/prism/src/lib/images/levels/level-one.base64.ts","../../../projects/prism/src/lib/images/main-gunner/main-gunner-support.base64.ts","../../../projects/prism/src/lib/images/scenery/lava/lava-one.base64.ts","../../../projects/prism/src/lib/images/levels/bridge.base64.ts","../../../projects/prism/src/lib/images/scenery/rock/rock.base64.ts","../../../projects/prism/src/lib/images/scenery/grass.base64.ts","../../../projects/prism/src/lib/images/main-gunner/missiles/missile.base64.ts","../../../projects/prism/src/lib/images/main-gunner/missiles/missile-red.base64.ts","../../../projects/prism/src/lib/images/main-gunner/missiles/missile-blue.base64.ts","../../../projects/prism/src/lib/images/main-gunner/missiles/missile-green.base64.ts","../../../projects/prism/src/lib/images/main-gunner/missiles/missile-indigo.base64.ts","../../../projects/prism/src/lib/images/main-gunner/missiles/missile-orange.base64.ts","../../../projects/prism/src/lib/images/main-gunner/missiles/missile-yellow.base64.ts","../../../projects/prism/src/lib/images/main-gunner/missiles/missile-violet.base64.ts","../../../projects/prism/src/lib/images/levels/path.base64.ts","../../../projects/prism/src/lib/images/scenery/slime/slime.base64.ts","../../../projects/prism/src/lib/images/levels/path-direction.base64.ts","../../../projects/prism/src/lib/images/alien/alien-1/alien-one-left.base64.ts","../../../projects/prism/src/lib/images/scenery/tree/tree-land.base64.ts","../../../projects/prism/src/lib/images/alien/alien-dropship/alien-dropship-1.base64.ts","../../../projects/prism/src/lib/images/alien/alien-dropship/tractor-beam/tractor-beam-1.base64.ts","../../../projects/prism/src/lib/images/alien/alien-base.base64.ts","../../../projects/prism/src/lib/images/scenery/water/water-eleven.base64.ts","../../../projects/prism/src/lib/images/scenery/water/water-three.base64.ts","../../../projects/prism/src/lib/images/scenery/water/water-one.base64.ts","../../../projects/prism/src/lib/images/scenery/water/water-waves.base64.ts","../../../projects/prism/src/lib/images/alien/alien-dropship/tractor-beam/tractor-beam-2.base64.ts","../../../projects/prism/src/lib/images/alien/alien-dropship/tractor-beam/tractor-beam-3.base64.ts","../../../projects/prism/src/lib/images/scenery/rock/rock-land.base64.ts","../../../projects/prism/src/lib/images/scenery/slime/slime-ground.base64.ts","../../../projects/prism/src/lib/images/scenery/slime/slime-two.base64.ts","../../../projects/prism/src/lib/images/alien/alien-2/alien-2-animate-east-1.base64.ts","../../../projects/prism/src/lib/images/alien/alien-2/alien-2-animate-east-2.base64.ts","../../../projects/prism/src/lib/images/alien/alien-2/alien-2-animate-west-2.base64.ts","../../../projects/prism/src/lib/images/alien/alien-2/alien-2-animate-north-1.base64.ts","../../../projects/prism/src/lib/images/alien/alien-2/alien-2-animate-north-2.base64.ts","../../../projects/prism/src/lib/images/number/number-0.base64.ts","../../../projects/prism/src/lib/images/number/number-1.base64.ts","../../../projects/prism/src/lib/images/number/number-2.base64.ts","../../../projects/prism/src/lib/images/number/number-3.base64.ts","../../../projects/prism/src/lib/images/number/number-4.base64.ts","../../../projects/prism/src/lib/images/number/number-5.base64.ts","../../../projects/prism/src/lib/images/number/number-6.base64.ts","../../../projects/prism/src/lib/images/number/number-7.base64.ts","../../../projects/prism/src/lib/images/number/number-8.base64.ts","../../../projects/prism/src/lib/images/number/number-9.base64.ts","../../../projects/prism/src/lib/images/letter/letter-l.base64.ts","../../../projects/prism/src/lib/images/letter/letter-p.base64.ts","../../../projects/prism/src/lib/images/alien/alien-dropship/alien-dropship-2.base64.ts","../../../projects/prism/src/lib/service/image.service.ts","../../../projects/prism/src/lib/service/game.service.ts","../../../projects/prism/src/lib/gameboard/gameboard.component.ts","../../../projects/prism/src/lib/gameboard/gameboard.component.html","../../../projects/prism/src/lib/aliens/alien/test-component/alien.component.ts","../../../projects/prism/src/lib/aliens/alien/test-component/alien.component.html","../../../projects/prism/src/lib/text/letter/test-component/letter.component.ts","../../../projects/prism/src/lib/text/letter/test-component/letter.component.html","../../../projects/prism/src/lib/gunner/main-gunner/main-gunner-constants.ts","../../../projects/prism/src/lib/gunner/test-component/main-gunner.component.ts","../../../projects/prism/src/lib/gunner/test-component/main-gunner.component.html","../../../projects/prism/src/lib/missile/test-component/missile.component.ts","../../../projects/prism/src/lib/missile/test-component/missile.component.html","../../../projects/prism/src/lib/text/number/test-component/number.component.ts","../../../projects/prism/src/lib/text/number/test-component/number.component.html","../../../projects/prism/src/lib/base/test-component/base.component.ts","../../../projects/prism/src/lib/base/test-component/base.component.html","../../../projects/prism/src/lib/prism/prism-blast/test-component/prism-blast.component.ts","../../../projects/prism/src/lib/prism/prism-blast/test-component/prism-blast.component.html","../../../projects/prism/src/lib/prism/prism-blast-icon/test-component/prism-blast-icon.component.ts","../../../projects/prism/src/lib/prism/prism-blast-icon/test-component/prism-blast-icon.component.html","../../../projects/prism/src/lib/scenery/test-component/scenery.component.ts","../../../projects/prism/src/lib/scenery/test-component/scenery.component.html","../../../projects/prism/src/lib/prism/prism.component.ts","../../../projects/prism/src/lib/prism/prism.component.html","../../../projects/prism/src/lib/prism.module.ts","../../../projects/prism/src/public-api.ts","../../../projects/prism/src/bp-prism-game.ts"],"sourcesContent":["import { Component, Inject } from '@angular/core';\nimport { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';\nimport { DisplayDialogDataModel } from './model/display-dialog-model';\n\n/**\n * Display Dialog component for display\n */\n@Component({\n selector: 'bp-prism-display-dialog',\n templateUrl: './display-dialog.component.html',\n styleUrls: ['./display-dialog.component.scss']\n})\nexport class DisplayDialogComponent {\n /**\n * The title of the dialog box\n */\n title: string;\n\n /**\n * The messate text of the dialog box\n */\n messageText: string;\n\n /**\n * If The message should be displayed\n */\n displayMessage: boolean;\n\n /**\n * If font is red\n */\n isRedFont: boolean;\n\n /**\n * The GenericDialogComponent constructor\n *\n * @param dialogRef MatDialogRef of this from DI\n * @param data MAT_DIALOG_DATA from DI of the caller\n */\n constructor(\n public dialogRef: MatDialogRef<DisplayDialogComponent>,\n @Inject(MAT_DIALOG_DATA) private data: DisplayDialogDataModel\n ) {\n this.title = this.data.title;\n this.messageText = this.data.messageText;\n this.displayMessage = this.messageText !== undefined;\n this.isRedFont = data.isFontRed;\n }\n}\n","<div class=\"dialog-container\">\n <h1 mat-dialog-title name=\"title\" [innerHtml]=\"title\" [class.game-over-font]=\"isRedFont\"></h1>\n <div mat-dialog-content name=\"messageText\" [innerHtml]=\"messageText\" *ngIf=\"displayMessage\"></div>\n</div>\n","import { Injectable } from '@angular/core';\nimport { MatDialog, MatDialogRef, DialogPosition } from '@angular/material/dialog';\nimport { DisplayDialogComponent } from '../text/display-dialog/display-dialog.component';\nimport { DisplayDialogDataModel } from '../text/display-dialog/model/display-dialog-model';\nimport { GameDataModel } from '../model/game-data.model';\n\n/**\n * The display dialog service\n */\n@Injectable({\n providedIn: 'root'\n})\nexport class DisplayDialogService {\n /**\n * The constructor\n *\n * @param dialog The MatDialog from DI\n */\n\n constructor(private dialog: MatDialog) {}\n\n /**\n * Get the Dialog Position\n */\n private getDialogPosition(): DialogPosition {\n return {\n top: '350px'\n } as DialogPosition;\n }\n\n /**\n * Display the game over text\n */\n public displayGameOver(data: GameDataModel): MatDialogRef<DisplayDialogComponent> {\n return this.dialog.open(DisplayDialogComponent, {\n panelClass: 'display-dialog-container',\n position: this.getDialogPosition(),\n data: {\n title: `GAME OVER`,\n messageText: `High Score: ${data.highScore}<br>Level: ${data.level}`,\n isFontRed: true\n } as DisplayDialogDataModel\n });\n }\n\n /**\n * Display the next level text\n */\n public displayNextLevel(data: GameDataModel): MatDialogRef<DisplayDialogComponent> {\n return this.dialog.open(DisplayDialogComponent, {\n panelClass: 'display-dialog-container',\n position: this.getDialogPosition(),\n data: {\n title: `NEXT LEVEL`,\n messageText: `Level: ${data.level}`,\n isFontRed: false\n } as DisplayDialogDataModel\n });\n }\n\n /**\n * Display the game paused text\n */\n public displayGamePaused(): MatDialogRef<DisplayDialogComponent> {\n return this.dialog.open(DisplayDialogComponent, {\n panelClass: 'display-dialog-container',\n position: this.getDialogPosition(),\n data: {\n title: `PAUSED`,\n isFontRed: false\n } as DisplayDialogDataModel\n });\n }\n}\n","import { Injectable } from '@angular/core';\nimport { CookieService } from 'ngx-cookie-service';\nimport { GameDataModel } from '../model/game-data.model';\n\n/**\n * The Cookie service\n */\n@Injectable({\n providedIn: 'root'\n})\nexport class GameCookieService {\n /**\n * The constructor\n * @param cookieService The cookieService from DI\n */\n constructor(private cookieService: CookieService) {}\n\n /**\n * Get the cookie\n */\n private getCookie(cookieName: string): string {\n return this.cookieService.get(cookieName);\n }\n\n /**\n * Get the High Score\n */\n public getGameData(): GameDataModel {\n const cookie = this.getCookie('bp-prism');\n return cookie ? (JSON.parse(cookie) as GameDataModel) : ({ highScore: 0, level: 1 } as GameDataModel);\n }\n\n /**\n * Set the cookie\n */\n public setGameData(data: GameDataModel): void {\n this.cookieService.set('bp-prism', JSON.stringify(data));\n }\n\n /**\n * Get the Debug information\n */\n public getDebugData(): string {\n const cookie = this.getCookie('bp-prism-debug');\n /* eslint-disable-next-line */\n return cookie ? JSON.parse(cookie)['assetName'] as string : '';\n }\n\n /**\n * Set the debug cookie data\n *\n * @param assetName The asset name\n */\n public setDebugData(assetName: string): void {\n this.cookieService.set('bp-prism-debug', JSON.stringify(Object({ assetName })));\n }\n}\n","/**\n * The Game board\n * 1 - Blank\n * 2 - Trees\n * 3 - Rocks\n * 4 - Water\n * 5 - Grass\n * 6 - Slime\n * 7 - Lava\n * 8 - Main Gunner\n * 9 - Alien Base\n * 10 - Prism Base\n * 11 - Score\n * 12 - High Score\n * 13 - Level\n * 14 - Prism Blast icon\n * 15 - Bridge\n * 16 - Path\n */\n\n// prettier-ignore\nexport const GAMEBOARD = [\n [1, 12, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 11, 1, 1, 1, 1, 1, 1, 1, 1, 1],\n [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],\n [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],\n [2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, 2, 0, 0, 0, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2],\n [2, 0, 0, 0, 2, 2, 2, 3, 3, 3, 3, 3, 2, 0, 2, 0, 2, 2, 0, 0, 0, 3, 3, 3, 0, 0, 0, 0, 0, 9, 0],\n [2, 0, 2, 0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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n];\n\n/**\n * GAMEBOARD TWO\n */\nconst GAMEBOARDTWO = JSON.parse(JSON.stringify(GAMEBOARD)) as number[][];\nGAMEBOARDTWO[6][1] = 0;\nGAMEBOARDTWO[18][2] = 9;\n\nGAMEBOARDTWO[4][29] = 0;\nGAMEBOARDTWO[16][26] = 9;\n\nGAMEBOARDTWO[7][10] = 0;\nGAMEBOARDTWO[8][18] = 9;\n\nGAMEBOARDTWO[11][17] = 0;\nGAMEBOARDTWO[21][15] = 9;\n\n/**\n * GAMEBOARD THREE\n */\nconst GAMEBOARDTHREE = JSON.parse(JSON.stringify(GAMEBOARD)) as number[][];\nGAMEBOARDTHREE[6][1] = 0;\nGAMEBOARDTHREE[10][5] = 9;\n\nGAMEBOARDTHREE[4][29] = 0;\nGAMEBOARDTHREE[20][24] = 9;\n\nGAMEBOARDTHREE[7][10] = 0;\nGAMEBOARDTHREE[13][20] = 9;\n\nGAMEBOARDTHREE[11][17] = 0;\nGAMEBOARDTHREE[3][15] = 9;\n\n/**\n * GAMEBOARD FOUR\n */\nconst GAMEBOARDFOUR = JSON.parse(JSON.stringify(GAMEBOARD)) as number[][];\nGAMEBOARDFOUR[6][1] = 0;\nGAMEBOARDFOUR[20][0] = 9;\n\nGAMEBOARDFOUR[4][29] = 0;\nGAMEBOARDFOUR[4][28] = 9;\n\nGAMEBOARDFOUR[7][10] = 0;\nGAMEBOARDFOUR[16][18] = 9;\n\nGAMEBOARDFOUR[11][17] = 0;\nGAMEBOARDFOUR[8][7] = 9;\n\n/**\n * The Game Boards\n */\nexport const GAMEBOARDS = [\n GAMEBOARD,\n GAMEBOARDTWO,\n GAMEBOARDTHREE,\n GAMEBOARDFOUR,\n GAMEBOARD,\n GAMEBOARDTWO,\n GAMEBOARDTHREE,\n GAMEBOARDFOUR,\n GAMEBOARD\n];\n\n/**\n * Block Size\n */\nexport const BLOCK_SIZE = 5;\n\n/**\n * Columns\n */\nexport const COLS = GAMEBOARD[0].length * BLOCK_SIZE;\n/**\n * Rows\n */\nexport const ROWS = GAMEBOARD.length * BLOCK_SIZE;\n\n/**\n * The Level Waves\n */\nexport class LEVELWAVES {\n /**\n * Level 0 Wave\n */\n static readonly 0 = 1;\n /**\n * Level 1 Wave\n */\n static readonly 1 = 1;\n /**\n * Level 2 Wave\n */\n static readonly 2 = 2;\n /**\n * Level 3 Wave\n */\n static readonly 3 = 3;\n /**\n * Level 4 Wave\n */\n static readonly 4 = 4;\n /**\n * Level 5 Wave\n */\n static readonly 5 = 5;\n /**\n * Level 6 Wave\n */\n static readonly 6 = 6;\n /**\n * Level 7 Wave\n */\n static readonly 7 = 7;\n}\n\n/**\n * The Level Speed\n */\nexport class LEVELSPEED {\n /**\n * Level 0 Speed\n */\n static readonly 0 = 500;\n /**\n * Level 1 Speed\n */\n static readonly 1 = 450;\n /**\n * Level 2 Speed\n */\n static readonly 2 = 400;\n /**\n * Level 3 Speed\n */\n static readonly 3 = 375;\n /**\n * Level 4 Speed\n */\n static readonly 4 = 350;\n /**\n * Level 5 Speed\n */\n static readonly 5 = 325;\n /**\n * Level 6 Speed\n */\n static readonly 6 = 300;\n /**\n * Level 7 Speed\n */\n static readonly 7 = 275;\n}\n\n/**\n * The Level Creep\n */\nexport class LEVELCREEP {\n /**\n * Level 0 Creep\n */\n static readonly 0 = 5;\n /**\n * Level 1 Creep\n */\n static readonly 1 = 10;\n /**\n * Level 2 Creep\n */\n static readonly 2 = 15;\n /**\n * Level 3 Creep\n */\n static readonly 3 = 20;\n /**\n * Level 4 Creep\n */\n static readonly 4 = 25;\n /**\n * Level 5 Creep\n */\n static readonly 5 = 30;\n /**\n * Level 6 Creep\n */\n static readonly 6 = 40;\n /**\n * Level 7 Creep\n */\n static readonly 7 = 50;\n}\n\n/**\n * The keys\n */\nexport class KEY {\n /**\n * Space\n */\n static readonly SPACE = 'Space';\n /**\n * Left\n */\n static readonly LEFT = 'ArrowLeft';\n /**\n * Right\n */\n static readonly RIGHT = 'ArrowRight';\n /**\n * KeyP\n */\n static readonly P = 'KeyP';\n /**\n * Down\n */\n static readonly DOWN = 'ArrowDown';\n /**\n * up\n */\n static readonly UP = 'ArrowUp';\n}\n","/**\n * The Observable Enum\n */\nexport enum ObservableTypeEnum {\n /**\n * Alien Hit\n */\n alienDestroyed = 'alienDestroyed',\n /**\n * Game Over\n */\n gameOver = 'gameOver',\n /**\n * Game Paused\n */\n gamePaused = 'gamePaused',\n /**\n * Images Loaded\n */\n imagesLoaded = 'imagesLoaded',\n /**\n * Key Down Event\n */\n keyDownEvent = 'keyDownEvent',\n /**\n * Key Up Event\n */\n keyUpEvent = 'keyUpEvent',\n /**\n * Level Completed\n */\n levelCompleted = 'levelCompleted',\n /**\n * Missile Destroyed Event\n */\n missileDestroyed = 'missileDestroyed',\n /**\n * Missile Launched Event\n */\n missileLaunched = 'missileLaunched',\n /**\n * Prism Base Destroyed\n */\n prismBaseDestroyed = 'prismBaseDestroyed',\n /**\n * Prism Blast Defused Event\n */\n prismBlastDefused = 'prismBlastDefused',\n /**\n * Prism Blast Fire Event\n */\n prismBlastFire = 'prismBlastFire',\n /**\n * Prism Blast Launched Event\n */\n prismBlastLaunched = 'prismBlastLaunched'\n}\n","/**\n * The Asset Align Enum\n */\nexport enum AssetAlignEnum {\n /**\n * Left\n */\n left = 'left',\n /**\n * Left Third\n */\n leftThird = 'leftThird',\n /**\n * Left Fourth\n */\n leftFourth = 'leftFourth',\n /**\n * right\n */\n right = 'right',\n /**\n * right Third\n */\n rightThird = 'rightThird',\n /**\n * right Fourth\n */\n rightFourth = 'rightFourth',\n /**\n * Center\n */\n center = 'center'\n}\n","/**\n * The Asset Align Vertical Enum\n */\nexport enum AssetAlignVerticalEnum {\n /**\n * Top\n */\n top = 'top',\n /**\n * Bottom\n */\n bottom = 'bottom',\n /**\n * Middle\n */\n middle = 'middle'\n}\n","import { IAsset } from '../interface/asset.interface';\nimport { GameService } from '../service/game.service';\nimport { ObservableModel } from '../model/observable.model';\nimport { ObservableTypeEnum } from '../enum/observable-type.enum';\nimport { TimerModel } from '../model/timer.model';\nimport { BoundaryModel } from '../model/boundary.model';\nimport { AssetAlignEnum } from './enum/asset-align.enum';\nimport { AssetAlignVerticalEnum } from './enum/asset-align-vertical.enum';\nimport { AssetScaleModel } from '../model/asset-scale.mode';\nimport { ImageLocationModel } from '../model/image/image-location.model';\nimport { ImageLoadedEnum } from '../enum/image-loaded.enum';\n\n/**\n * The Asset Class\n */\nexport abstract class AssetClass implements IAsset {\n /**\n * The x coordinate\n */\n public x: number;\n /**\n * The y coordinate\n */\n public y: number;\n /**\n * The request id from the animation\n */\n protected requestId: number;\n /**\n * The Asset Timmer\n */\n protected assetTimer: TimerModel;\n /**\n * Animation Counter\n */\n protected animationCounter: number;\n /**\n * the boardary model\n */\n protected boundary: BoundaryModel;\n /**\n * Is the asset is destroyed\n */\n public isDestroyed: boolean;\n /**\n * If the asset can be animated\n */\n public isAnimated: boolean;\n /**\n * If the asset knowns the game is over\n */\n protected isGameOver: boolean;\n /**\n * If the asset knowns the game is paused\n */\n protected isGamePaused: boolean;\n /**\n * The scale of the object\n */\n public assetScale: AssetScaleModel;\n /**\n * The images\n */\n protected images: ImageLocationModel[];\n /**\n * If the image is loaded\n */\n protected isImageLoaded: boolean;\n /**\n * The asset height\n */\n private assetHeight: number;\n /**\n * The asset width\n */\n private assetWidth: number;\n\n /**\n * Constructor\n * @param gameService The game service\n * @param ctx The ctx\n * @param assetUid the uid of the asset\n * @param imageType The optional animation number\n */\n constructor(\n protected gameService: GameService,\n protected ctx: CanvasRenderingContext2D,\n protected assetUid: number,\n protected imageType?: ImageLoadedEnum\n ) {\n this.assetScale = {\n x: 1,\n y: 1\n } as AssetScaleModel;\n this.x = 0;\n this.y = 0;\n\n this.images = [];\n\n this.assetHeight = 0;\n this.assetWidth = 0;\n\n this.isAnimated = false;\n this.isDestroyed = false;\n this.isGameOver = false;\n this.isGamePaused = false;\n this.isImageLoaded = false;\n\n this.assetTimer = { start: performance.now(), elapsed: 0 };\n this.animationCounter = 0;\n\n this.boundary = this.gameService.getBoundary();\n\n this.init();\n }\n\n /**\n * Init the asset\n */\n init(): void {\n this.gameService.getMasterObservable().subscribe((result: ObservableModel) => {\n if (result.type === ObservableTypeEnum.keyDownEvent || result.type === ObservableTypeEnum.keyUpEvent) {\n this.processKeyStroke(result);\n } else if (result.type === ObservableTypeEnum.gameOver) {\n this.isGameOver = result.booleanData;\n } else if (result.type === ObservableTypeEnum.gamePaused) {\n this.isGamePaused = result.booleanData;\n }\n });\n }\n /**\n * The extended animate class\n */\n /* eslint-disable-next-line */\n public animate(): void {}\n\n /**\n * Get the Asset height\n */\n getAssetHeight(): number {\n return this.assetHeight * this.assetScale.y;\n }\n\n /**\n * Get the Asset Width\n */\n getAssetWidth(): number {\n return this.assetWidth * this.assetScale.x;\n }\n\n /**\n * set The Asset Dimensions\n * @param height The asset height\n * @param width The asset width\n */\n setAssetDimensions(height: number, width: number): void {\n this.assetHeight = height;\n this.assetWidth = width;\n }\n\n /**\n * Get the asset uid\n */\n get uid() {\n return this.assetUid;\n }\n\n /**\n * Process the key stroke\n * @param eventCode the key event code\n */\n /* eslint-disable-next-line */\n protected processKeyStroke(event: ObservableModel): void {}\n\n /**\n * Move the asset\n * @param asset The asset input\n */\n move(asset: IAsset): void {\n this.x = asset.x;\n this.y = asset.y;\n }\n\n /**\n * Determine if we should stop the animation\n */\n protected stopAnimation(): boolean {\n return this.isDestroyed || this.isGameOver || this.isGamePaused;\n }\n\n /**\n * Position the Asset\n */\n positionAsset(alignPosition: AssetAlignEnum, justifyPosition: AssetAlignVerticalEnum): IAsset {\n let x = 0;\n let y = 0;\n\n if (alignPosition === AssetAlignEnum.center) {\n x = (this.boundary.right - this.getAssetWidth()) / 2;\n } else if (alignPosition === AssetAlignEnum.leftThird) {\n x = this.boundary.right / 3 - this.getAssetWidth() / 2;\n } else if (alignPosition === AssetAlignEnum.leftFourth) {\n x = this.boundary.right / 4 - this.getAssetWidth() / 2;\n } else if (alignPosition === AssetAlignEnum.rightThird) {\n x = (this.boundary.right * 2) / 3 - this.getAssetWidth() / 2;\n } else if (alignPosition === AssetAlignEnum.rightFourth) {\n x = (this.boundary.right * 3) / 4 - this.getAssetWidth() / 2;\n } else if (alignPosition === AssetAlignEnum.right) {\n x = this.boundary.right - this.getAssetWidth();\n }\n\n if (justifyPosition === AssetAlignVerticalEnum.bottom) {\n y = this.boundary.floor - this.getAssetHeight();\n } else if (justifyPosition === AssetAlignVerticalEnum.middle) {\n y = (this.boundary.floor - this.getAssetHeight()) / 2;\n }\n\n return {\n x: Math.round(x),\n y: Math.round(y)\n } as IAsset;\n }\n}\n","import { GameService } from '../service/game.service';\nimport { AssetClass } from '../asset/asset.class';\nimport { ImageLocationModel } from '../model/image/image-location.model';\n\n/**\n * The Prism Base Class\n */\nexport abstract class BaseClass extends AssetClass {\n /**\n * The current base\n */\n protected currentBase: ImageLocationModel;\n\n /**\n * Constructor\n * @param gameService The GameService\n * @param ctx The ctx\n * @param guid The guid of the alien\n */\n constructor(gameService: GameService, ctx: CanvasRenderingContext2D, guid: number) {\n super(gameService, ctx, guid);\n }\n\n /**\n * Draw the base\n */\n protected draw(): void {\n if (this.isImageLoaded) {\n this.ctx.save();\n this.ctx.translate(this.x, this.y);\n this.ctx.scale(this.assetScale.x, this.assetScale.y);\n this.ctx.drawImage(this.currentBase.imageSource, this.currentBase.x, this.currentBase.y);\n this.ctx.restore();\n }\n }\n\n /**\n * Animate the base\n */\n public animate(): void {\n this.draw();\n }\n}\n","/**\n * The Image Loaded Enum\n */\nexport enum ImageLoadedEnum {\n /**\n * Unknown\n */\n unknown = 'unknown',\n /**\n * Alien Base\n */\n alienBase = 'alienBase',\n /**\n * Alien Dropship 1\n */\n alienDropship1 = 'alienDropship1',\n /**\n * Alien Dropship 2\n */\n alienDropship2 = 'alienDropship2',\n /**\n * Alien One Right\n */\n alienOneRight = 'alienOneRight',\n /**\n * Alien One Left\n */\n alienOneLeft = 'alienOneLeft',\n /**\n * Alien 2 Animation East 1\n */\n alien2AnimationEast1 = 'alien2AnimationEast1',\n /**\n * Alien 2 Animation East 2\n */\n alien2AnimationEast2 = 'alien2AnimationEast2',\n /**\n * Alien 2 Animation North 1\n */\n alien2AnimationNorth1 = 'alien2AnimationNorth1',\n /**\n * Alien 2 Animation North 2\n */\n alien2AnimationNorth2 = 'alien2AnimationNorth2',\n /**\n * Alien 2 Animation West 1\n */\n alien2AnimationWest1 = 'alien2AnimationWest1',\n /**\n * Alien 2 Animation West 2\n */\n alien2AnimationWest2 = 'alien2AnimationWest2',\n /**\n * Scenery Bridge\n */\n bridge = 'bridge',\n /**\n * grass\n */\n grass = 'grass',\n /**\n * Scenery Lava\n */\n lava = 'lava',\n /**\n * letter l\n */\n letterl = 'letterl',\n /**\n * letter p\n */\n letterp = 'letterp',\n /**\n * level one\n */\n levelOneMap = 'levelOneMap',\n /**\n * Main Gunner\n */\n mainGunner = 'mainGunner',\n /**\n * Main Gunner Support\n */\n mainGunnerSupport = 'mainGunnerSupport',\n /**\n * Blue missile\n */\n missileBlue = 'missileBlue',\n /**\n * missile green\n */\n missileGreen = 'missileGreen',\n /**\n * missile indigo\n */\n missileIndigo = 'missileIndigo',\n /**\n * missile orange\n */\n missileOrange = 'missileOrange',\n /**\n * missile red\n */\n missileRed = 'missileRed',\n /**\n * missile violet\n */\n missileViolet = 'missileViolet',\n /**\n * missile white\n */\n missileWhite = 'missileWhite',\n /**\n * missile yellow\n */\n missileYellow = 'missileYellow',\n /**\n * number 0\n */\n number0 = 'number0',\n /**\n * number 1\n */\n number1 = 'number1',\n /**\n * number 2\n */\n number2 = 'number2',\n /**\n * number 3\n */\n number3 = 'number3',\n /**\n * number 4\n */\n number4 = 'number4',\n /**\n * number 5\n */\n number5 = 'number5',\n /**\n * number 6\n */\n number6 = 'number6',\n /**\n * number 7\n */\n number7 = 'number7',\n /**\n * number 8\n */\n number8 = 'number8',\n /**\n * number 9\n */\n number9 = 'number9',\n /**\n * path\n */\n path = 'path',\n /**\n * path direction\n */\n pathDirection = 'pathDirection',\n /**\n * prism base\n */\n prismBase = 'prismBase',\n /**\n * prism blast icon\n */\n prismBlastIcon = 'prismBlastIcon',\n /**\n * rock\n */\n rock = 'rock',\n /**\n * rock land\n */\n rockGround = 'rockGround',\n /**\n * slime\n */\n slime = 'slime',\n /**\n * slime 2\n */\n slime2 = 'slime2',\n /**\n * slime ground\n */\n slimeGround = 'slimeGround',\n /**\n * Tractor Beam 1\n */\n tractorBeam1 = 'tractorBeam1',\n /**\n * Tractor Beam 2\n */\n tractorBeam2 = 'tractorBeam2',\n /**\n * Tractor Beam 3\n */\n tractorBeam3 = 'tractorBeam3',\n /**\n * Scenery Tree\n */\n tree = 'tree',\n /**\n * Scenery Tree Land\n */\n treeGround = 'treeGround',\n /**\n * Scenery Water 0\n */\n water0 = 'water0',\n /**\n * Scenery Water 1\n */\n water1 = 'water1',\n /**\n * Scenery Water 2\n */\n water2 = 'water2',\n /**\n * Scenery Water 3\n */\n water3 = 'water3',\n /**\n * Scenery Water 4\n */\n water4 = 'water4',\n /**\n * Scenery Water 5\n */\n water5 = 'water5',\n /**\n * Scenery Water 6\n */\n water6 = 'water6',\n /**\n * Scenery Water 7\n */\n water7 = 'water7',\n /**\n * Scenery Water 8\n */\n water8 = 'water8',\n /**\n * Scenery Water 9\n */\n water9 = 'water9',\n /**\n * Scenery Water 10\n */\n water10 = 'water10',\n /**\n * Scenery Water 11\n */\n water11 = 'water11',\n /**\n * Scenery Water 12\n */\n water12 = 'water12',\n /**\n * Scenery Water 13\n */\n water13 = 'water13',\n /**\n * Scenery Water 14\n */\n water14 = 'water14',\n /**\n * Scenery Water 15\n */\n water15 = 'water15',\n /**\n * Scenery Water Waves\n */\n waterWaves = 'waterWaves'\n}\n","import { GameService } from '../../service/game.service';\nimport { BaseClass } from '../base.class';\nimport { KEY, BLOCK_SIZE } from '../../gameboard/gameboard-constants';\nimport { ObservableModel } from '../../model/observable.model';\nimport { ObservableTypeEnum } from '../../enum/observable-type.enum';\nimport { IAsset } from '../../interface/asset.interface';\nimport { AssetScaleModel } from '../../model/asset-scale.mode';\nimport { ImageLoadedEnum } from '../../enum/image-loaded.enum';\n\n/**\n * The Prism Base Class\n */\nexport class PrismBaseClass extends BaseClass {\n /**\n * moves\n */\n private moves = {\n [KEY.P]: true\n };\n\n /**\n * Constructor\n * @param gameService The GameService\n * @param ctx The ctx\n * @param guid The guid of the alien\n */\n constructor(gameService: GameService, ctx: CanvasRenderingContext2D, guid: number) {\n super(gameService, ctx, guid);\n this.loadPrismBaseImages();\n\n this.assetScale = {\n x: 0.2,\n y: 0.2\n } as AssetScaleModel;\n }\n\n /**\n * Load the alien Images\n */\n private loadPrismBaseImages(): void {\n const imagesToLoad = [ImageLoadedEnum.prismBase];\n\n imagesToLoad.map((key: ImageLoadedEnum) => {\n this.images.push(this.gameService.getImage(key));\n this.isImageLoaded = true;\n });\n\n this.currentBase = this.images[0];\n }\n\n /**\n * Press Key Stroke\n * @param event The Key event\n */\n protected processKeyStroke(event: ObservableModel): void {\n const eventCode = event.stringData;\n const keyDown = event.type === ObservableTypeEnum.keyDownEvent;\n\n if (this.moves[eventCode] && keyDown) {\n this.gameService.emitMasterObservableEvent({\n type: ObservableTypeEnum.prismBlastLaunched,\n assetCoordinateData: {\n x: this.x,\n y: this.y - BLOCK_SIZE\n } as IAsset,\n booleanData: true\n } as ObservableModel);\n }\n }\n}\n","import { GameService } from '../../service/game.service';\nimport { BaseClass } from '../base.class';\nimport { AssetScaleModel } from '../../model/asset-scale.mode';\nimport { ImageLoadedEnum } from '../../enum/image-loaded.enum';\n\n/**\n * The Alien Base Class\n */\nexport class AlienBaseClass extends BaseClass {\n /**\n * Constructor\n * @param gameService The GameService\n * @param ctx The ctx\n * @param guid The guid of the alien\n */\n constructor(gameService: GameService, ctx: CanvasRenderingContext2D, guid: number) {\n super(gameService, ctx, guid);\n\n this.loadAlienBaseImages();\n\n this.assetScale = {\n x: 0.2,\n y: 0.2\n } as AssetScaleModel;\n }\n\n /**\n * Load the alien Images\n */\n private loadAlienBaseImages(): void {\n const imagesToLoad = [ImageLoadedEnum.alienBase];\n\n imagesToLoad.map((key: ImageLoadedEnum) => {\n this.images.push(this.gameService.getImage(key));\n this.isImageLoaded = true;\n });\n\n this.currentBase = this.images[0];\n }\n}\n","/**\n * The Asset Direction Enum\n */\nexport enum AssetDirectionEnum {\n /**\n * East\n */\n east = 90,\n /**\n * West\n */\n west = -90,\n /**\n * North\n */\n north = 0,\n /**\n * South\n */\n south = 180\n}\n","import { IAsset } from '../../interface/asset.interface';\nimport { GameService } from '../../service/game.service';\nimport { AssetClass } from '../../asset/asset.class';\nimport { ImageLocationModel } from '../../model/image/image-location.model';\nimport { TimerModel } from '../../model/timer.model';\nimport { BLOCK_SIZE } from '../../gameboard/gameboard-constants';\nimport { AssetDirectionEnum } from '../../enum/asset-direction.enum';\nimport { ObservableModel } from '../../model/observable.model';\nimport { ObservableTypeEnum } from '../../enum/observable-type.enum';\n\n/**\n * The Alien Class\n */\nexport abstract class AlienClass extends AssetClass {\n /**\n * The alien moves for debug\n */\n protected nextMove: IAsset;\n /**\n * The alien moves for debug\n */\n protected allMoves: IAsset[];\n /**\n * The alien speed number\n */\n private alienSpeed: number;\n /**\n * The current alien\n */\n protected currentAlien: ImageLocationModel;\n\n /**\n * All the East facing aliens\n */\n protected eastAlienImages: ImageLocationModel[];\n\n /**\n * All the West facing aliens\n */\n protected westAlienImages: ImageLocationModel[];\n\n /**\n * All the North facing aliens\n */\n protected northAlienImages: ImageLocationModel[];\n\n /**\n * The Asset Timmer\n */\n private alienAssetTimer: TimerModel;\n\n /**\n * The Current Alien Direction\n */\n private currentAlienDirection: AssetDirectionEnum;\n\n /**\n * The original alien speed\n */\n private originamAlienSpeed: number;\n\n /**\n * Constructor\n * @param gameService The GameService\n * @param ctx The ctx\n * @param guid The guid of the alien\n */\n constructor(gameService: GameService, ctx: CanvasRenderingContext2D, guid: number) {\n super(gameService, ctx, guid);\n this.alienAssetTimer = { start: performance.now(), elapsed: 0 };\n this.alienSpeed = 500;\n this.originamAlienSpeed = this.alienSpeed;\n this.currentAlienDirection = AssetDirectionEnum.west;\n this.eastAlienImages = [];\n this.westAlienImages = [];\n this.northAlienImages = [];\n\n this.gameService.getMasterObservable().subscribe((event: ObservableModel) => {\n if (event.type === ObservableTypeEnum.prismBlastLaunched && event.booleanData) {\n this.alienSpeed = 2000;\n } else if (event.type === ObservableTypeEnum.prismBlastDefused && event.booleanData) {\n this.alienSpeed = this.originamAlienSpeed;\n }\n });\n }\n\n /**\n * Determine the path of the creep\n *\n * @param moves All the moves of the creep\n */\n public setCreepPath(moves: IAsset[]): void {\n this.allMoves = moves;\n this.nextMove = this.allMoves[0];\n this.move(this.allMoves[0]);\n }\n\n /**\n * Set the creep speed\n * @param speed The speed to set\n */\n public setCreepSpeed(speed: number): void {\n this.alienSpeed = speed;\n }\n\n /**\n * Draw the alien\n */\n protected draw(): void {\n if (this.isImageLoaded) {\n this.ctx.save();\n this.ctx.translate(this.x + BLOCK_SIZE / 2, this.y + BLOCK_SIZE / 2);\n this.ctx.scale(this.assetScale.x, this.assetScale.y);\n this.ctx.drawImage(this.currentAlien.imageSource, this.currentAlien.x, this.currentAlien.y);\n this.ctx.restore();\n }\n }\n\n /**\n * Animate the alien\n * @param now the current time\n */\n public animate(now = 0): void {\n this.assetTimer.elapsed = now - this.assetTimer.start;\n this.alienAssetTimer.elapsed = now - this.alienAssetTimer.start;\n\n if (this.stopAnimation()) {\n return;\n }\n\n if (this.assetTimer.elapsed > Math.floor(this.alienSpeed / 2)) {\n this.assetTimer.start = now;\n this.nextMove = this.allMoves.shift();\n this.move(this.nextMove);\n\n if (this.nextMove.rotate === 90 && this.currentAlienDirection !== AssetDirectionEnum.east) {\n this.currentAlienDirection = AssetDirectionEnum.east;\n this.images = this.eastAlienImages;\n } else if (this.nextMove.rotate === -90 && this.currentAlienDirection !== AssetDirectionEnum.west) {\n this.currentAlienDirection = AssetDirectionEnum.west;\n this.images = this.westAlienImages;\n } else if (this.nextMove.rotate === 0 && this.currentAlienDirection !== AssetDirectionEnum.north) {\n this.currentAlienDirection = AssetDirectionEnum.north;\n this.images = this.northAlienImages;\n }\n\n if (this.gameService.isBaseDestroy(this)) {\n this.isDestroyed = true;\n return;\n }\n }\n\n if (this.alienAssetTimer.elapsed > Math.floor(this.alienSpeed / 4)) {\n this.alienAssetTimer.start = now;\n this.currentAlien = this.images[this.animationCounter++ % this.images.length];\n }\n\n this.draw();\n }\n}\n","import { GameService } from '../../service/game.service';\nimport { AlienClass } from '../alien/alien.class';\nimport { AssetScaleModel } from '../../model/asset-scale.mode';\nimport { ImageLoadedEnum } from '../../enum/image-loaded.enum';\n\n/**\n * The Alien 1 Class\n */\nexport class Alien1Class extends AlienClass {\n /**\n * Constructor\n * @param gameService The GameService\n * @param ctx The ctx\n * @param guid The guid of the alien\n * @param spawnLocation The guid of the alien\n */\n constructor(gameService: GameService, ctx: CanvasRenderingContext2D, guid: number) {\n super(gameService, ctx, guid);\n\n this.loadAlienImages();\n\n this.assetScale = {\n x: 0.2,\n y: 0.2\n } as AssetScaleModel;\n }\n\n /**\n * Load the alien Images\n */\n private loadAlienImages(): void {\n const imagesToLoad = [ImageLoadedEnum.alienOneRight, ImageLoadedEnum.alienOneLeft];\n\n imagesToLoad.map((key: ImageLoadedEnum) => {\n this.images.push(this.gameService.getImage(key));\n this.isImageLoaded = true;\n });\n\n this.currentAlien = this.images[0];\n this.eastAlienImages = this.images;\n this.northAlienImages = this.images;\n this.westAlienImages = this.images;\n }\n}\n","import { GameService } from '../../service/game.service';\nimport { AlienClass } from '../alien/alien.class';\nimport { AssetScaleModel } from '../../model/asset-scale.mode';\nimport { ImageLoadedEnum } from '../../enum/image-loaded.enum';\n\n/**\n * The Alien 2 Class\n */\nexport class Alien2Class extends AlienClass {\n /**\n * Constructor\n * @param gameService The GameService\n * @param ctx The ctx\n * @param guid The guid of the alien\n * @param spawnLocation The guid of the alien\n */\n constructor(gameService: GameService, ctx: CanvasRenderingContext2D, guid: number) {\n super(gameService, ctx, guid);\n\n this.loadAlienImages();\n\n this.assetScale = {\n x: 0.2,\n y: 0.2\n } as AssetScaleModel;\n }\n\n /**\n * Load the alien Images\n */\n private loadAlienImages(): void {\n const imagesToLoad = [\n ImageLoadedEnum.alien2AnimationEast1,\n ImageLoadedEnum.alien2AnimationEast2,\n ImageLoadedEnum.alien2AnimationNorth1,\n ImageLoadedEnum.alien2AnimationNorth2,\n ImageLoadedEnum.alien2AnimationWest1,\n ImageLoadedEnum.alien2AnimationWest2\n ];\n\n imagesToLoad.map((key: ImageLoadedEnum) => {\n this.images.push(this.gameService.getImage(key));\n this.isImageLoaded = true;\n });\n\n this.eastAlienImages = [this.images[0], this.images[1]];\n this.northAlienImages = [this.images[2], this.images[3]];\n this.westAlienImages = [this.images[4], this.images[5]];\n\n this.images = this.westAlienImages;\n\n this.currentAlien = this.images[0];\n }\n}\n","/**\n * The Alien Path Enum\n */\nexport enum AlienPathEnum {\n /**\n * Empty\n */\n empty = 'empty',\n /**\n * Start\n */\n start = 'start',\n /**\n * Invalid\n */\n invalid = 'invalid',\n /**\n * Valid\n */\n valid = 'valid',\n /**\n * Goal\n */\n goal = 'goal',\n /**\n * Main Gunner\n */\n gunner = 'gunner',\n /**\n * Alien Base\n */\n alientBase = 'alienBase',\n /**\n * Blocked\n */\n blocked = 'blocked',\n /**\n * Unknown\n */\n unknown = 'unknown',\n /**\n * Visited\n */\n visited = 'visited',\n /**\n * Obstacle\n */\n obstacle = 'obstacle'\n}\n","/**\n * The Alien Path Direction Enum\n */\nexport enum AlienPathDirectionEnum {\n /**\n * North\n */\n north = 'north',\n /**\n * East\n */\n east = 'east',\n /**\n * West\n */\n west = 'west',\n /**\n * South\n */\n south = 'south'\n}\n","import { Injectable } from '@angular/core';\nimport { IAsset } from '../interface/asset.interface';\nimport { AlienPathEnum } from '../enum/alien-path.enum';\nimport { AlienLocationModel } from '../model/alien/alien-location.model';\nimport { AlienPathDirectionEnum } from '../enum/alien-path-direction.enum';\nimport { BLOCK_SIZE } from '../gameboard/gameboard-constants';\nimport { AssetDirectionEnum } from '../enum/asset-direction.enum';\n\n/**\n * The path service\n */\n@Injectable({\n providedIn: 'root'\n})\nexport class PathService {\n // http://gregtrowbridge.com/a-basic-pathfinding-algorithm/\n /**\n * Finds the shortest path for an alien from the spawn location\n * To the base\n *\n * @param startCoordinates the Starting Coordinating\n */\n findShortestPath(startCoordinates: IAsset, gameboard: AlienPathEnum[][]): IAsset[] {\n const pathBoard = JSON.parse(JSON.stringify(gameboard)) as AlienPathEnum[][];\n const distanceFromLeft = startCoordinates.x;\n const distanceFromTop = startCoordinates.y;\n\n // Each \"location\" will store its coordinates\n // and the shortest path required to arrive there\n const location = {\n distanceFromTop,\n distanceFromLeft,\n path: [\n {\n x: distanceFromLeft * BLOCK_SIZE,\n y: distanceFromTop * BLOCK_SIZE\n } as IAsset\n ],\n status: AlienPathEnu