赞 | 13 |
VIP | 0 |
好人卡 | 0 |
积分 | 12 |
经验 | 0 |
最后登录 | 2024-11-22 |
在线时间 | 100 小时 |
Lv3.寻梦者
- 梦石
- 0
- 星屑
- 1188
- 在线时间
- 100 小时
- 注册时间
- 2022-1-14
- 帖子
- 29
|
加入我们,或者,欢迎回来。
您需要 登录 才可以下载或查看,没有帐号?注册会员
x
主要问题就是界面打开之后,即使金钱和素材足够,也会显示素材无法选择……
传不了图,简单po一下用法
事件脚本:
SceneManager.call(Scene_MakeItem)
SceneManager.scene.prepare(0)
代码:
#============================================================================== # ■ Scene_MakeItem #------------------------------------------------------------------------------ # 表单式合成界面 #============================================================================== #~模块 module INDIX_MAKEITEM_INI TABLE1 = [[0, 3, 50, [1,1], [2,1] ], [0, 4, 60, [1,1], [2,2] ] #[(0物品/1武器/2护甲), 3(id), 50(制作价格), [1(id(物品)),1(数量)],[2,1]] ] #一个表单里包含一套物品制作方式,使用时直接调用表单 TABLE2 = [[1,10, 50, [1,2], [2,1] ], [2, 6, 60, [1,1], [2,1] ] ] def table return [TABLE1, TABLE2] #实际调用时以table[1]表示第0个表单,以此类推 end end #~列表窗口 class Window_MakeItemList < Window_Selectable include INDIX_MAKEITEM_INI def initialize(x, y, height, page) super(x, y, window_width, height) @page = page @shop_goods = [] @shop_recipes = [] for i in 0...table[@page].size recipe = table[@page][i] if recipe good = [recipe[0],recipe[1], recipe[2]] @shop_goods.push(good) @shop_recipes.push(recipe) end end @money = 0 refresh select(0) end def window_width return 304 end def item_max #项目最大数 @data ? @data.size : 1 end def item #项目获取 @data[index] end def money=(money) #所持金 @money = money refresh end def current_item_enabled? #选择项目的有效状态 enable?(@data[index]) end def price(item) #价格 @price[item] end def enable?(item) #是否可用 @makable[item] end def recipe(item) #配方 @recipe[item] end def have_mat?(recipe) flag = true if @money >= recipe[2] for i in 3...recipe.size id = recipe[i][0] num = recipe[i][1] item = $data_items[id] if $game_party.item_number(item) < [num, 1].max flag = false end end else flag = false end return flag end def refresh #刷新 make_item_list create_contents draw_all_items end def make_item_list #列表作成 @data = [] @price = {} @makable = {} @recipe = {} for i in 0...@shop_goods.size goods = @shop_goods[i] recipe = @shop_recipes[i] case goods[0] when 0; item = $data_items[goods[1]] when 1; item = $data_weapons[goods[1]] when 2; item = $data_armors[goods[1]] end if item @data.push(item) @price[item] = goods[2] @makable[item] = have_mat?(recipe) @recipe[item] = recipe end end end def draw_item(index) #绘制项目 item = @data[index] rect = item_rect(index) draw_item_name(item, rect.x, rect.y, enable?(item)) rect.width -= 4 draw_text(rect, price(item), 2) end def material_window=(material_window) @material_window = material_window call_update_help end def update_help @help_window.set_item(item) if @help_window @material_window.set(item, recipe(item)) if @material_window end end #~素材窗口 class Window_MakeItemMaterial < Window_Base def initialize(x, y, width, height) super(x, y, width, height) @item = nil refresh end def refresh contents.clear draw_possession(4, 0) draw_material_info(0, line_height * 2) end #设定物品 def set(item, recipe) @item = item @recipe = recipe @make_number = 1 refresh end #设定个数 def set_num(make_number) @make_number = make_number refresh end #绘制所持数 def draw_possession(x, y) rect = Rect.new(x, y, contents.width - 4 - x, line_height) change_color(system_color) draw_text(rect, Vocab::Possession) change_color(normal_color) draw_text(rect, $game_party.item_number(@item), 2) end #绘制素材情报 def draw_material_info(x, y) rect = Rect.new(x, y, contents.width, line_height) change_color(system_color) contents.font.size = 18 draw_text(rect, "素材", 0) if @recipe for i in 3...@recipe.size id = @recipe[i][0] num = @recipe[i][1] item = $data_items[id] rect = Rect.new(x, y + line_height*i, contents.width, line_height) enabled = true enabled = false if [num*@make_number, 1].max > $game_party.item_number(item) draw_item_name(item, rect.x, rect.y, enabled) change_color(normal_color, enabled) if num > 0 draw_text(rect, "#{num*@make_number}/#{$game_party.item_number(item)}", 2) end end end change_color(normal_color) contents.font.size = 24 end end #~输入个数窗口 class Window_MakeItemNumber < Window_ShopNumber def refresh contents.clear draw_item_name(@item, 0, item_y) draw_number draw_total_price end def material_window=(material_window) @material_window = material_window call_update_help end #个数变更 def change_number(amount) @number = [[@number + amount, @max].min, 1].max call_update_help #追加 end def call_update_help @material_window.set_num(@number) if @material_window end end #~合成物品场景 class Scene_MakeItem < Scene_MenuBase #准备 def prepare(page) @page = page end #开始 def start super create_help_window create_number_window create_gold_window create_material_window create_list_window end def create_number_window wy = @help_window.height wh = Graphics.height - wy @number_window = Window_MakeItemNumber.new(0, wy, wh) @number_window.viewport = @viewport @number_window.hide @number_window.set_handler(:ok, method(:on_number_ok)) @number_window.set_handler(:cancel, method(:on_number_cancel)) end def create_gold_window @gold_window = Window_Gold.new @gold_window.viewport = @viewport @gold_window.x = @number_window.width @gold_window.y = @help_window.height @gold_window.width = Graphics.width - @number_window.width end def create_material_window wx = @number_window.width wy = @help_window.height + @gold_window.height ww = Graphics.width - wx wh = Graphics.height - wy @material_window = Window_MakeItemMaterial.new(wx, wy, ww, wh) @material_window.viewport = @viewport @number_window.material_window = @material_window end def create_list_window wy = @help_window.height wh = Graphics.height - wy @list_window = Window_MakeItemList.new(0, wy, wh, @page) @list_window.viewport = @viewport @list_window.help_window = @help_window @list_window.material_window = @material_window @list_window.activate @list_window.set_handler(:ok, method(:on_list_ok)) @list_window.set_handler(:cancel, method(:return_scene)) end #启用物品列表 def activate_list_window @list_window.money = money @list_window.show.activate end #-------------------------------------------------------------------------- # ● 合成[決定] #-------------------------------------------------------------------------- def on_list_ok @item = @list_window.item @list_window.hide @number_window.set(@item, max_buy, buying_price, currency_unit) @number_window.show.activate end #-------------------------------------------------------------------------- # ● 個数入力[決定] #-------------------------------------------------------------------------- def on_number_ok Sound.play_shop do_syntetic(@number_window.number) end_number_input @gold_window.refresh end #-------------------------------------------------------------------------- # ● 個数入力[キャンセル] #-------------------------------------------------------------------------- def on_number_cancel Sound.play_cancel end_number_input end #-------------------------------------------------------------------------- # ● 合成の実行 #-------------------------------------------------------------------------- def do_syntetic(number) $game_party.lose_gold(number * buying_price) $game_party.gain_item(@item, number) @recipe = @list_window.recipe(@item) for i in 3...@recipe.size id = @recipe[i][0] num = @recipe[i][1] item = $data_items[id] $game_party.lose_item(item, num*number) end end #-------------------------------------------------------------------------- # ● 個数入力の終了 #-------------------------------------------------------------------------- def end_number_input @number_window.hide activate_list_window end #-------------------------------------------------------------------------- # ● 最大購入可能個数の取得 #-------------------------------------------------------------------------- def max_buy max = $game_party.max_item_number(@item) - $game_party.item_number(@item) @recipe = @list_window.recipe(@item) for i in 3...@recipe.size id = @recipe[i][0] num = @recipe[i][1] item = $data_items[id] if num > 0 max_buf = $game_party.item_number(item)/num else max_buf = 999 end max = [max, max_buf].min end buying_price == 0 ? max : [max, money / buying_price].min end #-------------------------------------------------------------------------- # ● 所持金の取得 #-------------------------------------------------------------------------- def money @gold_window.value end #-------------------------------------------------------------------------- # ● 通貨単位の取得 #-------------------------------------------------------------------------- def currency_unit @gold_window.currency_unit end #-------------------------------------------------------------------------- # ● 合成費用の取得 #-------------------------------------------------------------------------- def buying_price @list_window.price(@item) end end
#==============================================================================
# ■ Scene_MakeItem
#------------------------------------------------------------------------------
# 表单式合成界面
#==============================================================================
#~模块
module INDIX_MAKEITEM_INI
TABLE1 = [[0, 3, 50, [1,1], [2,1] ],
[0, 4, 60, [1,1], [2,2] ]
#[(0物品/1武器/2护甲), 3(id), 50(制作价格), [1(id(物品)),1(数量)],[2,1]]
] #一个表单里包含一套物品制作方式,使用时直接调用表单
TABLE2 = [[1,10, 50, [1,2], [2,1] ],
[2, 6, 60, [1,1], [2,1] ]
]
def table
return [TABLE1, TABLE2] #实际调用时以table[1]表示第0个表单,以此类推
end
end
#~列表窗口
class Window_MakeItemList < Window_Selectable
include INDIX_MAKEITEM_INI
def initialize(x, y, height, page)
super(x, y, window_width, height)
@page = page
@shop_goods = []
@shop_recipes = []
for i in 0...table[@page].size
recipe = table[@page][i]
if recipe
good = [recipe[0],recipe[1], recipe[2]]
@shop_goods.push(good)
@shop_recipes.push(recipe)
end
end
@money = 0
refresh
select(0)
end
def window_width
return 304
end
def item_max #项目最大数
@data ? @data.size : 1
end
def item #项目获取
@data[index]
end
def money=(money) #所持金
@money = money
refresh
end
def current_item_enabled? #选择项目的有效状态
enable?(@data[index])
end
def price(item) #价格
@price[item]
end
def enable?(item) #是否可用
@makable[item]
end
def recipe(item) #配方
@recipe[item]
end
def have_mat?(recipe)
flag = true
if @money >= recipe[2]
for i in 3...recipe.size
id = recipe[i][0]
num = recipe[i][1]
item = $data_items[id]
if $game_party.item_number(item) < [num, 1].max
flag = false
end
end
else
flag = false
end
return flag
end
def refresh #刷新
make_item_list
create_contents
draw_all_items
end
def make_item_list #列表作成
@data = []
@price = {}
@makable = {}
@recipe = {}
for i in 0...@shop_goods.size
goods = @shop_goods[i]
recipe = @shop_recipes[i]
case goods[0]
when 0; item = $data_items[goods[1]]
when 1; item = $data_weapons[goods[1]]
when 2; item = $data_armors[goods[1]]
end
if item
@data.push(item)
@price[item] = goods[2]
@makable[item] = have_mat?(recipe)
@recipe[item] = recipe
end
end
end
def draw_item(index) #绘制项目
item = @data[index]
rect = item_rect(index)
draw_item_name(item, rect.x, rect.y, enable?(item))
rect.width -= 4
draw_text(rect, price(item), 2)
end
def material_window=(material_window)
@material_window = material_window
call_update_help
end
def update_help
@help_window.set_item(item) if @help_window
@material_window.set(item, recipe(item)) if @material_window
end
end
#~素材窗口
class Window_MakeItemMaterial < Window_Base
def initialize(x, y, width, height)
super(x, y, width, height)
@item = nil
refresh
end
def refresh
contents.clear
draw_possession(4, 0)
draw_material_info(0, line_height * 2)
end
#设定物品
def set(item, recipe)
@item = item
@recipe = recipe
@make_number = 1
refresh
end
#设定个数
def set_num(make_number)
@make_number = make_number
refresh
end
#绘制所持数
def draw_possession(x, y)
rect = Rect.new(x, y, contents.width - 4 - x, line_height)
change_color(system_color)
draw_text(rect, Vocab::Possession)
change_color(normal_color)
draw_text(rect, $game_party.item_number(@item), 2)
end
#绘制素材情报
def draw_material_info(x, y)
rect = Rect.new(x, y, contents.width, line_height)
change_color(system_color)
contents.font.size = 18
draw_text(rect, "素材", 0)
if @recipe
for i in 3...@recipe.size
id = @recipe[i][0]
num = @recipe[i][1]
item = $data_items[id]
rect = Rect.new(x, y + line_height*i, contents.width, line_height)
enabled = true
enabled = false if [num*@make_number, 1].max > $game_party.item_number(item)
draw_item_name(item, rect.x, rect.y, enabled)
change_color(normal_color, enabled)
if num > 0
draw_text(rect, "#{num*@make_number}/#{$game_party.item_number(item)}", 2)
end
end
end
change_color(normal_color)
contents.font.size = 24
end
end
#~输入个数窗口
class Window_MakeItemNumber < Window_ShopNumber
def refresh
contents.clear
draw_item_name(@item, 0, item_y)
draw_number
draw_total_price
end
def material_window=(material_window)
@material_window = material_window
call_update_help
end
#个数变更
def change_number(amount)
@number = [[@number + amount, @max].min, 1].max
call_update_help #追加
end
def call_update_help
@material_window.set_num(@number) if @material_window
end
end
#~合成物品场景
class Scene_MakeItem < Scene_MenuBase
#准备
def prepare(page)
@page = page
end
#开始
def start
super
create_help_window
create_number_window
create_gold_window
create_material_window
create_list_window
end
def create_number_window
wy = @help_window.height
wh = Graphics.height - wy
@number_window = Window_MakeItemNumber.new(0, wy, wh)
@number_window.viewport = @viewport
@number_window.hide
@number_window.set_handler(:ok, method(:on_number_ok))
@number_window.set_handler(:cancel, method(:on_number_cancel))
end
def create_gold_window
@gold_window = Window_Gold.new
@gold_window.viewport = @viewport
@gold_window.x = @number_window.width
@gold_window.y = @help_window.height
@gold_window.width = Graphics.width - @number_window.width
end
def create_material_window
wx = @number_window.width
wy = @help_window.height + @gold_window.height
ww = Graphics.width - wx
wh = Graphics.height - wy
@material_window = Window_MakeItemMaterial.new(wx, wy, ww, wh)
@material_window.viewport = @viewport
@number_window.material_window = @material_window
end
def create_list_window
wy = @help_window.height
wh = Graphics.height - wy
@list_window = Window_MakeItemList.new(0, wy, wh, @page)
@list_window.viewport = @viewport
@list_window.help_window = @help_window
@list_window.material_window = @material_window
@list_window.activate
@list_window.set_handler(:ok, method(:on_list_ok))
@list_window.set_handler(:cancel, method(:return_scene))
end
#启用物品列表
def activate_list_window
@list_window.money = money
@list_window.show.activate
end
#--------------------------------------------------------------------------
# ● 合成[決定]
#--------------------------------------------------------------------------
def on_list_ok
@item = @list_window.item
@list_window.hide
@number_window.set(@item, max_buy, buying_price, currency_unit)
@number_window.show.activate
end
#--------------------------------------------------------------------------
# ● 個数入力[決定]
#--------------------------------------------------------------------------
def on_number_ok
Sound.play_shop
do_syntetic(@number_window.number)
end_number_input
@gold_window.refresh
end
#--------------------------------------------------------------------------
# ● 個数入力[キャンセル]
#--------------------------------------------------------------------------
def on_number_cancel
Sound.play_cancel
end_number_input
end
#--------------------------------------------------------------------------
# ● 合成の実行
#--------------------------------------------------------------------------
def do_syntetic(number)
$game_party.lose_gold(number * buying_price)
$game_party.gain_item(@item, number)
@recipe = @list_window.recipe(@item)
for i in 3...@recipe.size
id = @recipe[i][0]
num = @recipe[i][1]
item = $data_items[id]
$game_party.lose_item(item, num*number)
end
end
#--------------------------------------------------------------------------
# ● 個数入力の終了
#--------------------------------------------------------------------------
def end_number_input
@number_window.hide
activate_list_window
end
#--------------------------------------------------------------------------
# ● 最大購入可能個数の取得
#--------------------------------------------------------------------------
def max_buy
max = $game_party.max_item_number(@item) - $game_party.item_number(@item)
@recipe = @list_window.recipe(@item)
for i in 3...@recipe.size
id = @recipe[i][0]
num = @recipe[i][1]
item = $data_items[id]
if num > 0
max_buf = $game_party.item_number(item)/num
else
max_buf = 999
end
max = [max, max_buf].min
end
buying_price == 0 ? max : [max, money / buying_price].min
end
#--------------------------------------------------------------------------
# ● 所持金の取得
#--------------------------------------------------------------------------
def money
@gold_window.value
end
#--------------------------------------------------------------------------
# ● 通貨単位の取得
#--------------------------------------------------------------------------
def currency_unit
@gold_window.currency_unit
end
#--------------------------------------------------------------------------
# ● 合成費用の取得
#--------------------------------------------------------------------------
def buying_price
@list_window.price(@item)
end
end
|
|