Class: Core::Game::Combat::Actor

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

Overview

Party member

Instance Attribute Summary collapse

Attributes inherited from BattleObject

#target

Instance Method Summary collapse

Methods inherited from BattleObject

#attacked

Constructor Details

#initialize(char, x, y, z) ⇒ Actor

Returns a new instance of Actor.



187
188
189
190
191
192
193
194
195
196
197
198
# File 'lib/game/combat/battle.rb', line 187

def initialize(char, x, y, z)
  super(char.charset, x, y, z)
  @character = char
  @health = Bar.new(x - 8, y - 8, 100, 48, 6, :health, 100, false)
  @health.set(@character.health)
  @next = Bar.new(x - 8, y - 16, 100, 48, 6, :health, 600 - (@character.agility*5), false)
  @next.visible = false
  @ready = false
  @ready_shown = false
  @moving = false
  @ready_time = 600 - (@character.agility*5)
end

Instance Attribute Details

#characterObject (readonly)

Returns the value of attribute character.



185
186
187
# File 'lib/game/combat/battle.rb', line 185

def character
  @character
end

#ready_shownObject

Returns the value of attribute ready_shown.



186
187
188
# File 'lib/game/combat/battle.rb', line 186

def ready_shown
  @ready_shown
end

Instance Method Details

#drawObject



218
219
220
221
222
# File 'lib/game/combat/battle.rb', line 218

def draw
  super
  @health.draw
  @next.draw
end

#nameObject



231
232
233
# File 'lib/game/combat/battle.rb', line 231

def name
  return @character.name
end

#ready!Object



226
227
228
229
# File 'lib/game/combat/battle.rb', line 226

def ready!
  @next.fade
  @ready = true
end

#ready?Boolean

Returns:

  • (Boolean)


223
224
225
# File 'lib/game/combat/battle.rb', line 223

def ready?
  return @ready
end

#update(pause) ⇒ Object



199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
# File 'lib/game/combat/battle.rb', line 199

def update(pause)
  super
  if !pause
    if @moving
      @health.x, @health.y = @x - 8, @y - 8
      @next.x, @health.y = @x - 8, @y - 16
    end
    if @ready_time == 0
      ready!
      @ready_time = -1
    elsif @ready_time > 0
      @ready_time -= 1
      @next.visible = true
      @next.set(@next.max - @ready_time)
    end
  end
  @health.update
  @next.update
end