设为首页收藏本站|繁體中文

Project1

 找回密码
 注册会员
搜索
查看: 1514|回复: 4
打印 上一主题 下一主题

[已经解决] 商店买卖价、最大值变动脚本 VER 1.2 的一些问题

 关闭 [复制链接]

Lv1.梦旅人

梦石
0
星屑
50
在线时间
244 小时
注册时间
2010-6-19
帖子
95
跳转到指定楼层
1
发表于 2011-8-4 14:24:42 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
本帖最后由 mmmkly 于 2011-8-4 14:26 编辑

我发现我找bug的能力还是不错的啊…………
话说最近用了题目上那个脚本
但是遇到了些问题
搜索了一下,好像也没有更新过的版本了
所以就提问下
看看怎么解决
脚本帖子在http://rpg.blue/thread-112331-1-1.html

脚本:
  1. #------------------------------------------------------------------------------
  2. # 商店买卖价、最大值变动脚本 VER 1.2
  3. #
  4. # 更新了商店可以买的数目的BUG(紧急更新)
  5. # 可以使商店变动的脚本。
  6. # 更新几个可以关闭功能的方法。
  7. # 制作 by 精灵使者
  8. #------------------------------------------------------------------------------
  9.   #--------------------------------------------------------------------------
  10.   # ● 设定部分
  11.   #--------------------------------------------------------------------------
  12.    BUY_SELL_SWITCH = 1   #默认此脚本的开启开关号,为0则不使用开关,默认开启
  13.    BUY_VARIABLE = 2      #卖价浮动变量ID号,如果ID号或者其值为0的话则默认卖价
  14.                          #100的时候也是原卖价,如果是其他数值按照100的比例浮动。
  15.                          #例如200的时候就是原价的2倍,50的时候是原价的一半。
  16.    SELL_VARIABLE = 1     #买价浮动变量ID号,如果ID号或者值为0的的话则是默认买价
  17.                          #设置的原理同卖价变量(100的时候是原买价)
  18.    BUY_MAX_VARIABLE = 3  #购买最高个数变量ID号,如果手持物品超过此数则无法购买,
  19.                          #购买变量ID号或者值为0的时候是99个,否则则是可以买物品的
  20.                          #个数。
  21.   
  22. #==============================================================================
  23. # ■ Scene_Shop
  24. #------------------------------------------------------------------------------
  25. #  处理商店画面的类。
  26. #==============================================================================

  27. class Scene_Shop
  28.   #--------------------------------------------------------------------------
  29.   # ● 主处理
  30.   #--------------------------------------------------------------------------
  31.   def main
  32.     # 生成帮助窗口
  33.     @help_window = Window_Help.new
  34.     # 生成指令窗口
  35.     @command_window = Window_ShopCommand.new
  36.     # 生成金钱窗口
  37.     @gold_window = Window_Gold.new
  38.     @gold_window.x = 480
  39.     @gold_window.y = 64
  40.     # 生成时间窗口
  41.     @dummy_window = Window_Base.new(0, 128, 640, 352)
  42.     # 生成购买窗口
  43.     @buy_window = Window_ShopBuy.new($game_temp.shop_goods)
  44.     @buy_window.active = false
  45.     @buy_window.visible = false
  46.     @buy_window.help_window = @help_window
  47.     # 生成卖出窗口
  48.     @sell_window = Window_ShopSell.new
  49.     @sell_window.active = false
  50.     @sell_window.visible = false
  51.     @sell_window.help_window = @help_window
  52.     # 生成数量输入窗口
  53.     @number_window = Window_ShopNumber.new
  54.     @number_window.active = false
  55.     @number_window.visible = false
  56.     # 生成状态窗口
  57.     @status_window = Window_ShopStatus.new
  58.     @status_window.visible = false
  59.     # 执行过渡
  60.     Graphics.transition
  61.     # 主循环
  62.     loop do
  63.       # 刷新游戏画面
  64.       Graphics.update
  65.       # 刷新输入信息
  66.       Input.update
  67.       # 刷新画面
  68.       update
  69.       # 如果画面切换的话就中断循环
  70.       if $scene != self
  71.         break
  72.       end
  73.     end
  74.     # 准备过渡
  75.     Graphics.freeze
  76.     # 释放窗口
  77.     @help_window.dispose
  78.     @command_window.dispose
  79.     @gold_window.dispose
  80.     @dummy_window.dispose
  81.     @buy_window.dispose
  82.     @sell_window.dispose
  83.     @number_window.dispose
  84.     @status_window.dispose
  85.   end
  86.   #--------------------------------------------------------------------------
  87.   # ● 刷新画面
  88.   #--------------------------------------------------------------------------
  89.   def update
  90.     # 刷新窗口
  91.     @help_window.update
  92.     @command_window.update
  93.     @gold_window.update
  94.     @dummy_window.update
  95.     @buy_window.update
  96.     @sell_window.update
  97.     @number_window.update
  98.     @status_window.update
  99.     # 指令窗口激活的情况下: 调用 update_command
  100.     if @command_window.active
  101.       update_command
  102.       return
  103.     end
  104.     # 购买窗口激活的情况下: 调用 update_buy
  105.     if @buy_window.active
  106.       update_buy
  107.       return
  108.     end
  109.     # 卖出窗口激活的情况下: 调用 update_sell
  110.     if @sell_window.active
  111.       update_sell
  112.       return
  113.     end
  114.     # 个数输入窗口激活的情况下: 调用 update_number
  115.     if @number_window.active
  116.       update_number
  117.       return
  118.     end
  119.   end
  120.   #--------------------------------------------------------------------------
  121.   # ● 刷新画面 (指令窗口激活的情况下)
  122.   #--------------------------------------------------------------------------
  123.   def update_command
  124.     # 按下 B 键的情况下
  125.     if Input.trigger?(Input::B)
  126.       # 演奏取消 SE
  127.       $game_system.se_play($data_system.cancel_se)
  128.       # 切换到地图画面
  129.       $scene = Scene_Map.new
  130.       return
  131.     end
  132.     # 按下 C 键的情况下
  133.     if Input.trigger?(Input::C)
  134.       # 命令窗口光标位置分支
  135.       case @command_window.index
  136.       when 0  # 购买
  137.         # 演奏确定 SE
  138.         $game_system.se_play($data_system.decision_se)
  139.         # 窗口状态转向购买模式
  140.         @command_window.active = false
  141.         @dummy_window.visible = false
  142.         @buy_window.active = true
  143.         @buy_window.visible = true
  144.         @buy_window.refresh
  145.         @status_window.visible = true
  146.       when 1  # 卖出
  147.         # 演奏确定 SE
  148.         $game_system.se_play($data_system.decision_se)
  149.         # 窗口状态转向卖出模式
  150.         @command_window.active = false
  151.         @dummy_window.visible = false
  152.         @sell_window.active = true
  153.         @sell_window.visible = true
  154.         @sell_window.refresh
  155.       when 2  # 取消
  156.         # 演奏确定 SE
  157.         $game_system.se_play($data_system.decision_se)
  158.         # 切换到地图画面
  159.         $scene = Scene_Map.new
  160.       end
  161.       return
  162.     end
  163.   end
  164.   #--------------------------------------------------------------------------
  165.   # ● 刷新画面 (购买窗口激活的情况下)
  166.   #--------------------------------------------------------------------------
  167.   def update_buy
  168.     # 设置状态窗口的物品
  169.     @status_window.item = @buy_window.item
  170.     # 按下 B 键的情况下
  171.     if Input.trigger?(Input::B)
  172.       # 演奏取消 SE
  173.       $game_system.se_play($data_system.cancel_se)
  174.       # 窗口状态转向初期模式
  175.       @command_window.active = true
  176.       @dummy_window.visible = true
  177.       @buy_window.active = false
  178.       @buy_window.visible = false
  179.       @status_window.visible = false
  180.       @status_window.item = nil
  181.       # 删除帮助文本
  182.       @help_window.set_text("")
  183.       return
  184.     end
  185.     # 按下 C 键的情况下
  186.     if Input.trigger?(Input::C)
  187.       # 获取物品
  188.       @item = @buy_window.item
  189.       # 物品无效的情况下、或者价格在所持金以上的情况下
  190.       if @item == nil or @item.price * $game_variables[BUY_VARIABLE] / 100 > $game_party.gold
  191.         # 演奏冻结 SE
  192.         $game_system.se_play($data_system.buzzer_se)
  193.         return
  194.       end
  195.       # 获取物品所持数
  196.       case @item
  197.       when RPG::Item
  198.         number = $game_party.item_number(@item.id)
  199.       when RPG::Weapon
  200.         number = $game_party.weapon_number(@item.id)
  201.       when RPG::Armor
  202.         number = $game_party.armor_number(@item.id)
  203.       end
  204.       # 如果已经拥有了 99 个情况下
  205.       if BUY_SELL_SWITCH == 0
  206.         @buy_max = $game_variables[BUY_MAX_VARIABLE]
  207.       elsif !$game_switches[BUY_SELL_SWITCH]
  208.         @buy_max = 99
  209.       else
  210.         @buy_max = $game_variables[BUY_MAX_VARIABLE]
  211.       end
  212.       if number >= @buy_max
  213.         # 演奏冻结 SE
  214.         $game_system.se_play($data_system.buzzer_se)
  215.         return
  216.       end
  217.       # 演奏确定 SE
  218.       $game_system.se_play($data_system.decision_se)
  219.       # 计算可以最多购买的数量
  220.       max = @item.price == 0 ? @buy_max : $game_party.gold / @item.price
  221.       max = [max, (@buy_max - number)].min
  222.       # 窗口状态转向数值输入模式
  223.       @buy_window.active = false
  224.       @buy_window.visible = false
  225.       ######################################################
  226.       if BUY_SELL_SWITCH == 0
  227.       @number_window.set(@item, max, @item.price *
  228.       $game_variables[BUY_VARIABLE] / 100)
  229.       elsif !$game_switches[BUY_SELL_SWITCH] or BUY_VARIABLE == 0
  230.       @number_window.set(@item, max, @item.price)
  231.     else
  232.       @number_window.set(@item, max, @item.price *
  233.       $game_variables[BUY_VARIABLE] / 100)
  234.     end
  235.       #####################################################
  236.       @number_window.active = true
  237.       @number_window.visible = true
  238.     end
  239.   end
  240.   #--------------------------------------------------------------------------
  241.   # ● 画面更新 (卖出窗口激活的情况下)
  242.   #--------------------------------------------------------------------------
  243.   def update_sell
  244.     # 按下 B 键的情况下
  245.     if Input.trigger?(Input::B)
  246.       # 演奏取消 SE
  247.       $game_system.se_play($data_system.cancel_se)
  248.       # 窗口状态转向初期模式
  249.       @command_window.active = true
  250.       @dummy_window.visible = true
  251.       @sell_window.active = false
  252.       @sell_window.visible = false
  253.       @status_window.item = nil
  254.       # 删除帮助文本
  255.       @help_window.set_text("")
  256.       return
  257.     end
  258.     # 按下 C 键的情况下
  259.     if Input.trigger?(Input::C)
  260.       # 获取物品
  261.       @item = @sell_window.item
  262.       # 设置状态窗口的物品
  263.       @status_window.item = @item
  264.       # 物品无效的情况下、或者价格为 0 (不能卖出) 的情况下
  265.       if @item == nil or @item.price == 0
  266.         # 演奏冻结 SE
  267.         $game_system.se_play($data_system.buzzer_se)
  268.         return
  269.       end
  270.       # 演奏确定 SE
  271.       $game_system.se_play($data_system.decision_se)
  272.       # 获取物品的所持数
  273.       case @item
  274.       when RPG::Item
  275.         number = $game_party.item_number(@item.id)
  276.       when RPG::Weapon
  277.         number = $game_party.weapon_number(@item.id)
  278.       when RPG::Armor
  279.         number = $game_party.armor_number(@item.id)
  280.       end
  281.       # 最大卖出个数 = 物品的所持数
  282.       max = number
  283.       # 窗口状态转向个数输入模式
  284.       @sell_window.active = false
  285.       @sell_window.visible = false
  286.       ###############################################################
  287.       if BUY_SELL_SWITCH == 0
  288.         @number_window.set(@item, max, @item.price *
  289.         $game_variables[SELL_VARIABLE] / 100)
  290.       elsif !$game_switches[BUY_SELL_SWITCH] or SELL_VARIABLE == 0
  291.         @number_window.set(@item, max, @item.price / 2)
  292.       else
  293.         @number_window.set(@item, max, @item.price *
  294.         $game_variables[SELL_VARIABLE] / 100)
  295.       end
  296.       ###############################################################
  297.       @number_window.active = true
  298.       @number_window.visible = true
  299.       @status_window.visible = true
  300.     end
  301.   end
  302.   #--------------------------------------------------------------------------
  303.   # ● 刷新画面 (个数输入窗口激活的情况下)
  304.   #--------------------------------------------------------------------------
  305.   def update_number
  306.     # 按下 B 键的情况下
  307.     if Input.trigger?(Input::B)
  308.       # 演奏取消 SE
  309.       $game_system.se_play($data_system.cancel_se)
  310.       # 设置个数输入窗口为不活动·非可视状态
  311.       @number_window.active = false
  312.       @number_window.visible = false
  313.       # 命令窗口光标位置分支
  314.       case @command_window.index
  315.       when 0  # 购买
  316.         # 窗口状态转向购买模式
  317.         @buy_window.active = true
  318.         @buy_window.visible = true
  319.       when 1  # 卖出
  320.         # 窗口状态转向卖出模式
  321.         @sell_window.active = true
  322.         @sell_window.visible = true
  323.         @status_window.visible = false
  324.       end
  325.       return
  326.     end
  327.     # 按下 C 键的情况下
  328.     if Input.trigger?(Input::C)
  329.       # 演奏商店 SE
  330.       $game_system.se_play($data_system.shop_se)
  331.       # 设置个数输入窗口为不活动·非可视状态
  332.       @number_window.active = false
  333.       @number_window.visible = false
  334.       # 命令窗口光标位置分支
  335.       case @command_window.index
  336.       when 0  # 购买
  337.         # 购买处理
  338.         ###############################################
  339.       if BUY_SELL_SWITCH == 0
  340.         $game_party.lose_gold(@number_window.number * (@item.price *
  341.         $game_variables[BUY_VARIABLE] / 100))
  342.       elsif !$game_switches[BUY_SELL_SWITCH] or BUY_VARIABLE == 0
  343.         $game_party.lose_gold(@number_window.number * @item.price)
  344.       else
  345.         $game_party.lose_gold(@number_window.number * (@item.price *
  346.         $game_variables[BUY_VARIABLE] / 100))
  347.       end
  348.       ###################################################
  349.         case @item
  350.         when RPG::Item
  351.           $game_party.gain_item(@item.id, @number_window.number)
  352.         when RPG::Weapon
  353.           $game_party.gain_weapon(@item.id, @number_window.number)
  354.         when RPG::Armor
  355.           $game_party.gain_armor(@item.id, @number_window.number)
  356.         end
  357.         # 刷新各窗口
  358.         @gold_window.refresh
  359.         @buy_window.refresh
  360.         @status_window.refresh
  361.         # 窗口状态转向购买模式
  362.         @buy_window.active = true
  363.         @buy_window.visible = true
  364.       when 1  # 卖出
  365.         # 卖出处理
  366.         ###############################################################
  367.       if BUY_SELL_SWITCH == 0
  368.         $game_party.gain_gold(@number_window.number * (@item.price *
  369.         $game_variables[SELL_VARIABLE] / 100))
  370.       elsif !$game_switches[BUY_SELL_SWITCH] or SELL_VARIABLE == 0
  371.         $game_party.gain_gold(@number_window.number * (@item.price / 2))
  372.       else
  373.         $game_party.gain_gold(@number_window.number * (@item.price *
  374.         $game_variables[SELL_VARIABLE] / 100))
  375.       end
  376.         ##############################################################
  377.         case @item
  378.         when RPG::Item
  379.           $game_party.lose_item(@item.id, @number_window.number)
  380.         when RPG::Weapon
  381.           $game_party.lose_weapon(@item.id, @number_window.number)
  382.         when RPG::Armor
  383.           $game_party.lose_armor(@item.id, @number_window.number)
  384.         end
  385.         # 刷新各窗口
  386.         @gold_window.refresh
  387.         @sell_window.refresh
  388.         @status_window.refresh
  389.         # 窗口状态转向卖出模式
  390.         @sell_window.active = true
  391.         @sell_window.visible = true
  392.         @status_window.visible = false
  393.       end
  394.       return
  395.     end
  396.   end
  397. end
  398. #==============================================================================
  399. # ■ Window_ShopBuy
  400. #------------------------------------------------------------------------------
  401. #  商店画面、浏览显示可以购买的商品的窗口。
  402. #==============================================================================

  403. class Window_ShopBuy < Window_Selectable
  404.   #--------------------------------------------------------------------------
  405.   # ● 初始化对像
  406.   #     shop_goods : 商品
  407.   #--------------------------------------------------------------------------
  408.   def initialize(shop_goods)
  409.     super(0, 128, 368, 352)
  410.     @shop_goods = shop_goods
  411.     refresh
  412.     self.index = 0
  413.   end
  414.   #--------------------------------------------------------------------------
  415.   # ● 获取物品
  416.   #--------------------------------------------------------------------------
  417.   def item
  418.     return @data[self.index]
  419.   end
  420.   #--------------------------------------------------------------------------
  421.   # ● 刷新
  422.   #--------------------------------------------------------------------------
  423.   def refresh
  424.     if self.contents != nil
  425.       self.contents.dispose
  426.       self.contents = nil
  427.     end
  428.     @data = []
  429.     for goods_item in @shop_goods
  430.       case goods_item[0]
  431.       when 0
  432.         item = $data_items[goods_item[1]]
  433.       when 1
  434.         item = $data_weapons[goods_item[1]]
  435.       when 2
  436.         item = $data_armors[goods_item[1]]
  437.       end
  438.       if item != nil
  439.         @data.push(item)
  440.       end
  441.     end
  442.     # 如果项目数不是 0 就生成位图、描绘全部项目
  443.     @item_max = @data.size
  444.     if @item_max > 0
  445.       self.contents = Bitmap.new(width - 32, row_max * 32)
  446.       for i in 0...@item_max
  447.         draw_item(i)
  448.       end
  449.     end
  450.   end
  451.   #--------------------------------------------------------------------------
  452.   # ● 描绘羡慕
  453.   #     index : 项目编号
  454.   #--------------------------------------------------------------------------
  455.   def draw_item(index)
  456.     item = @data[index]
  457.     # 获取物品所持数
  458.     case item
  459.     when RPG::Item
  460.       number = $game_party.item_number(item.id)
  461.     when RPG::Weapon
  462.       number = $game_party.weapon_number(item.id)
  463.     when RPG::Armor
  464.       number = $game_party.armor_number(item.id)
  465.     end
  466.     # 价格在所持金以下、并且所持数不是 99 的情况下为普通文字颜色
  467.     # 除此之外的情况设置为无效文字色
  468.     ###############################################################
  469.       if BUY_SELL_SWITCH == 0
  470.         @buy_max = $game_variables[BUY_MAX_VARIABLE]
  471.       elsif !$game_switches[BUY_SELL_SWITCH] or BUY_MAX_VARIABLE == 0
  472.         @buy_max = 99
  473.       else
  474.         @buy_max = $game_variables[BUY_MAX_VARIABLE]
  475.       end
  476.     ###############################################################
  477.     if item.price * $game_variables[BUY_VARIABLE] / 100 <= $game_party.gold and number < @buy_max
  478.       self.contents.font.color = normal_color
  479.     else
  480.       self.contents.font.color = disabled_color
  481.     end
  482.     x = 4
  483.     y = index * 32
  484.     rect = Rect.new(x, y, self.width - 32, 32)
  485.     self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
  486.     bitmap = RPG::Cache.icon(item.icon_name)
  487.     opacity = self.contents.font.color == normal_color ? 255 : 128
  488.     self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
  489.     self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
  490.     ####################################################
  491.     if BUY_SELL_SWITCH == 0
  492.       self.contents.draw_text(x + 240, y, 88, 32, (item.price *
  493.       $game_variables[BUY_VARIABLE] / 100).to_s, 2)
  494.     elsif !$game_switches[BUY_SELL_SWITCH] or BUY_VARIABLE == 0
  495.       self.contents.draw_text(x + 240, y, 88, 32, item.price.to_s, 2)
  496.     else
  497.       self.contents.draw_text(x + 240, y, 88, 32, (item.price *
  498.       $game_variables[BUY_VARIABLE] / 100).to_s, 2)
  499.     end
  500.     #####################################################
  501.   end
  502.   #--------------------------------------------------------------------------
  503.   # ● 刷新帮助文本
  504.   #--------------------------------------------------------------------------
  505.   def update_help
  506.     @help_window.set_text(self.item == nil ? "" : self.item.description)
  507.   end
  508. end
