class Hardpoint

Not intended to be overridden

Attributes

assigned_weapon_class[RW]
group_number[RW]
image_angle[RW]
image_hardpoint[RW]
image_hardpoint_height_half[RW]
image_hardpoint_width_half[RW]
main_weapon[RW]
slot_type[RW]
x[RW]
x_offset[RW]
y[RW]
y_offset[RW]

Public Class Methods

new(scale, x, y, screen_width, screen_height, group_number, x_offset, y_offset, item, slot_type, options = {}) click to toggle source

MISSILE_LAUNCHER_MIN_ANGLE = 75 MISSILE_LAUNCHER_MAX_ANGLE = 105 MISSILE_LAUNCHER_INIT_ANGLE = 90

Calls superclass method GeneralObject::new
# File line-em-up/models/hardpoint.rb, line 21
def initialize(scale, x, y, screen_width, screen_height, group_number, x_offset, y_offset, item, slot_type, options = {})
  # puts "GHARDPOINT INIT: #{y_offset}"
  @group_number = group_number
  @x_offset = x_offset# * scale
  @y_offset = y_offset# * scale
  @slot_type = slot_type
  super(scale, x + @x_offset, y + @y_offset, screen_width, screen_height, options)
  @main_weapon = nil
  @drawable_items_near_self = []

  if item
    @assigned_weapon_class = item
    @image_hardpoint = item.get_hardpoint_image
  else
    @image_hardpoint = Gosu::Image.new("#{MEDIA_DIRECTORY}/hardpoint_empty.png")
  end
  @image_hardpoint_width_half = @image_hardpoint.width  / 2
  @image_hardpoint_height_half = @image_hardpoint.height  / 2
  @image_angle = options[:image_angle]
end

Public Instance Methods

attack(pointer, opts = {}) click to toggle source
# File line-em-up/models/hardpoint.rb, line 50
def attack pointer, opts = {}
  # puts "HARDPOINT ATTACK"
  attack_projectile = nil
  if @main_weapon.nil?
    # options = {damage_increase: @damage_increase, relative_y_padding: @image_height_half}
    options = {}
    options[:damage_increase] = opts[:damage_increase] if opts[:damage_increase]
    options[:image_angle] = @image_angle
    if @assigned_weapon_class
      @main_weapon = @assigned_weapon_class.new(@scale, @screen_width, @screen_height, self, options)
      @drawable_items_near_self << @main_weapon
      attack_projectile = @main_weapon.attack(pointer)
    end
  else
    @main_weapon.active = true if @main_weapon.active == false
    @drawable_items_near_self << @main_weapon
    attack_projectile = @main_weapon.attack(pointer)
  end
  if attack_projectile
    return {
      projectiles: [attack_projectile],
      cooldown: @assigned_weapon_class::COOLDOWN_DELAY
    }
  else
    return nil
  end
end
draw() click to toggle source
# File line-em-up/models/hardpoint.rb, line 90
def draw
  # puts "DRAWING HARDPOINT: #{@x} and #{@y}"
  @drawable_items_near_self.reject! { |item| item.draw }

  if @image_angle != nil
    @image_hardpoint.draw_rot(@x, @y, get_draw_ordering, @image_angle, 0.5, 0.5, @scale, @scale)
  else
    @image_hardpoint.draw(@x - @image_hardpoint_width_half, @y - @image_hardpoint_height_half, get_draw_ordering, @scale, @scale)
  end

end
draw_gl() click to toggle source
# File line-em-up/models/hardpoint.rb, line 102
def draw_gl
  @drawable_items_near_self.reject! { |item| item.draw_gl }
end
get_draw_ordering() click to toggle source
# File line-em-up/models/hardpoint.rb, line 86
def get_draw_ordering
  ZOrder::Hardpoint
end
get_x() click to toggle source
# File line-em-up/models/hardpoint.rb, line 78
def get_x
  @x
end
get_y() click to toggle source
# File line-em-up/models/hardpoint.rb, line 82
def get_y
  @y
end
stop_attack() click to toggle source
# File line-em-up/models/hardpoint.rb, line 44
def stop_attack
  # puts "HARDPOINT STOP ATTACK"
  @main_weapon.deactivate if @main_weapon

end
update(mouse_x = nil, mouse_y = nil, player = nil, scroll_factor = 1) click to toggle source
# File line-em-up/models/hardpoint.rb, line 107
def update mouse_x = nil, mouse_y = nil, player = nil, scroll_factor = 1
  # puts "HARDPOINT X offset: #{@x_offset}"
  # puts "HARDPOINT Y offset: #{@y_offset}"
  @x = player.x + @x_offset# * @scale
  @y = player.y + @y_offset# * @scale
  # Update list of weapons for special cases like beans. Could iterate though an association in the future.
  @main_weapon.update(mouse_x, mouse_y, self, scroll_factor) if @main_weapon
  # @cooldown_wait -= 1              if @cooldown_wait > 0
  # @secondary_cooldown_wait -= 1    if @secondary_cooldown_wait > 0
  # @grapple_hook_cooldown_wait -= 1 if @grapple_hook_cooldown_wait > 0
  # @time_alive += 1 if self.is_alive
end