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

Project1

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

[已经过期] 典当行脚本为何无法改菜单高度?

[复制链接]

Lv4.逐梦者

梦石
0
星屑
9280
在线时间
2504 小时
注册时间
2011-5-20
帖子
15389

开拓者

跳转到指定楼层
1
发表于 2012-6-16 10:38:43 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
  1. #==============================================================================
  2. # ■ Scene_SellShop
  3. #------------------------------------------------------------------------------
  4. #  处理商店画面的类。使用方法:$scene=Scene_SellShop.new。
  5. #                               这种商店称作“典当行”,只能卖不能买。
  6. #==============================================================================

  7. class Scene_SellShop
  8.   #--------------------------------------------------------------------------
  9.   # ● 主处理
  10.   #--------------------------------------------------------------------------
  11.   def main
  12.     # 生成帮助窗口
  13.     $itembankflag = 0
  14.     @help_window = Window_Help.new
  15.     # 生成指令窗口
  16.     @command_window = Window_SSShopCommand.new
  17.     # 生成金钱窗口
  18.     @gold_window = Window_Gold.new
  19.     @gold_window.x = 800#480
  20.     @gold_window.y = 192#64
  21.     # 生成时间窗口
  22.     @dummy_window = Window_Base.new(0, 128, 800, 480)#0,128,640,352
  23.     # 生成卖出窗口
  24.     @sell_window = Window_ShopSell.new
  25.     @sell_window.active = false
  26.     @sell_window.visible = false
  27.     @sell_window.help_window = @help_window
  28.     # 生成数量输入窗口
  29.     @number_window = Window_ShopNumber.new
  30.     @number_window.active = false
  31.     @number_window.visible = false
  32.     # 生成状态窗口
  33.     @status_window = Window_ShopStatus.new
  34.     @status_window.visible = false
  35.     # 执行过渡
  36.     Graphics.transition
  37.     # 主循环
  38.     loop do
  39.       # 刷新游戏画面
  40.       Graphics.update
  41.       # 刷新输入信息
  42.       Input.update
  43.       # 刷新画面
  44.       update
  45.       # 如果画面切换的话就中断循环
  46.       if $scene != self
  47.         break
  48.       end
  49.     end
  50.     # 准备过渡
  51.     Graphics.freeze
  52.     # 释放窗口
  53.     @help_window.dispose
  54.     @command_window.dispose
  55.     @gold_window.dispose
  56.     @dummy_window.dispose
  57.    
  58.     @sell_window.dispose
  59.     @number_window.dispose
  60.     @status_window.dispose
  61.   end
  62.   #--------------------------------------------------------------------------
  63.   # ● 刷新画面
  64.   #--------------------------------------------------------------------------
  65.   def update
  66.     # 刷新窗口
  67.     @help_window.update
  68.     @command_window.update
  69.     @gold_window.update
  70.     @dummy_window.update
  71.    
  72.     @sell_window.update
  73.     @number_window.update
  74.     @status_window.update
  75.     # 指令窗口激活的情况下: 调用 update_command
  76.     if @command_window.active
  77.       update_command
  78.       return
  79.     end
  80.    
  81.     # 卖出窗口激活的情况下: 调用 update_sell
  82.     if @sell_window.active
  83.       update_sell
  84.       return
  85.     end
  86.     # 个数输入窗口激活的情况下: 调用 update_number
  87.     if @number_window.active
  88.       update_number
  89.       return
  90.     end
  91.   end
  92.   #--------------------------------------------------------------------------
  93.   # ● 刷新画面 (指令窗口激活的情况下)
  94.   #--------------------------------------------------------------------------
  95.   def update_command
  96.     # 按下 B 键的情况下
  97.     if Input.trigger?(Input::B)
  98.       # 演奏取消 SE
  99.       $game_system.se_play($data_system.cancel_se)
  100.       # 切换到地图画面
  101.       $scene = Scene_Map.new
  102.       return
  103.     end
  104.     # 按下 C 键的情况下
  105.     if Input.trigger?(Input::C)
  106.       # 命令窗口光标位置分支
  107.       case @command_window.index
  108.       when 0  # 卖出
  109.         # 演奏确定 SE
  110.         $game_system.se_play($data_system.decision_se)
  111.         # 窗口状态转向卖出模式
  112.         @command_window.active = false
  113.         @dummy_window.visible = false
  114.         @sell_window.active = true
  115.         @sell_window.visible = true
  116.         @sell_window.refresh
  117.       when 1  # 取消
  118.         # 演奏确定 SE
  119.         $game_system.se_play($data_system.decision_se)
  120.         # 切换到地图画面
  121.         $scene = Scene_Map.new
  122.       end
  123.       return
  124.     end
  125.   end
  126.   
  127.   #--------------------------------------------------------------------------
  128.   # ● 画面更新 (卖出窗口激活的情况下)
  129.   #--------------------------------------------------------------------------
  130.   def update_sell
  131.     # 按下 B 键的情况下
  132.     if Input.trigger?(Input::B)
  133.       # 演奏取消 SE
  134.       $game_system.se_play($data_system.cancel_se)
  135.       # 窗口状态转向初期模式
  136.       @command_window.active = true
  137.       @dummy_window.visible = true
  138.       @sell_window.active = false
  139.       @sell_window.visible = false
  140.       @status_window.item = nil
  141.       # 删除帮助文本
  142.       @help_window.set_text("")
  143.       return
  144.     end
  145.     # 按下 C 键的情况下
  146.     if Input.trigger?(Input::C)
  147.       # 获取物品
  148.       @item = @sell_window.item
  149.       # 设置状态窗口的物品
  150.       @status_window.item = @item
  151.       # 物品无效的情况下、或者价格为 0 (不能卖出) 的情况下
  152.       if @item == nil or @item.price == 0
  153.         # 演奏冻结 SE
  154.         $game_system.se_play($data_system.buzzer_se)
  155.         return
  156.       end
  157.       # 演奏确定 SE
  158.       $game_system.se_play($data_system.decision_se)
  159.       # 获取物品的所持数
  160.       case @item
  161.       when RPG::Item
  162.         number = $game_party.item_number(@item.id)
  163.       when RPG::Weapon
  164.         number = $game_party.weapon_number(@item.id)
  165.       when RPG::Armor
  166.         number = $game_party.armor_number(@item.id)
  167.       end
  168.       # 最大卖出个数 = 物品的所持数
  169.       max = number
  170.       # 窗口状态转向个数输入模式
  171.       @sell_window.active = false
  172.       @sell_window.visible = false
  173.       @number_window.set(@item, max, @item.price / 2)
  174.       @number_window.active = true
  175.       @number_window.visible = true
  176.       @status_window.visible = true
  177.     end
  178.   end
  179.   #--------------------------------------------------------------------------
  180.   # ● 刷新画面 (个数输入窗口激活的情况下)
  181.   #--------------------------------------------------------------------------
  182.   def update_number
  183.     # 按下 B 键的情况下
  184.     if Input.trigger?(Input::B)
  185.       # 演奏取消 SE
  186.       $game_system.se_play($data_system.cancel_se)
  187.       # 设置个数输入窗口为不活动·非可视状态
  188.       @number_window.active = false
  189.       @number_window.visible = false
  190.       # 命令窗口光标位置分支
  191.       case @command_window.index
  192.       when 0  # 卖出
  193.         # 窗口状态转向卖出模式
  194.         @sell_window.active = true
  195.         @sell_window.visible = true
  196.         @status_window.visible = false
  197.       end
  198.       return
  199.     end
  200.     # 按下 C 键的情况下
  201.     if Input.trigger?(Input::C)
  202.       # 演奏商店 SE
  203.       $game_system.se_play($data_system.shop_se)
  204.       # 设置个数输入窗口为不活动·非可视状态
  205.       @number_window.active = false
  206.       @number_window.visible = false
  207.       # 命令窗口光标位置分支
  208.       case @command_window.index
  209.       when 0  # 卖出
  210.         # 卖出处理
  211.         $game_party.gain_gold(@number_window.number * (@item.price / 2))
  212.         case @item
  213.         when RPG::Item
  214.           $game_party.lose_item(@item.id, @number_window.number)
  215.         when RPG::Weapon
  216.           $game_party.lose_weapon(@item.id, @number_window.number)
  217.         when RPG::Armor
  218.           $game_party.lose_armor(@item.id, @number_window.number)
  219.         end
  220.         # 刷新各窗口
  221.         @gold_window.refresh
  222.         @sell_window.refresh
  223.         @status_window.refresh
  224.         # 窗口状态转向卖出模式
  225.         @sell_window.active = true
  226.         @sell_window.visible = true
  227.         @status_window.visible = false
  228.       end
  229.       return
  230.     end
  231.   end
  232. end


  233. #==============================================================================
  234. # ■ Window_ShopCommand
  235. #------------------------------------------------------------------------------
  236. #  商店画面、选择要做的事的窗口
  237. #==============================================================================

  238. class Window_SSShopCommand < Window_Selectable
  239.   #--------------------------------------------------------------------------
  240.   # ● 初始化对像
  241.   #--------------------------------------------------------------------------
  242.   def initialize
  243.     super(0, 64, 800, 64)#0,64,480,64选项窗口大小
  244.     self.contents = Bitmap.new(width - 32, height - 32)
  245.     @item_max = 2
  246.     @column_max = 2
  247.     @commands = ["     出售", "     算了"]
  248.     refresh
  249.     self.index = 0
  250.   end
  251.   #--------------------------------------------------------------------------
  252.   # ● 刷新
  253.   #--------------------------------------------------------------------------
  254.   def refresh
  255.     self.contents.clear
  256.     for i in 0...@item_max
  257.       draw_item(i)
  258.     end
  259.   end
  260.   #--------------------------------------------------------------------------
  261.   # ● 描绘卖出选项位置
  262.   #     index : 项目编号
  263.   #--------------------------------------------------------------------------
  264.   def draw_item(index)
  265.     x = 64 + index * 400
  266.     self.contents.draw_text(x, 0, 192, 32, @commands[index])#0,128,32
  267.   end
  268. end
复制代码
插入后打开先是有2歌项目,卖出、取消
点了卖出之后,里面现实的菜单高度变小了,但是却没有改的地方···而且里面卖品也是走样,还是一排2歌怎样改成4歌


‘‘──chd114于2012-6-16 10:39补充以下内容:

[@]hcm[/@]
’’


‘‘──chd114于2012-6-16 10:41补充以下内容:

