Project1
标题:
为什么我的商店是一次性的?
[打印本页]
作者:
876加几
时间:
2014-2-5 21:59
标题:
为什么我的商店是一次性的?
本帖最后由 876加几 于 2014-2-5 22:02 编辑
我美化了下默认商店,可是商店只能使用1次了,第二次使用就会发生RGSS停用。
商店脚本:
#==============================================================================
# ■ Scene_Shop
#------------------------------------------------------------------------------
# 处理商店画面的类。
#==============================================================================
class Scene_Shop
#--------------------------------------------------------------------------
# ● 主处理
#--------------------------------------------------------------------------
def main
# 生成背景
@spriteset = Spriteset_Map.new
[url=home.php?mod=space&uid=8407]@black[/url] = Sprite.new
@black.bitmap = Bitmap.new(640, 480)
@black.bitmap.fill_rect(0, 0, 640, 480, Color.new(0, 0, 0, 192))
@black.z = 6000
# 生成帮助窗口
@help_window = Window_Help.new(640 - 160)
@help_window.y = 32
@help_window.x = 640
@help_window.z = 6100
# 生成指令窗口
@command_window = Window_Command.new(160, ["购买", "卖出", "取消"])
@command_window.x = 32
@command_window.y = 224
@command_window.active = false
@command_window.z = 6100
@command_window.index = -1
# 生成选择角色窗口
@select_window = Window_ShopActor.new
@select_window.active = true
@select_window.z = 6100
# 生成金钱窗口
@gold_window = Window_Gold.new
@gold_window.x = 32
@gold_window.y = 160
@gold_window.z = 6100
@select_window.help_window = @gold_window
# 生成金钱窗口
@gold_window2 = Window_ShopGold.new
@gold_window2.x = 640
@gold_window2.y = 480 - 96
@gold_window2.z = 6100
# 生成时间窗口
#@dummy_window = Window_Base.new(640, 64, 480, 352)
# 生成购买窗口
@buy_window = Window_ShopBuy.new($game_temp.shop_goods)
@buy_window.y = 96
@buy_window.active = false
@buy_window.visible = false
@buy_window.x = 640
@buy_window.z = 6100
@buy_window.help_window = @help_window
# 生成卖出窗口
@sell_window = Window_ShopSell.new
@sell_window.y = 96
@sell_window.active = false
@sell_window.visible = false
@sell_window.x = 640
@sell_window.z = 6100
@sell_window.help_window = @help_window
# 生成数量输入窗口
@number_window = Window_ShopNumber.new
@number_window.y = 96
@number_window.active = false
@number_window.visible = false
@number_window.x = 640
@number_window.z = 6100
# 生成状态窗口
@status_window = Window_ShopStatus.new
@status_window.y = 96
@status_window.visible = false
@status_window.x = 640 + 208
@status_window.z = 6100
# 执行过渡
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
@gold_window2.dispose
#@dummy_window.dispose
@buy_window.dispose
@sell_window.dispose
@number_window.dispose
@status_window.dispose
@select_window.dispose
@black.bitmap.dispose
@black.dispose
$actor = nil
$select_actor = nil
end
#--------------------------------------------------------------------------
# ● 刷新画面
#--------------------------------------------------------------------------
def update
# 刷新窗口
@help_window.update
@command_window.update
@gold_window.update
@gold_window2.update
#@dummy_window.update
@buy_window.update
@sell_window.update
@number_window.update
@status_window.update
@select_window.update
# 角色选择窗口激活的情况下: 调用 update_command
if @select_window.active
update_select
return
end
# 指令窗口激活的情况下: 调用 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_select
if Input.trigger?(Input::B)
# 演奏取消 SE
$game_system.se_play($data_system.cancel_se)
# 切换到地图画面
$scene = Scene_Map.new
# 复原几率
for i in 1..4
actor = $game_actors[i]
actor.shop_buy_value = 100
end
return
end
if Input.trigger?(Input::C)
unless @select_window.disable_items.include?(@select_window.index)
# 演奏确定 SE
$game_system.se_play($data_system.decision_se)
# 设定值
$select_actor = @select_window.index
$actor = @select_window.index
# 设置窗口状态
@command_window.active = true
@command_window.index = 0
@command_window.refresh
@select_window.active = false
#@dummy_window.visible = true
return
end
# 演奏冻结 SE
$game_system.se_play($data_system.buzzer_se)
return
end
end
#--------------------------------------------------------------------------
# ● 刷新画面 (指令窗口激活的情况下)
#--------------------------------------------------------------------------
def update_command
# 按下 B 键的情况下
if Input.trigger?(Input::B)
# 演奏取消 SE
$game_system.se_play($data_system.cancel_se)
# 设置窗口状态
@command_window.active = false
@command_window.index = -1
#@dummy_window.visible = true
@select_window.active = true
@select_window.refresh
return
end
# 按下 C 键的情况下
if Input.trigger?(Input::C)
# 命令窗口光标位置分支
case @command_window.index
when 0 # 购买
# 演奏确定 SE
$game_system.se_play($data_system.decision_se)
# 窗口状态转向购买模式
app_buy_window
when 1 # 卖出
# 演奏确定 SE
$game_system.se_play($data_system.decision_se)
# 窗口状态转向卖出模式
app_sell_window
when 2 # 取消
# 演奏确定 SE
$game_system.se_play($data_system.decision_se)
# 设置窗口状态
@command_window.active = false
@command_window.index = -1
#@dummy_window.visible = true
@select_window.active = true
@select_window.visible = true
@select_window.refresh
@gold_window.empty
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)
# 窗口状态转向初期模式
del_buy_window
return
end
# 按下 C 键的情况下
if Input.trigger?(Input::C)
# 获取物品
@item = @buy_window.item
@item_price = @item.price * ($game_party.actors[$select_actor].buy_gold_value / 100.0).round
# 物品无效的情况下、或者价格在所持金以上的情况下
if @item == nil or @item_price > $game_party.actors[$select_actor].gold or @item.level_limit > $game_party.actors[$select_actor].level
# 演奏冻结 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.actors[$select_actor].buy_gold_value == 0 ? 99 : $game_party.actors[$select_actor].gold / (@item.price * ($game_party.actors[$select_actor].buy_gold_value / 100.0).round)
max = [max, 99 - number].min
# 窗口状态转向数值输入模式
@buy_window.active = false
@buy_window.visible = false
@number_window.set(@item, max, @item_price, $game_party.actors[$select_actor])
@number_window.active = true
@number_window.visible = true
@status_window.visible = false
end
end
#--------------------------------------------------------------------------
# ● 画面更新 (卖出窗口激活的情况下)
#--------------------------------------------------------------------------
def update_sell
# 按下 B 键的情况下
if Input.trigger?(Input::B)
# 演奏取消 SE
$game_system.se_play($data_system.cancel_se)
# 窗口状态转向初期模式
del_sell_window
return
end
# 按下 C 键的情况下
if Input.trigger?(Input::C)
# 获取物品
@item = @sell_window.item
if @item != nil
@item_price = @item.price * ($game_party.actors[$select_actor].buy_gold_value / 100.0).round
end
# 设置状态窗口的物品
@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 / 4 * 3, $game_party.actors[$select_actor])
@number_window.active = true
@number_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
@status_window.visible = true
when 1 # 卖出
# 窗口状态转向卖出模式
@sell_window.active = true
@sell_window.visible = true
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.actors[@select_window.index].lose_gold((@number_window.number * (@item.price * ($game_party.actors[@select_window.index].buy_gold_value / 100.0))).round)
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($game_party.actors[@select_window.index].id)
@gold_window2.refresh($game_party.actors[@select_window.index].id)
@buy_window.refresh
@status_window.refresh
# 窗口状态转向购买模式
@buy_window.active = true
@buy_window.visible = true
@status_window.visible = true
when 1 # 卖出
# 卖出处理
$game_party.actors[@select_window.index].gain_gold(@number_window.number * (@item_price/4*3))
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($game_party.actors[@select_window.index].id)
@gold_window2.refresh($game_party.actors[@select_window.index].id)
@sell_window.refresh
@status_window.refresh
# 窗口状态转向卖出模式
@sell_window.active = true
@sell_window.visible = true
end
return
end
end
def app_buy_window
@command_window.active = false
#@dummy_window.visible = false
@buy_window.visible = true
@status_window.visible = true
@buy_window.refresh
@gold_window2.refresh($game_party.actors[@select_window.index].id)
loop do
@buy_window.x -= 10
@select_window.x -= 10
@command_window.x -= 10
@status_window.x -= 10
@help_window.x -= 10
@number_window.x -= 10
@gold_window.x -= 10
@gold_window2.x -= 10
if @buy_window.x == 160
break
end
Graphics.update
end
@buy_window.active = true
end
def del_buy_window
@buy_window.active = false
loop do
@buy_window.x += 10
@select_window.x += 10
@command_window.x += 10
@status_window.x += 10
@help_window.x += 10
@number_window.x += 10
@gold_window.x += 10
@gold_window2.x += 10
if @command_window.x == 32
break
end
Graphics.update
end
@command_window.active = true
#@dummy_window.visible = true
@buy_window.visible = false
@buy_window.refresh
@status_window.visible = false
@status_window.item = nil
@help_window.set_text("")
end
def app_sell_window
@command_window.active = false
#@dummy_window.visible = false
@sell_window.visible = true
@sell_window.refresh
@gold_window2.refresh($game_party.actors[@select_window.index].id)
loop do
@sell_window.x -= 10
@select_window.x -= 10
@command_window.x -= 10
@help_window.x -= 10
@number_window.x -= 10
@gold_window.x -= 10
@gold_window2.x -= 10
if @sell_window.x == 160
break
end
Graphics.update
end
@sell_window.active = true
end
def del_sell_window
@sell_window.active = false
loop do
@sell_window.x += 10
@select_window.x += 10
@command_window.x += 10
@help_window.x += 10
@number_window.x += 10
@gold_window.x += 10
@gold_window2.x += 10
if @command_window.x == 32
break
end
Graphics.update
end
@command_window.active = true
#@dummy_window.visible = true
@sell_window.visible = false
@sell_window.refresh
@status_window.visible = false
@status_window.item = nil
@help_window.set_text("")
end
end
复制代码
还有一些窗口脚本。(但不关于标题)
千万别拿脚本来测试!!!
这是怎么回事?
作者:
天地有正气
时间:
2014-2-8 07:56
尝试复制到新工程或者重写?
我上次就莫名其妙出错,重写后好了。。
欢迎光临 Project1 (https://rpg.blue/)
Powered by Discuz! X3.1