Method: Unit#initialize
- Defined in:
- lib/lib/units/unit.rb
#initialize(x, y, faction, map, infopane) ⇒ Unit
Returns a new instance of Unit.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/lib/units/unit.rb', line 12 def initialize(x, y, faction, map, infopane) @x = x @y = y @faction = faction @map = map @infopane = infopane @armour_max = 1 @armour_left = @armour_max @moves_max = 1 @moves_left = @moves_max @cargo = [] # transported units @cargo_max = 0 @function = UnitFunction.new(FUNCNONE, self) # Store yourself coords_unit = @map.get_unit(@x, @y) if !coords_unit @map.set_unit(@x, @y, self) else # some town has just built you coords_unit.cargo.insert(-1, self) # -1 = to the end end end |