class Game_System
attr :shop_type,true
alias db initialize
def initialize
@shop_type = 0
db
end
end
class Window_ShopCommand
def draw_item(index)
if $game_system.shop_type == 1 and index == 0
self.contents.font.color = disabled_color
end
if $game_system.shop_type == 2 and index == 1
self.contents.font.color = disabled_color
end
x = 4 + index * 160
self.contents.draw_text(x, 0, 128, 32, @commands[index])
self.contents.font.color = normal_color
end
end
class Scene_Shop
alias daiboy_update_command update_command
def update_command
if Input.trigger?(Input::C)
# 命令窗口光标位置分支
case @command_window.index
when 0 # 购买
$game_system.se_play($data_system.buzzer_se) if $game_system.shop_type == 1
return if $game_system.shop_type == 1
when 1 # 卖出
$game_system.se_play($data_system.buzzer_se) if $game_system.shop_type == 2
return if $game_system.shop_type == 2
end
end
daiboy_update_command
end
end
class Window_ShopStatus < Window_Base
#--------------------------------------------------------------------------
# ● 初始化对像
#--------------------------------------------------------------------------
def initialize
super(320, 128, 250, 352)
self.contents = Bitmap.new(width - 32, height - 32)
@item = nil
refresh
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh
self.contents.clear
if @item == nil
return
end
case @item
when RPG::Item
number = $game_party.item_number(@item.id)
when RPG::Weapon
number = $game_party.weapon_number(@item.id)
when RPG::Armor
number = $game_party.armor_number(@item.id)
end
self.contents.font.color = system_color
self.contents.draw_text(4, 0, 200, 32, "所持数")
self.contents.font.color = normal_color
self.contents.draw_text(180, 0, 32, 32, number.to_s, 2)
if @item.is_a?(RPG::Item)
return
end
# 添加装备品信息
for i in 0...$game_party.actors.size
# 获取角色
actor = $game_party.actors
# 可以装备为普通文字颜色、不能装备设置为无效文字颜色
if actor.equippable?(@item)
self.contents.font.color = normal_color
else
self.contents.font.color = disabled_color
end
# 描绘角色名字
self.contents.draw_text(4, 64 + 64 * i, 120, 32, actor.name)
# 获取当前的装备品
if @item.is_a?(RPG::Weapon)
item1 = $data_weapons[actor.weapon_id]
elsif @item.kind == 0
item1 = $data_armors[actor.armor1_id]
elsif @item.kind == 1
item1 = $data_armors[actor.armor2_id]
elsif @item.kind == 2
item1 = $data_armors[actor.armor3_id]
else
item1 = $data_armors[actor.armor4_id]
end
# 可以装备的情况
if actor.equippable?(@item)
# 武器的情况
if @item.is_a?(RPG::Weapon)
atk1 = item1 != nil ? item1.atk : 0
atk2 = @item != nil ? @item.atk : 0
change = atk2 - atk1
end
# 防具的情况
if @item.is_a?(RPG::Armor)
pdef1 = item1 != nil ? item1.pdef : 0
mdef1 = item1 != nil ? item1.mdef : 0
pdef2 = @item != nil ? @item.pdef : 0
mdef2 = @item != nil ? @item.mdef : 0
change = pdef2 - pdef1 + mdef2 - mdef1
end
# 描绘能力值变化
self.contents.draw_text(100, 64 + 64 * i, 112, 32,
sprintf("%+d", change), 2)
end
# 描绘物品
if item1 != nil
x = 4
y = 64 + 64 * i + 32
bitmap = RPG::Cache.icon(item1.icon_name)
opacity = self.contents.font.color == normal_color ? 255 : 128
self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
self.contents.draw_text(x + 28, y, 212, 32, item1.name)
end
end
end
#--------------------------------------------------------------------------
# ● 设置物品
# item : 新的物品
#--------------------------------------------------------------------------
def item=(item)
if @item != item
@item = item
refresh
end
end
end
#--------------------------------------------------------------------------
# ● 主处理
#--------------------------------------------------------------------------
def main
# 生成命令窗口
s1 = $data_system.words.item
s2 = $data_system.words.skill
s3 = $data_system.words.equip
s4 = "状态"
s5 = "任务"
s6 = "介绍"
s7 = "存档"
s8 = "结束"
@command_window = Window_Command.new(90, [s1, s2, s3, s4, s5, s6, s7, s8])
@command_window.x = 35
@command_window.y = 90
# 同伴人数为 0 的情况下
if $game_party.actors.size == 0
# 物品、特技、装备、状态无效化
@command_window.disable_item(0)
@command_window.disable_item(1)
@command_window.disable_item(2)
@command_window.disable_item(3)
end
# 禁止存档的情况下
if $game_system.save_disabled
# 存档无效
@command_window.disable_item(6)
end
# 生成游戏时间窗口
@playtime_window = Window_PlayTime.new
@playtime_window.x = 285
@playtime_window.y = 314
# 生成步数窗口
@steps_window = Window_Steps.new
@steps_window.x = 125
@steps_window.y = 314
# 生成金钱窗口
@gold_window = Window_Gold.new
@gold_window.x = 445
@gold_window.y = 314
# 生成状态窗口
@status_window = Window_MenuStatus.new
@status_window.x = 125
@status_window.y = 90
# 执行过渡
Graphics.transition
# 主循环
loop do
# 刷新游戏画面
Graphics.update
# 刷新输入信息
Input.update
# 刷新画面
update
# 如果切换画面就中断循环
if $scene != self
break
end
end
# 准备过渡
Graphics.freeze
# 释放窗口
@command_window.dispose
@playtime_window.dispose
@steps_window.dispose
@gold_window.dispose
@status_window.dispose
end
#--------------------------------------------------------------------------
# ● 刷新画面
#--------------------------------------------------------------------------
def update
# 刷新窗口
@command_window.update
@playtime_window.update
@steps_window.update
@gold_window.update
@status_window.update
# 命令窗口被激活的情况下: 调用 update_command
if @command_window.active
update_command
return
end
# 状态窗口被激活的情况下: 调用 update_status
if @status_window.active
update_status
return
end
end
#--------------------------------------------------------------------------
# ● 刷新画面 (命令窗口被激活的情况下)
#--------------------------------------------------------------------------
def update_command
# 按下 B 键的情况下
if Input.trigger?(Input::B)
# 演奏取消 SE
$game_system.se_play($data_system.cancel_se)
# 切换的地图画面
$scene = Scene_Map.new
return
end
# 按下 C 键的情况下
if Input.trigger?(Input::C)
# 同伴人数为 0、存档、游戏结束以外的场合
if $game_party.actors.size == 0 and @command_window.index < 4
# 演奏冻结 SE
$game_system.se_play($data_system.buzzer_se)
return
end
# 命令窗口的光标位置分支
case @command_window.index
when 0 # 物品
# 演奏确定 SE
$game_system.se_play($data_system.decision_se)
# 切换到物品画面
$scene = Scene_Item.new
when 1 # 特技
# 演奏确定 SE
$game_system.se_play($data_system.decision_se)
# 激活状态窗口
@command_window.active = false
@status_window.active = true
@status_window.index = 0
when 2 # 装备
# 演奏确定 SE
$game_system.se_play($data_system.decision_se)
# 激活状态窗口
@command_window.active = false
@status_window.active = true
@status_window.index = 0
when 3 # 状态
# 演奏确定 SE
$game_system.se_play($data_system.decision_se)
# 激活状态窗口
@command_window.active = false
@status_window.active = true
@status_window.index = 0
when 4
# 決定 SE を演奏
$game_system.se_play($data_system.decision_se)
$scene = Scene_Task.new
when 5
# 決定 SE を演奏
$game_system.se_play($data_system.decision_se)
@command_window.active = false
@status_window.active = true
@status_window.index = 0
when 6 # 存档
# 禁止存档的情况下
if $game_system.save_disabled
# 演奏冻结 SE
$game_system.se_play($data_system.buzzer_se)
return
end
# 演奏确定 SE
$game_system.se_play($data_system.decision_se)
# 切换到存档画面
$scene = Scene_Save.new
when 7 # 游戏结束
# 演奏确定 SE
$game_system.se_play($data_system.decision_se)
# 切换到游戏结束画面
$scene = Scene_End.new
end
return
end
end
#--------------------------------------------------------------------------
# ● 刷新画面 (状态窗口被激活的情况下)
#--------------------------------------------------------------------------
def update_status
# 按下 B 键的情况下
if Input.trigger?(Input::B)
# 演奏取消 SE
$game_system.se_play($data_system.cancel_se)
# 激活命令窗口
@command_window.active = true
@status_window.active = false
@status_window.index = -1
return
end
# 按下 C 键的情况下
if Input.trigger?(Input::C)
# 命令窗口的光标位置分支
case @command_window.index
when 1 # 特技
# 本角色的行动限制在 2 以上的情况下
if $game_party.actors[@status_window.index].restriction >= 2
# 演奏冻结 SE
$game_system.se_play($data_system.buzzer_se)
return
end
# 演奏确定 SE
$game_system.se_play($data_system.decision_se)
# 切换到特技画面
$scene = Scene_Skill.new(@status_window.index)
when 2 # 装备
# 演奏确定 SE
$game_system.se_play($data_system.decision_se)
# 切换的装备画面
$scene = Scene_Equip.new(@status_window.index)
when 3 # 状态
# 演奏确定 SE
$game_system.se_play($data_system.decision_se)
# 切换到状态画面
$scene = Scene_Status.new(@status_window.index)
when 5
# 演奏确定 SE
$game_system.se_play($data_system.decision_se)
$scene = Scene_Charactor.new(@status_window.index)
end
return
end
end
end
#==============================================================================
# ■ Scene_Shop
#------------------------------------------------------------------------------
# 处理商店画面的类。
#==============================================================================
class Scene_Shop
#--------------------------------------------------------------------------
# ● 主处理
#--------------------------------------------------------------------------
def main
# 生成帮助窗口
@help_window = Window_Help.new
# 生成指令窗口
@command_window = Window_ShopCommand.new
# 生成金钱窗口
@gold_window = Window_Gold.new
@gold_window.x = 320
@gold_window.y = 64
# 生成时间窗口
@dummy_window = Window_Base.new(160, 128, 320, 352)
# 生成购买窗口
@buy_window = Window_ShopBuy.new($game_temp.shop_goods)
@buy_window.active = false
@buy_window.visible = false
@buy_window.help_window = @help_window
# 生成卖出窗口
@sell_window = Window_ShopSell.new
@sell_window.active = false
@sell_window.visible = false
@sell_window.help_window = @help_window
# 生成数量输入窗口
@number_window = Window_ShopNumber.new
@number_window.active = false
@number_window.visible = false
# 生成状态窗口
@status_window = Window_ShopStatus.new
@status_window.visible = false
# 执行过渡
Graphics.transition
# 主循环
loop do
# 刷新游戏画面
Graphics.update
# 刷新输入信息
Input.update
# 刷新画面
update
# 如果画面切换的话就中断循环
if $scene != self
break
end
end
# 准备过渡
Graphics.freeze
# 释放窗口
@help_window.dispose
@command_window.dispose
@gold_window.dispose
@dummy_window.dispose
@buy_window.dispose
@sell_window.dispose
@number_window.dispose
@status_window.dispose
end
#--------------------------------------------------------------------------
# ● 刷新画面
#--------------------------------------------------------------------------
def update
# 刷新窗口
@help_window.update
@command_window.update
@gold_window.update
@dummy_window.update
@buy_window.update
@sell_window.update
@number_window.update
@status_window.update
# 指令窗口激活的情况下: 调用 update_command
if @command_window.active
update_command
return
end
# 购买窗口激活的情况下: 调用 update_buy
if @buy_window.active
update_buy
return
end
# 卖出窗口激活的情况下: 调用 update_sell
if @sell_window.active
update_sell
return
end
# 个数输入窗口激活的情况下: 调用 update_number
if @number_window.active
update_number
return
end
end
#--------------------------------------------------------------------------
# ● 刷新画面 (指令窗口激活的情况下)
#--------------------------------------------------------------------------
def update_command
# 按下 B 键的情况下
if Input.trigger?(Input::B)
# 演奏取消 SE
$game_system.se_play($data_system.cancel_se)
# 切换到地图画面
$scene = Scene_Map.new
return
end
# 按下 C 键的情况下
if Input.trigger?(Input::C)
# 命令窗口光标位置分支
case @command_window.index
when 0 # 购买
# 演奏确定 SE
$game_system.se_play($data_system.decision_se)
# 窗口状态转向购买模式
@command_window.active = false
@dummy_window.visible = false
@buy_window.active = true
@buy_window.visible = true
@buy_window.refresh
@status_window.visible = true
when 1 # 卖出
# 演奏确定 SE
$game_system.se_play($data_system.decision_se)
# 窗口状态转向卖出模式
@command_window.active = false
@dummy_window.visible = false
@sell_window.active = true
@sell_window.visible = true
@sell_window.refresh
when 2 # 取消
# 演奏确定 SE
$game_system.se_play($data_system.decision_se)
# 切换到地图画面
$scene = Scene_Map.new
end
return
end
end
#--------------------------------------------------------------------------
# ● 刷新画面 (购买窗口激活的情况下)
#--------------------------------------------------------------------------
def update_buy
# 设置状态窗口的物品
@status_window.item = @buy_window.item
# 按下 B 键的情况下
if Input.trigger?(Input::B)
# 演奏取消 SE
$game_system.se_play($data_system.cancel_se)
# 窗口状态转向初期模式
@command_window.active = true
@dummy_window.visible = true
@buy_window.active = false
@buy_window.visible = false
@status_window.visible = false
@status_window.item = nil
# 删除帮助文本
@help_window.set_text("")
return
end
# 按下 C 键的情况下
if Input.trigger?(Input::C)
# 获取物品
@item = @buy_window.item
# 物品无效的情况下、或者价格在所持金以上的情况下
if @item == nil or @item.price > $game_party.gold
# 演奏冻结 SE
$game_system.se_play($data_system.buzzer_se)
return
end
# 获取物品所持数
case @item
when RPG::Item
number = $game_party.item_number(@item.id)
when RPG::Weapon
number = $game_party.weapon_number(@item.id)
when RPG::Armor
number = $game_party.armor_number(@item.id)
end
# 如果已经拥有了 99 个情况下
if number == 99
# 演奏冻结 SE
$game_system.se_play($data_system.buzzer_se)
return
end
# 演奏确定 SE
$game_system.se_play($data_system.decision_se)
# 计算可以最多购买的数量
max = @item.price == 0 ? 99 : $game_party.gold / @item.price
max = [max, 99 - number].min
# 窗口状态转向数值输入模式
@buy_window.active = false
@buy_window.visible = false
@number_window.set(@item, max, @item.price)
@number_window.active = true
@number_window.visible = true
end
end
#--------------------------------------------------------------------------
# ● 画面更新 (卖出窗口激活的情况下)
#--------------------------------------------------------------------------
def update_sell
# 按下 B 键的情况下
if Input.trigger?(Input::B)
# 演奏取消 SE
$game_system.se_play($data_system.cancel_se)
# 窗口状态转向初期模式
@command_window.active = true
@dummy_window.visible = true
@sell_window.active = false
@sell_window.visible = false
@status_window.item = nil
# 删除帮助文本
@help_window.set_text("")
return
end
# 按下 C 键的情况下
if Input.trigger?(Input::C)
# 获取物品
@item = @sell_window.item
# 设置状态窗口的物品
@status_window.item = @item
# 物品无效的情况下、或者价格为 0 (不能卖出) 的情况下
if @item == nil or @item.price == 0
# 演奏冻结 SE
$game_system.se_play($data_system.buzzer_se)
return
end
# 演奏确定 SE
$game_system.se_play($data_system.decision_se)
# 获取物品的所持数
case @item
when RPG::Item
number = $game_party.item_number(@item.id)
when RPG::Weapon
number = $game_party.weapon_number(@item.id)
when RPG::Armor
number = $game_party.armor_number(@item.id)
end
# 最大卖出个数 = 物品的所持数
max = number
# 窗口状态转向个数输入模式
@sell_window.active = false
@sell_window.visible = false
@number_window.set(@item, max, @item.price / 2)
@number_window.active = true
@number_window.visible = true
@status_window.visible = true
end
end
#--------------------------------------------------------------------------
# ● 刷新画面 (个数输入窗口激活的情况下)
#--------------------------------------------------------------------------
def update_number
# 按下 B 键的情况下
if Input.trigger?(Input::B)
# 演奏取消 SE
$game_system.se_play($data_system.cancel_se)
# 设置个数输入窗口为不活动·非可视状态
@number_window.active = false
@number_window.visible = false
# 命令窗口光标位置分支
case @command_window.index
when 0 # 购买
# 窗口状态转向购买模式
@buy_window.active = true
@buy_window.visible = true
when 1 # 卖出
# 窗口状态转向卖出模式
@sell_window.active = true
@sell_window.visible = true
@status_window.visible = false
end
return
end
# 按下 C 键的情况下
if Input.trigger?(Input::C)
# 演奏商店 SE
$game_system.se_play($data_system.shop_se)
# 设置个数输入窗口为不活动·非可视状态
@number_window.active = false
@number_window.visible = false
# 命令窗口光标位置分支
case @command_window.index
when 0 # 购买
# 购买处理
$game_party.lose_gold(@number_window.number * @item.price)
case @item
when RPG::Item
$game_party.gain_item(@item.id, @number_window.number)
when RPG::Weapon
$game_party.gain_weapon(@item.id, @number_window.number)
when RPG::Armor
$game_party.gain_armor(@item.id, @number_window.number)
end
# 刷新各窗口
@gold_window.refresh
@buy_window.refresh
@status_window.refresh
# 窗口状态转向购买模式
@buy_window.active = true
@buy_window.visible = true
when 1 # 卖出
# 卖出处理
$game_party.gain_gold(@number_window.number * (@item.price / 2))
case @item
when RPG::Item
$game_party.lose_item(@item.id, @number_window.number)
when RPG::Weapon
$game_party.lose_weapon(@item.id, @number_window.number)
when RPG::Armor
$game_party.lose_armor(@item.id, @number_window.number)
end
# 刷新各窗口
@gold_window.refresh
@sell_window.refresh
@status_window.refresh
# 窗口状态转向卖出模式
@sell_window.active = true
@sell_window.visible = true
@status_window.visible = false
end
return
end
end
end
#==============================================================================
# 本脚本来自www.66RPG.com,使用和转载请保留此信息
#==============================================================================
class Window_MenuStatus < Window_Selectable
def refresh
self.contents.clear
@item_max = $game_party.actors.size
for i in 0...$game_party.actors.size
x = 64 + i%2 * 224
y = i/2 * 96 + 16
actor = $game_party.actors
if (i % 2) == 0
draw_actor_graphic(actor, x - 40, y + 65)
self.contents.font.size = 18
draw_actor_name(actor, x, y)
#draw_actor_class(actor, x + 144+50, y)
draw_actor_level(actor, x+94, y )
draw_actor_state(actor, x , y + 52)
#draw_actor_exp(actor, x+50, y + 64)
draw_actor_hp(actor, x , y + 16)
draw_actor_sp(actor, x , y + 32)
else
draw_actor_graphic(actor, x - 40, y + 65)
draw_actor_name(actor, x, y)
#draw_actor_class(actor, x + 144+50, y)
draw_actor_level(actor, x+94, y )
draw_actor_state(actor, x , y + 52)
#draw_actor_exp(actor, x+50, y + 64)
draw_actor_hp(actor, x , y + 16)
draw_actor_sp(actor, x , y + 32)
end
end
end
end
#==============================================================================
# ■ Window_Base
#==============================================================================
class Window_Base < Window
alias xrxs_mp7_initialize initialize
def initialize(x, y, width, height)
xrxs_mp7_initialize(x, y, width, height)
if $scene.is_a?(Scene_Menu) or
$scene.is_a?(Scene_Item) or
$scene.is_a?(Scene_Skill) or
$scene.is_a?(Scene_Equip) or
$scene.is_a?(Scene_Status) or
$scene.is_a?(Scene_Save) or
$scene.is_a?(Scene_End) or $scene.is_a?(Scene_Shop)
self.back_opacity = 200 #————这个数值可调,为透明程度
end
end
end
module XRXS_MP7_Module
def create_spriteset
@spriteset = Spriteset_Map.new
end
def dispose_spriteset
@spriteset.dispose
end
end
class Scene_Menu
include XRXS_MP7_Module
alias xrxs_mp7_main main
def main
create_spriteset
xrxs_mp7_main
dispose_spriteset
end
end
class Scene_Item
include XRXS_MP7_Module
alias xrxs_mp7_main main
def main
create_spriteset
xrxs_mp7_main
dispose_spriteset
end
end
class Scene_Skill
include XRXS_MP7_Module
alias xrxs_mp7_main main
def main
create_spriteset
xrxs_mp7_main
dispose_spriteset
end
end
class Scene_Equip
include XRXS_MP7_Module
alias xrxs_mp7_main main
def main
create_spriteset
xrxs_mp7_main
dispose_spriteset
end
end
class Scene_Status
include XRXS_MP7_Module
alias xrxs_mp7_main main
def main
create_spriteset
xrxs_mp7_main
dispose_spriteset
end
end
class Scene_Save
include XRXS_MP7_Module
alias xrxs_mp7_main main
def main
create_spriteset
xrxs_mp7_main
dispose_spriteset
end
end
class Scene_End
include XRXS_MP7_Module
alias xrxs_mp7_main main
def main
create_spriteset
xrxs_mp7_main
dispose_spriteset
end
end
class Scene_Shop
include XRXS_MP7_Module
alias xrxs_mp7_main main
def main
create_spriteset
xrxs_mp7_main
dispose_spriteset
end
end
#==============================================================================
# 本脚本来自www.66RPG.com,使用和转载请保留此信息
#==============================================================================
# ——————————————————————————————
class Bitmap
#------------------------------------------------------------
# ● 矩形をグラデーション表示
# color1 : スタートカラー
# color2 : エンドカラー
# align : 0:横にグラデーション
# 1:縦にグラデーション
# 2:斜めにグラデーション(激重につき注意)
#--------------------------------------------------------
def gradation_rect(x, y, width, height, color1, color2, align = 0)
if align == 0
for i in x...x + width
red = color1.red + (color2.red - color1.red) * (i - x) / (width - 1)
green = color1.green +
(color2.green - color1.green) * (i - x) / (width - 1)
blue = color1.blue +
(color2.blue - color1.blue) * (i - x) / (width - 1)
alpha = color1.alpha +
(color2.alpha - color1.alpha) * (i - x) / (width - 1)
color = Color.new(red, green, blue, alpha)
fill_rect(i, y, 1, height, color)
end
elsif align == 1
for i in y...y + height
red = color1.red +
(color2.red - color1.red) * (i - y) / (height - 1)
green = color1.green +
(color2.green - color1.green) * (i - y) / (height - 1)
blue = color1.blue +
(color2.blue - color1.blue) * (i - y) / (height - 1)
alpha = color1.alpha +
(color2.alpha - color1.alpha) * (i - y) / (height - 1)
color = Color.new(red, green, blue, alpha)
fill_rect(x, i, width, 1, color)
end
elsif align == 2
for i in x...x + width
for j in y...y + height
red = color1.red + (color2.red - color1.red) *
((i - x) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
green = color1.green + (color2.green - color1.green) *
((i - x) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
blue = color1.blue + (color2.blue - color1.blue) *
((i - x) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
alpha = color1.alpha + (color2.alpha - color1.alpha) *
((i - x) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
color = Color.new(red, green, blue, alpha)
set_pixel(i, j, color)
end
end
elsif align == 3
for i in x...x + width
for j in y...y + height
red = color1.red + (color2.red - color1.red) *
((x + width - i) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
green = color1.green + (color2.green - color1.green) *
((x + width - i) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
blue = color1.blue + (color2.blue - color1.blue) *
((x + width - i) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
alpha = color1.alpha + (color2.alpha - color1.alpha) *
((x + width - i) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
color = Color.new(red, green, blue, alpha)
set_pixel(i, j, color)
end
end
end
end
end
#==============================================================================
# ■ Spriteset_Battle
#------------------------------------------------------------------------------
# 处理战斗画面的活动块的类。本类在 Scene_Battle 类
# 的内部使用。
#==============================================================================
class Spriteset_Battle
#--------------------------------------------------------------------------
# ● 定义实例变量
#--------------------------------------------------------------------------
attr_reader :viewport1 # 敌人方的显示端口
attr_reader :viewport2 # 角色方的显示端口
#--------------------------------------------------------------------------
# ● 初始化变量
#--------------------------------------------------------------------------
def initialize
# 生成显示端口
@viewport1 = Viewport.new(0, 0, 640, 480)
@viewport2 = Viewport.new(0, 0, 640, 480)
@viewport3 = Viewport.new(0, 0, 640, 480)
@viewport4 = Viewport.new(0, 0, 640, 480)
@viewport2.z = 101
@viewport3.z = 200
@viewport4.z = 5000
# 生成战斗背景活动块
@battleback_sprite = Sprite.new(@viewport1)
# 生成敌人活动块
@enemy_sprites = []
for enemy in $game_troop.enemies.reverse
@enemy_sprites.push(Sprite_Battler.new(@viewport1, enemy))
end
# 生成敌人活动块
@actor_sprites = []
@actor_sprites.push(Sprite_Battler.new(@viewport2))
@actor_sprites.push(Sprite_Battler.new(@viewport2))
@actor_sprites.push(Sprite_Battler.new(@viewport2))
@actor_sprites.push(Sprite_Battler.new(@viewport2))
# 生成天候
@weather = RPG::Weather.new(@viewport1)
# 生成图片活动块
@picture_sprites = []
for i in 51..100
@picture_sprites.push(Sprite_Picture.new(@viewport3,
$game_screen.pictures))
end
# 生成计时器块
@timer_sprite = Sprite_Timer.new
# 刷新画面
update
end
#--------------------------------------------------------------------------
# ● 释放
#--------------------------------------------------------------------------
def dispose
# 如果战斗背景位图存在的情况下就释放
if @battleback_sprite.bitmap != nil
@battleback_sprite.bitmap.dispose
end
# 释放战斗背景活动块
@battleback_sprite.dispose
# 释放敌人活动块、角色活动块
for sprite in @enemy_sprites + @actor_sprites
sprite.dispose
end
# 释放天候
@weather.dispose
# 释放图片活动块
for sprite in @picture_sprites
sprite.dispose
end
# 释放计时器活动块
@timer_sprite.dispose
# 释放显示端口
@viewport1.dispose
@viewport2.dispose
@viewport3.dispose
@viewport4.dispose
end
#--------------------------------------------------------------------------
# ● 显示效果中判定
#--------------------------------------------------------------------------
def effect?
# 如果是在显示效果中的话就返回 true
for sprite in @enemy_sprites + @actor_sprites
return true if sprite.effect?
end
return false
end
#--------------------------------------------------------------------------
# ● 刷新画面
#--------------------------------------------------------------------------
def update
# 刷新角色的活动块 (对应角色的替换)
@actor_sprites[0].battler = $game_party.actors[0]
@actor_sprites[1].battler = $game_party.actors[1]
@actor_sprites[2].battler = $game_party.actors[2]
@actor_sprites[3].battler = $game_party.actors[3]
# 战斗背景的文件名与现在情况有差异的情况下
if @battleback_name != $game_temp.battleback_name
@battleback_name = $game_temp.battleback_name
if @battleback_sprite.bitmap != nil
@battleback_sprite.bitmap.dispose
end
@battleback_sprite.bitmap = RPG::Cache.battleback(@battleback_name)
@battleback_sprite.src_rect.set(0, 0, 640, 480)
end
# 刷新战斗者的活动块
for sprite in @enemy_sprites + @actor_sprites
sprite.update
end
# 刷新天气图形
@weather.type = $game_screen.weather_type
@weather.max = $game_screen.weather_max
@weather.update
# 刷新图片活动块
for sprite in @picture_sprites
sprite.update
end
# 刷新计时器活动块
@timer_sprite.update
# 设置画面的色调与震动位置
@viewport1.tone = $game_screen.tone
@viewport1.ox = $game_screen.shake
# 设置画面的闪烁色
@viewport4.color = $game_screen.flash_color
# 刷新显示端口
@viewport1.update
@viewport2.update
@viewport4.update
end
end
#==============================================================================
# ■ Window_BattleStatus
#------------------------------------------------------------------------------
# 显示战斗画面同伴状态的窗口。
#==============================================================================
class Window_BattleStatus < Window_Base
#--------------------------------------------------------------------------
# ● 初始化对像
#--------------------------------------------------------------------------
def initialize
super(0, 320, 640, 180)
self.contents = Bitmap.new(width - 32, height - 32)
self.opacity = 0
@level_up_flags = [false, false, false, false]
refresh
end
#--------------------------------------------------------------------------
# ● 释放
#--------------------------------------------------------------------------
def dispose
super
end
#--------------------------------------------------------------------------
# ● 设置升级标志
# actor_index : 角色索引
#--------------------------------------------------------------------------
def level_up(actor_index)
@level_up_flags[actor_index] = true
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh
self.contents.clear
@item_max = $game_party.actors.size
for i in 0...$game_party.actors.size
actor = $game_party.actors
actor_x = i * 160 + 4
self.contents.font.size = 20
draw_actor_graphic(actor, actor_x+10, 100)
draw_actor_name(actor, actor_x+25, 50)
self.contents.font.size = 22
draw_actor_hp(actor, actor_x, 70, 120)
draw_actor_sp(actor, actor_x, 86, 120)
if @level_up_flags
self.contents.font.color = normal_color
self.contents.draw_text(actor_x, 96, 120, 32, " 升级了!")
else
self.contents.font.size = 18
draw_actor_state(actor, actor_x, 105)
end
end
end
#--------------------------------------------------------------------------
# ● 刷新画面
#--------------------------------------------------------------------------
def update
super
# 主界面的不透明度下降
if $game_temp.battle_main_phase
self.contents_opacity -= 4 if self.contents_opacity > 191
else
self.contents_opacity += 4 if self.contents_opacity < 255
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
s5 = "逃跑"
@actor_command_window = Window_Command.new(160, [s1, s2, s3, s4, s5])
# 不能逃跑的情况下
if $game_temp.battle_can_escape == false
@actor_command_window.disable_item(4)
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
class Scene_Battle
def start_phase2
# 转移到回合 2
@phase = 2
# 设置角色为非选择状态
@actor_index = -1
@active_battler = nil
# 有效化同伴指令窗口
#@party_command_window.active = true
#@party_command_window.visible = true
# 无效化角色指令窗口
@actor_command_window.active = false
@actor_command_window.visible = false
# 清除主回合标志
$game_temp.battle_main_phase = false
# 清除全体同伴的行动
$game_party.clear_actions
# 不能输入命令的情况下
unless $game_party.inputable?
# 开始主回合
start_phase4
end
end
#--------------------------------------------------------------------------
# ● 刷新画面 (同伴命令回合)
#--------------------------------------------------------------------------
def update_phase2
# 演奏确定 SE
$game_system.se_play($data_system.decision_se)
# 开始角色的命令回合
start_phase3
end
# 按下 C 键的情况下
if Input.trigger?(Input::C)
# 同伴指令窗口光标位置分支
case @party_command_window.index
when 0 # 战斗
# 演奏确定 SE
$game_system.se_play($data_system.decision_se)
# 开始角色的命令回合
start_phase3
when 1 # 逃跑
# 不能逃跑的情况下
if $game_temp.battle_can_escape == false
# 演奏冻结 SE
$game_system.se_play($data_system.buzzer_se)
return
end
# 演奏确定 SE
$game_system.se_play($data_system.decision_se)
# 逃走处理
update_phase2_escape
end
return
end
end
class Scene_Battle
#--------------------------------------------------------------------------
# ● 刷新画面 (角色命令回合 : 基本命令)
#--------------------------------------------------------------------------
def update_phase3_basic_command
# 按下 B 键的情况下
if Input.trigger?(Input::B)
# 演奏取消 SE
$game_system.se_play($data_system.cancel_se)
# 转向前一个角色的指令输入
phase3_prior_actor
return
end
# 按下 C 键的情况下
if Input.trigger?(Input::C)
# 角色指令窗口光标位置分之
case @actor_command_window.index
when 0 # 攻击
# 演奏确定 SE
$game_system.se_play($data_system.decision_se)
# 设置行动
@active_battler.current_action.kind = 0
@active_battler.current_action.basic = 0
# 开始选择敌人
start_enemy_select
when 1 # 特技
# 演奏确定 SE
$game_system.se_play($data_system.decision_se)
# 设置行动
@active_battler.current_action.kind = 1
# 开始选择特技
start_skill_select
when 2 # 防御
# 演奏确定 SE
$game_system.se_play($data_system.decision_se)
# 设置行动
@active_battler.current_action.kind = 0
@active_battler.current_action.basic = 1
# 转向下一位角色的指令输入
phase3_next_actor
when 3 # 物品
# 演奏确定 SE
$game_system.se_play($data_system.decision_se)
# 设置行动
@active_battler.current_action.kind = 2
# 开始选择物品
start_item_select
when 4
escaping
end
return
end
end
def escaping
# 不能逃跑的情况下
if $game_temp.battle_can_escape == false
# 演奏冻结 SE
$game_system.se_play($data_system.buzzer_se)
return
end
# 演奏确定 SE
$game_system.se_play($data_system.decision_se)
# 逃走处理
update_phase2_escape
end
end