#==============================================================================
# ■ Game_Event
#------------------------------------------------------------------------------
# 处理事件的类。条件判断、事件页的切换、并行处理、执行事件功能
# 在 Game_Map 类的内部使用。
#==============================================================================
class Game_Event < Game_Character
#——————————————————————————————————————
# 用来返回名称
#——————————————————————————————————————
def name
return @event.name
end
def name=(newname)
@event.name = newname
end
end
class Sprite_Character < RPG::Sprite
#--------------------------------------------------------------------------
attr_accessor :character # 角色
def initialize(viewport, character = nil)
name = character.name
# @character = character
super(viewport)
@showsprite = Sprite.new
@showsprite.bitmap = Bitmap.new(100, 48)
@showsprite.bitmap.font.name = (["微软雅黑"])
@showsprite.bitmap.font.size = 16
@showsprite.bitmap.font.bold = true
@character = character
@actor = $game_party.actors[0]
if not @character.is_a?(Game_Player)
@arpg_hp = character.arpg_hp
@arpg_hpmax = character.arpg_hpmax
else
@arpg_hp = @actor.hp
@arpg_hpmax = @actor.maxhp
@arpg_sp = @actor.sp
@arpg_spmax = @actor.maxsp
end
@evname = name
if @character.is_a?(Game_Player)
@old_hp = @actor.hp
else
@old_hp = character.arpg_hp# @arpg_hp#@actor.hp
end
@old_sp = @actor.sp
@old_level = @actor.level
draw_character_bar
# end
@showsprite.x = self.x-76
@showsprite.y = self.y-self.oy-45
@showsprite.z = self.y
@showsprite.visible = true#@character.is_a?(Game_Player) ? (@actor.dead? ?
#false : true) : false
update
end
def draw_character_bar
@character = character
if not @character.is_a?(Game_Player)
@arpg_hp = character.arpg_hp
@arpg_hpmax = character.arpg_hpmax
else
@arpg_hp = @actor.hp
@arpg_hpmax = @actor.maxhp
@arpg_sp = @actor.sp
@arpg_spmax = @actor.maxsp
end
@showsprite = Sprite.new
@showsprite.bitmap = Bitmap.new(150, 148)# 100 48
@showsprite.bitmap.font.name = (["微软雅黑"])
@showsprite.bitmap.font.size = 17
@showsprite.bitmap.font.bold = true
#self.z = @showsprite.z
if not @character.is_a?(Game_Player)
txt = @evname#@actor.name
else
txt = @actor.name
end
#if $game_switches[9] == false
# txt = ""
# end
if txt != "" and @evname[0, 2]!="EV" and @evname[0, 2]!="Cs"
# txt += " (Lv " + @actor.level.to_s + ")"
# if not @character.is_a?(Game_Player) and character.arpg_hp > 0
txt = character.name #+ " L.v.5" #$data_enemies[@event.id].name
# else
# txt = ""
# end
@showsprite.bitmap.font.color.set(255, 255, 255)
if character.name.split(/,/)[1] != nil #name.split(/,/)[0]
case character.name.split(/,/)[1] # g绿 y黄 r红
when "g"
@showsprite.bitmap.font.color.set(50, 255, 50)
when "y"
@showsprite.bitmap.font.color.set(255, 255, 50)
when "r"
@showsprite.bitmap.font.color.set(255, 0, 0)
end
end
@showsprite.bitmap.draw_text2(-5, 85, 160, 36, txt.split(/,/)[0], 1)
# @sprite.bitmap.draw_text2(-5, 85, 160, 36, txt.split(/,/)[0], 1)
end
if @arpg_hp > 0 #and 1==2# @wait_count > 0an
if @character.is_a?(Game_Player) #and 1==2
@showsprite.bitmap.fill_rect(55, 30, 42, 1, Color.new(0, 0, 0,230))
@showsprite.bitmap.fill_rect(55, 30, 1, 5, Color.new(0, 0, 0,230))
@showsprite.bitmap.fill_rect(55, 34, 42, 1, Color.new(0, 0, 0,230))
@showsprite.bitmap.fill_rect(96, 30, 1, 5, Color.new(0, 0, 0,230))
w = @arpg_hp * 4000 / (@arpg_hpmax) / 100
@showsprite.bitmap.fill_rect(56, 31, 40, 3, Color.new(0, 0, 0))
@showsprite.bitmap.fill_rect(56, 31, w, 3, Color.new(0, 255, 20))
else
if @character.Jzjs > 0 #$game_variables[50] == @character.id and @character.Jzjs > 0
@showsprite.bitmap.fill_rect(55, 30, 42, 1, Color.new(0, 0, 0,230))
@showsprite.bitmap.fill_rect(55, 30, 1, 5, Color.new(0, 0, 0,230))
@showsprite.bitmap.fill_rect(55, 34, 42, 1, Color.new(0, 0, 0,230))
@showsprite.bitmap.fill_rect(96, 30, 1, 5, Color.new(0, 0, 0,230))
w = @arpg_hp * 4000 / (@arpg_hpmax) / 100
@showsprite.bitmap.fill_rect(56, 31, 40, 3, Color.new(0, 0, 0))
@showsprite.bitmap.fill_rect(56, 31, w, 3, Color.new(0, 255, 20))
# txt = @character.name
# @showsprite.bitmap.font.color.set(0, 255, 0)
#@showsprite.bitmap.draw_text(40, 10, 160, 12, txt, 1)
end
end
# @showsprite.bitmap.font.color.set(255, 255, 255)
# @showsprite.bitmap.draw_text(0, 30, 160, 12, "123", 1)
if @character.is_a?(Game_Player) #and 1==
w = @arpg_sp * 4000 / (@arpg_spmax) / 100
@showsprite.bitmap.fill_rect(55, 36, 42, 1, Color.new(0, 0, 0,230))
@showsprite.bitmap.fill_rect(55, 36, 1, 5, Color.new(0, 0, 0,230))
@showsprite.bitmap.fill_rect(55, 40, 42, 1, Color.new(0, 0, 0,230))
@showsprite.bitmap.fill_rect(96, 36, 1, 5, Color.new(0, 0, 0,230))
@showsprite.bitmap.fill_rect(56, 37, w, 3, Color.new(20, 0, 255))
end
end
end
#--------------------------------------------------------------------------
#--------------------------------------------------------------------------
def update
super
# 元件 ID、文件名、色相与现在的情况存在差异的情况下
@character = character
if not @character.is_a?(Game_Player)
@arpg_hp = character.arpg_hp
@wait_count = character.wait_count
else
@arpg_hp = @actor.hp
@arpg_sp = @actor.sp
@wait_count = 1
end
if @tile_id != @character.tile_id or
@character_name != @character.character_name or
@character_hue != @character.character_hue
# 记忆元件 ID 与文件名、色相
@tile_id = @character.tile_id
@character_name = @character.character_name
@character_hue = @character.character_hue
# 元件 ID 为有效值的情况下
if @tile_id >= 384
self.bitmap = RPG::Cache.tile($game_map.tileset_name,
@tile_id, @character.character_hue)
self.src_rect.set(0, 0, 32, 32)
self.ox = 16
self.oy = 32
# 元件 ID 为无效值的情况下
else
self.bitmap = RPG::Cache.character(@character.character_name,
@character.character_hue)
@cw = bitmap.width / 4
@ch = bitmap.height / 4
if @character_name.include?("one")
@cw = bitmap.width
@ch = bitmap.height
end
self.ox = @cw / 2
self.oy = @ch
end
end
# 设置可视状态
self.visible = (not @character.transparent)
# 图形是角色的情况下
if @tile_id == 0
# 设置传送目标的矩形
sx = @character.pattern * @cw
sy = (@character.direction - 2) / 2 * @ch
self.src_rect.set(sx, sy, @cw, @ch)
end
# if @character.is_a?(Game_Player)
if @old_hp != @arpg_hp or ( @character.is_a?(Game_Player) and @old_sp != @arpg_sp)
@showsprite.dispose
@actor = $game_party.actors[0]
if not @character.is_a?(Game_Player)
@arpg_hp = character.arpg_hp
@arpg_hpmax = character.arpg_hpmax
else
@arpg_hp = @actor.hp
@arpg_hpmax = @actor.maxhp
end
#@old_hp = @actor.hp
@old_sp = @actor.sp
@old_level = @actor.level
draw_character_bar
# update
end
# end
@showsprite.x = self.x-76
@showsprite.y = self.y-100
# @showsprite.x = 350
# @showsprite.y = 180
# end
if @character.name[0, 2]!="EV" #and @arpg_hp > 0 @evname
@showsprite.visible = true
# if (not @character.is_a?(Game_Player)) and @character.Jzjs <= 0#($game_variables[50] != @character.id)
# @showsprite.visible = false
# end
else
@showsprite.visible = false
end
# @showsprite.visible = true#@character.is_a?(Game_Player) ? (@actor.dead? ?
#false : true) : false
# 设置脚本的坐标
self.x = @character.screen_x
self.y = @character.screen_y
self.z = @character.screen_z(@ch)
# 设置不透明度、合成方式、茂密
self.opacity = @character.opacity
self.blend_type = @character.blend_type
self.bush_depth = @character.bush_depth
# 动画
if @character.animation_id != 0
animation = $data_animations[@character.animation_id]
animation(animation, true)
@character.animation_id = 0
end
end
end
#==============================================================================
class Game_Player < Game_Character
def name
return $game_party.actors[0].name# "afa"
end
end