#==============================================================================
# ■ Arrow_Base
#------------------------------------------------------------------------------
# 在战斗画面使用的箭头光标的活动块。本类作为
# Arrow_Enemy 类与 Arrow_Actor 类的超级类使用。
#==============================================================================
class Arrow_Base < Sprite
#--------------------------------------------------------------------------
# ● 定义实例变量
#--------------------------------------------------------------------------
attr_reader :index # 光标位置
attr_reader :help_window # 帮助窗口
#--------------------------------------------------------------------------
# ● 初始化对像
# viewport : 显示端口
#--------------------------------------------------------------------------
def initialize(viewport)
super(viewport)
self.bitmap = Cache.system("Arrow")
self.ox = 16
self.oy = 64
self.z = 2500
@blink_count = 0
@index = 0
@help_window = nil
update
end
#--------------------------------------------------------------------------
# ● 设置光标位置
# index : 新的光标位置
#--------------------------------------------------------------------------
def index=(index)
@index = index
update
end
#--------------------------------------------------------------------------
# ● 设置帮助窗口
# help_window : 新的帮助窗口
#--------------------------------------------------------------------------
def help_window=(help_window)
@help_window = help_window
# 刷新帮助文本 (update_help 定义了继承目标)
if @help_window != nil
update_help
end
end
#--------------------------------------------------------------------------
# ● 刷新画面
#--------------------------------------------------------------------------
def update
# 刷新点灭记数
@blink_count = (@blink_count + 1) % 12
# 设置传送源矩形
if @blink_count < 6
self.src_rect.set(0, 0, 32, 32)
else
self.src_rect.set(32, 0, 32, 32)
end
# 刷新帮助文本 (update_help 定义了继承目标)
if @help_window != nil
update_help
end
end
end
#==============================================================================
# ■ Arrow_Enemy
#------------------------------------------------------------------------------
# 选择敌人的箭头光标。本类继承 Arrow_Base
# 类。
#==============================================================================
class Arrow_Enemy < Arrow_Base
#--------------------------------------------------------------------------
# ● 获取光标指向的敌人
#--------------------------------------------------------------------------
def enemy
return $game_troop.members[@index]
end
def dispose
@enemy.loop_white_flash = false unless @enemy.nil?
super
end
#--------------------------------------------------------------------------
# ● 刷新画面
#--------------------------------------------------------------------------
def update
super
if @enemy != enemy and enemy.exist?
@enemy.loop_white_flash = false unless @enemy.nil?
enemy.loop_white_flash = true
@enemy = enemy
end
# 如果指向不存在的敌人就离开
$game_troop.members.size.times do
break if self.enemy.exist?
@index += 1
@index %= $game_troop.members.size
end
# 光标右
if Input.repeat?(Input::RIGHT) or Input.repeat?(Input::DOWN)
Sound.play_cursor
$game_troop.members.size.times do
@index += 1
@index %= $game_troop.members.size
break if self.enemy.exist?
end
end
# 光标左
if Input.repeat?(Input::LEFT) or Input.repeat?(Input::UP)
Sound.play_cursor
$game_troop.members.size.times do
@index += $game_troop.members.size - 1
@index %= $game_troop.members.size
break if self.enemy.exist?
end
end
# 设置活动块坐标
if self.enemy != nil
self.x = self.enemy.screen_x
self.y = self.enemy.screen_y
end
end
#--------------------------------------------------------------------------
# ● 刷新帮助文本
#--------------------------------------------------------------------------
def update_help
# 帮助窗口显示敌人的名字与状态
@help_window.set_enemy(self.enemy)
end
end
class Scene_Battle ##
#--------------------------------------------------------------------------
# ● 更新画面
#--------------------------------------------------------------------------
def update
super
update_basic(true)
update_info_viewport # 更新显示信息的视区
if $game_message.visible
@info_viewport.visible = false
@message_window.visible = true
end
unless $game_message.visible # 在显示消息以外的情况
return if judge_win_loss # 判断胜败
update_scene_change
if @enemy_arrow != nil
update_target_enemy_selection # 选择敌方对象
elsif @target_actor_window != nil
update_target_actor_selection # 选择对象角色
elsif @skill_window != nil
update_skill_selection # 选择特技
elsif @item_window != nil
update_item_selection # 选择物品
elsif @party_command_window.active
update_party_command_selection # 选择同伴指令
elsif @actor_command_window.active
update_actor_command_selection # 选择角色指令
else
process_battle_event # 战斗处理
process_action # 战斗行动
process_battle_event # 处理战斗事件
end
end
end
def set_window(visible)
if !@skill_window.nil?
@skill_window.visible = visible
elsif !@item_window.nil?
@item_window.visible = visible
end
end
#--------------------------------------------------------------------------
# ● 开始选择对象的敌方角色
#--------------------------------------------------------------------------
def start_target_enemy_selection
set_window(false)
@enemy_arrow = Arrow_Enemy.new(@spriteset.viewport3)
@enemy_window = Window_Enemy.new(176,0)
@enemy_arrow.help_window = @enemy_window
@actor_command_window.active = false
end
#--------------------------------------------------------------------------
# ● 选择对象敌方角色结束
#--------------------------------------------------------------------------
def end_target_enemy_selection
@enemy_arrow.dispose
@enemy_arrow = nil
@enemy_window.dispose
set_window(true)
if @actor_command_window.index == 0
@actor_command_window.active = true
end
end
#--------------------------------------------------------------------------
# ● 更新选择对象敌方角色
#--------------------------------------------------------------------------
def update_target_enemy_selection
@enemy_arrow.update
if Input.trigger?(Input::B)
Sound.play_cancel
end_target_enemy_selection
elsif Input.trigger?(Input::C)
Sound.play_decision
@active_battler.action.target_index = @enemy_arrow.enemy.index
end_target_enemy_selection
end_skill_selection
end_item_selection
next_actor
end
end
end
class Spriteset_Battle ##
def viewport3
return @viewport3
end
end
class Game_Battler
attr_accessor :loop_white_flash # 循环白色闪烁标记
end
class Sprite_Battler ##
alias old_setup_new_effect setup_new_effect
def setup_new_effect
if @battler.loop_white_flash and @effect_duration == 0
@battler.white_flash = true
end
old_setup_new_effect
end
end
#==============================================================================
# ■ Window_Enemy
#------------------------------------------------------------------------------
# 显示敌人信息的窗口,光标Arrow用。
#==============================================================================
class Window_Enemy < Window_Base
#--------------------------------------------------------------------------
# ● 初始化窗口
# x : 窗口的X坐标
# y : 窗口的Y坐标
#--------------------------------------------------------------------------
def initialize(x, y)
# super(x+70, y, 300, WLH * 3 + 32)
super(x+70, y, 300, WLH * 5 + 32)
# self.opacity = 0
end
#--------------------------------------------------------------------------
# ● 设置文本
# text : 窗口显示的字符串
# align : 对齐方式 (0..左对齐、1..中间对齐、2..右对齐)
#--------------------------------------------------------------------------
def set_text(text, align = 0)
# 如果文本和对齐方式的至少一方与上次的不同
# if text != @text or align != @align
# 再描绘文本
self.contents.clear
self.contents.font.color = normal_color
self.contents.draw_text(4, 0, self.width - 40, 32, text, align)
@text = text
@align = align
@actor = nil
# end
self.visible = true
end
#--------------------------------------------------------------------------
# ● 设置敌人
# enemy : 要显示名字和状态的敌人
#--------------------------------------------------------------------------
def set_enemy(enemy)
self.contents.font.size = 14
if @enemy != enemy
text = enemy.name
set_text(text)
w = enemy.states.size * 24
draw_actor_state(enemy, contents.width - w , 50, w)
draw_actor_hp(enemy, 0 , WLH )
draw_actor_mp(enemy, contents.width - 120 , WLH )
draw_actor_parameter(enemy, 0,WLH * 3 , 0)
draw_actor_parameter(enemy, 150,WLH * 3 , 1)
draw_actor_parameter(enemy, 0,WLH * 4 , 2)
draw_actor_parameter(enemy, 150,WLH * 4 , 3)
@enemy = enemy
end
end
end