#==============================================================================
# ■ Window_Battlecommand
#------------------------------------------------------------------------------
# 战斗的命令选择行窗口。
#==============================================================================
class Window_Battlecommand < Window_Selectable
#--------------------------------------------------------------------------
# ● 初始化对像
# width : 窗口的宽
# commands : 命令字符串序列
#--------------------------------------------------------------------------
def initialize(width, commands)
# 由命令的个数计算出窗口的高
super(0, 0, width, commands.size * 32) #+ 32
@item_max = commands.size
@commands = commands
@command_icons = [
"攻击",
"技能",
"防御",
"道具"
]
# self.windowskin = RPG::Cache.windowskin("")
self.contents = Bitmap.new(width - 32, @item_max * 32)
self.opacity = 0
@back_sprite = Sprite.new
@back_sprite.bitmap = RPG::Cache.picture("魔导阵")
@back_sprite.ox = @back_sprite.bitmap.width / 2
@back_sprite.oy = @back_sprite.bitmap.height / 2
@back_sprite.x = self.x + 376
@back_sprite.y = self.y + 92
@back_sprite.z = 9999
refresh
self.index = 0
end
#--------------------------------------------------------------------------
# ● 释放
#--------------------------------------------------------------------------
def dispose
super
@back_sprite.dispose
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh
self.contents.clear
@commands.each_with_index do |command, i|
draw_item(command, i)
end
end
#--------------------------------------------------------------------------
# ● 更新
#--------------------------------------------------------------------------
alias magic_update update
def update
magic_update
@back_sprite.angle -= 2
end
#--------------------------------------------------------------------------
# ● 描绘项目
# commands : 项目
# i : 序号,从0开始
#--------------------------------------------------------------------------
def draw_item(command, i)
file = @command_icons[i]
if file == nil
bitmap = Bitmap.new(24,24)
else
bitmap = RPG::Cache.icon(@command_icons[i])
end
if i == 0
self.contents.blt(4+40, i*32 + 4 , bitmap , Rect.new(0,0,24,24))
self.contents.draw_text(4+64, i*32 , width - 32 - 36 , 32 , command)
elsif i == 1
self.contents.blt(4+4, i*32 + 4 , bitmap , Rect.new(0,0,24,24))
self.contents.draw_text(4+24+4, i*32 , width - 32 - 36 , 32 , command)
elsif i == 2
self.contents.blt(4+64+16, (i-1)*32 + 4 , bitmap , Rect.new(0,0,24,24))
self.contents.draw_text(4+64+24+16, (i-1)*32 , width - 32 - 36 , 32 , command)
elsif i == 3
self.contents.blt(4+40, (i-1)*32 + 4 , bitmap , Rect.new(0,0,24,24))
self.contents.draw_text(4+64, (i-1)*32 , width - 32 - 36 , 32 , command)
# self.contents.blt(4, i*32 + 4 , bitmap , Rect.new(0,0,24,24))
# self.contents.draw_text(4+32, i*32 , width - 32 - 36 , 32 , command)
end
end
end
class Scene_Battle
#--------------------------------------------------------------------------
# ● 主处理
#--------------------------------------------------------------------------
def main
# 初始化战斗用的各种暂时数据
$game_temp.in_battle = true
$game_temp.battle_turn = 0
$game_temp.battle_event_flags.clear
$game_temp.battle_abort = false
$game_temp.battle_main_phase = false
$game_temp.battleback_name = $game_map.battleback_name
$game_temp.forcing_battler = nil
# 初始化战斗用事件解释器
$game_system.battle_interpreter.setup(nil, 0)
# 准备队伍
@troop_id = $game_temp.battle_troop_id
$game_troop.setup(@troop_id)
# 生成角色命令窗口
s1 = $data_system.words.attack
s2 = $data_system.words.skill
s3 = $data_system.words.guard
s4 = $data_system.words.item
if $game_switches[6]
@actor_command_window = Window_Battlecommand.new(224, [s1, s2, s3, s4])
@actor_command_window.z = 9999
else
@actor_command_window = Window_Command.new(160, [s1, s2, s3, s4])
end
#
@actor_command_window.y = 160
@actor_command_window.back_opacity = 160
@actor_command_window.active = false
@actor_command_window.visible = false
# 生成其它窗口
@party_command_window = Window_PartyCommand.new
@help_window = Window_Help.new
@help_window.back_opacity = 160
@help_window.visible = false
@status_window = Window_BattleStatus.new
@message_window = Window_Message.new
# 生成活动块
@spriteset = Spriteset_Battle.new
# 初始化等待计数
@wait_count = 0
# 执行过渡
if $data_system.battle_transition == ""
Graphics.transition(20)
else
Graphics.transition(40, "Graphics/Transitions/" +
$data_system.battle_transition)
end
# 开始自由战斗回合
start_phase1
# 主循环
loop do
# 刷新游戏画面
Graphics.update
# 刷新输入信息
Input.update
# 刷新画面
update
# 如果画面切换的话就中断循环
if $scene != self
break
end
end
# 刷新地图
$game_map.refresh
# 准备过渡
Graphics.freeze
# 释放窗口
@actor_command_window.dispose
@party_command_window.dispose
@help_window.dispose
@status_window.dispose
@message_window.dispose
if @skill_window != nil
@skill_window.dispose
end
if @item_window != nil
@item_window.dispose
end
if @result_window != nil
@result_window.dispose
end
# 释放活动块
@spriteset.dispose
# 标题画面切换中的情况
if $scene.is_a?(Scene_Title)
# 淡入淡出画面
Graphics.transition
Graphics.freeze
end
# 战斗测试或者游戏结束以外的画面切换中的情况
if $BTEST and not $scene.is_a?(Scene_Gameover)
$scene = nil
end
end
end