class GeoWars::Units::Unit

Direct Known Subclasses

Defined in:

geo_wars/units/unit.cr

Constant Summary

DEFAULT_ATTACK_CELLS_RELATIVE = [0, 1, -1].permutations.map do |arr| {x: arr[0], y: arr[1]} end.select do |move| (move[:x] + move[:y]).abs == 1 end
DEFAULT_DAMAGE = 1
DISABLED_DARKNESS = 0.325
MAX_HIT_POINTS = 10
MAX_MOVEMENT = 3
MOVEMENT_RADIUS_COLOR = LibRay::Color.new(r: 255, g: 255, b: 255, a: 125)
SELECTED_BORDER_COLOR = LibRay::BLACK
SELECTED_BORDER_SIZE_RATIO = 16
SELECTED_BORDER_TIMER = 0.75
SIZE_RATIO = 0.5

Constructors

Class Method Summary

Instance Method Summary

Constructor Detail

def self.new(x : Int32, y : Int32, player : GeoWars::Player, max_movement : Int32 = MAX_MOVEMENT, default_damage : Int32 = DEFAULT_DAMAGE, attack_cells_relative_initial : Array(NamedTuple(x: Int32, y: Int32)) = DEFAULT_ATTACK_CELLS_RELATIVE) #

[View source]

Class Method Detail

def self.deserialize(line, players) #

[View source]

Instance Method Detail

def add_moves(moves, moves_left, cells, cells_x, cells_y) #

[View source]
def attack(unit : Units::Unit, unit_cell, current_cell) #

[View source]
def attack(cursor_cell, cells) #

[View source]
def attack_preview_percentage(unit : Units::Unit, unit_cell) #

[View source]
def can_attack? #

[View source]
def damage(unit : Units::Unit, unit_cell) #

[View source]
def description #

[View source]
def die #

[View source]
def disable #

[View source]
def disabled? : Bool? #

[View source]
def draw(viewport) #

[View source]
def draw_attack_radius(viewport) #

[View source]
def draw_movement_radius(viewport) #

[View source]
def enable #

[View source]
def jump_to(x : Int32, y : Int32) #

[View source]
def max_movement : Int32 #

[View source]
def move(cursor_cell, cells) #

[View source]
def move_absolute(move) #

[View source]
def player : Player #

[View source]
def remove? : Bool #

[View source]
def select(cells, cells_x, cells_y) #

[View source]
def selectable?(turn_player) #

[View source]
def selected? : Bool #

[View source]
def serialize(players) #

[View source]
def take_damage(damage) #

[View source]
def terrain_moves(terrain) #

[View source]
def turn_reset #

[View source]
def unselect #

[View source]
def update(frame_time) #

[View source]
def update_attack_cells(cells) #

[View source]
def update_moves(cells, cells_x, cells_y) #

[View source]
def valid_move?(cursor_cell, moves_relative) #

[View source]
def x : Int32 #

[View source]
def y : Int32 #

[View source]