-
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.
Create sub-folders in src. Add scan stop shoot behaviour to tank.
- Loading branch information
Showing
30 changed files
with
416 additions
and
230 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,4 +4,5 @@ node_modules | |
dist | ||
# don't lint nyc coverage output | ||
coverage | ||
jest.config.js | ||
jest.config.js | ||
tests |
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,43 @@ | ||
import BarrackGameObject from "./static-objects/BarrackGameObject" | ||
import FactoryGameObject from "./static-objects/FactoryGameObject" | ||
import GameScene from "./GameScene" | ||
import SoldierGameObject from "./mobile-objects/SoldierGameObject" | ||
import TankGameObject from "./mobile-objects/TankGameObject" | ||
|
||
export default abstract class ForceControl { | ||
protected abstract factory: FactoryGameObject | ||
protected abstract barrack: BarrackGameObject | ||
protected abstract boardableBodies: Phaser.Physics.Arcade.Group | ||
|
||
protected tankObjects = new Set<TankGameObject>() | ||
protected soliderObjects = new Set<SoldierGameObject>() | ||
|
||
constructor(protected readonly scene: GameScene, protected readonly owner: number) {} | ||
|
||
update(time: number, delta: number): void { | ||
this.soliderObjects.forEach(soldier => soldier.update(time, delta)) | ||
this.tankObjects.forEach(tank => tank.update(time)) | ||
} | ||
|
||
protected buildTank(): void { | ||
const tank = new TankGameObject(this.scene, this.owner, this.factory.spawnX, 50) | ||
tank.move(50 * this.owner, this.owner < 0) | ||
this.tankObjects.add(tank) | ||
this.scene.gameMap.add(tank) | ||
tank.destroyCallback = () => { | ||
this.tankObjects.delete(tank) | ||
this.scene.gameMap.remove(tank) | ||
} | ||
} | ||
|
||
protected buildSoldier(): void { | ||
const soldier = new SoldierGameObject(this.scene, this.owner, this.barrack.spawnX, this.boardableBodies) | ||
soldier.move(10 * this.owner, this.owner < 0) | ||
this.soliderObjects.add(soldier) | ||
this.scene.gameMap.add(soldier) | ||
soldier.destroyCallback = () => { | ||
this.soliderObjects.delete(soldier) | ||
this.scene.gameMap.remove(soldier) | ||
} | ||
} | ||
} |
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.