忘记补充了,这个是和一下几个脚本在一起的
  1. #==============================================================================
  2. # 本脚本来自www.66RPG.com,使用和转载请保留此信息
  3. # 欢迎访问www.66RPG.com
  4. # 梦想世界,在你手中
  5. #==============================================================================  
  6. #
  7. # Sample master list for crafting script (物品分类增强版)
  8. # written by Deke
  9. # 增强:叶子
  10. # 增强版编写日期:12-30-2005
  11. #============================================================================================
  12. # 简介:
  13. # 这是一个很不错的合成物品系统,可以通过游戏的过程,不断学习可以合成的
  14. # 物品方法。
  15. # ------
  16. # 增强版补充说明:
  17. # 在这个增强版中,可以对成品进行手动分类。
  18. # 成品增加了一个分类属性。
  19. # 这个分类纯粹是按自己的意愿,没有规定第几类必须是什么。
  20. # 召唤特定分类的界面,就只会看到特定分类的成品。
  21. #
  22. # 例如:
  23. # 使用脚本$scene = Scene_Craft.new(1),
  24. # 出来的界面就只会显示成品分类为1的东西
  25. # 同样道理,使用脚本$scene = Scene_Craft.new(2),
  26. # 出来的界面就只会显示成品分类为2的东西
  27. #
  28. # 如果使用脚本$scene = Scene_Craft.new或$scene = Scene_Craft.new(0)来召唤界面
  29. # 就可以看到所有成品。
  30. #
  31. # 注意:不要弄混淆“成品种类”和“成品分类”
  32. # 成品种类是指成品是普通物品(0),防具(1)或武器(2)
  33. # 成品分类是指此物品的自定义分类
  34. #
  35. #
  36. # 使用方法:
  37. # 1、召唤界面:使用脚本$scene = Scene_Craft.new(分类的数字)
  38. # 例如:使用脚本$scene = Scene_Craft.new(1),出来分类1的界面
  39. #
  40. # 2、学习合成:$game_party.learn_recipe(合成项目)
  41. #
  42. #  2.1、其实这个脚本可以使同一成品有不同配方
  43. #
  44. #    就这样说可能解释得不清楚,先来解释一下脚本学习配方的原理:
  45. #    $game_party.learn_recipe(合成项目)的处理过程并不是直接学习这个配方,
  46. #    而是在配方库中找到和合成项目成品相同的配方。
  47. #
  48. #    如果配方库中有两个配方成品相同的话,配方版本就变得重要。
  49. #    $game_party.learn_recipe(合成项目,配方版本)
  50. #    配方版本为1的话,学到的配方就是@recipe_list[xx]中与合成项目成品相同且数字最小的配方
  51. #    配方版本为2的话,学到的配方就是数字第二小的配方
  52. #    在上面这个脚本语句中,不填配方版本的话就默认为1
  53. #
  54. #  2.2、忘记配方:$game_party.forget_recipe(合成项目)
  55. #   2.21、同样道理,这个语句也可以写配方版本
  56. #    $game_party.forget_recipe(合成项目,配方版本)
  57. #    配方版本定义见2.1
  58. #
  59. #  2.3、配方版本不能乱填!例如游戏中某一个配方的成品是唯一的,与所有其它配方的成品都不相同
  60. #   那么学习的时候就不用填配方版本。
  61. #   如果这时在配方版本填了2的话,就有可能学不到或者忘不了(-_-||)
  62. #   
  63. #
  64. # 3、合成定义:
  65. # 这个合成脚本可以定义两种合成物品。一种是预先定义好了的,就像下面这样,
  66. # 直接写在这里就可以,另一种是在学习之前现场定义。
  67. #
  68. # 4、举例
  69. #  4.1、学会recipe_list[1]定义的合成:$game_party.learn_recipe($game_temp.recipe_list[1])
  70. #       注意,一行如果输入不下,在(的后面或[的后面按回车换行,否则可能出错
  71. #
  72. #  4.2、在游戏中临时定义一种合成,让玩家学会。使用事件中的脚本如下,   
  73. #  脚本:
  74. #    材料 = [$game_variables[1],$game_variables[2]]  #——材料编号是变量1、2的编号
  75. #    材料种类 = [0,0]                                #——材料是物品
  76. #    材料数量 = [$game_variables[3],$game_variables[4]]  #——需要材料数量是变量3、4的编号
  77. #    成品 = $game_variables[5]                       #——获得结果编号是5
  78. #    成品种类 = 1                                    #——成品是防具类
  79. #    成品分类 = 1                                    #——这一项不写的话默认为0
  80. #    $game_party.learn_recipe(Game_Recipe.new(材料,材料种类,材料数量,成品,成品种类,成品分类))
  81. #    上面这条语句的成品分类这一项不写也行,这样它就默认为0了。
  82. #    (也就是此物品没有分类,不会在分类菜单中出现)
  83. #    省略成品分类的脚本语句可以像下面这样写:
  84. #    $game_party.learn_recipe(Game_Recipe.new(材料,材料种类,材料数量,成品,成品种类))
  85. #
  86. #===========================================================================================
  87. $VAR_NUMBER = 136

  88. class Game_Temp
  89. attr_reader :recipe_list  
  90. alias crafting_temp_initialize initialize
  91. def initialize
  92.    crafting_temp_initialize
  93.    @recipe_list=[]
  94.    get_recipe_list
  95. end

  96. def get_recipe_list   
  97.    材料 = [1]             # 需要材料的数据库编号
  98.    材料种类 = [0]         # 需要材料的种类,0是普通物品,1是防具,2是武器
  99.    材料数量 = [2]         # 需要材料的数量
  100.    成品 = 2                  # 获得物品编号
  101.    获得数 = 1
  102.    成品种类 = 0              # 获得物品种类,0是普通物品,1是防具,2是武器
  103.    成品分类 = 0              # 获得成品分类
  104.    @recipe_list[1] = Game_Recipe.new(材料,材料种类, 材料数量,成品,获得数,成品种类,成品分类)
  105.    
  106.    材料 = [1,2]             # 需要材料的数据库编号
  107.    材料种类 = [0,0]         # 需要材料的种类,0是普通物品,1是防具,2是武器
  108.    材料数量 = [2,1]         # 需要材料的数量
  109.    成品 = 3                 # 获得物品编号
  110.    获得数 = 2
  111.    成品种类 = 0              # 获得物品种类,0是普通物品,1是防具,2是武器
  112.    成品分类 = 0              # 获得成品分类
  113.    @recipe_list[2] = Game_Recipe.new(材料,材料种类, 材料数量,成品,获得数,成品种类,成品分类)
  114.    
  115.    材料 = [1]             # 需要材料的数据库编号
  116.    材料种类 = [2]         # 需要材料的种类,0是普通物品,1是防具,2是武器
  117.    材料数量 = [2]         # 需要材料的数量
  118.    成品 = 4                 # 获得物品编号
  119.    获得数 = 1
  120.    成品种类 = 2              # 获得物品种类,0是普通物品,1是防具,2是武器
  121.    成品分类 = 0              # 获得成品分类
  122.    @recipe_list[3] = Game_Recipe.new(材料,材料种类, 材料数量,成品,获得数,成品种类,成品分类)
  123.    
  124.    材料 = [1,2]             # 需要材料的数据库编号
  125.    材料种类 = [2,2]         # 需要材料的种类,0是普通物品,1是防具,2是武器
  126.    材料数量 = [2,2]         # 需要材料的数量
  127.    成品 = 4                 # 获得物品编号
  128.    获得数 = 3
  129.    成品种类 = 2              # 获得物品种类,0是普通物品,1是防具,2是武器
  130.    成品分类 = 0              # 获得成品分类
  131.    @recipe_list[4] = Game_Recipe.new(材料,材料种类, 材料数量,成品,获得数,成品种类,成品分类)
  132.    
  133. end # of get_recipe_list method
  134. end # of updates to Game_Temp Class

  135. #================================
  136. # CRAFTING PROGRAM
  137. #----------------------------------------------------------------
  138. #-written by Deke
  139. #-yes_no window code created by Phsylomortis
  140. #----------------------------------------------------------------
  141. #================================

  142. #updates to Game_Party class
  143. =begin

  144.   负重系统v0.1

  145.   作者:秀秀
  146.   
  147.   功能:物品 武器 防具都多了重量属性
  148.          
  149.         增加了背包负重 超过负重最大值 则不能获得
  150.   
  151.   使用方法:在(物品,武器,防具)数据库中设置名称
  152.   
  153.             方式为:名称+n+重量
  154.             
  155.             比如 铜剑n1.5  表示铜剑重量为1.5
  156.                  回复剂n0.5 表示回复剂重量为0.5
  157.            
  158.             设置背包重量:默认为变量1,一定要在游戏开始设置好     
  159.                           搜索 VAR_NUMBER 可以改变存放背包负重的变量
  160.                           当然也可以随时改变这个数值

  161.             获取背包最大负重:
  162.                           $game_variables[VAR_NUMBER]
  163.             获取背包当前负重:
  164.                           $gane_party.weight
  165.             获取物品重量:
  166.                           $data_items[id].weight
  167.             获取武器重量:
  168.                           $data_weapons[id].weight     
  169.             获取防具重量:
  170.                           $data_armors[id].weight

  171. =end                     


  172. module RPG
  173.   class Item
  174.     def name
  175.       return @name.split(/,/)[0] # w 代表重量
  176.     end
  177.     def weight
  178.       return @name.split(/,/)[1].to_i # w 代表重量
  179.     end  
  180.    end

  181.   class Weapon
  182.     def name
  183.       return @name.split(/,/)[0] # w 代表重量
  184.     end
  185.     def weight
  186.       return @name.split(/,/)[1].to_i # w 代表重量
  187.     end  
  188.    end
  189.    
  190.   class Armor
  191.     def name
  192.       return @name.split(/,/)[0] # w 代表重量
  193.     end
  194.     def weight
  195.       return @name.split(/,/)[1].to_i # w 代表重量
  196.     end  
  197.   end
  198. end

  199. class Game_Party
  200.   
  201.   #--------------------------------------------------------------------------
  202.   # ● 定义实例变量
  203.   #--------------------------------------------------------------------------
  204.   attr_accessor :weight
  205.   #--------------------------------------------------------------------------
  206.   # ● 初始化对像
  207.   #--------------------------------------------------------------------------
  208.   alias wt_initialize initialize
  209.   def initialize
  210.     wt_initialize
  211.     @weight = 0
  212.   end
  213.   
  214.   
  215.   #--------------------------------------------------------------------------
  216.   # ● 增加物品 (减少)
  217.   #     item_id : 物品 ID
  218.   #     n       : 个数
  219.   #--------------------------------------------------------------------------
  220.   def gain_item(item_id, n)
  221.     # 更新 hash 的个数数据
  222.     if item_id > 0
  223.       
  224.       temp = @weight + $data_items[item_id].weight * n
  225.       
  226.       return if (n < 0 and @items[item_id] == nil)
  227.       
  228.       if temp > max_weight
  229.         return
  230.       end
  231.       if temp < 0
  232.         a = @weight
  233.         for i in 1..n.abs
  234.           a -= $data_items[item_id].weight
  235.           if a < 0
  236.             return
  237.           else
  238.             # 数量-1
  239.             @items[item_id] = [[item_number(item_id) - i, 0].max, 99].min
  240.             # 负重-1
  241.             @weight -= $data_items[item_id].weight
  242.             # p @weight
  243.           end  
  244.         end
  245.         # p @weight
  246.         return
  247.       end  
  248.       
  249.       if @items[item_id] != nil
  250.         b = @items[item_id] - n.abs
  251.         if b < 0 and n < 0
  252.           c = @items[item_id]
  253.           @items[item_id] = [[item_number(item_id) + n, 0].max, 99].min
  254.           @weight -= $data_items[item_id].weight * c
  255.           # p @weight
  256.           return
  257.         end
  258.       end  
  259.       
  260.       @items[item_id] = [[item_number(item_id) + n, 0].max, 99].min
  261.       @weight = temp
  262.       # p @weight
  263.     end
  264.   end
  265.   #--------------------------------------------------------------------------
  266.   # ● 增加武器 (减少)
  267.   #     weapon_id : 武器 ID
  268.   #     n         : 个数
  269.   #--------------------------------------------------------------------------
  270.   def gain_weapon(weapon_id, n)
  271.     # 更新 hash 的个数数据
  272.     if weapon_id > 0
  273.       temp = @weight + $data_weapons[weapon_id].weight * n
  274.       
  275.       return if (n < 0 and @weapons[weapon_id] == nil)
  276.       
  277.       if temp > max_weight
  278.         return
  279.       end
  280.       if temp < 0
  281.         a = @weight
  282.         for i in 1..n.abs
  283.           a -= $data_weapons[weapon_id].weight
  284.           if a < 0
  285.             return
  286.           else
  287.             # 数量-1
  288.             @weapons[weapon_id] = [[weapon_number(weapon_id) - i, 0].max, 99].min
  289.             # 负重-1
  290.             @weight -= $data_weapons[weapon_id].weight
  291.            # p @weight
  292.           end  
  293.         end
  294.        # p @weight
  295.         return
  296.       end  
  297.       
  298.       if @weapons[weapon_id] != nil
  299.         b = @weapons[weapon_id] - n.abs
  300.         if b < 0 and n < 0
  301.           c = @weapons[weapon_id]
  302.           @weapons[weapon_id] = [[weapon_number(weapon_id) + n, 0].max, 99].min
  303.           @weight -= $data_weapons[weapon_id].weight * c
  304.         #  p @weight
  305.           return
  306.         end
  307.       end
  308.       
  309.       @weapons[weapon_id] = [[weapon_number(weapon_id) + n, 0].max, 99].min
  310.       @weight = temp
  311.      # p @weight
  312.     end
  313.   end
  314.   #--------------------------------------------------------------------------
  315.   # ● 增加防具 (减少)
  316.   #     armor_id : 防具 ID
  317.   #     n        : 个数
  318.   #--------------------------------------------------------------------------
  319.   def gain_armor(armor_id, n)
  320.     # 更新 hash 的个数数据
  321.     if armor_id > 0
  322.       temp = @weight + $data_armors[armor_id].weight * n
  323.       
  324.       return if (n < 0 and @armors[armor_id] == nil)
  325.       
  326.       if temp > max_weight
  327.         return
  328.       end
  329.       if temp < 0
  330.         a = @weight
  331.         for i in 1..n.abs
  332.           a -= $data_armors[armor_id].weight
  333.           if a < 0
  334.             return
  335.           else
  336.             # 数量-1
  337.             @armors[armor_id] = [[armor_number(armor_id) - i, 0].max, 99].min
  338.             # 负重-1
  339.             @weight -= $data_armors[armor_id].weight
  340.             # p @weight
  341.           end  
  342.         end
  343.         # p @weight
  344.         return
  345.       end  
  346.       
  347.       if @armors[armor_id] != nil
  348.         b = @armors[armor_id] - n.abs
  349.         if b < 0 and n < 0
  350.           c = @armors[armor_id]
  351.           @armors[armor_id] = [[armor_number(armor_id) + n, 0].max, 99].min
  352.           @weight -= $data_armors[armor_id].weight * c
  353.           # p @weight
  354.           return
  355.         end
  356.       end
  357.       
  358.       @armors[armor_id] = [[armor_number(armor_id) + n, 0].max, 99].min
  359.       @weight = temp
  360.       # p @weight
  361.     end
  362.   end

  363.   def max_weight
  364.     return $game_variables[$VAR_NUMBER]
  365.   end

  366.   def check_weight
  367.   
  368.   end

  369. end  


  370. #================================================================================

  371. #==============================================================================
  372. # ■ Scene_Item
  373. #------------------------------------------------------------------------------
  374. #  处理物品画面的类。
  375. #==============================================================================

  376. class Scene_Item
  377.   alias ori_main main
  378.   def main
  379.     @weight_window = Window_Weight.new
  380.     @weight_window.x = 0
  381.     @weight_window.y = 544
  382.     @weight_window.z = 9999
  383.     ori_main
  384.     @weight_window.dispose
  385.   end  
  386.   alias ori_update update
  387. #  def update
  388. #      case @item_window.item
  389.   #     when RPG::Item
  390.    #      @weight_window.refresh($data_items[@item_window.item.id].weight)
  391.     #   when RPG::Weapon
  392.      #    @weight_window.refresh($data_weapons[@item_window.item.id].weight)
  393.       # when RPG::Armor  
  394.        #  @weight_window.refresh($data_armors[@item_window.item.id].weight)
  395. #       end
  396. #   ori_update
  397.   #end
  398.   end

  399. class Window_Item < Window_Selectable
  400.   #--------------------------------------------------------------------------
  401.   # ● 初始化对像
  402.   #--------------------------------------------------------------------------
  403.   def initialize
  404.     super(0, 64, 800, 480)#0,64,640,592
  405.     @column_max = 2
  406.     refresh
  407.     self.index = 0
  408.     # 战斗中的情况下将窗口移至中央并将其半透明化
  409.     if $game_temp.in_battle
  410.       self.y = 64
  411.       self.height = 256
  412.       self.back_opacity = 160
  413.     end
  414.   end
  415. end  
  416.   
  417. class Window_Weight < Window_Base
  418.   def initialize
  419.     super(0,0,800,64)#0,0,640,64
  420.     self.opacity = 128
  421.     self.contents = Bitmap.new(width-32,height-32)
  422.     refresh(nil)
  423.   end  
  424.   def refresh(weight)
  425.     self.contents.clear
  426.     if weight != nil
  427.       self.contents.draw_text(0,0,256,32,"物品重量:#{weight}")
  428.     end
  429.     self.contents.draw_text(256,0,320,32,"背包重量:"+$game_party.weight.to_s + "/" + $game_variables[$VAR_NUMBER].to_s , 0)
  430.   end
  431. end  

  432. class Game_Party

  433. attr_accessor       :recipes

  434. alias crafting_party_initialize initialize

  435. def initialize
  436.    crafting_party_initialize
  437.    @recipes=[]
  438. end

  439. #----------------------------------------------------------------------
  440. def know?(recipe, version = 1)
  441.    unless recipe.is_a?(Game_Recipe)
  442.      recipe = get_recipe_from_master_list(recipe, version)
  443.    end
  444.    return $game_party.recipes.include?(recipe)
  445. end

  446. #----------------------------------------------------------------------
  447. def learn_recipe(recipe , version = 1)
  448.    unless recipe.is_a?(Game_Recipe)
  449.      recipe = get_recipe_from_master_list(recipe, version)
  450.    end
  451.    if recipe.is_a?(Game_Recipe)
  452.      unless know?(recipe)
  453.        @recipes.push(recipe)
  454.      end
  455.    end
  456. end

  457. #----------------------------------------------------------------------
  458. def forget_recipe(recipe , version = 1)
  459.    if !recipe.is_a?(Game_Recipe)
  460.      recipe = get_recipe_from_master_list(recipe, version)
  461.    end
  462.    if recipe.is_a?(Game_Recipe)
  463.      for i in [email protected]
  464.        if recipe == @recipes[i]
  465.          index = i
  466.          break
  467.        end
  468.      end
  469.      if index != nil
  470.        @recipes.delete(@recipes[index])
  471.      end
  472.    end
  473. end

  474. #----------------------------------------------------------------------
  475. def get_recipe_from_master_list(item, version)
  476.    index = nil
  477.    for i in 0...$game_temp.recipe_list.size
  478.      #print $game_temp.recipe_list.size
  479.      if item[0] == $game_temp.recipe_list[i].result and item[1] ==$game_temp.recipe_list[i].result_type
  480.        version -= 1
  481.        if version == 0
  482.          index = i
  483.          break
  484.        end
  485.      end
  486.    end
  487.    if index.is_a?(Integer)
  488.      return ($game_temp.recipe_list[index])
  489.    else
  490.      return false
  491.    end
  492. end

  493. end # of Game_Party updates

  494. #================================
  495. class Game_Recipe

  496. attr_reader :ingredients
  497. attr_reader :quantities
  498. attr_reader :result
  499. attr_reader :result_num
  500. attr_reader :result_type
  501. attr_reader :ingredient_types
  502. attr_reader :craft_type  #物品分类

  503. #----------------------------------------------------------------------
  504. def initialize( ingredients, ingredient_types, quantities, result, result_num,result_type, craft_type=0)
  505.    @ingredients = ingredients
  506.    @ingredient_types = ingredient_types
  507.    @quantities = quantities
  508.    @result = result
  509.    @result_num = result_num
  510.    $rrresultnum = result_num
  511.    @result_type = result_type
  512.    @craft_type = craft_type
  513. end

  514. #----------------------------------------------------------------------
  515. def name
  516.    case @result_type
  517.      when 0
  518.        name = $data_items[@result].name
  519.      when 1
  520.        name = $data_armors[@result].name
  521.      when 2
  522.        name = $data_weapons[@result].name
  523.    end
  524.    return name
  525. end

  526. #----------------------------------------------------------------------
  527. def have
  528.    have_all = true
  529.    for i in [email protected]
  530.      case @ingredient_types[i]
  531.        when 0
  532.          if $game_party.item_number(@ingredients[i]) < @quantities[i]
  533.            have_all=false
  534.          end
  535.        when 1
  536.          if $game_party.armor_number(@ingredients[i]) < @quantities[i]
  537.            have_all=false
  538.          end
  539.        when 2
  540.          if $game_party.weapon_number(@ingredients[i]) < @quantities[i]
  541.            have_all=false
  542.          end
  543.      end
  544.    end
  545.    return have_all
  546. end

  547. #----------------------------------------------------------------------
  548. def decrement
  549.    for i in [email protected]
  550.      case @ingredient_types[i]
  551.      when 0
  552.        $game_party.lose_item(@ingredients[i], @quantities[i])
  553.      when 1
  554.        $game_party.lose_armor(@ingredients[i], @quantities[i])
  555.      when 2
  556.        $game_party.lose_weapon(@ingredients[i], @quantities[i])
  557.      end
  558.    end
  559. end

  560. #----------------------------------------------------------------------
  561. def make
  562.    if have
  563.      decrement
  564.      case @result_type
  565.      when 0
  566.        $game_party.gain_item(@result, @result_num)
  567.      when 1
  568.        $game_party.gain_armor(@result, @result_num)
  569.      when 2
  570.        $game_party.gain_weapon(@result, @result_num)
  571.      end
  572.    end
  573. end

  574. #----------------------------------------------------------------------
  575. def == (recipe)
  576.    if recipe.is_a?(Game_Recipe)
  577.      equal = true
  578.      if recipe.ingredients != self.ingredients
  579.        equal = false
  580.      end
  581.      if recipe.ingredient_types != self.ingredient_types
  582.        equal = false
  583.      end
  584.      if recipe.quantities != self.quantities
  585.        equal = false
  586.      end
  587.      if recipe.result != self.result
  588.        equal=false
  589.      end
  590.      if recipe.result_type != self.result_type
  591.        equal = false
  592.      end
  593.    else
  594.      equal = false
  595.    end
  596.    return equal
  597. end

  598. end # of Game_Recipe class

  599. #===================================

  600. class Window_Craft < Window_Selectable
  601. attr_reader :data #声明数据
  602. #--------------------------------------------------------------------------
  603. def initialize(craft_type=0)
  604.    @craft_type = craft_type
  605.    super(0, 64, 240, 544)#0,64,240,416
  606.    @column_max = 1
  607.    refresh
  608.    self.index = 0
  609. end

  610. #--------------------------------------------------------------------------
  611. def recipe
  612.    return @data[self.index]
  613. end

  614. #--------------------------------------------------------------------------
  615. def refresh
  616.    if self.contents != nil
  617.      self.contents.dispose
  618.      self.contents = nil
  619.    end
  620.    @data = []
  621.    for i in 0...$game_party.recipes.size
  622.       #@craft_type为0时就显示全部物品
  623.       #不为0时就显示对应物品
  624.      @data.push($game_party.recipes[i])
  625.      #if @craft_type == 0
  626.      #  @data.push($game_party.recipes[i])
  627.      #elsif $game_party.recipes[i].craft_type == @craft_type
  628.      #  @data.push($game_party.recipes[i])
  629.      #end
  630.    end
  631.    @item_max = @data.size
  632.    if @item_max > 0
  633.      self.contents = Bitmap.new(width - 32, row_max * 32)
  634.      self.contents.font.name = "黑体" # = "黑体"
  635.      self.contents.font.size = 18 # = 18
  636.      for i in 0...@item_max
  637.        draw_item(i)
  638.      end
  639.    end
  640. end

  641. #--------------------------------------------------------------------------
  642. def draw_item(index)
  643.    recipe = @data[index]
  644.    self.contents.font.color = recipe.have ? normal_color : disabled_color
  645.    x = 16
  646.    y = index * 32
  647.    self.contents.draw_text(x , y, self.width-32, 32, recipe.name, 0)
  648. end

  649. #--------------------------------------------------------------------------
  650. def update_help
  651.    current_recipe = recipe
  652.    if current_recipe.is_a?(Game_Recipe)
  653.    case current_recipe.result_type
  654.      when 0
  655.        description = $data_items[current_recipe.result].description
  656.      when 1
  657.        description = $data_armors[current_recipe.result].description
  658.      when 2
  659.        description = $data_weapons[current_recipe.result].description
  660.      end
  661.    else
  662.      description = ""
  663.    end
  664.    @help_window.set_text(description)
  665.    @help_window.update
  666. end

  667. end # of Window_Craft

  668. #=======================================
  669. class Window_CraftResult < Window_Base

  670. #--------------------------------------------------------------------------
  671. def initialize
  672.    super(240, 64, 560, 184)#240,64,400,184
  673.    self.contents = Bitmap.new(width - 32, height - 32)
  674.    self.contents.font.name = "黑体" # = $fontface.is_a?(String) ? $fontface : $defaultfonttype
  675.    self.contents.font.size = 18 # = 20
  676.    @result = nil
  677.    @type = nil
  678. end

  679. #--------------------------------------------------------------------------
  680. def refresh
  681.    self.contents.clear
  682.    case @type
  683.      when 0
  684.        item = $data_items[@result]
  685.        if item.recover_hp_rate > item.recover_hp
  686.          hp_string = "HP回复率:"
  687.          hp_stat = item.recover_hp_rate
  688.        else
  689.          hp_string = "HP回复量:"
  690.          hp_stat = item.recover_hp
  691.        end
  692.        if item.recover_sp_rate > item.recover_sp
  693.          sp_string = "SP回复率:"
  694.          sp_stat = item.recover_sp_rate
  695.        else
  696.          sp_string = "SP回复量:"
  697.          sp_stat = item.recover_sp
  698.        end
  699.        @strings = [hp_string, sp_string, "物理防御:" , "魔法防御:", "命中率:", "分散度:"]
  700.        @stats = [hp_stat, sp_stat, item. pdef_f, item.mdef_f, item.hit, item.variance,
  701.                       $rrresultnum]
  702.        ssstats=$game_party.item_number(@result)               
  703.        @bitmap = RPG::Cache.icon(item.icon_name)
  704.      when 1
  705.        item = $data_armors[@result]
  706.        @strings = ["物理防御:", "魔法防御:", "回避修正:", "力量增加:", "灵巧增加:",
  707.                       "速度增加:", "魔力增加:"]
  708.        @stats = [item.pdef, item.mdef, item.eva, item.str_plus, item.dex_plus,
  709.                    item.agi_plus, item.int_plus, $rrresultnum]
  710.        ssstats=$game_party.armor_number(@result)            
  711.        @bitmap = RPG::Cache.icon(item.icon_name)
  712.      when 2
  713.        item = $data_weapons[@result]
  714.        @strings =["攻击力:", "物理防御:", "魔法防御:", "力量增加:", "灵巧增加:",
  715.                    "速度增加:", "魔力增加:"]
  716.        @stats = [item.atk, item.pdef, item.mdef, item.str_plus, item.dex_plus,
  717.                    item.agi_plus, item.int_plus, $rrresultnum]
  718.        ssstats=$game_party.weapon_number(@result)            
  719.        @bitmap = RPG::Cache.icon(item.icon_name)
  720.    end
  721.    for i in [email protected]
  722.      x = i%2 * 184
  723.      y = i /2 *28 +32
  724.      self.contents.font.color = normal_color
  725.      self.contents.draw_text(x,y,100, 28,@strings[i])
  726.      self.contents.font.color = system_color
  727.      self.contents.draw_text(x + 110, y, 45, 28, @stats[i].to_s)
  728.    end
  729.    self.contents.blt(0, 0, @bitmap, Rect.new(0, 0, 32, 32), 255)
  730.    self.contents.font.color= normal_color
  731.    self.contents.draw_text(40, 0, 300, 28, "待合成物品的现有数量:")
  732.    self.contents.font.color = system_color
  733.    count = ssstats.to_s
  734.    self.contents.draw_text(294, 0, 45, 28, count)
  735. end
  736.    
  737. #----------------------------------------------------------------------
  738. def set_result(result , type)
  739.    @result = result
  740.    @type = type
  741.    refresh
  742. end

  743. end #of Window_CraftResult

  744. #=======================================
  745. class Window_CraftIngredients < Window_Base

  746. #--------------------------------------------------------------------------
  747. def initialize
  748.    super(240, 248, 560, 472)#240,248,400,232
  749.    self.contents = Bitmap.new(width - 32, height - 32)
  750.    self.contents.font.name = "黑体" # = $fontface.is_a?(String) ? $fontface : $defaultfonttype
  751.    self.contents.font.size = 18 # = 20
  752.    @ingredients = []
  753.    @types = []
  754.    @quantities = []
  755.    @item = nil
  756.    @count = 0
  757. end

  758. #--------------------------------------------------------------------------
  759. def refresh
  760.    self.contents.clear
  761.    for i in [email protected]
  762.      case @types[i]
  763.      when 0
  764.        @item = $data_items[@ingredients[i]]
  765.        @count = $game_party.item_number(@ingredients[i])
  766.      when 1
  767.        @item = $data_armors[@ingredients[i]]
  768.        @count = $game_party.armor_number(@ingredients[i])
  769.      when 2
  770.        @item = $data_weapons[@ingredients[i]]
  771.        @count = $game_party.weapon_number(@ingredients[i])
  772.      end
  773.      y = i *26
  774.      self.contents.blt(0, y, RPG::Cache.icon(@item.icon_name), Rect.new(0, 0, 32, 32), 255)
  775.      self.contents.font.color = @count >= @quantities[i] ? normal_color : disabled_color
  776.      self.contents.draw_text(30, y, 280, 28, @item.name)
  777.      self.contents.draw_text(300, y, 45, 28, @quantities[i].to_s)
  778.      self.contents.font.color = system_color
  779.      self.contents.draw_text(245, y, 45, 28, @count.to_s )     
  780.    end
  781. end
  782.      
  783. #--------------------------------------------------------------------------
  784. def set_ingredients(ingredients , types, quantities)
  785.    @ingredients = ingredients
  786.    @types = types
  787.    @quantities = quantities
  788.    refresh
  789. end

  790. end # of Window_CraftIngredients

  791. #======================================
  792. class Scene_Craft

  793. #--------------------------------------------------------------------------
  794. # @craft_type:物品种类,0就是全部
  795. def initialize(craft_type=0,craft_index=0)
  796.    @craft_index=craft_index
  797.    @craft_type = craft_type
  798. end

  799. #--------------------------------------------------------------------------
  800. def main
  801.    @craft_window = Window_Craft.new(@craft_type)
  802.    @craft_window.index=@craft_index
  803.    @confirm_window = Window_Base.new(120, 188, 400, 64)#120,188,400,64
  804.    @confirm_window.contents = Bitmap.new(368, 32)
  805.    @confirm_window.contents.font.name = "黑体"
  806.    @confirm_window.contents.font.size = 20
  807.    @help_window = Window_Help.new
  808.    @craft_window.help_window = @help_window
  809.    @result_window=Window_CraftResult.new
  810.    @ingredients_window=Window_CraftIngredients.new
  811.    @yes_no_window = Window_Command.new(100, ["确定", "放弃"])
  812.    @confirm_window.visible = false
  813.    @confirm_window.z = 1500
  814.    @yes_no_window.visible = false
  815.    @yes_no_window.active = false
  816.    @yes_no_window.index = 1
  817.    @yes_no_window.x = 270
  818.    @yes_no_window.y = 252
  819.    @yes_no_window.z = 1500
  820.    @label_window = Window_Base.new(450,200,285,52)#450,200,190,52
  821.    @label_window.contents=Bitmap.new(@label_window.width - 32,@label_window.height - 32)
  822.    @label_window.contents.font.size=20
  823.    @label_window.contents.font.color = @label_window.normal_color
  824.    @label_window.contents.font.name = "黑体"
  825.    @label_window.contents.draw_text(0, 0, @label_window.contents.width, 20, "  现有   需要")
  826.    Graphics.transition
  827.    loop do
  828.      Graphics.update
  829.      Input.update
  830.      update
  831.      if $scene != self
  832.        break
  833.      end
  834.    end
  835.    Graphics.freeze
  836.    @help_window.dispose
  837.    @craft_window.dispose
  838.    @result_window.dispose
  839.    @ingredients_window.dispose
  840.    @confirm_window.dispose
  841.    @yes_no_window.dispose
  842.    @label_window.dispose
  843. end

  844. #--------------------------------------------------------------------------
  845. def update
  846.    @craft_window.update
  847.    @ingredients_window.update
  848.    if @craft_window.data.size > 0 #本类窗口物品大于0的话
  849.      @result_window.set_result(@craft_window.recipe.result, @craft_window.recipe.result_type)
  850.      @ingredients_window.set_ingredients(@craft_window.recipe.ingredients,
  851.                                                           @craft_window.recipe.ingredient_types,
  852.                                                           @craft_window.recipe.quantities)
  853.    end
  854.    if @craft_window.active
  855.      update_craft
  856.      return
  857.    end
  858.    if @yes_no_window.active
  859.      confirm_update
  860.      return
  861.    end
  862. end

  863. #--------------------------------------------------------------------------
  864. def update_craft
  865.    if Input.trigger?(Input::B)
  866.      $game_system.se_play($data_system.cancel_se)
  867.      $scene = Scene_Menu.new(0)
  868.      return
  869.    end
  870.    if Input.trigger?(Input::C) and $game_party.recipes.size != 0
  871.      @recipe = @craft_window.recipe
  872.      if @recipe != nil
  873.        if @recipe.have
  874.          @yes_no_window.active = true
  875.          @craft_window.active = false
  876.        else
  877.          $game_system.se_play($data_system.buzzer_se)
  878.          return
  879.        end
  880.      else
  881.        $game_system.se_play($data_system.buzzer_se)
  882.        return
  883.      end
  884.    end
  885. end

  886. #--------------------------------------------------------------------------
  887. def confirm_update
  888.    @craft_index = @craft_window.index
  889.    @confirm_window.visible = true
  890.    @confirm_window.z = 1500
  891.    @yes_no_window.visible = true
  892.    @yes_no_window.active = true
  893.    @yes_no_window.z = 1500
  894.    @yes_no_window.update
  895.    string = "合成 " + @recipe.name + "?"
  896.    cw = @confirm_window.contents.text_size(string).width
  897.    center = @confirm_window.contents.width/2 - cw /2
  898.    unless @drawn
  899.      @confirm_window.contents.draw_text(center, 0, cw, 30, string)
  900.      @drawn = true
  901.    end
  902.    if Input.trigger?(Input::C)
  903.      if @yes_no_window.index == 0
  904.        $game_system.se_play($data_system.decision_se)
  905.        @recipe.make
  906.        $game_system.se_play($data_system.save_se)
  907.        $scene=Scene_Craft.new(@craft_index)
  908.      else
  909.        $game_system.se_play($data_system.cancel_se)
  910.        $scene=Scene_Craft.new(@craft_index)
  911.      end
  912.    end
  913.    if Input.trigger?(Input::B)
  914.      $game_system.se_play($data_system.cancel_se)
  915.      $scene=Scene_Craft.new(@craft_index)
  916.    end
  917. end

  918. end # of Scene_Craft

  919. #==============================================================================
  920. # 本脚本来自www.66RPG.com,使用和转载请保留此信息
  921. # 欢迎访问www.66RPG.com
  922. # 梦想世界,在你手中
  923. #==============================================================================
