class Game_Temp
attr_accessor :bought
alias rb_initialize initialize
def initialize
@bought = false
rb_initialize
end
end
class Scene_Shop
alias rb_main main
def main
$game_temp.bought = false
rb_main
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_temp.bought = true
# 购买处理
$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