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

Project1

 找回密码
 注册会员
搜索

请教使用物品合成脚本出问题?

查看数: 1529 | 评论数: 1 | 收藏 0
关灯 | 提示:支持键盘翻页<-左 右->
    组图打开中,请稍候......
发布时间: 2013-1-1 22:32

正文摘要:

是在事件中使用脚本RUBY 代码复制$scene = Scene_Craft.new$scene = Scene_Craft.new 呼出界面时跳出的错误 RUBY 代码复制#================================== ...

回复

飞3a 发表于 2013-1-2 21:49:58
ArgumentError 类表示一种错误,如果函数提供的参数与为该函数定义的参数不一致,则会出现该错误。例如,如果在调用函数时使用了错误的参数数目、不正确的参数类型或无效参数,则会发生此错误。

从322行来看,问题不是出在这一行。
我尝试把楼主提供的脚本贴到一个新建的工程上面,然后139行报了语法错误(也不知道错在什么地方,去掉了后面email 的那个斜杠还是报错。)

不知道是不是和别的脚本冲突了。

如果不行的话,试试看这个脚本。来源于牧场之星。(主站范例游戏)
RUBY 代码复制
  1. #==============================================================================
  2. # 本脚本来自[url]www.66RPG.com[/url],使用和转载请保留此信息
  3. #==============================================================================  
  4.  
  5. # Sample master list for crafting script
  6. # written by Deke
  7. #============================================================================================
  8. # 简介:
  9. # 这是一个很不错的合成物品系统,可以通过游戏的过程,不断学习可以合成的
  10. # 物品方法。
  11. #
  12. # 使用方法:
  13. # 1、召唤界面:使用脚本$scene = Scene_Craft.new
  14. #
  15. # 2、学习合成:$game_party.learn_recipe(合成项目)
  16. #
  17. # 3、合成定义:
  18. # 这个合成脚本可以定义两种合成物品。一种是预先定义好了的,就像下面这样,
  19. # 直接写在这里就可以,另一种是在学习之前现场定义。
  20. #
  21. # 4、举例
  22. #  4.1、学会recipe_list[1]定义的合成:$game_party.learn_recipe($game_temp.recipe_list[1])
  23. #       注意,一行如果输入不下,在(的后面或[的后面按回车换行,否则可能出错
  24. #
  25. #  4.2、在游戏中临时定义一种合成,让玩家学会。使用事件中的脚本如下,   
  26. #  脚本:
  27. #    材料 = [$game_variables[1],$game_variables[2]]  #——材料编号是变量1、2的编号
  28. #    材料种类 = [0,0]                                #——材料是物品
  29. #    材料数量 = [$game_variables[3],$game_variables[4]]  #——需要材料数量是变量3、4的编号
  30. #    成品 = $game_variables[5]                       #——获得结果编号是5
  31. #    成品种类 = 1                                    #——成品是防具类
  32. #    $game_party.learn_recipe(Game_Recipe.new(材料,材料种类, 材料数量,成品,成品种类))
  33. #===========================================================================================
  34. class Game_Temp
  35.   attr_reader :recipe_list  
  36.   alias crafting_temp_initialize initialize
  37.   def initialize
  38.     crafting_temp_initialize
  39.     @recipe_list=[]
  40.     get_recipe_list
  41.   end  
  42.   def get_recipe_list   
  43.     ##########################################################################
  44.     # 0 号合成物品设定 (巧克力蛋糕)
  45.     ##########################################################################
  46.     材料 = [37, 150, 156]             # 需要材料的数据库编号
  47.     材料种类 = [0, 0, 0]         # 需要材料的种类,0是普通物品,1是防具,2是武器
  48.     材料数量 = [1, 2, 2]         # 需要材料的数量
  49.     成品 = 203                  # 获得物品编号
  50.     成品种类 = 0              # 获得物品种类,0是普通物品,1是防具,2是武器
  51.     @recipe_list[0] = Game_Recipe.new(材料,材料种类, 材料数量,成品,成品种类)
  52.  
  53.     ##########################################################################
  54.     # 1 号合成物品设定 (苹果蛋糕)
  55.     ##########################################################################
  56.     材料 = [71, 150, 156]          # 需要材料的数据库编号
  57.     材料种类 = [0, 0, 0]      # 需要材料的种类,0是普通物品,1是防具,2是武器
  58.     材料数量 = [1, 2, 3]      # 需要材料的数量
  59.     成品 = 205                  # 获得物品编号
  60.     成品种类 = 0              # 获得物品种类,0是普通物品,1是防具,2是武器
  61.     @recipe_list[1] = Game_Recipe.new(材料,材料种类, 材料数量,成品,成品种类)
  62.  
  63.     ##########################################################################
  64.     # 2 号合成物品设定 (起司蛋糕)
  65.     ##########################################################################
  66.     材料 = [147, 150, 156]            # 需要材料的数据库编号
  67.     材料种类 = [0, 0, 0]         # 需要材料的种类,0是普通物品,1是防具,2是武器
  68.     材料数量 = [2, 2, 2]         # 需要材料的数量
  69.     成品 = 206                  # 获得物品编号
  70.     成品种类 = 0              # 获得物品种类,0是普通物品,1是防具,2是武器
  71.     @recipe_list[2] = Game_Recipe.new(材料,材料种类, 材料数量,成品,成品种类)
  72.  
  73.     ##########################################################################
  74.     # 3 号合成物品设定 (蜂蜜水)
  75.     ##########################################################################
  76.     材料 = [72, 156]            # 需要材料的数据库编号
  77.     材料种类 = [0, 0]         # 需要材料的种类,0是普通物品,1是防具,2是武器
  78.     材料数量 = [1, 2]         # 需要材料的数量
  79.     成品 = 204                  # 获得物品编号
  80.     成品种类 = 0              # 获得物品种类,0是普通物品,1是防具,2是武器
  81.     @recipe_list[3] = Game_Recipe.new(材料,材料种类, 材料数量,成品,成品种类)
  82.  
  83.     ##########################################################################
  84.     # 4 号合成物品设定 (A级三明治)
  85.     ##########################################################################
  86.     材料 = [187, 147, 152]            # 需要材料的数据库编号
  87.     材料种类 = [0, 0, 0]         # 需要材料的种类,0是普通物品,1是防具,2是武器
  88.     材料数量 = [1, 1, 2]         # 需要材料的数量
  89.     成品 = 207                  # 获得物品编号
  90.     成品种类 = 0              # 获得物品种类,0是普通物品,1是防具,2是武器
  91.     @recipe_list[4] = Game_Recipe.new(材料,材料种类, 材料数量,成品,成品种类)
  92.     ##########################################################################
  93.     # 5 号合成物品设定 (A+级三明治)
  94.     ##########################################################################
  95.     材料 = [188, 147, 152]            # 需要材料的数据库编号
  96.     材料种类 = [0, 0, 0]         # 需要材料的种类,0是普通物品,1是防具,2是武器
  97.     材料数量 = [1, 1, 2]         # 需要材料的数量
  98.     成品 = 208                # 获得物品编号
  99.     成品种类 = 0             # 获得物品种类,0是普通物品,1是防具,2是武器
  100.     @recipe_list[5] = Game_Recipe.new(材料,材料种类, 材料数量,成品,成品种类)
  101.     ##########################################################################
  102.     # 6 号合成物品设定 (黄金三明治)
  103.     ##########################################################################
  104.     材料 = [189, 147, 152]            # 需要材料的数据库编号
  105.     材料种类 = [0, 0, 0]         # 需要材料的种类,0是普通物品,1是防具,2是武器
  106.     材料数量 = [1, 1, 2]         # 需要材料的数量
  107.     成品 = 209                 # 获得物品编号
  108.     成品种类 = 0              # 获得物品种类,0是普通物品,1是防具,2是武器
  109.     @recipe_list[6] = Game_Recipe.new(材料,材料种类, 材料数量,成品,成品种类)
  110.     ##########################################################################
  111.     # 7 号合成物品设定 (蔬菜炒饭)
  112.     ##########################################################################
  113.     材料 = [151, 153, 154, 155, 157, 50, 51]            # 需要材料的数据库编号
  114.     材料种类 = [0, 0, 0, 0, 0, 0, 0]         # 需要材料的种类,0是普通物品,1是防具,2是武器
  115.     材料数量 = [1, 1, 1, 1, 1, 1, 1]         # 需要材料的数量
  116.     成品 = 210                 # 获得物品编号
  117.     成品种类 = 0              # 获得物品种类,0是普通物品,1是防具,2是武器
  118.     @recipe_list[7] = Game_Recipe.new(材料,材料种类, 材料数量,成品,成品种类)
  119.     ##########################################################################
  120.     # 8 号合成物品设定 (冰淇淋)
  121.     ##########################################################################
  122.     材料 = [193, 156]            # 需要材料的数据库编号
  123.     材料种类 = [0, 0]         # 需要材料的种类,0是普通物品,1是防具,2是武器
  124.     材料数量 = [1, 2]         # 需要材料的数量
  125.     成品 = 211                 # 获得物品编号
  126.     成品种类 = 0              # 获得物品种类,0是普通物品,1是防具,2是武器
  127.     @recipe_list[8] = Game_Recipe.new(材料,材料种类, 材料数量,成品,成品种类)
  128.     ##########################################################################
  129.     # 9 号合成物品设定 (冰淇淋)
  130.     ##########################################################################
  131.     材料 = [194, 156]            # 需要材料的数据库编号
  132.     材料种类 = [0, 0]         # 需要材料的种类,0是普通物品,1是防具,2是武器
  133.     材料数量 = [1, 2]         # 需要材料的数量
  134.     成品 = 211                 # 获得物品编号
  135.     成品种类 = 0              # 获得物品种类,0是普通物品,1是防具,2是武器
  136.     @recipe_list[9] = Game_Recipe.new(材料,材料种类, 材料数量,成品,成品种类)
  137.     ##########################################################################
  138.     # 10 号合成物品设定 (玉米浓汤)
  139.     ##########################################################################
  140.     材料 = [54, 156, 72]            # 需要材料的数据库编号
  141.     材料种类 = [0, 0, 0]         # 需要材料的种类,0是普通物品,1是防具,2是武器
  142.     材料数量 = [2, 1, 1]         # 需要材料的数量
  143.     成品 = 214                 # 获得物品编号
  144.     成品种类 = 0              # 获得物品种类,0是普通物品,1是防具,2是武器
  145.     @recipe_list[10] = Game_Recipe.new(材料,材料种类, 材料数量,成品,成品种类)
  146.     ##########################################################################
  147.     # 11 号合成物品设定 (鳕鱼饭团)
  148.     ##########################################################################
  149.     材料 = [157, 154, 130]            # 需要材料的数据库编号
  150.     材料种类 = [0, 0, 0]         # 需要材料的种类,0是普通物品,1是防具,2是武器
  151.     材料数量 = [1, 2, 1]         # 需要材料的数量
  152.     成品 = 215                 # 获得物品编号
  153.     成品种类 = 0              # 获得物品种类,0是普通物品,1是防具,2是武器
  154.     @recipe_list[11] = Game_Recipe.new(材料,材料种类, 材料数量,成品,成品种类)
  155.     ##########################################################################
  156.     # 12 号合成物品设定 (鳕鱼饭团)
  157.     ##########################################################################
  158.     材料 = [157, 154, 132]            # 需要材料的数据库编号
  159.     材料种类 = [0, 0, 0]         # 需要材料的种类,0是普通物品,1是防具,2是武器
  160.     材料数量 = [1, 2, 1]         # 需要材料的数量
  161.     成品 = 216                 # 获得物品编号
  162.     成品种类 = 0              # 获得物品种类,0是普通物品,1是防具,2是武器
  163.     @recipe_list[12] = Game_Recipe.new(材料,材料种类, 材料数量,成品,成品种类)
  164.  
  165.   end # of get_recipe_list method
  166. end # of updates to Game_Temp Class
  167.  
  168. #================================
  169. # CRAFTING PROGRAM
  170. #----------------------------------------------------------------
  171. #-written by Deke
  172. #-yes_no window code created by Phsylomortis
  173. #----------------------------------------------------------------
  174. #================================
  175.  
  176. #updates to Game_Party class
  177.  
  178. class Game_Party
  179.  
  180.   attr_accessor       :recipes
  181.  
  182.   alias crafting_party_initialize initialize
  183.  
  184.   def initialize
  185.     crafting_party_initialize
  186.     @recipes=[]
  187.   end
  188.  
  189.   #----------------------------------------------------------------------
  190.   def know?(recipe, version = 1)
  191.     unless recipe.is_a?(Game_Recipe)
  192.       recipe = get_recipe_from_master_list(recipe, version)
  193.     end
  194.     return $game_party.recipes.include?(recipe)
  195.   end
  196.  
  197. #----------------------------------------------------------------------
  198.   def learn_recipe(recipe , version = 1)
  199.     unless recipe.is_a?(Game_Recipe)
  200.       recipe = get_recipe_from_master_list(recipe, version)
  201.     end
  202.     if recipe.is_a?(Game_Recipe)
  203.       unless know?(recipe)
  204.         @recipes.push(recipe)
  205.       end
  206.     end
  207.   end
  208.  
  209. #----------------------------------------------------------------------
  210.   def forget_recipe(recipe , version = 1)
  211.     if !recipe.is_a?(Game_Recipe)
  212.       recipe = get_recipe_from_master_list(recipe, version)
  213.     end
  214.     if recipe.is_a?(Game_Recipe)
  215.       for i in [email]0...@recipes.size[/email]
  216.         if recipe == @recipes[i]
  217.           index = i
  218.           break
  219.         end
  220.       end
  221.       if index != nil
  222.         @recipes.delete(@recipes[index])
  223.       end
  224.     end
  225.   end
  226.  
  227. #----------------------------------------------------------------------
  228.   def get_recipe_from_master_list(item, version)
  229.     index = nil
  230.     for i in 0...$game_temp.recipe_list.size
  231.       if item[0] == $game_temp.recipe_list[i].result and item[1] ==$game_temp.recipe_list[i].result_type
  232.         version -= 1
  233.         if version == 0
  234.           index = i
  235.           break
  236.         end
  237.       end
  238.     end
  239.     if index.is_a?(Integer)
  240.       return ($game_temp.recipe_list[index])
  241.     else
  242.       return false
  243.     end
  244.   end
  245.  
  246. end # of Game_Party updates
  247.  
  248. #================================
  249. class Game_Recipe
  250.  
  251.   attr_reader :ingredients
  252.   attr_reader :quantities
  253.   attr_reader :result
  254.   attr_reader :result_type
  255.   attr_reader :ingredient_types
  256.  
  257. #----------------------------------------------------------------------
  258.   def initialize( ingredients, ingredient_types, quantities, result, result_type)
  259.     @ingredients = ingredients
  260.     @ingredient_types = ingredient_types
  261.     @quantities = quantities
  262.     @result = result
  263.     @result_type = result_type
  264.   end
  265.  
  266. #----------------------------------------------------------------------
  267.   def name
  268.     case @result_type
  269.       when 0
  270.         name = $data_items[@result].name
  271.       when 1
  272.         name = $data_armors[@result].name
  273.       when 2
  274.         name = $data_weapons[@result].name
  275.     end
  276.     return name
  277.   end
  278.  
  279. #----------------------------------------------------------------------
  280.   def have
  281.     have_all = true
  282.     for i in [email]0...@ingredients.size[/email]
  283.       case @ingredient_types[i]
  284.         when 0
  285.           if $game_party.item_number(@ingredients[i]) < @quantities[i]
  286.             have_all=false
  287.           end
  288.         when 1
  289.           if $game_party.armor_number(@ingredients[i]) < @quantities[i]
  290.             have_all=false
  291.           end
  292.         when 2
  293.           if $game_party.weapon_number(@ingredients[i]) < @quantities[i]
  294.             have_all=false
  295.           end
  296.       end
  297.     end
  298.     return have_all
  299.   end
  300.  
  301. #----------------------------------------------------------------------
  302.   def decrement
  303.     for i in [email]0...@ingredients.size[/email]
  304.       case @ingredient_types[i]
  305.       when 0
  306.         $game_party.lose_item(@ingredients[i], @quantities[i])
  307.       when 1
  308.         $game_party.lose_armor(@ingredients[i], @quantities[i])
  309.       when 2
  310.         $game_party.lose_weapon(@ingredients[i], @quantities[i])
  311.       end
  312.     end
  313.   end
  314.  
  315. #----------------------------------------------------------------------
  316.   def make
  317.     if have
  318.       case @result_type
  319.       when 0
  320.         $game_party.gain_item(@result, 1)
  321.       when 1
  322.         $game_party.gain_armor(@result, 1)
  323.       when 2
  324.         $game_party.gain_weapon(@result, 1)
  325.       end
  326.       decrement
  327.     end
  328.   end
  329.  
  330. #----------------------------------------------------------------------
  331.   def == (recipe)
  332.     if recipe.is_a?(Game_Recipe)
  333.       equal = true
  334.       if recipe.ingredients != self.ingredients
  335.         equal = false
  336.       end
  337.       if recipe.ingredient_types != self.ingredient_types
  338.         equal = false
  339.       end
  340.       if recipe.quantities != self.quantities
  341.         equal = false
  342.       end
  343.       if recipe.result != self.result
  344.         equal=false
  345.       end
  346.       if recipe.result_type != self.result_type
  347.         equal = false
  348.       end
  349.     else
  350.       equal = false
  351.     end
  352.     return equal
  353.   end
  354.  
  355. end # of Game_Recipe class
  356.  
  357. #===================================
  358.  
  359. class Window_Craft < Window_Selectable
  360.  
  361.   #--------------------------------------------------------------------------
  362.   def initialize
  363.     super(0, 64, 240, 416)
  364.     @column_max = 1
  365.     refresh
  366.     self.index = 0
  367.   end
  368.  
  369.   #--------------------------------------------------------------------------
  370.   def recipe
  371.     return @data[self.index]
  372.   end
  373.  
  374.   #--------------------------------------------------------------------------
  375.   def refresh
  376.     if self.contents != nil
  377.       self.contents.dispose
  378.       self.contents = nil
  379.     end
  380.     @data = []
  381.     for i in 0...$game_party.recipes.size
  382.         @data.push($game_party.recipes[i])
  383.     end
  384.     @item_max = @data.size
  385.     if @item_max > 0
  386.       self.contents = Bitmap.new(width - 32, row_max * 32)
  387.       self.contents.font.name = "黑体" # = "黑体"
  388.       self.contents.font.size = 18 # = 18
  389.       for i in 0...@item_max
  390.         draw_item(i)
  391.       end
  392.     end
  393.   end
  394.  
  395.   #--------------------------------------------------------------------------
  396.   def draw_item(index)
  397.     recipe = @data[index]
  398.     self.contents.font.color = recipe.have ? normal_color : disabled_color
  399.     x = 16
  400.     y = index * 32
  401.     self.contents.draw_text(x , y, self.width-32, 32, recipe.name, 0)
  402.   end
  403.  
  404.   #--------------------------------------------------------------------------
  405.   def update_help
  406.     current_recipe = recipe
  407.     if current_recipe.is_a?(Game_Recipe)
  408.     case current_recipe.result_type
  409.       when 0
  410.         description = $data_items[current_recipe.result].description
  411.       when 1
  412.         description = $data_armors[current_recipe.result].description
  413.       when 2
  414.         description = $data_weapons[current_recipe.result].description
  415.       end
  416.     else
  417.       description = ""
  418.     end
  419.     @help_window.set_text(description)
  420.     @help_window.update
  421.   end
  422.  
  423. end # of Window_Craft
  424.  
  425. #=======================================
  426. class Window_CraftResult < Window_Base
  427.  
  428.   #--------------------------------------------------------------------------
  429.   def initialize
  430.     super(240, 64, 400, 184)
  431.     self.contents = Bitmap.new(width - 32, height - 32)
  432.     self.contents.font.name = "黑体" # = $fontface.is_a?(String) ? $fontface : $defaultfonttype
  433.     self.contents.font.size = 18 # = 20
  434.     @result = nil
  435.     @type = nil
  436.   end
  437.  
  438.   #--------------------------------------------------------------------------
  439.   def refresh
  440.     self.contents.clear
  441.     case @type
  442.       when 0
  443.         item = $data_items[@result]
  444.         if item.recover_hp_rate > item.recover_hp
  445.           hp_string = "体力回复率:"
  446.           hp_stat = item.recover_hp_rate
  447.         else
  448.           hp_string = "体力回复量:"
  449.           hp_stat = item.recover_hp
  450.         end
  451.         if item.recover_sp_rate > item.recover_sp
  452.           sp_string = "精力回复率:"
  453.           sp_stat = item.recover_sp_rate
  454.         else
  455.           sp_string = "精力回复量:"
  456.           sp_stat = item.recover_sp
  457.         end
  458.         @strings = [hp_string, sp_string, "物理防御:" , "魔法防御:", "命中率:", "分散度:"]
  459.         @stats = [hp_stat, sp_stat, item. pdef_f, item.mdef_f, item.hit, item.variance,
  460.                        $game_party.item_number(@result)]
  461.         @bitmap = RPG::Cache.icon(item.icon_name)
  462.       when 1
  463.         item = $data_armors[@result]
  464.         @strings = ["物理防御:", "魔法防御:", "回避修正:", "力量增加:", "灵巧增加:",
  465.                        "速度增加:", "魔力增加:"]
  466.         @stats = [item.pdef, item.mdef, item.eva, item.str_plus, item.dex_plus,
  467.                     item.agi_plus, item.int_plus, $game_party.armor_number(@result) ]
  468.         @bitmap = RPG::Cache.icon(item.icon_name)
  469.       when 2
  470.         item = $data_weapons[@result]
  471.         @strings =["攻击力:", "物理防御:", "魔法防御:", "力量增加:", "灵巧增加:",
  472.                     "速度增加:", "魔力增加:"]
  473.         @stats = [item.atk, item.pdef, item.mdef, item.str_plus, item.dex_plus,
  474.                     item.agi_plus, item.int_plus, $game_party.weapon_number(@result) ]
  475.         @bitmap = RPG::Cache.icon(item.icon_name)
  476.     end
  477.     for i in [email]0...@strings.size[/email]
  478.       x = i%2 * 184
  479.       y = i /2 *28 +32
  480.       self.contents.font.color = normal_color
  481.       self.contents.draw_text(x,y,100, 28,@strings[i])
  482.       self.contents.font.color = system_color
  483.       self.contents.draw_text(x + 110, y, 45, 28, @stats[i].to_s)
  484.     end
  485.     self.contents.blt(0, 0, @bitmap, Rect.new(0, 0, 24, 24), 255)
  486.     self.contents.font.color= normal_color
  487.     self.contents.draw_text(40, 0, 300, 28, "待合成物品的现有数量:")
  488.     self.contents.font.color = system_color
  489.     count = @stats[@stats.size - 1].to_s
  490.     self.contents.draw_text(294, 0, 45, 28, count )
  491.   end
  492.  
  493. #----------------------------------------------------------------------
  494.   def set_result(result , type)
  495.     @result = result
  496.     @type = type
  497.     refresh
  498.   end
  499.  
  500. end #of Window_CraftResult
  501.  
  502. #=======================================
  503. class Window_CraftIngredients < Window_Base
  504.  
  505.   #--------------------------------------------------------------------------
  506.   def initialize
  507.     super(240, 248, 400, 232)
  508.     self.contents = Bitmap.new(width - 32, height - 32)
  509.     self.contents.font.name = "黑体" # = $fontface.is_a?(String) ? $fontface : $defaultfonttype
  510.     self.contents.font.size = 18 # = 20
  511.     @ingredients = []
  512.     @types = []
  513.     @quantities = []
  514.     @item = nil
  515.     @count = 0
  516.   end
  517.  
  518.   #--------------------------------------------------------------------------
  519.   def refresh
  520.     self.contents.clear
  521.     for i in [email]0...@ingredients.size[/email]
  522.       case @types[i]
  523.       when 0
  524.         @item = $data_items[@ingredients[i]]
  525.         @count = $game_party.item_number(@ingredients[i])
  526.       when 1
  527.         @item = $data_armors[@ingredients[i]]
  528.         @count = $game_party.armor_number(@ingredients[i])
  529.       when 2
  530.         @item = $data_weapons[@ingredients[i]]
  531.         @count = $game_party.weapon_number(@ingredients[i])
  532.       end
  533.       y = i *26
  534.       self.contents.blt(0, y, RPG::Cache.icon(@item.icon_name), Rect.new(0, 0, 24, 24), 255)
  535.       self.contents.font.color = @count >= @quantities[i] ? normal_color : disabled_color
  536.       self.contents.draw_text(30, y, 280, 28, @item.name)
  537.       self.contents.draw_text(300, y, 45, 28, @quantities[i].to_s)
  538.       self.contents.font.color = system_color
  539.       self.contents.draw_text(245, y, 45, 28, @count.to_s )     
  540.     end
  541.   end
  542.  
  543.   #--------------------------------------------------------------------------
  544.   def set_ingredients(ingredients , types, quantities)
  545.     @ingredients = ingredients
  546.     @types = types
  547.     @quantities = quantities
  548.     refresh
  549.   end
  550.  
  551. end # of Window_CraftIngredients
  552.  
  553. #======================================
  554. class Scene_Craft
  555.  
  556.   #--------------------------------------------------------------------------
  557.   def initialize(craft_index=0)
  558.     @craft_index=craft_index
  559.   end
  560.  
  561.   #--------------------------------------------------------------------------
  562.   def main
  563.     @craft_window = Window_Craft.new
  564.     @craft_window.index=@craft_index
  565.     @confirm_window = Window_Base.new(120, 188, 400, 64)
  566.     @confirm_window.contents = Bitmap.new(368, 32)
  567.     @confirm_window.contents.font.name = "黑体"
  568.     @confirm_window.contents.font.size = 20
  569.     @help_window = Window_Help.new
  570.     @craft_window.help_window = @help_window
  571.     @result_window=Window_CraftResult.new
  572.     @ingredients_window=Window_CraftIngredients.new
  573.     @yes_no_window = Window_Command.new(100, ["确定", "放弃"])
  574.     @confirm_window.visible = false
  575.     @confirm_window.z = 1500
  576.     @yes_no_window.visible = false
  577.     @yes_no_window.active = false
  578.     @yes_no_window.index = 1
  579.     @yes_no_window.x = 270
  580.     @yes_no_window.y = 252
  581.     @yes_no_window.z = 1500
  582.     @label_window = Window_Base.new(450,200,190,52)
  583.     @label_window.contents=Bitmap.new(@label_window.width - 32,@label_window.height - 32)
  584.     @label_window.contents.font.size=20
  585.     @label_window.contents.font.color = @label_window.normal_color
  586.     @label_window.contents.font.name = "黑体"
  587.     @label_window.contents.draw_text(0, 0, @label_window.contents.width, 20, "  现有   需要")
  588.     Graphics.transition
  589.     loop do
  590.       Graphics.update
  591.       Input.update
  592.       update
  593.       if $scene != self
  594.         break
  595.       end
  596.     end
  597.     Graphics.freeze
  598.     @help_window.dispose
  599.     @craft_window.dispose
  600.     @result_window.dispose
  601.     @ingredients_window.dispose
  602.     @confirm_window.dispose
  603.     @yes_no_window.dispose
  604.     @label_window.dispose
  605.   end
  606.  
  607.   #--------------------------------------------------------------------------
  608.   def update
  609.     @craft_window.update
  610.     @ingredients_window.update
  611.     if $game_party.recipes.size > 0
  612.       @result_window.set_result(@craft_window.recipe.result, @craft_window.recipe.result_type)
  613.       @ingredients_window.set_ingredients(@craft_window.recipe.ingredients,
  614.                                                            @craft_window.recipe.ingredient_types,
  615.                                                            @craft_window.recipe.quantities)
  616.     end
  617.     if @craft_window.active
  618.       update_craft
  619.       return
  620.     end
  621.     if @yes_no_window.active
  622.       confirm_update
  623.       return
  624.     end
  625.   end
  626.  
  627.   #--------------------------------------------------------------------------
  628.   def update_craft
  629.     if Input.trigger?(Input::B)
  630.       $game_system.se_play($data_system.cancel_se)
  631.       $scene = Scene_Map.new
  632.       return
  633.     end
  634.     if Input.trigger?(Input::C) and $game_party.recipes.size != 0
  635.       @recipe = @craft_window.recipe
  636.       if @recipe.have
  637.         @yes_no_window.active = true
  638.         @craft_window.active = false
  639.       else
  640.         $game_system.se_play($data_system.buzzer_se)
  641.         return
  642.       end
  643.     end
  644.   end
  645.  
  646.   #--------------------------------------------------------------------------
  647.   def confirm_update
  648.     @craft_index = @craft_window.index
  649.     @confirm_window.visible = true
  650.     @confirm_window.z = 1500
  651.     @yes_no_window.visible = true
  652.     @yes_no_window.active = true
  653.     @yes_no_window.z = 1500
  654.     @yes_no_window.update
  655.     string = "合成 " + @recipe.name + "?"
  656.     cw = @confirm_window.contents.text_size(string).width
  657.     center = @confirm_window.contents.width/2 - cw /2
  658.     unless @drawn
  659.       @confirm_window.contents.draw_text(center, 0, cw, 30, string)
  660.       @drawn = true
  661.     end
  662.     if Input.trigger?(Input::C)
  663.       if @yes_no_window.index == 0
  664.         $game_system.se_play($data_system.decision_se)
  665.         @recipe.make
  666.         $game_system.se_play($data_system.save_se)
  667.         $scene=Scene_Craft.new(@craft_index)
  668.       else
  669.         $game_system.se_play($data_system.cancel_se)
  670.         $scene=Scene_Craft.new(@craft_index)
  671.       end
  672.     end
  673.     if Input.trigger?(Input::B)
  674.       $game_system.se_play($data_system.cancel_se)
  675.       $scene=Scene_Craft.new(@craft_index)
  676.     end
  677.   end
  678.  
  679. end # of Scene_Craft
  680.  
  681. #==============================================================================
  682. # 本脚本来自[url]www.66RPG.com[/url],使用和转载请保留此信息
  683. #==============================================================================
拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

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

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

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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