复制代码
  1. #==============================================================================
  2. # 本脚本来自www.66rpg.com,转载和使用请保留此信息
  3. # 脚本名:真实商店,脚本作者:柳柳
  4. #==============================================================================
  5. #
  6. # 功能:
  7. #
  8. # 买进卖出的物品在商店有所体现,卖出后会在商店可买物品中出现,物品有数量限制
  9. # 商店可进货出货————总之就是模拟真实商店。
  10. #  
  11. # 这个脚本和原装商店并不冲突,两个商店可以并存。
  12. #
  13. # 使用方法:
  14. #
  15. # 1、在下面被井号框起来的中间部分,设置初期物品。格式如下:
  16. #    @goods[商店编号] = [ [种类,ID,可卖数量] ,  [种类,ID,可卖数量]......]
  17. #    其中种类,0为道具,1为武器,2为防具;ID是数据库编号
  18. #
  19. # 2、调用:$scene = Scene_Shop_Va.new(商店编号)  
  20. #    比如你可以直接测试$scene = Scene_Shop_Va.new(1),已经设置好了。
  21. #
  22. # 3、商店出货:$game_system.shop_change(商店编号,种类,ID,数量)
  23. #    如果是进货,把数量设置为负数即可
  24. #
  25. class WWWindow_ShopCommand < Window_Selectable
  26.   #--------------------------------------------------------------------------
  27.   # ● 初始化对像
  28.   #--------------------------------------------------------------------------
  29.   def initialize
  30.     super(0, 64, 800, 64)#0,64,48,64
  31.     self.contents = Bitmap.new(width - 32, height - 32)
  32.     @item_max = 3
  33.     @column_max = 3
  34.     @commands = ["   买进", "   卖出", "   算了"]
  35.     refresh
  36.     self.index = 0
  37.   end
  38.   #--------------------------------------------------------------------------
  39.   # ● 刷新
  40.   #--------------------------------------------------------------------------
  41.   def refresh
  42.     self.contents.clear
  43.     for i in 0...@item_max
  44.       draw_item(i)
  45.     end
  46.   end
  47.   #--------------------------------------------------------------------------
  48.   # ● 描绘项目
  49.   #     index : 项目编号
  50.   #--------------------------------------------------------------------------
  51.   def draw_item(index)
  52.     x = 4 + index * 265
  53.     self.contents.draw_text(x, 0, 128, 32, @commands[index])
  54.   end
  55. end
  56. class W2Window_ShopCommand < Window_Selectable
  57.   #--------------------------------------------------------------------------
  58.   # ● 初始化对像
  59.   #--------------------------------------------------------------------------
  60.   def initialize
  61.     super(0, 64, 640, 192)#0,64,480,64
  62.     self.contents = Bitmap.new(width - 32, height - 32)
  63.     @item_max = 3
  64.     @column_max = 3
  65.     @commands = ["取出物品", "存入物品", "算了"]
  66.     refresh
  67.     self.index = 0
  68.   end
  69.   #--------------------------------------------------------------------------
  70.   # ● 刷新
  71.   #--------------------------------------------------------------------------
  72.   def refresh
  73.     self.contents.clear
  74.     for i in 0...@item_max
  75.       draw_item(i)
  76.     end
  77.   end
  78.   #--------------------------------------------------------------------------
  79.   # ● 描绘项目
  80.   #     index : 项目编号
  81.   #--------------------------------------------------------------------------
  82.   def draw_item(index)
  83.     x = 4 + index * 265
  84.     self.contents.draw_text(x, 0, 128, 32, @commands[index])
  85.   end
  86. end

  87. class Game_System
  88.   attr_accessor :goods   
  89.   alias vaule_shop_66RPG_initialize initialize
  90.   def initialize
  91.     vaule_shop_66RPG_initialize
  92.     @goods = []
  93.   ###########################################################################
  94.     # 初期的时候的商店物品,编号顺序:种类,ID,可卖数量
  95.     @goods[0] = [[-1,-1,-1]]
  96.     @goods[1] = [[0,1,30],[0,2,30],[2,1,10],[1,2,10],[1,3,10]]
  97.   ###########################################################################
  98.   end
  99.   def shop_change(shop,kind,id,delnumber)
  100.     dl = delnumber
  101.     for dt in $game_system.goods[shop]
  102.       if (dt[0]==kind) and (dt[1]==id)
  103.         dt[2] -= dl
  104.         dt[2] = [dt[2],99].min
  105.         if dt[2] == 0
  106.           $game_system.goods[shop].delete(dt)
  107.         end
  108.         return
  109.       end
  110.     end
  111.     $game_system.goods[shop].push([kind,id,-delnumber])
  112.   end
  113. end

  114. class Scene_Shop_Va
  115.   def initialize(shop_number)
  116.     # 当前商店编号
  117.     @shop_now = shop_number
  118.     # 0号商店为物品仓库
  119.     $itembankflag = @shop_now > 0 ? 0 : 1
  120.   end   
  121.   #--------------------------------------------------------------------------
  122.   # ● 主处理
  123.   #--------------------------------------------------------------------------
  124.   def main
  125.     # 生成帮助窗口
  126.     @help_window = Window_Help.new
  127.     # 生成指令窗口
  128.     if $itembankflag == 0 #是不是物品仓库?
  129.       @command_window = WWWindow_ShopCommand.new
  130.     else
  131.       @command_window = W2Window_ShopCommand.new
  132.     end  
  133.     # 生成金钱窗口
  134.     @gold_window = Window_Gold.new
  135.     @gold_window.x = 800
  136.     @gold_window.y = 64
  137.     # 生成时间窗口
  138.     @dummy_window = Window_Base.new(0, 128, 800, 592)#0,128,640,352
  139.     # 生成购买窗口
  140.     @buy_window = Window_ShopBuy_Va.new($game_system.goods[@shop_now])
  141.     @buy_window.active = false
  142.     @buy_window.visible = false
  143.     @buy_window.help_window = @help_window
  144.     # 生成卖出窗口
  145.     @sell_window = Window_ShopSell.new
  146.     @sell_window.active = false
  147.     @sell_window.visible = false
  148.     @sell_window.help_window = @help_window
  149.     # 生成数量输入窗口
  150.     @number_window = Window_ShopNumber.new
  151.     @number_window.active = false
  152.     @number_window.visible = false
  153.     # 生成状态窗口
  154.     @status_window = Window_ShopStatus.new
  155.     @status_window.visible = false
  156.     # 执行过渡
  157.     Graphics.transition
  158.     # 主循环
  159.     loop do
  160.       # 刷新游戏画面
  161.       Graphics.update
  162.       # 刷新输入信息
  163.       Input.update
  164.       # 刷新画面
  165.       update
  166.       # 如果画面切换的话就中断循环
  167.       if $scene != self
  168.         break
  169.       end
  170.     end
  171.     # 准备过渡
  172.     Graphics.freeze
  173.     # 释放窗口
  174.     @help_window.dispose
  175.     @command_window.dispose
  176.     @gold_window.dispose
  177.     @dummy_window.dispose
  178.     @buy_window.dispose
  179.     @sell_window.dispose
  180.     @number_window.dispose
  181.     @status_window.dispose
  182.   end
  183.   #--------------------------------------------------------------------------
  184.   # ● 刷新画面
  185.   #--------------------------------------------------------------------------
  186.   def update
  187.     # 刷新窗口
  188.     @help_window.update
  189.     @command_window.update
  190.     @gold_window.update
  191.     @dummy_window.update
  192.     @buy_window.update
  193.     @sell_window.update
  194.     @number_window.update
  195.     @status_window.update
  196.     # 指令窗口激活的情况下: 调用 update_command
  197.     if @command_window.active
  198.       update_command
  199.       return
  200.     end
  201.     # 购买窗口激活的情况下: 调用 update_buy
  202.     if @buy_window.active
  203.       update_buy
  204.       return
  205.     end
  206.     # 卖出窗口激活的情况下: 调用 update_sell
  207.     if @sell_window.active
  208.       update_sell
  209.       return
  210.     end
  211.     # 个数输入窗口激活的情况下: 调用 update_number
  212.     if @number_window.active
  213.       update_number
  214.       return
  215.     end
  216.   end
  217.   #--------------------------------------------------------------------------
  218.   # ● 刷新画面 (指令窗口激活的情况下)
  219.   #--------------------------------------------------------------------------
  220.   def update_command
  221.     # 按下 B 键的情况下
  222.     if Input.trigger?(Input::B)
  223.       # 演奏取消 SE
  224.       $game_system.se_play($data_system.cancel_se)
  225.       # 切换到地图画面
  226.       $scene = Scene_Map.new
  227.       return
  228.     end
  229.     # 按下 C 键的情况下
  230.     if Input.trigger?(Input::C)
  231.       # 命令窗口光标位置分支
  232.       case @command_window.index
  233.       when 0  # 购买
  234.         # 演奏确定 SE
  235.         $game_system.se_play($data_system.decision_se)
  236.         # 窗口状态转向购买模式
  237.         @command_window.active = false
  238.         @dummy_window.visible = false
  239.         @buy_window.active = true
  240.         @buy_window.visible = true
  241.         @buy_window.refresh
  242.         @status_window.visible = true
  243.       when 1  # 卖出
  244.         # 演奏确定 SE
  245.         $game_system.se_play($data_system.decision_se)
  246.         # 窗口状态转向卖出模式
  247.         @command_window.active = false
  248.         @dummy_window.visible = false
  249.         @sell_window.active = true
  250.         @sell_window.visible = true
  251.         @sell_window.refresh
  252.       when 2  # 取消
  253.         # 演奏确定 SE
  254.         $game_system.se_play($data_system.decision_se)
  255.         # 切换到地图画面
  256.         $scene = Scene_Map.new
  257.       end
  258.       return
  259.     end
  260.   end
  261.   #--------------------------------------------------------------------------
  262.   # ● 刷新画面 (购买窗口激活的情况下)
  263.   #--------------------------------------------------------------------------
  264.   def update_buy
  265.     # 设置状态窗口的物品
  266.     @status_window.item = @buy_window.item
  267.     # 按下 B 键的情况下
  268.     if Input.trigger?(Input::B)
  269.       # 演奏取消 SE
  270.       $game_system.se_play($data_system.cancel_se)
  271.       # 窗口状态转向初期模式
  272.       @command_window.active = true
  273.       @dummy_window.visible = true
  274.       @buy_window.active = false
  275.       @buy_window.visible = false
  276.       @status_window.visible = false
  277.       @status_window.item = nil
  278.       # 删除帮助文本
  279.       @help_window.set_text("")
  280.       return
  281.     end
  282.     # 按下 C 键的情况下
  283.     if Input.trigger?(Input::C)
  284.       # 获取物品
  285.       @item = @buy_window.item
  286.       
  287. # 如果是物品仓库就不对金钱做出处理=============================================      
  288.       ppprice = $itembankflag == 0 ? @item.price : 0
  289.       # 物品无效的情况下、或者价格在所持金以上的情况下
  290.       if @item == nil or ppprice > $game_party.gold
  291.         # 演奏冻结 SE
  292.         $game_system.se_play($data_system.buzzer_se)
  293.         return
  294.       end
  295.       # 获取物品所持数
  296.       case @item
  297.       when RPG::Item
  298.         number = $game_party.item_number(@item.id)
  299.       when RPG::Weapon
  300.         number = $game_party.weapon_number(@item.id)
  301.       when RPG::Armor
  302.         number = $game_party.armor_number(@item.id)
  303.       end
  304.       # 如果已经拥有了 99 个情况下
  305.       if number == 99
  306.         # 演奏冻结 SE
  307.         $game_system.se_play($data_system.buzzer_se)
  308.         return
  309.       end
  310.       # 演奏确定 SE
  311.       $game_system.se_play($data_system.decision_se)
  312.       # 计算可以最多购买的数量
  313.       max = ppprice == 0 ? 99 : $game_party.gold / @item.price
  314. # =============================================================================      
  315.       
  316.       max = [[max, 99 - number].min,@buy_window.item_number].min
  317.       # 窗口状态转向数值输入模式
  318.       @buy_window.active = false
  319.       @buy_window.visible = false
  320.       @number_window.set(@item, max, ppprice)
  321.       @number_window.active = true
  322.       @number_window.visible = true
  323.     end
  324.   end
  325.   #--------------------------------------------------------------------------
  326.   # ● 画面更新 (卖出窗口激活的情况下)
  327.   #--------------------------------------------------------------------------
  328.   def update_sell
  329.     # 按下 B 键的情况下
  330.     if Input.trigger?(Input::B)
  331.       # 演奏取消 SE
  332.       $game_system.se_play($data_system.cancel_se)
  333.       # 窗口状态转向初期模式
  334.       @command_window.active = true
  335.       @dummy_window.visible = true
  336.       @sell_window.active = false
  337.       @sell_window.visible = false
  338.       @status_window.item = nil
  339.       # 删除帮助文本
  340.       @help_window.set_text("")
  341.       return
  342.     end
  343.     # 按下 C 键的情况下
  344.     if Input.trigger?(Input::C)
  345.       # 获取物品
  346.       @item = @sell_window.item
  347.       # 设置状态窗口的物品
  348.       @status_window.item = @item
  349.       # 物品无效的情况下、或者价格为 0 (不能卖出) 的情况下
  350.       if @item == nil or @item.price == 0
  351.         # 演奏冻结 SE
  352.         $game_system.se_play($data_system.buzzer_se)
  353.         return
  354.       end
  355.       # 演奏确定 SE
  356.       $game_system.se_play($data_system.decision_se)
  357.       # 获取物品的所持数
  358.       case @item
  359.       when RPG::Item
  360.         number = $game_party.item_number(@item.id)
  361.       when RPG::Weapon
  362.         number = $game_party.weapon_number(@item.id)
  363.       when RPG::Armor
  364.         number = $game_party.armor_number(@item.id)
  365.       end
  366.       # 最大卖出个数 = 物品的所持数
  367.       max = number
  368.       # 窗口状态转向个数输入模式
  369.       @sell_window.active = false
  370.       @sell_window.visible = false
  371.       @number_window.set(@item, max, @item.price)
  372.       @number_window.active = true
  373.       @number_window.visible = true
  374.       @status_window.visible = true
  375.     end
  376.   end
  377.   #--------------------------------------------------------------------------
  378.   # ● 刷新画面 (个数输入窗口激活的情况下)
  379.   #--------------------------------------------------------------------------
  380.   def update_number
  381.     # 按下 B 键的情况下
  382.     if Input.trigger?(Input::B)
  383.       # 演奏取消 SE
  384.       $game_system.se_play($data_system.cancel_se)
  385.       # 设置个数输入窗口为不活动·非可视状态
  386.       @number_window.active = false
  387.       @number_window.visible = false
  388.       # 命令窗口光标位置分支
  389.       case @command_window.index
  390.       when 0  # 购买
  391.         # 窗口状态转向购买模式
  392.         @buy_window.active = true
  393.         @buy_window.visible = true
  394.       when 1  # 卖出
  395.         # 窗口状态转向卖出模式
  396.         @sell_window.active = true
  397.         @sell_window.visible = true
  398.         @status_window.visible = false
  399.       end
  400.       return
  401.     end
  402.     # 按下 C 键的情况下
  403.     if Input.trigger?(Input::C)
  404.       # 演奏商店 SE
  405.       $game_system.se_play($data_system.shop_se)
  406.       # 设置个数输入窗口为不活动·非可视状态
  407.       @number_window.active = false
  408.       @number_window.visible = false
  409.       # 命令窗口光标位置分支
  410.       case @command_window.index
  411.       when 0  # 购买
  412.         # 购买处理
  413.         temp = 0
  414.         if $超重不能买 > 0
  415.           @number_window.active = true
  416.           @number_window.visible = true
  417.           return
  418.         end  
  419. # 如果是物品仓库就不对金钱做出处理=============================================        
  420.         if $itembankflag == 0
  421.           $game_party.lose_gold(@number_window.number * @item.price)
  422.         end  
  423. # =============================================================================        
  424.         
  425.         case @item
  426.         when RPG::Item
  427.           $game_party.gain_item(@item.id, @number_window.number)
  428.         when RPG::Weapon
  429.           $game_party.gain_weapon(@item.id, @number_window.number)
  430.           temp = 1
  431.         when RPG::Armor
  432.           $game_party.gain_armor(@item.id, @number_window.number)
  433.           temp = 2
  434.         end
  435.         goods_del(temp,@item.id,@number_window.number)
  436.         # 刷新各窗口
  437.         @buy_window = Window_ShopBuy_Va.new($game_system.goods[@shop_now])
  438.         @gold_window.refresh
  439.         @buy_window.refresh
  440.         @status_window.refresh
  441.         # 窗口状态转向购买模式
  442.         @buy_window.active = true
  443.         @buy_window.visible = true
  444.       when 1  # 卖出
  445.         # 卖出处理
  446.         
  447. # 如果是物品仓库就不对金钱做出处理=============================================        
  448.         if $itembankflag == 0
  449.           $game_party.gain_gold(@number_window.number * @item.price)
  450.         end  
  451. # =============================================================================        
  452.         
  453.         temp = 0
  454.         case @item
  455.         when RPG::Item
  456.           $game_party.lose_item(@item.id, @number_window.number)
  457.         when RPG::Weapon
  458.           $game_party.lose_weapon(@item.id, @number_window.number)
  459.           temp = 1
  460.         when RPG::Armor
  461.           $game_party.lose_armor(@item.id, @number_window.number)
  462.           temp = 2
  463.         end
  464.         # 刷新各窗口
  465.         goods_del(temp,@item.id,-@number_window.number)
  466.         @buy_window = Window_ShopBuy_Va.new($game_system.goods[@shop_now])
  467.         @buy_window.active = false
  468.         @buy_window.visible = false
  469.         @buy_window.help_window = @help_window
  470.         @gold_window.refresh
  471.         @sell_window.refresh
  472.         @status_window.refresh
  473.         # 窗口状态转向卖出模式
  474.         @sell_window.active = true
  475.         @sell_window.visible = true
  476.         @status_window.visible = false
  477.       end
  478.       return
  479.     end
  480.   end
  481.   # 删除可出售商品内容
  482.   def goods_del(kind,id,delnumber)
  483.     dl = delnumber
  484.     for dt in $game_system.goods[@shop_now]
  485.       if (dt[0]==kind) and (dt[1]==id)
  486.         dt[2] -= dl
  487.         dt[2] = [dt[2],99].min
  488.         if dt[2] == 0
  489.           $game_system.goods[@shop_now].delete(dt)
  490.         end
  491.         return
  492.       end
  493.     end
  494.     $game_system.goods[@shop_now].push([kind,id,-delnumber])
  495.   end
  496. end

  497. #==============================================================================
  498. # ■ Window_ShopBuy_Va
  499. #------------------------------------------------------------------------------
  500. #  商店画面、浏览显示可以购买的商品的窗口。
  501. #==============================================================================

  502. class Window_ShopBuy_Va < Window_Selectable
  503.   attr_accessor :shop_goods
  504.   #--------------------------------------------------------------------------
  505.   # ● 初始化对像
  506.   #     shop_goods : 商品
  507.   #--------------------------------------------------------------------------
  508.   def initialize(shop_goods)
  509.     super(0, 128, 528, 592)#0,128,368,352
  510.     @shop_goods = shop_goods
  511.     refresh
  512.     self.index = 0
  513.   end
  514.   #--------------------------------------------------------------------------
  515.   # ● 获取物品
  516.   #--------------------------------------------------------------------------
  517.   def item
  518.     return @data[self.index]
  519.   end
  520.   #--------------------------------------------------------------------------
  521.   # ● 获取物品
  522.   #--------------------------------------------------------------------------
  523.   def item_number
  524.     return @data_number[self.index]
  525.   end
  526.   #--------------------------------------------------------------------------
  527.   # ● 刷新
  528.   #--------------------------------------------------------------------------
  529.   def refresh
  530.     if self.contents != nil
  531.       self.contents.dispose
  532.       self.contents = nil
  533.     end
  534.     @data = []
  535.     @data_number = []
  536.     for goods_item in @shop_goods
  537.       case goods_item[0]
  538.       when 0
  539.         item = $data_items[goods_item[1]]
  540.       when 1
  541.         item = $data_weapons[goods_item[1]]
  542.       when 2
  543.         item = $data_armors[goods_item[1]]
  544.       end
  545.       if (item != nil) and (goods_item[2] != 0)
  546.         @data.push(item)
  547.         @data_number.push(goods_item[2])
  548.       else
  549.         @data.delete(item)
  550.       end
  551.     end
  552.     # 如果项目数不是 0 就生成位图、描绘全部项目
  553.     @item_max = @data.size
  554.     if @item_max > 0
  555.       self.contents = Bitmap.new(width - 32, row_max * 32)
  556.       for i in 0...@item_max
  557.         draw_item(i)
  558.       end
  559.     end
  560.   end
  561.   #--------------------------------------------------------------------------
  562.   # ● 描绘羡慕
  563.   #     index : 项目编号
  564.   #--------------------------------------------------------------------------
  565.   def draw_item(index)
  566.     item = @data[index]
  567.     # 获取物品所持数
  568.     case item
  569.     when RPG::Item
  570.       number = $game_party.item_number(item.id)
  571.     when RPG::Weapon
  572.       number = $game_party.weapon_number(item.id)
  573.     when RPG::Armor
  574.       number = $game_party.armor_number(item.id)
  575.     end
  576.     # 价格在所持金以下、并且所持数不是 99 的情况下为普通文字颜色
  577.     # 除此之外的情况设置为无效文字色
  578.     if item.price <= $game_party.gold and number < 99
  579.       self.contents.font.color = normal_color
  580.     else
  581.       self.contents.font.color = disabled_color
  582.     end
  583.     x = 4
  584.     y = index * 32
  585.     rect = Rect.new(x, y, self.width - 32, 32)
  586.     self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
  587.     bitmap = RPG::Cache.icon(item.icon_name)
  588.     opacity = self.contents.font.color == normal_color ? 255 : 128
  589.     self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 32, 32), opacity)
  590.     self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
  591.     self.contents.draw_text(x + 240, y, 88, 32, "剩  ", 2)
  592.     self.contents.draw_text(x + 240, y, 88, 32, @data_number[index].to_s, 2)
  593.     if $itembankflag == 0  
  594.       self.contents.draw_text(x + 180, y, 88, 32, item.price.to_s, 2)
  595.     end  
  596.   end
  597.   #--------------------------------------------------------------------------
  598.   # ● 刷新帮助文本
  599.   #--------------------------------------------------------------------------
  600.   def update_help
  601.     @help_window.set_text(self.item == nil ? "" : self.item.description)
  602.   end
  603. end

  604. #==============================================================================
  605. # 本脚本来自www.66RPG.com,使用和转载请保留此信息
  606. #==============================================================================
