Advertisement
Guest User

Untitled

a guest
Sep 20th, 2014
195
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 4.57 KB | None | 0 0
  1. module Cooking
  2.   Recipes = {
  3.   # ID => [ITEM_ID, FAIL_ITEM_ID, REQ_LV, EXP_GAINED]
  4.   1 => [2, 20, 1, 100],
  5.   2 => [3, 1, 2, 300]
  6.   }
  7.   def self.ingredients(id)
  8.     case id
  9.     when 1
  10.       return [[1, 3], [2, 1]]
  11.     when 2
  12.       return [[1, 2], [2, 3]]
  13.     end
  14.   end
  15. end
  16.  
  17.  
  18. class Game_Party < Game_Unit
  19.   attr_reader :cooking_lv
  20.   attr_reader :learned_recipes
  21.   alias init_cooking_skills initialize unless $@
  22.   def initiliaze(*args)
  23.     init_cooking_skills(*args)
  24.     @cooking_lv = 1
  25.     @cooking_exp = 0
  26.     @cooking_exp_list = [0, 100, 200, 500, 700, 2000, 10000]
  27.     @learned_recipes = []
  28.   end
  29.   def gain_cooking_exp(value)
  30.     @cooking_exp  += value
  31.     @cooking_exp = [@cooking_exp, 9999].max
  32.     if @cookign_exp_list[@cooking_lv] < @cooking_exp
  33.       gain_cooking_lv
  34.     end
  35.   end
  36.   def gain_cooking_lv
  37.     @cooking_lv += 1
  38.   end
  39.   def learn_recipe(number)
  40.     @learned_recipes.push(number)
  41.     @learned_recipes.sort!
  42.   end
  43.   def forget_recipe(number)
  44.     @learned_recipes.delete(number)
  45.   end
  46. end
  47.  
  48.  
  49. class Cooking_Title < Window_Base
  50.   def initialize
  51.     super(0, 0, 544, 64)
  52.     refresh
  53.   end
  54.   def refresh
  55.     create_contents
  56.     fsize = self.contents.font.size
  57.     self.contents.font.size = 24
  58.     self.contents.draw_text(0, 0, 544, line_height+8, "Cooking")
  59.     self.contents.font.size = fsize
  60.     self.contents.draw_text(0, 0, 544, line_height+8, "Level : #($game_party.cooking_lv)", 2)
  61.   end
  62. end
  63.  
  64. class Cooking_Available_List < Window_Selectable
  65.   def initialize
  66.     super(0, 64, 544/3, 416-64)
  67.     refresh
  68.   end
  69.   def refresh
  70.     recipes = $game_party.learned_recipes
  71.     @item_max = recipes.size
  72.     create_contents
  73.     for i in 0...@item_max
  74.       recipe_data = Cooking::Recipes[recipes[i]]
  75.       current_lv = $game_party.cooking_lv
  76.       if recipe_data[2] > current_lv
  77.         draw_recipe_disabled(i)
  78.       else
  79.         draw_recipe_enabled(i)
  80.       end
  81.     end
  82.   end
  83.   def draw_recipe_disabled(index)
  84.     fcolor = self.contents.font.color
  85.     self.contents.font.color = Color.new(50, 50, 50, 255)
  86.     rect = item_rect(index)
  87.     recipe_id = $game_party.learned_recipes[index]
  88.     recipe_data = Cooking::Recipes[recipe_id]
  89.     item_id = recipe_data[0]
  90.     item = $data_items[item_id]
  91.     self.contents.draw_text(rect, item.name)
  92.     self.contents.font.color = fcolor
  93.   end
  94.   def draw_recipe_enabled(index)
  95.     self.contents.font.color = normal_color
  96.     rect = item_rect(index)
  97.     recipe_id = $game_party.learned_recipes[index]
  98.     recipe_data = Cooking::Recipes[recipe_id]
  99.     item_id = recipe_data[0]
  100.     item = $data_items[item_id]
  101.     self.contents.draw_text(rect, item.name)
  102.   end
  103. end
  104.  
  105.  
  106. class Cooking_Details < Window_Selectable
  107.   def initialize
  108.     super(544/3, 64, 544*(2/3), 416-64)
  109.     refresh
  110.   end
  111.   def refresh(recipe = nil)
  112.     @recipe = recipe
  113.     create_contents
  114.     return if recipe == nil
  115.     @recipe_data = Cooking::Recipes[@recipe]
  116.     @item = $data_items[@recipe_data[0]]
  117.     fsize = self.contents.font.size
  118.     self.contents.font.size = 24
  119.     self.contents.font.bold = true
  120.     self.contents.draw_text(0,0,width-32, line_height+8, @item.name, 1)
  121.     draw_icon(@item.icon_index, ((width-32)/2)-12, line_height+16)
  122.     draw_item_description
  123.     draw_ingredients
  124.   end
  125.   def draw_item_description
  126.    
  127.   end
  128.   def draw_ingredients
  129.    
  130.   end
  131. end
  132.  
  133. class Scene_Cooking < Scene_Base
  134.   def start
  135.     create_windows
  136.   end
  137.   def create_windows
  138.     @title = Cooking_Title.new
  139.     @list = Cooking_Available_List.new
  140.     @details = Cooking_Details.new
  141.     @list.active = true
  142.     @list.index = 0
  143.     @details.active = false
  144.   end
  145.   def post_start
  146.    
  147.   end
  148.   def update
  149.     if @list.active == true
  150.       update_list
  151.       return
  152.     end
  153.     if @details.active == true
  154.       update_details
  155.       return
  156.     end
  157.   end
  158.   def update_list
  159.     if Input.trigger?(Input::C)
  160.       recipe_id = $game_party.learned_recipes[@list.index]
  161.       data = Cooking::Recipes[recipe_id]
  162.       if data[2] > $game_party.cooking_lv
  163.         Sound.play_buzzer
  164.         return
  165.       end
  166.       Sound.play_decision
  167.       @list.active = false
  168.       @details.active = true
  169.       @details.index = 0
  170.     end
  171.     if Input.trigger?(Input::B)
  172.       Sound.play_cancel
  173.       SceneManager.goto(Scene_Map)
  174.     end
  175.   end
  176.   def pre_terminate
  177.    
  178.   end
  179.   def terminate
  180.     @title.dispose
  181.     @list.dispose
  182.     @details.dispose
  183.   end
  184. end
  185.  
  186. class Game_Interpreter
  187.   def learn_recipe(number)
  188.     $game_party.learn_recipe(number)
  189.   end
  190.   def forget_recipe(number)
  191.     $game_party.forget_recipe(number)
  192.   end
  193. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement