-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: move the stuff to object service
- Loading branch information
Showing
20 changed files
with
282 additions
and
181 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
export enum ObjectType { | ||
ship = 'ship', | ||
enemy = 'enemy', | ||
meteor = 'meteor', | ||
rocket = 'rocket', | ||
collectable = 'collectable', | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,16 @@ | ||
import { FrameObject, Texture } from 'pixi.js'; | ||
import { ExplosionService } from '../../services/explosion.service'; | ||
import { AnimatedGameSprite } from './animated-game-sprite'; | ||
import { Ship } from './ship'; | ||
import { ObjectType } from './object-type.enum'; | ||
|
||
export class Rocket extends AnimatedGameSprite { | ||
reference: Ship | undefined; | ||
constructor( | ||
explosion: ExplosionService, | ||
speed: number, | ||
textures: Texture[] | FrameObject[], | ||
autoUpdate?: boolean) { | ||
super(ObjectType.rocket, explosion, speed, textures, autoUpdate); | ||
|
||
override hit(object2: AnimatedGameSprite): boolean { | ||
return this.reference !== object2 && super.hit(object2); | ||
this.energy = 1; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,8 @@ | ||
import { inject } from '@angular/core'; | ||
import { AnimatedSprite } from 'pixi.js'; | ||
import { ApplicationService } from './application.service'; | ||
import { ExplosionService } from './explosion.service'; | ||
import { ObjectService } from './object.service'; | ||
|
||
export abstract class BaseService { | ||
private explosion = inject(ExplosionService); | ||
|
||
protected readonly application = inject(ApplicationService); | ||
|
||
protected explode( | ||
x: number, | ||
y: number, | ||
oncomplete: (explosion: AnimatedSprite) => void = (): void => { | ||
}, | ||
): void { | ||
void this.explosion.explode(this.application.stage, x, y, oncomplete); | ||
} | ||
protected readonly object = inject(ObjectService); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.