复制代码




谢谢了

点评

版本已经更新,更新到v1.3  发表于 2011-8-11 10:59
没事做个游戏
暗黑-外传
剧情:■■■■■□□□□□
脚本:■■■■■■■■■□
素材:■■■■■■■■■■
地图:■■■■■■■■■□
系统:■■■■■■■■□□
整体完成度:■■■■■■■□□□
发布日期:未知

Lv5.捕梦者 (管理员)

老黄鸡

梦石
0
星屑
39679
在线时间
7486 小时
注册时间
2009-7-6
帖子
13483

开拓者贵宾

2
发表于 2011-8-11 07:49:59 | 只看该作者
= =的确是有诡异的判断问题,稍等上工程.
RGDirect - DirectX驱动的RGSS,点我了解.
RM全系列成套系统定制请联系QQ1213237796
不接受对其他插件维护的委托
回复

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
145
在线时间
698 小时
注册时间
2009-11-15
帖子
538
3
发表于 2011-8-11 07:50:18 | 只看该作者
  1. #------------------------------------------------------------------------------
  2. # 商店买卖价、最大值变动脚本 VER 1.2
  3. #
  4. # 更新了商店可以买的数目的BUG(紧急更新)
  5. # 可以使商店变动的脚本。
  6. # 更新几个可以关闭功能的方法。
  7. # 制作 by 精灵使者
  8. #------------------------------------------------------------------------------
  9.   #--------------------------------------------------------------------------
  10.   # ● 设定部分
  11.   #--------------------------------------------------------------------------
  12.    BUY_SELL_SWITCH = 1   #默认此脚本的开启开关号,为0则不使用开关,默认开启
  13.    BUY_VARIABLE = 2      #卖价浮动变量ID号,如果ID号或者其值为0的话则默认卖价
  14.                          #100的时候也是原卖价,如果是其他数值按照100的比例浮动。
  15.                          #例如200的时候就是原价的2倍,50的时候是原价的一半。
  16.    SELL_VARIABLE = 1     #买价浮动变量ID号,如果ID号或者值为0的的话则是默认买价
  17.                          #设置的原理同卖价变量(100的时候是原买价)
  18.    BUY_MAX_VARIABLE = 3  #购买最高个数变量ID号,如果手持物品超过此数则无法购买,
  19.                          #购买变量ID号或者值为0的时候是99个,否则则是可以买物品的
  20.                          #个数。
  21.   
  22. #==============================================================================
  23. # ■ Scene_Shop
  24. #------------------------------------------------------------------------------
  25. #  处理商店画面的类。
  26. #==============================================================================

  27. class Scene_Shop
  28.   #--------------------------------------------------------------------------
  29.   # ● 主处理
  30.   #--------------------------------------------------------------------------
  31.   def main
  32.     # 生成帮助窗口
  33.     @help_window = Window_Help.new
  34.     # 生成指令窗口
  35.     @command_window = Window_ShopCommand.new
  36.     # 生成金钱窗口
  37.     @gold_window = Window_Gold.new
  38.     @gold_window.x = 480
  39.     @gold_window.y = 64
  40.     # 生成时间窗口
  41.     @dummy_window = Window_Base.new(0, 128, 640, 352)
  42.     # 生成购买窗口
  43.     @buy_window = Window_ShopBuy.new($game_temp.shop_goods)
  44.     @buy_window.active = false
  45.     @buy_window.visible = false
  46.     @buy_window.help_window = @help_window
  47.     # 生成卖出窗口
  48.     @sell_window = Window_ShopSell.new
  49.     @sell_window.active = false
  50.     @sell_window.visible = false
  51.     @sell_window.help_window = @help_window
  52.     # 生成数量输入窗口
  53.     @number_window = Window_ShopNumber.new
  54.     @number_window.active = false
  55.     @number_window.visible = false
  56.     # 生成状态窗口
  57.     @status_window = Window_ShopStatus.new
  58.     @status_window.visible = false
  59.     # 执行过渡
  60.     Graphics.transition
  61.     # 主循环
  62.     loop do
  63.       # 刷新游戏画面
  64.       Graphics.update
  65.       # 刷新输入信息
  66.       Input.update
  67.       # 刷新画面
  68.       update
  69.       # 如果画面切换的话就中断循环
  70.       if $scene != self
  71.         break
  72.       end
  73.     end
  74.     # 准备过渡
  75.     Graphics.freeze
  76.     # 释放窗口
  77.     @help_window.dispose
  78.     @command_window.dispose
  79.     @gold_window.dispose
  80.     @dummy_window.dispose
  81.     @buy_window.dispose
  82.     @sell_window.dispose
  83.     @number_window.dispose
  84.     @status_window.dispose
  85.   end
  86.   #--------------------------------------------------------------------------
  87.   # ● 刷新画面
  88.   #--------------------------------------------------------------------------
  89.   def update
  90.     # 刷新窗口
  91.     @help_window.update
  92.     @command_window.update
  93.     @gold_window.update
  94.     @dummy_window.update
  95.     @buy_window.update
  96.     @sell_window.update
  97.     @number_window.update
  98.     @status_window.update
  99.     # 指令窗口激活的情况下: 调用 update_command
  100.     if @command_window.active
  101.       update_command
  102.       return
  103.     end
  104.     # 购买窗口激活的情况下: 调用 update_buy
  105.     if @buy_window.active
  106.       update_buy
  107.       return
  108.     end
  109.     # 卖出窗口激活的情况下: 调用 update_sell
  110.     if @sell_window.active
  111.       update_sell
  112.       return
  113.     end
  114.     # 个数输入窗口激活的情况下: 调用 update_number
  115.     if @number_window.active
  116.       update_number
  117.       return
  118.     end
  119.   end
  120.   #--------------------------------------------------------------------------
  121.   # ● 刷新画面 (指令窗口激活的情况下)
  122.   #--------------------------------------------------------------------------
  123.   def update_command
  124.     # 按下 B 键的情况下
  125.     if Input.trigger?(Input::B)
  126.       # 演奏取消 SE
  127.       $game_system.se_play($data_system.cancel_se)
  128.       # 切换到地图画面
  129.       $scene = Scene_Map.new
  130.       return
  131.     end
  132.     # 按下 C 键的情况下
  133.     if Input.trigger?(Input::C)
  134.       # 命令窗口光标位置分支
  135.       case @command_window.index
  136.       when 0  # 购买
  137.         # 演奏确定 SE
  138.         $game_system.se_play($data_system.decision_se)
  139.         # 窗口状态转向购买模式
  140.         @command_window.active = false
  141.         @dummy_window.visible = false
  142.         @buy_window.active = true
  143.         @buy_window.visible = true
  144.         @buy_window.refresh
  145.         @status_window.visible = true
  146.       when 1  # 卖出
  147.         # 演奏确定 SE
  148.         $game_system.se_play($data_system.decision_se)
  149.         # 窗口状态转向卖出模式
  150.         @command_window.active = false
  151.         @dummy_window.visible = false
  152.         @sell_window.active = true
  153.         @sell_window.visible = true
  154.         @sell_window.refresh
  155.       when 2  # 取消
  156.         # 演奏确定 SE
  157.         $game_system.se_play($data_system.decision_se)
  158.         # 切换到地图画面
  159.         $scene = Scene_Map.new
  160.       end
  161.       return
  162.     end
  163.   end
  164.   #--------------------------------------------------------------------------
  165.   # ● 刷新画面 (购买窗口激活的情况下)
  166.   #--------------------------------------------------------------------------
  167.   def update_buy
  168.     # 设置状态窗口的物品
  169.     @status_window.item = @buy_window.item
  170.     # 按下 B 键的情况下
  171.     if Input.trigger?(Input::B)
  172.       # 演奏取消 SE
  173.       $game_system.se_play($data_system.cancel_se)
  174.       # 窗口状态转向初期模式
  175.       @command_window.active = true
  176.       @dummy_window.visible = true
  177.       @buy_window.active = false
  178.       @buy_window.visible = false
  179.       @status_window.visible = false
  180.       @status_window.item = nil
  181.       # 删除帮助文本
  182.       @help_window.set_text("")
  183.       return
  184.     end
  185.     # 按下 C 键的情况下
  186.     if Input.trigger?(Input::C)
  187.       # 获取物品
  188.       @item = @buy_window.item
  189.       # 物品无效的情况下、或者价格在所持金以上的情况下
  190.       if @item == nil or @item.price * $game_variables[BUY_VARIABLE] / 100 > $game_party.gold
  191.         # 演奏冻结 SE
  192.         $game_system.se_play($data_system.buzzer_se)
  193.         return
  194.       end
  195.       # 获取物品所持数
  196.       case @item
  197.       when RPG::Item
  198.         number = $game_party.item_number(@item.id)
  199.       when RPG::Weapon
  200.         number = $game_party.weapon_number(@item.id)
  201.       when RPG::Armor
  202.         number = $game_party.armor_number(@item.id)
  203.       end
  204.       # 如果已经拥有了 99 个情况下
  205.       if BUY_SELL_SWITCH == 0
  206.         @buy_max = $game_variables[BUY_MAX_VARIABLE]
  207.       elsif !$game_switches[BUY_SELL_SWITCH]
  208.         @buy_max = 99
  209.       else
  210.         @buy_max = $game_variables[BUY_MAX_VARIABLE]
  211.       end
  212.       if number >= @buy_max
  213.         # 演奏冻结 SE
  214.         $game_system.se_play($data_system.buzzer_se)
  215.         return
  216.       end
  217.       # 演奏确定 SE
  218.       $game_system.se_play($data_system.decision_se)
  219.       # 计算可以最多购买的数量
  220.       max = @item.price == 0 ? @buy_max : $game_party.gold / (@item.price * $game_variables[BUY_VARIABLE] / 100)
  221.       max = [max, (@buy_max - number)].min
  222.       # 窗口状态转向数值输入模式
  223.       @buy_window.active = false
  224.       @buy_window.visible = false
  225.       ######################################################
  226.       if BUY_SELL_SWITCH == 0
  227.       @number_window.set(@item, max, @item.price *
  228.       $game_variables[BUY_VARIABLE] / 100)
  229.       elsif !$game_switches[BUY_SELL_SWITCH] or BUY_VARIABLE == 0
  230.       @number_window.set(@item, max, @item.price)
  231.     else
  232.       @number_window.set(@item, max, @item.price *
  233.       $game_variables[BUY_VARIABLE] / 100)
  234.     end
  235.       #####################################################
  236.       @number_window.active = true
  237.       @number_window.visible = true
  238.     end
  239.   end
  240.   #--------------------------------------------------------------------------
  241.   # ● 画面更新 (卖出窗口激活的情况下)
  242.   #--------------------------------------------------------------------------
  243.   def update_sell
  244.     # 按下 B 键的情况下
  245.     if Input.trigger?(Input::B)
  246.       # 演奏取消 SE
  247.       $game_system.se_play($data_system.cancel_se)
  248.       # 窗口状态转向初期模式
  249.       @command_window.active = true
  250.       @dummy_window.visible = true
  251.       @sell_window.active = false
  252.       @sell_window.visible = false
  253.       @status_window.item = nil
  254.       # 删除帮助文本
  255.       @help_window.set_text("")
  256.       return
  257.     end
  258.     # 按下 C 键的情况下
  259.     if Input.trigger?(Input::C)
  260.       # 获取物品
  261.       @item = @sell_window.item
  262.       # 设置状态窗口的物品
  263.       @status_window.item = @item
  264.       # 物品无效的情况下、或者价格为 0 (不能卖出) 的情况下
  265.       if @item == nil or @item.price == 0
  266.         # 演奏冻结 SE
  267.         $game_system.se_play($data_system.buzzer_se)
  268.         return
  269.       end
  270.       # 演奏确定 SE
  271.       $game_system.se_play($data_system.decision_se)
  272.       # 获取物品的所持数
  273.       case @item
  274.       when RPG::Item
  275.         number = $game_party.item_number(@item.id)
  276.       when RPG::Weapon
  277.         number = $game_party.weapon_number(@item.id)
  278.       when RPG::Armor
  279.         number = $game_party.armor_number(@item.id)
  280.       end
  281.       # 最大卖出个数 = 物品的所持数
  282.       max = number
  283.       # 窗口状态转向个数输入模式
  284.       @sell_window.active = false
  285.       @sell_window.visible = false
  286.       ###############################################################
  287.       if BUY_SELL_SWITCH == 0
  288.         @number_window.set(@item, max, @item.price *
  289.         $game_variables[SELL_VARIABLE] / 100)
  290.       elsif !$game_switches[BUY_SELL_SWITCH] or SELL_VARIABLE == 0
  291.         @number_window.set(@item, max, @item.price / 2)
  292.       else
  293.         @number_window.set(@item, max, @item.price *
  294.         $game_variables[SELL_VARIABLE] / 100)
  295.       end
  296.       ###############################################################
  297.       @number_window.active = true
  298.       @number_window.visible = true
  299.       @status_window.visible = true
  300.     end
  301.   end
  302.   #--------------------------------------------------------------------------
  303.   # ● 刷新画面 (个数输入窗口激活的情况下)
  304.   #--------------------------------------------------------------------------
  305.   def update_number
  306.     # 按下 B 键的情况下
  307.     if Input.trigger?(Input::B)
  308.       # 演奏取消 SE
  309.       $game_system.se_play($data_system.cancel_se)
  310.       # 设置个数输入窗口为不活动·非可视状态
  311.       @number_window.active = false
  312.       @number_window.visible = false
  313.       # 命令窗口光标位置分支
  314.       case @command_window.index
  315.       when 0  # 购买
  316.         # 窗口状态转向购买模式
  317.         @buy_window.active = true
  318.         @buy_window.visible = true
  319.       when 1  # 卖出
  320.         # 窗口状态转向卖出模式
  321.         @sell_window.active = true
  322.         @sell_window.visible = true
  323.         @status_window.visible = false
  324.       end
  325.       return
  326.     end
  327.     # 按下 C 键的情况下
  328.     if Input.trigger?(Input::C)
  329.       # 演奏商店 SE
  330.       $game_system.se_play($data_system.shop_se)
  331.       # 设置个数输入窗口为不活动·非可视状态
  332.       @number_window.active = false
  333.       @number_window.visible = false
  334.       # 命令窗口光标位置分支
  335.       case @command_window.index
  336.       when 0  # 购买
  337.         # 购买处理
  338.         ###############################################
  339.       if BUY_SELL_SWITCH == 0
  340.         $game_party.lose_gold(@number_window.number * (@item.price *
  341.         $game_variables[BUY_VARIABLE] / 100))
  342.       elsif !$game_switches[BUY_SELL_SWITCH] or BUY_VARIABLE == 0
  343.         $game_party.lose_gold(@number_window.number * @item.price)
  344.       else
  345.         $game_party.lose_gold(@number_window.number * (@item.price *
  346.         $game_variables[BUY_VARIABLE] / 100))
  347.       end
  348.       ###################################################
  349.         case @item
  350.         when RPG::Item
  351.           $game_party.gain_item(@item.id, @number_window.number)
  352.         when RPG::Weapon
  353.           $game_party.gain_weapon(@item.id, @number_window.number)
  354.         when RPG::Armor
  355.           $game_party.gain_armor(@item.id, @number_window.number)
  356.         end
  357.         # 刷新各窗口
  358.         @gold_window.refresh
  359.         @buy_window.refresh
  360.         @status_window.refresh
  361.         # 窗口状态转向购买模式
  362.         @buy_window.active = true
  363.         @buy_window.visible = true
  364.       when 1  # 卖出
  365.         # 卖出处理
  366.         ###############################################################
  367.       if BUY_SELL_SWITCH == 0
  368.         $game_party.gain_gold(@number_window.number * (@item.price *
  369.         $game_variables[SELL_VARIABLE] / 100))
  370.       elsif !$game_switches[BUY_SELL_SWITCH] or SELL_VARIABLE == 0
  371.         $game_party.gain_gold(@number_window.number * (@item.price / 2))
  372.       else
  373.         $game_party.gain_gold(@number_window.number * (@item.price *
  374.         $game_variables[SELL_VARIABLE] / 100))
  375.       end
  376.         ##############################################################
  377.         case @item
  378.         when RPG::Item
  379.           $game_party.lose_item(@item.id, @number_window.number)
  380.         when RPG::Weapon
  381.           $game_party.lose_weapon(@item.id, @number_window.number)
  382.         when RPG::Armor
  383.           $game_party.lose_armor(@item.id, @number_window.number)
  384.         end
  385.         # 刷新各窗口
  386.         @gold_window.refresh
  387.         @sell_window.refresh
  388.         @status_window.refresh
  389.         # 窗口状态转向卖出模式
  390.         @sell_window.active = true
  391.         @sell_window.visible = true
  392.         @status_window.visible = false
  393.       end
  394.       return
  395.     end
  396.   end
  397. end
  398. #==============================================================================
  399. # ■ Window_ShopBuy
  400. #------------------------------------------------------------------------------
  401. #  商店画面、浏览显示可以购买的商品的窗口。
  402. #==============================================================================

  403. class Window_ShopBuy < Window_Selectable
  404.   #--------------------------------------------------------------------------
  405.   # ● 初始化对像
  406.   #     shop_goods : 商品
  407.   #--------------------------------------------------------------------------
  408.   def initialize(shop_goods)
  409.     super(0, 128, 368, 352)
  410.     @shop_goods = shop_goods
  411.     refresh
  412.     self.index = 0
  413.   end
  414.   #--------------------------------------------------------------------------
  415.   # ● 获取物品
  416.   #--------------------------------------------------------------------------
  417.   def item
  418.     return @data[self.index]
  419.   end
  420.   #--------------------------------------------------------------------------
  421.   # ● 刷新
  422.   #--------------------------------------------------------------------------
  423.   def refresh
  424.     if self.contents != nil
  425.       self.contents.dispose
  426.       self.contents = nil
  427.     end
  428.     @data = []
  429.     for goods_item in @shop_goods
  430.       case goods_item[0]
  431.       when 0
  432.         item = $data_items[goods_item[1]]
  433.       when 1
  434.         item = $data_weapons[goods_item[1]]
  435.       when 2
  436.         item = $data_armors[goods_item[1]]
  437.       end
  438.       if item != nil
  439.         @data.push(item)
  440.       end
  441.     end
  442.     # 如果项目数不是 0 就生成位图、描绘全部项目
  443.     @item_max = @data.size
  444.     if @item_max > 0
  445.       self.contents = Bitmap.new(width - 32, row_max * 32)
  446.       for i in 0...@item_max
  447.         draw_item(i)
  448.       end
  449.     end
  450.   end
  451.   #--------------------------------------------------------------------------
  452.   # ● 描绘羡慕
  453.   #     index : 项目编号
  454.   #--------------------------------------------------------------------------
  455.   def draw_item(index)
  456.     item = @data[index]
  457.     # 获取物品所持数
  458.     case item
  459.     when RPG::Item
  460.       number = $game_party.item_number(item.id)
  461.     when RPG::Weapon
  462.       number = $game_party.weapon_number(item.id)
  463.     when RPG::Armor
  464.       number = $game_party.armor_number(item.id)
  465.     end
  466.     # 价格在所持金以下、并且所持数不是 99 的情况下为普通文字颜色
  467.     # 除此之外的情况设置为无效文字色
  468.     ###############################################################
  469.       if BUY_SELL_SWITCH == 0
  470.         @buy_max = $game_variables[BUY_MAX_VARIABLE]
  471.       elsif !$game_switches[BUY_SELL_SWITCH] or BUY_MAX_VARIABLE == 0
  472.         @buy_max = 99
  473.       else
  474.         @buy_max = $game_variables[BUY_MAX_VARIABLE]
  475.       end
  476.     ###############################################################
  477.     if item.price * $game_variables[BUY_VARIABLE] / 100 <= $game_party.gold and number < @buy_max
  478.       self.contents.font.color = normal_color
  479.     else
  480.       self.contents.font.color = disabled_color
  481.     end
  482.     x = 4
  483.     y = index * 32
  484.     rect = Rect.new(x, y, self.width - 32, 32)
  485.     self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
  486.     bitmap = RPG::Cache.icon(item.icon_name)
  487.     opacity = self.contents.font.color == normal_color ? 255 : 128
  488.     self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
  489.     self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
  490.     ####################################################
  491.     if BUY_SELL_SWITCH == 0
  492.       self.contents.draw_text(x + 240, y, 88, 32, (item.price *
  493.       $game_variables[BUY_VARIABLE] / 100).to_s, 2)
  494.     elsif !$game_switches[BUY_SELL_SWITCH] or BUY_VARIABLE == 0
  495.       self.contents.draw_text(x + 240, y, 88, 32, item.price.to_s, 2)
  496.     else
  497.       self.contents.draw_text(x + 240, y, 88, 32, (item.price *
  498.       $game_variables[BUY_VARIABLE] / 100).to_s, 2)
  499.     end
  500.     #####################################################
  501.   end
  502.   #--------------------------------------------------------------------------
  503.   # ● 刷新帮助文本
  504.   #--------------------------------------------------------------------------
  505.   def update_help
  506.     @help_window.set_text(self.item == nil ? "" : self.item.description)
  507.   end
  508. end
复制代码

点评

谢谢 要是能评分就好了  发表于 2011-8-16 19:49
考上三级了!
回复

使用道具 举报

Lv3.寻梦者 (暗夜天使)

精灵族の天使

梦石
0
星屑
1697
在线时间
3038 小时
注册时间
2007-3-16
帖子
33731

开拓者贵宾

4
发表于 2011-8-11 11:13:50 | 只看该作者
更新到版本VER 1.03
修复了楼主所说的BUG。
欢迎下载
回复

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
244 小时
注册时间
2010-6-19
帖子
95
5
 楼主| 发表于 2011-8-16 19:46:26 | 只看该作者
精灵使者 发表于 2011-8-11 11:13
更新到版本VER 1.03
修复了楼主所说的BUG。
欢迎下载

谢谢了
这下 没问题了
没事做个游戏
暗黑-外传
剧情:■■■■■□□□□□
脚本:■■■■■■■■■□
素材:■■■■■■■■■■
地图:■■■■■■■■■□
系统:■■■■■■■■□□
整体完成度:■■■■■■■□□□
发布日期:未知
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作

GMT+8, 2024-4-29 03:19

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表