复制代码
  1. #==============================================================================
  2. # ■ Scene_Shop
  3. #------------------------------------------------------------------------------
  4. #  处理商店画面的类。改变了原先的商店模式,只能买不能卖。
  5. #==============================================================================

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

  345. class Window_ShopBuy < Window_Selectable
  346.   #--------------------------------------------------------------------------
  347.   # ● 初始化对像
  348.   #     shop_goods : 商品
  349.   #--------------------------------------------------------------------------
  350.   def initialize(shop_goods)
  351.     super(0, 128, 712, 480)#0,128,552,352
  352.     @shop_goods = shop_goods
  353.     refresh
  354.     self.index = 0
  355.   end
  356.   #--------------------------------------------------------------------------
  357.   # ● 获取物品
  358.   #--------------------------------------------------------------------------
  359.   def item
  360.     return @data[self.index]
  361.   end
  362.   #--------------------------------------------------------------------------
  363.   # ● 刷新
  364.   #--------------------------------------------------------------------------
  365.   def refresh
  366.     if self.contents != nil
  367.       self.contents.dispose
  368.       self.contents = nil
  369.     end
  370.     @data = []
  371.     for goods_item in @shop_goods
  372.       case goods_item[0]
  373.       when 0
  374.         item = $data_items[goods_item[1]]
  375.       when 1
  376.         item = $data_weapons[goods_item[1]]
  377.       when 2
  378.         item = $data_armors[goods_item[1]]
  379.       end
  380.       if item != nil
  381.         @data.push(item)
  382.       end
  383.     end
  384.     # 如果项目数不是 0 就生成位图、描绘全部项目
  385.     @item_max = @data.size
  386.     if @item_max > 0
  387.       self.contents = Bitmap.new(width - 32, row_max * 32)
  388.       for i in 0...@item_max
  389.         draw_item(i)
  390.       end
  391.     end
  392.   end
  393.   #--------------------------------------------------------------------------
  394.   # ● 描绘羡慕
  395.   #     index : 项目编号
  396.   #--------------------------------------------------------------------------
  397.   def draw_item(index)
  398.     item = @data[index]
  399.     # 获取物品所持数
  400.     case item
  401.     when RPG::Item
  402.       number = $game_party.item_number(item.id)
  403.     when RPG::Weapon
  404.       number = $game_party.weapon_number(item.id)
  405.     when RPG::Armor
  406.       number = $game_party.armor_number(item.id)
  407.     end
  408.     # 价格在所持金以下、并且所持数不是 99 的情况下为普通文字颜色
  409.     # 除此之外的情况设置为无效文字色
  410.    
  411.     if (item.price <= $game_party.gold and number < 99) or $itembankflag==1
  412.       self.contents.font.color = normal_color
  413.     else
  414.       self.contents.font.color = disabled_color
  415.     end
  416.     x = 4
  417.     y = index * 32
  418.     rect = Rect.new(x, y, self.width - 32, 32)
  419.     self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
  420.     bitmap = RPG::Cache.icon(item.icon_name)
  421.     opacity = self.contents.font.color == normal_color ? 255 : 128
  422.     self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 32, 32), opacity)
  423.     self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
  424.     self.contents.draw_text(x + 240, y, 88, 32, item.price.to_s, 2)
  425.   end
  426.   #--------------------------------------------------------------------------
  427.   # ● 刷新帮助文本
  428.   #--------------------------------------------------------------------------
  429.   def update_help
  430.     @help_window.set_text(self.item == nil ? "" : self.item.description)
  431.   end
  432. end

  433. #==============================================================================
  434. # ■ Window_ShopNumber
  435. #------------------------------------------------------------------------------
  436. #  商店画面、输入买卖数量的窗口。
  437. #==============================================================================

  438. class Window_ShopNumber < Window_Base
  439.   #--------------------------------------------------------------------------
  440.   # ● 初始化对像
  441.   #--------------------------------------------------------------------------
  442.   def initialize
  443.     super(0, 128, 528, 480)#0,128,368,352
  444.     self.contents = Bitmap.new(width - 32, height - 32)
  445.     @item = nil
  446.     @max = 1
  447.     @price = 0
  448.     @number = 1
  449.   end
  450.   #--------------------------------------------------------------------------
  451.   # ● 设置物品、最大个数、价格
  452.   #--------------------------------------------------------------------------
  453.   def set(item, max, price)
  454.     @item = item
  455.     @max = max
  456.     @price = price
  457.     @number = 1
  458.     refresh
  459.   end
  460.   #--------------------------------------------------------------------------
  461.   # ● 被输入的件数设置
  462.   #--------------------------------------------------------------------------
  463.   def number
  464.     return @number
  465.   end
  466.   #--------------------------------------------------------------------------
  467.   # ● 刷新
  468.   #--------------------------------------------------------------------------
  469.   def refresh
  470.     self.contents.clear
  471.     draw_item_name(@item, 4, 96)
  472.     case @item
  473.     when RPG::Item
  474.       wwwt=@number * $data_items[@item.id].weight
  475.     when RPG::Weapon
  476.       wwwt=@number * $data_weapons[@item.id].weight
  477.     when RPG::Armor
  478.       wwwt=@number * $data_armors[@item.id].weight
  479.     end
  480.     if wwwt>($game_variables[136]-$game_party.weight)
  481.       self.contents.font.color = normal_color
  482.       $超重不能买 = 1
  483.     else
  484.       self.contents.font.color = normal_color
  485.       $超重不能买 = 0
  486.     end  
  487.     self.contents.draw_text(4, 192, 336, 32, "总重", 2)#4,192,224,32
  488.     self.contents.draw_text(240, 192, 256, 32, wwwt.to_s, 2)#240,192,96,32
  489.     self.contents.draw_text(272, 96, 192, 32, "×")#272,96,32,32
  490.     self.contents.draw_text(308, 96, 184, 32, @number.to_s, 2)#308,96,24,32
  491.     self.cursor_rect.set(464, 96, 192, 32)#304,96,32,32
  492.     # 描绘合计价格和货币单位
  493.     domination = $data_system.words.gold
  494.     cx = contents.text_size(domination).width
  495.     total_price = @price * @number
  496.     #self.contents.font.color = normal_color
  497.     if $itembankflag != 1  
  498.       self.contents.draw_text(4, 160, 328-cx-2, 32, total_price.to_s, 2)
  499.       self.contents.font.color = system_color
  500.       self.contents.draw_text(332-cx, 160, cx, 32, domination, 2)
  501.     end   
  502.   end
  503.   #--------------------------------------------------------------------------
  504.   # ● 刷新画面
  505.   #--------------------------------------------------------------------------
  506.   def update
  507.     super
  508.     if self.active
  509.       # 光标右 (+1)
  510.       if Input.repeat?(Input::RIGHT) and @number < @max
  511.         $game_system.se_play($data_system.cursor_se)
  512.         @number += 1
  513.         refresh
  514.       end
  515.       # 光标左 (-1)
  516.       if Input.repeat?(Input::LEFT) and @number > 1
  517.         $game_system.se_play($data_system.cursor_se)
  518.         @number -= 1
  519.         refresh
  520.       end
  521.       # 光标上 (+10)
  522.       if Input.repeat?(Input::UP) and @number < @max
  523.         $game_system.se_play($data_system.cursor_se)
  524.         @number = [@number + 10, @max].min
  525.         refresh
  526.       end
  527.       # 光标下 (-10)
  528.       if Input.repeat?(Input::DOWN) and @number > 1
  529.         $game_system.se_play($data_system.cursor_se)
  530.         @number = [@number - 10, 1].max
  531.         refresh
  532.       end
  533.       case @item
  534.       when RPG::Item
  535.         $wwwt=@number * $data_items[@item.id].weight
  536.       when RPG::Weapon
  537.         $wwwt=@number * $data_weapons[@item.id].weight
  538.       when RPG::Armor
  539.         $wwwt=@number * $data_armors[@item.id].weight
  540.       end
  541.     end
  542.   end
  543. end
  544. #==============================================================================
  545. # ■ Window_ShopStatus
  546. #------------------------------------------------------------------------------
  547. #  商店画面、显示物品所持数与角色装备的窗口。
  548. #==============================================================================

  549. class Window_ShopStatus < Window_Base
  550.   #--------------------------------------------------------------------------
  551.   # ● 初始化对像
  552.   #--------------------------------------------------------------------------
  553.   def initialize
  554.     super(528, 128, 432, 480)#368,128,272,352
  555.     self.contents = Bitmap.new(width - 32, height - 32)
  556.     @item = nil
  557.     refresh
  558.   end
  559.   #--------------------------------------------------------------------------
  560.   # ● 刷新
  561.   #--------------------------------------------------------------------------
  562.   def refresh
  563.     self.contents.clear
  564.     if @item == nil
  565.       return
  566.     end
  567.     case @item
  568.     when RPG::Item
  569.       number = $game_party.item_number(@item.id)
  570.     when RPG::Weapon
  571.       number = $game_party.weapon_number(@item.id)
  572.     when RPG::Armor
  573.       number = $game_party.armor_number(@item.id)
  574.     end
  575.     self.contents.font.color = system_color
  576.     self.contents.draw_text(4, 0, 360, 32, "所持数")#4,0,200,32
  577.     self.contents.draw_text(4, 288, 384, 32, "剩余负载能力")#4,288,224,32
  578.     self.contents.font.color = normal_color
  579.    
  580.     self.contents.draw_text(204, 0, 32, 32, number.to_s, 2)
  581.     self.contents.draw_text(140, 288, 96, 32, ($game_variables[136]-$game_party.weight).to_s, 2)
  582.     if @item.is_a?(RPG::Item)#140,288,96,32
  583.       return
  584.     end
  585.     # 添加装备品信息
  586.     for i in 0...$game_party.actors.size
  587.       # 获取角色
  588.       actor = $game_party.actors[i]
  589.       # 可以装备为普通文字颜色、不能装备设置为无效文字颜色
  590.       if actor.equippable?(@item)
  591.         self.contents.font.color = normal_color
  592.       else
  593.         self.contents.font.color = disabled_color
  594.       end
  595.       # 描绘角色名字
  596.       self.contents.draw_text(4, 64 + 64 * i, 280, 32, actor.name)#120,32
  597.       # 获取当前的装备品
  598.       if @item.is_a?(RPG::Weapon)
  599.         item1 = $data_weapons[actor.weapon_id]
  600.       elsif @item.kind == 0
  601.         item1 = $data_armors[actor.armor1_id]
  602.       elsif @item.kind == 1
  603.         item1 = $data_armors[actor.armor2_id]
  604.       elsif @item.kind == 2
  605.         item1 = $data_armors[actor.armor3_id]
  606.       else
  607.         item1 = $data_armors[actor.armor4_id]
  608.       end
  609.       # 可以装备的情况
  610.       if actor.equippable?(@item)
  611.         # 武器的情况
  612.         if @item.is_a?(RPG::Weapon)
  613.           atk1 = item1 != nil ? item1.atk : 0
  614.           atk2 = @item != nil ? @item.atk : 0
  615.           change = atk2 - atk1
  616.         end
  617.         # 防具的情况
  618.         if @item.is_a?(RPG::Armor)
  619.           pdef1 = item1 != nil ? item1.pdef : 0
  620.           mdef1 = item1 != nil ? item1.mdef : 0
  621.           pdef2 = @item != nil ? @item.pdef : 0
  622.           mdef2 = @item != nil ? @item.mdef : 0
  623.           change = pdef2 - pdef1 + mdef2 - mdef1
  624.         end
  625.         # 描绘能力值变化
  626.         self.contents.draw_text(124, 64 + 64 * i, 112, 32,
  627.           sprintf("%+d", change), 2)
  628.       end
  629.       # 描绘物品
  630.       if item1 != nil
  631.         x = 4
  632.         y = 64 + 64 * i + 32
  633.         bitmap = RPG::Cache.icon(item1.icon_name)
  634.         opacity = self.contents.font.color == normal_color ? 255 : 128
  635.         self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 32, 32), opacity)
  636.         self.contents.draw_text(x + 28, y, 212, 32, item1.name)
  637.       end
  638.     end
  639.   end
  640.   #--------------------------------------------------------------------------
  641.   # ● 设置物品
  642.   #     item : 新的物品
  643.   #--------------------------------------------------------------------------
  644.   def item=(item)
  645.     if @item != item
  646.       @item = item
  647.       refresh
  648.     end
  649.   end
  650. end
  651. #==============================================================================
  652. # ■ Window_ShopCommand(购物中心窗口,只能买不能卖)
  653. #------------------------------------------------------------------------------
  654. #  商店画面、选择要做的事的窗口
  655. #==============================================================================

  656. class Window_ShopCommand < Window_Selectable
  657.   #--------------------------------------------------------------------------
  658.   # ● 初始化对像
  659.   #--------------------------------------------------------------------------
  660.   def initialize
  661.     super(0, 64, 640, 192)#0,64,480,64
  662.     self.contents = Bitmap.new(width - 32, height - 32)
  663.     @item_max = 2
  664.     @column_max = 2
  665.     @commands = ["购物", "取消"]
  666.     refresh
  667.     self.index = 0
  668.   end
  669.   #--------------------------------------------------------------------------
  670.   # ● 刷新
  671.   #--------------------------------------------------------------------------
  672.   def refresh
  673.     self.contents.clear
  674.     for i in 0...@item_max
  675.       draw_item(i)
  676.     end
  677.   end
  678.   #--------------------------------------------------------------------------
  679.   # ● 描绘项目
  680.   #     index : 项目编号
  681.   #--------------------------------------------------------------------------
  682.   def draw_item(index)
  683.     x = 64 + index * 400
  684.     self.contents.draw_text(x, 0, 288, 32, @commands[index])#0,128,32
  685.   end
  686. end
复制代码
这些要放在一起才有用···我的屏幕分辨率为800*608···注意是800*608不是800*600···
’’
[img]http://service.t.sina.com.cn/widget/qmd/5339802982/c02e16bd/7.png
您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

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

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

GMT+8, 2024-9-28 06:56

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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