Class: Core::Game::Combat::BattleEnemy

Inherits:
BattleObject show all
Defined in:
lib/game/combat/battle.rb

Instance Attribute Summary collapse

Attributes inherited from BattleObject

#target

Instance Method Summary collapse

Methods inherited from BattleObject

#attacked

Constructor Details

#initialize(enemy, x, y, z) ⇒ BattleEnemy

Returns a new instance of BattleEnemy.



148
149
150
151
152
153
154
# File 'lib/game/combat/battle.rb', line 148

def initialize(enemy, x, y, z)
  super(enemy.graphic, x, y, z)
  @data = enemy
  @gui = nil
  @frame = 8
  @w, @h = @graphics.first.width, @graphics.first.height
end

Instance Attribute Details

#dataObject (readonly)

Returns the value of attribute data.



146
147
148
# File 'lib/game/combat/battle.rb', line 146

def data
  @data
end

#gui=(value) ⇒ Object (writeonly)

Sets the attribute gui

Parameters:

  • value

    the value to set the attribute gui to.



147
148
149
# File 'lib/game/combat/battle.rb', line 147

def gui=(value)
  @gui = value
end

Instance Method Details

#drawObject



174
175
176
# File 'lib/game/combat/battle.rb', line 174

def draw
  super
end

#nameObject



178
179
180
# File 'lib/game/combat/battle.rb', line 178

def name
  return @data.name
end

#update(pause) ⇒ Object



156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
# File 'lib/game/combat/battle.rb', line 156

def update(pause)
  super
  x, y = Core.window.mouse_x, Core.window.mouse_y
  if Core.inside?(x, y, @x, @y, @x+@w, @y+@h) and Core.window.pressed?(Gosu::MsLeft)
    if x - 160 < 0
      x = 160
    elsif x > 1024-320
      x = 1024-320
    end
    if y - 128 < 0
      y = 128
    elsif y > 512
      y = 512
    end
    @gui.open_info(self, 256, 160)
  end
end