Class: Unit

Stardash. Unit

A unit in the game. May be a corvette, missleboat, martyr, transport, miner.

new Stardash.Unit()

Initializes a Unit with basic logic as provided by the Creer code generator. Never use this directly. It is for internal Joueur use.

Extends

Members

boolean acted

Whether or not this Unit has performed its action this turn.

number dashX

The x value this unit is dashing to.

number dashY

The y value this unit is dashing to.

number energy

The remaining health of the unit.

string gameObjectName

Inherited From:
Stardash.GameObject#gameObjectName
String representing the top level Class that this game object is an instance of. Used for reflection to create new instances on clients, but exposed for convenience should AIs want this data.

number genarium

The amount of Genarium ore carried by this unit. (0 to job carry capacity - other carried items).

string id

Inherited From:
Stardash.GameObject#id
A unique id for each instance of a GameObject or a sub class. Used for client and server communication. Should never change value after being set.

boolean isBusy

Tracks whether or not the ship is dashing or Mining. If true, it cannot do anything else.
The Job this Unit has.

number legendarium

The amount of Legendarium ore carried by this unit. (0 to job carry capacity - other carried items).

Array.<string> logs

Inherited From:
Stardash.GameObject#logs
Any strings logged will be stored here. Intended for debugging.

number moves

The distance this unit can still move.

number mythicite

The amount of Mythicite carried by this unit. (0 to job carry capacity - other carried items).
The Player that owns and can control this Unit.

Stardash.Unit protector

The martyr ship that is currently shielding this ship if any.

number rarium

The amount of Rarium carried by this unit. (0 to job carry capacity - other carried items).

number shield

The shield that a martyr ship has.

number x

The x value this unit is on.

number y

The y value this unit is on.

Methods

boolean attack(enemy)

Attacks the specified unit.
Name Type Description
enemy Stardash.Unit The Unit being attacked.
Returns: boolean
True if successfully attacked, false otherwise.

boolean dash(x, y)

Causes the unit to dash towards the designated destination.
Name Type Description
x number The x value of the destination's coordinates.
y number The y value of the destination's coordinates.
Returns: boolean
True if it moved, false otherwise.

log(message)

Inherited From:
Stardash.GameObject#log
Adds a message to this GameObject's logs. Intended for your own debugging purposes, as strings stored here are saved in the gamelog.
Name Type Description
message string A string to add to this GameObject's log. Intended for debugging.

boolean mine(body)

Allows a miner to mine a asteroid.
Name Type Description
body Stardash.Body The object to be mined.
Returns: boolean
True if successfully acted, false otherwise.

boolean move(x, y)

Moves this Unit from its current location to the new location specified.
Name Type Description
x number The x value of the destination's coordinates.
y number The y value of the destination's coordinates.
Returns: boolean
True if it moved, false otherwise.

boolean safe(x, y)

Tells you if your ship can move to that location from were it is without clipping the sun.
Name Type Description
x number The x position of the location you wish to arrive.
y number The y position of the location you wish to arrive.
Returns: boolean
True if pathable by this unit, false otherwise.

boolean shootdown(missile)

Attacks the specified projectile.
Name Type Description
missile Stardash.Projectile The projectile being shot down.
Returns: boolean
True if successfully attacked, false otherwise.

string toString()

Inherited From:
BaseGameObject#toString
toString override for easier debugging
Returns: string
readable string in the format `GameObjectName #id`

boolean transfer(unit, amount, material)

Grab materials from a friendly unit. Doesn't use a action.
Name Type Description
unit Stardash.Unit The unit you are grabbing the resources from.
amount number The amount of materials to you with to grab. Amounts <= 0 will pick up all the materials that the unit can.
material string The material the unit will pick up. 'genarium', 'rarium', 'legendarium', or 'mythicite'.
Returns: boolean
True if successfully taken, false otherwise.