class Spriteset_Battle
#---------------------------------------------------------------------------
# * 初始化
#---------------------------------------------------------------------------
alias icon_initialize initialize
def initialize
icon_initialize
creat_enemy_icon
icon_update
end
#---------------------------------------------------------------------------
# * 创建精灵实例
#---------------------------------------------------------------------------
def creat_enemy_icon
@enemy_icon = $game_troop.members.select {|item| item.have_state?}
@enemy_icon.reverse.collect do |icon|
Sprite_EnemyState.new(@viewport1, icon)
end
end
#--------------------------------------------------------------------------
# * 释放
#--------------------------------------------------------------------------
alias icon_dispose dispose
def dispose
icon_dispose
dispose_enemy_icon
end
#---------------------------------------------------------------------------
# * 更新
#---------------------------------------------------------------------------
alias icon_update update
def update
icon_update
update_enemy_icon
end
#---------------------------------------------------------------------------
# * 释放icon
#---------------------------------------------------------------------------
def dispose_enemy_icon
@enemy_icon.each {|sprite| sprite.dispose }
end
#---------------------------------------------------------------------------
# * 更新icon
#---------------------------------------------------------------------------
def update_enemy_icon
@enemy_icon.each {|sprite| sprite.update } if @enemy_icon
end
end
class Sprite_EnemyState < Sprite_Battler
#---------------------------------------------------------------------------
# * 初始化
#---------------------------------------------------------------------------
def initialize(viewport, battler = nil)
super(viewport, battler)
end
#---------------------------------------------------------------------------
# * 释放
#---------------------------------------------------------------------------
def dispose
bitmap.dispose if bitmap
super
end
#---------------------------------------------------------------------------
# * 更新
#---------------------------------------------------------------------------
def update
super
if @use_sprite
update_icon_bitmap
else
self.bitmap = nil
@effect_type = nil
end
end
#---------------------------------------------------------------------------
# * 更新画面Icon
#---------------------------------------------------------------------------
def update_icon_bitmap
icons = (@battler.state_icons + @battler.buff_icons)[0, width / 24]
icons.each_with_index {|n, i| draw_enemy_icon(n, @battler.x - 20 * i, @battler.y - 20) }
end
# --------------------------------------------------------------------------
# * 绘制敌人icon
# --------------------------------------------------------------------------
def draw_enemy_icon(icon_index, x, y,enabled = true)
bw = Graphics.width + 48
bh = Font.default_size*3
bitmap = Bitmap.new(bw,bh)
icbitmap = Cache.system("Iconset")
rect = Rect.new(icon_index % 16 * 24, icon_index / 16 * 24, 24, 24)
new_bitmap = bitmap.blt(x, y, icbitmap, rect, enabled ? 255 : translucent_alpha)
if bitmap != new_bitmap
self.bitmap = new_bitmap
init_visibility
end
end
end
class Game_Enemy
def have_state?
return true if @state != []
end
end