Class: EnemyFleet

EnemyFleet(game, bombFactory)

Enemy fleet of ships, could also be called Enemy Factory.

Constructor

new EnemyFleet(game, bombFactory)

Make a new enemy fleet and populate it with ships.
Parameters:
Name Type Description
game SpaceInvaders The current game instance.
bombFactory EnemyBombFactory The bomb factory that created this bomb.
Properties:
Name Type Description
bombFactory EnemyBombFactory This handles all the enemy bombs
deaths number Number of enemy killed in action
Author:
Source:

Extends

Members

totalAlive

Get how many enemies are still alive.
Source:

Methods

canMake() → {boolean}

Check if we can make a new instance based on maxItems
Inherited From:
Source:
Returns:
Type
boolean

destroy(item) → {Object}

Destroy an instance created by this factory
Parameters:
Name Type Description
item Object The item / instance to destroy
Inherited From:
Source:
Returns:
Returns the instance created
Type
Object

make(type, startX, startY, direction) → {boolean}

Public make method to create a new enemy ship
Parameters:
Name Type Description
type string Type of enemy ship to create (standard, boss, ufo).
startX number Starting X position.
startY number Starting Y position.
direction number Direction enemy ship is travelling
Overrides:
Source:
Returns:
Type
boolean

makeFleet() → {boolean}

Make a randomised fleet
Source:
Returns:
Type
boolean

makeItem(type, startX, startY, direction) → {EnemyShip}

Private make item method to create and return new ship instance.
Parameters:
Name Type Description
type string Type of enemy ship to create (standard, boss, ufo).
startX number Starting X position.
startY number Starting Y position.
direction number Direction enemy ship is travelling.
Overrides:
Source:
Returns:
- The enemy ship instance created.
Type
EnemyShip

removeShip(ship)

Remove a ship from the fleet.
Parameters:
Name Type Description
ship EnemyShip The ship being removed
Source:

reset() → {boolean}

Reset for a new game
Overrides:
Source:
Returns:
Type
boolean

resetCountdown()

Restart the auto make countdown based on max / min delay
Inherited From:
Source:

update()

Main update loop
Inherited From:
Source: