Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Unit

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

Hierarchy

Implements

  • IBaseGameObject

Index

Properties

acted

acted: boolean

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

dashX

dashX: number

The x value this unit is dashing to.

dashY

dashY: number

The y value this unit is dashing to.

energy

energy: number

The remaining health of the unit.

gameObjectName

gameObjectName: string

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.

genarium

genarium: number

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

  • other carried items).

id

id: string

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.

isBusy

isBusy: boolean

Tracks whether or not the ship is dashing or Mining. If true, it cannot do anything else.

job

job: Job

The Job this Unit has.

legendarium

legendarium: number

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

logs

logs: string[]

Any strings logged will be stored here. Intended for debugging.

moves

moves: number

The distance this unit can still move.

mythicite

mythicite: number

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

owner

owner: Player | undefined

The Player that owns and can control this Unit.

protector

protector: Unit | undefined

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

rarium

rarium: number

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

shield

shield: number

The shield that a martyr ship has.

x

x: number

The x value this unit is on.

y

y: number

The y value this unit is on.

Methods

attack

  • attack(enemy: Unit): Promise<boolean>
  • Attacks the specified unit.

    Parameters

    • enemy: Unit

      The Unit being attacked.

    Returns Promise<boolean>

    True if successfully attacked, false otherwise.

dash

  • dash(x: number, y: number): Promise<boolean>
  • Causes the unit to dash towards the designated destination.

    Parameters

    • x: number

      The x value of the destination's coordinates.

    • y: number

      The y value of the destination's coordinates.

    Returns Promise<boolean>

    True if it moved, false otherwise.

log

  • log(message: string): Promise<void>
  • Adds a message to this GameObject's logs. Intended for your own debugging purposes, as strings stored here are saved in the gamelog.

    Parameters

    • message: string

      A string to add to this GameObject's log. Intended for debugging.

    Returns Promise<void>

mine

  • mine(body: Body): Promise<boolean>
  • Allows a miner to mine a asteroid.

    Parameters

    • body: Body

      The object to be mined.

    Returns Promise<boolean>

    True if successfully acted, false otherwise.

move

  • move(x: number, y: number): Promise<boolean>
  • Moves this Unit from its current location to the new location specified.

    Parameters

    • x: number

      The x value of the destination's coordinates.

    • y: number

      The y value of the destination's coordinates.

    Returns Promise<boolean>

    True if it moved, false otherwise.

safe

  • safe(x: number, y: number): Promise<boolean>
  • Tells you if your ship can move to that location from were it is without clipping the sun.

    Parameters

    • 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 Promise<boolean>

    True if pathable by this unit, false otherwise.

shootdown

  • shootdown(missile: Projectile): Promise<boolean>
  • Attacks the specified projectile.

    Parameters

    • missile: Projectile

      The projectile being shot down.

    Returns Promise<boolean>

    True if successfully attacked, false otherwise.

toString

  • toString(): string
  • A toString override for easier debugging.

    example

    String(gameObject); 🠞 "GameObjectName #1245"

    Returns string

    A human readable representation of the game object.

transfer

  • transfer(unit: Unit, amount: number, material: "genarium" | "rarium" | "legendarium" | "mythicite"): Promise<boolean>
  • Grab materials from a friendly unit. Doesn't use a action.

    Parameters

    • unit: 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: "genarium" | "rarium" | "legendarium" | "mythicite"

      The material the unit will pick up. 'genarium', 'rarium', 'legendarium', or 'mythicite'.

    Returns Promise<boolean>

    True if successfully taken, false otherwise.

Generated using TypeDoc