Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- module Cooking
- Recipes = {
- # ID => [ITEM_ID, FAIL_ITEM_ID, REQ_LV, EXP_GAINED]
- 1 => [2, 20, 1, 100],
- 2 => [3, 1, 2, 300]
- }
- def self.ingredients(id)
- case id
- when 1
- return [[1, 3], [2, 1]]
- when 2
- return [[1, 2], [2, 3]]
- end
- end
- end
- class Game_Party < Game_Unit
- attr_reader :cooking_lv
- attr_reader :learned_recipes
- alias init_cooking_skills initialize unless $@
- def initiliaze(*args)
- init_cooking_skills(*args)
- @cooking_lv = 1
- @cooking_exp = 0
- @cooking_exp_list = [0, 100, 200, 500, 700, 2000, 10000]
- @learned_recipes = []
- end
- def gain_cooking_exp(value)
- @cooking_exp += value
- @cooking_exp = [@cooking_exp, 9999].max
- if @cookign_exp_list[@cooking_lv] < @cooking_exp
- gain_cooking_lv
- end
- end
- def gain_cooking_lv
- @cooking_lv += 1
- end
- def learn_recipe(number)
- @learned_recipes.push(number)
- @learned_recipes.sort!
- end
- def forget_recipe(number)
- @learned_recipes.delete(number)
- end
- end
- class Cooking_Title < Window_Base
- def initialize
- super(0, 0, 544, 64)
- refresh
- end
- def refresh
- create_contents
- fsize = self.contents.font.size
- self.contents.font.size = 24
- self.contents.draw_text(0, 0, 544, line_height+8, "Cooking")
- self.contents.font.size = fsize
- self.contents.draw_text(0, 0, 544, line_height+8, "Level : #($game_party.cooking_lv)", 2)
- end
- end
- class Cooking_Available_List < Window_Selectable
- def initialize
- super(0, 64, 544/3, 416-64)
- refresh
- end
- def refresh
- recipes = $game_party.learned_recipes
- @item_max = recipes.size
- create_contents
- for i in 0...@item_max
- recipe_data = Cooking::Recipes[recipes[i]]
- current_lv = $game_party.cooking_lv
- if recipe_data[2] > current_lv
- draw_recipe_disabled(i)
- else
- draw_recipe_enabled(i)
- end
- end
- end
- def draw_recipe_disabled(index)
- fcolor = self.contents.font.color
- self.contents.font.color = Color.new(50, 50, 50, 255)
- rect = item_rect(index)
- recipe_id = $game_party.learned_recipes[index]
- recipe_data = Cooking::Recipes[recipe_id]
- item_id = recipe_data[0]
- item = $data_items[item_id]
- self.contents.draw_text(rect, item.name)
- self.contents.font.color = fcolor
- end
- def draw_recipe_enabled(index)
- self.contents.font.color = normal_color
- rect = item_rect(index)
- recipe_id = $game_party.learned_recipes[index]
- recipe_data = Cooking::Recipes[recipe_id]
- item_id = recipe_data[0]
- item = $data_items[item_id]
- self.contents.draw_text(rect, item.name)
- end
- end
- class Cooking_Details < Window_Selectable
- def initialize
- super(544/3, 64, 544*(2/3), 416-64)
- refresh
- end
- def refresh(recipe = nil)
- @recipe = recipe
- create_contents
- return if recipe == nil
- @recipe_data = Cooking::Recipes[@recipe]
- @item = $data_items[@recipe_data[0]]
- fsize = self.contents.font.size
- self.contents.font.size = 24
- self.contents.font.bold = true
- self.contents.draw_text(0,0,width-32, line_height+8, @item.name, 1)
- draw_icon(@item.icon_index, ((width-32)/2)-12, line_height+16)
- draw_item_description
- draw_ingredients
- end
- def draw_item_description
- end
- def draw_ingredients
- end
- end
- class Scene_Cooking < Scene_Base
- def start
- create_windows
- end
- def create_windows
- @title = Cooking_Title.new
- @list = Cooking_Available_List.new
- @details = Cooking_Details.new
- @list.active = true
- @list.index = 0
- @details.active = false
- end
- def post_start
- end
- def update
- if @list.active == true
- update_list
- return
- end
- if @details.active == true
- update_details
- return
- end
- end
- def update_list
- if Input.trigger?(Input::C)
- recipe_id = $game_party.learned_recipes[@list.index]
- data = Cooking::Recipes[recipe_id]
- if data[2] > $game_party.cooking_lv
- Sound.play_buzzer
- return
- end
- Sound.play_decision
- @list.active = false
- @details.active = true
- @details.index = 0
- end
- if Input.trigger?(Input::B)
- Sound.play_cancel
- SceneManager.goto(Scene_Map)
- end
- end
- def pre_terminate
- end
- def terminate
- @title.dispose
- @list.dispose
- @details.dispose
- end
- end
- class Game_Interpreter
- def learn_recipe(number)
- $game_party.learn_recipe(number)
- end
- def forget_recipe(number)
- $game_party.forget_recipe(number)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement