赞 | 0 |
VIP | 0 |
好人卡 | 0 |
积分 | 1 |
经验 | 14813 |
最后登录 | 2016-11-13 |
在线时间 | 135 小时 |
Lv1.梦旅人
- 梦石
- 0
- 星屑
- 52
- 在线时间
- 135 小时
- 注册时间
- 2011-11-5
- 帖子
- 83
|
加入我们,或者,欢迎回来。
您需要 登录 才可以下载或查看,没有帐号?注册会员
x
本帖最后由 ji3rul4coco 于 2013-7-20 12:35 编辑
倉庫系統測試時,跑出這個↓
腳本如下
Window_WarehouseCommand
#encoding:utf-8 # ———————————————————————————————————— # 本脚本来自[url]www.66rpg.com[/url],转载请保留此信息 # ———————————————————————————————————— #============================================================================== #============================================================================== # ■ Window_WarehouseCommand #------------------------------------------------------------------------------ # 仓库画面中,选择存入/取出的窗口。 #============================================================================== class Window_WarehouseCommand < Window_HorzCommand #-------------------------------------------------------------------------- # ● 初始化对象 #-------------------------------------------------------------------------- def initialize(window_width, purchase_only) @window_width = window_width super(0, 0) end #-------------------------------------------------------------------------- # ● 获取窗口的宽度 #-------------------------------------------------------------------------- def window_width @window_width end #-------------------------------------------------------------------------- # ● 获取列数 #-------------------------------------------------------------------------- def col_max return 3 end #-------------------------------------------------------------------------- # ● 生成指令列表 #-------------------------------------------------------------------------- def make_command_list add_command("存入", :save , have_item) add_command("取出", :get , have_item(1)) add_command("取消", :cancel) end #-------------------------------------------------------------------------- # ● 仓库是否拥有物品 #-------------------------------------------------------------------------- def have_item(where = 0) case where when 0 data = [] # 例遍武器 for i in 1...$data_weapons.size if $game_party.item_number($data_weapons[i]) > 0 data.push($data_weapons[i]) end end # 例遍物品 for i in 1...$data_items.size if $game_party.item_number($data_items[i]) > 0 data.push($data_items[i]) end end # 例遍防具 for i in 1...$data_armors.size if $game_party.item_number($data_armors[i]) > 0 data.push($data_armors[i]) end end when 1 data = [] # 例遍武器 for i in 1...$data_weapons.size if $game_party.ware_num($data_weapons[i]) > 0 data.push($data_weapons[i]) end end # 例遍物品 for i in 1...$data_items.size if $game_party.ware_num($data_items[i]) > 0 data.push($data_items[i]) end end # 例遍防具 for i in 1...$data_armors.size if $game_party.ware_num($data_armors[i]) > 0 data.push($data_armors[i]) end end end if data != [] return true else return false end end end
#encoding:utf-8
# ————————————————————————————————————
# 本脚本来自[url]www.66rpg.com[/url],转载请保留此信息
# ————————————————————————————————————
#==============================================================================
#==============================================================================
# ■ Window_WarehouseCommand
#------------------------------------------------------------------------------
# 仓库画面中,选择存入/取出的窗口。
#==============================================================================
class Window_WarehouseCommand < Window_HorzCommand
#--------------------------------------------------------------------------
# ● 初始化对象
#--------------------------------------------------------------------------
def initialize(window_width, purchase_only)
@window_width = window_width
super(0, 0)
end
#--------------------------------------------------------------------------
# ● 获取窗口的宽度
#--------------------------------------------------------------------------
def window_width
@window_width
end
#--------------------------------------------------------------------------
# ● 获取列数
#--------------------------------------------------------------------------
def col_max
return 3
end
#--------------------------------------------------------------------------
# ● 生成指令列表
#--------------------------------------------------------------------------
def make_command_list
add_command("存入", :save , have_item)
add_command("取出", :get , have_item(1))
add_command("取消", :cancel)
end
#--------------------------------------------------------------------------
# ● 仓库是否拥有物品
#--------------------------------------------------------------------------
def have_item(where = 0)
case where
when 0
data = []
# 例遍武器
for i in 1...$data_weapons.size
if $game_party.item_number($data_weapons[i]) > 0
data.push($data_weapons[i])
end
end
# 例遍物品
for i in 1...$data_items.size
if $game_party.item_number($data_items[i]) > 0
data.push($data_items[i])
end
end
# 例遍防具
for i in 1...$data_armors.size
if $game_party.item_number($data_armors[i]) > 0
data.push($data_armors[i])
end
end
when 1
data = []
# 例遍武器
for i in 1...$data_weapons.size
if $game_party.ware_num($data_weapons[i]) > 0
data.push($data_weapons[i])
end
end
# 例遍物品
for i in 1...$data_items.size
if $game_party.ware_num($data_items[i]) > 0
data.push($data_items[i])
end
end
# 例遍防具
for i in 1...$data_armors.size
if $game_party.ware_num($data_armors[i]) > 0
data.push($data_armors[i])
end
end
end
if data != []
return true
else
return false
end
end
end
Window_WarehouseItem
#encoding:utf-8 # ———————————————————————————————————— # 本腳本來自[url]www.66rpg.com[/url],轉載請保留此信息 # ———————————————————————————————————— #============================================================================== # ■ Window_WarehouseItemSave #------------------------------------------------------------------------------ # 倉庫畫面中,存入物品的窗口。 #============================================================================== class Window_WarehouseItem < Window_Selectable #-------------------------------------------------------------------------- # ● 初始化對象 #-------------------------------------------------------------------------- def initialize(x, y, width, height, items = []) super(x, y, width, height) @action = 0 @data = [] end #-------------------------------------------------------------------------- # ● 獲取項目數 #-------------------------------------------------------------------------- def item_max @data ? @data.size : 0 end #-------------------------------------------------------------------------- # ● 刷新 #-------------------------------------------------------------------------- def refresh make_item_list create_contents if action != 0 draw_all_items end end #-------------------------------------------------------------------------- # ● 設置窗口動作 0:無 1:儲存 2:取出 #-------------------------------------------------------------------------- def set_action(action = 0) @action = action end #-------------------------------------------------------------------------- # ● 取得窗口動作 #-------------------------------------------------------------------------- def action return @action end #========================================================================== # ■ 生成物品列表 #========================================================================== def make_item_list case self.action when 0 @data = [] when 1 list_item when 2 list_ware end end #-------------------------------------------------------------------------- # ● 獲取背包物品 #-------------------------------------------------------------------------- def list_item @data = [] # 例遍武器 for i in 1...$data_weapons.size if $game_party.item_number($data_weapons[i]) > 0 @data.push($data_weapons[i]) end end # 例遍物品 for i in 1...$data_items.size if $game_party.item_number($data_items[i]) > 0 @data.push($data_items[i]) end end # 例遍防具 for i in 1...$data_armors.size if $game_party.item_number($data_armors[i]) > 0 @data.push($data_armors[i]) end end end #-------------------------------------------------------------------------- # ● 獲取倉庫物品 #-------------------------------------------------------------------------- def list_ware @data = [] # 例遍武器 for i in 1...$data_weapons.size if $game_party.ware_num($data_weapons[i]) > 0 @data.push($data_weapons[i]) end end # 例遍物品 for i in 1...$data_items.size if $game_party.ware_num($data_items[i]) > 0 @data.push($data_items[i]) end end # 例遍防具 for i in 1...$data_armors.size if $game_party.ware_num($data_armors[i]) > 0 @data.push($data_armors[i]) end end end #-------------------------------------------------------------------------- # ● 倉庫是否擁有物品 #-------------------------------------------------------------------------- def have_item(where = 0) case where when 0 list_item when 1 list_ware end if @data == [] return true else return false end end #-------------------------------------------------------------------------- # ■ 繪製項目 #-------------------------------------------------------------------------- def draw_item(index) case self.action when 1 draw_items(index) when 2 draw_ware(index) end end #-------------------------------------------------------------------------- # ● 背包物品數量 #-------------------------------------------------------------------------- def i_num(item) return $game_party.item_number(item) end #-------------------------------------------------------------------------- # ● 倉庫物品數量 #-------------------------------------------------------------------------- def w_num(item) return $game_party.ware_num(item) end #-------------------------------------------------------------------------- # ● 描繪背包物品 #-------------------------------------------------------------------------- def draw_items(index) item = @data[index] rect = item_rect(index) num = i_num(item) draw_item_name(item, rect.x, rect.y) rect.width -= 4 draw_text(rect.x, rect.y, rect.width, rect.height, ": " + num.to_s, 2) end #-------------------------------------------------------------------------- # ● 描繪倉庫物品 #-------------------------------------------------------------------------- def draw_ware(index) item = @data[index] rect = item_rect(index) num = w_num(item) draw_item_name(item, rect.x, rect.y, enable?(item)) rect.width -= 4 draw_text(rect.x, rect.y, rect.width, rect.height, ": " + num.to_s, 2) end #-------------------------------------------------------------------------- # ■ 繪製所有項目 #-------------------------------------------------------------------------- def draw_all_items item_max.times {|i| draw_item(i) } end #-------------------------------------------------------------------------- # ● 獲取焦點項目 #-------------------------------------------------------------------------- def get_item_now return @data[self.index] end #-------------------------------------------------------------------------- # ● 獲取項目數據 #-------------------------------------------------------------------------- def get_data return @data end #-------------------------------------------------------------------------- # ● 更新幫助內容 #-------------------------------------------------------------------------- def update_help @help_window.set_item(get_item_now) if @help_window end #-------------------------------------------------------------------------- # ● 查詢此物品是否可以取出 #-------------------------------------------------------------------------- def enable?(item) if $game_party.max_item_number(item) - $game_party.item_number(item) == 0 return false else return true end end #結束定義 end
#encoding:utf-8
# ————————————————————————————————————
# 本腳本來自[url]www.66rpg.com[/url],轉載請保留此信息
# ————————————————————————————————————
#==============================================================================
# ■ Window_WarehouseItemSave
#------------------------------------------------------------------------------
# 倉庫畫面中,存入物品的窗口。
#==============================================================================
class Window_WarehouseItem < Window_Selectable
#--------------------------------------------------------------------------
# ● 初始化對象
#--------------------------------------------------------------------------
def initialize(x, y, width, height, items = [])
super(x, y, width, height)
@action = 0
@data = []
end
#--------------------------------------------------------------------------
# ● 獲取項目數
#--------------------------------------------------------------------------
def item_max
@data ? @data.size : 0
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh
make_item_list
create_contents
if action != 0
draw_all_items
end
end
#--------------------------------------------------------------------------
# ● 設置窗口動作 0:無 1:儲存 2:取出
#--------------------------------------------------------------------------
def set_action(action = 0)
@action = action
end
#--------------------------------------------------------------------------
# ● 取得窗口動作
#--------------------------------------------------------------------------
def action
return @action
end
#==========================================================================
# ■ 生成物品列表
#==========================================================================
def make_item_list
case self.action
when 0
@data = []
when 1
list_item
when 2
list_ware
end
end
#--------------------------------------------------------------------------
# ● 獲取背包物品
#--------------------------------------------------------------------------
def list_item
@data = []
# 例遍武器
for i in 1...$data_weapons.size
if $game_party.item_number($data_weapons[i]) > 0
@data.push($data_weapons[i])
end
end
# 例遍物品
for i in 1...$data_items.size
if $game_party.item_number($data_items[i]) > 0
@data.push($data_items[i])
end
end
# 例遍防具
for i in 1...$data_armors.size
if $game_party.item_number($data_armors[i]) > 0
@data.push($data_armors[i])
end
end
end
#--------------------------------------------------------------------------
# ● 獲取倉庫物品
#--------------------------------------------------------------------------
def list_ware
@data = []
# 例遍武器
for i in 1...$data_weapons.size
if $game_party.ware_num($data_weapons[i]) > 0
@data.push($data_weapons[i])
end
end
# 例遍物品
for i in 1...$data_items.size
if $game_party.ware_num($data_items[i]) > 0
@data.push($data_items[i])
end
end
# 例遍防具
for i in 1...$data_armors.size
if $game_party.ware_num($data_armors[i]) > 0
@data.push($data_armors[i])
end
end
end
#--------------------------------------------------------------------------
# ● 倉庫是否擁有物品
#--------------------------------------------------------------------------
def have_item(where = 0)
case where
when 0
list_item
when 1
list_ware
end
if @data == []
return true
else
return false
end
end
#--------------------------------------------------------------------------
# ■ 繪製項目
#--------------------------------------------------------------------------
def draw_item(index)
case self.action
when 1
draw_items(index)
when 2
draw_ware(index)
end
end
#--------------------------------------------------------------------------
# ● 背包物品數量
#--------------------------------------------------------------------------
def i_num(item)
return $game_party.item_number(item)
end
#--------------------------------------------------------------------------
# ● 倉庫物品數量
#--------------------------------------------------------------------------
def w_num(item)
return $game_party.ware_num(item)
end
#--------------------------------------------------------------------------
# ● 描繪背包物品
#--------------------------------------------------------------------------
def draw_items(index)
item = @data[index]
rect = item_rect(index)
num = i_num(item)
draw_item_name(item, rect.x, rect.y)
rect.width -= 4
draw_text(rect.x, rect.y, rect.width, rect.height, ": " + num.to_s, 2) end
#--------------------------------------------------------------------------
# ● 描繪倉庫物品
#--------------------------------------------------------------------------
def draw_ware(index)
item = @data[index]
rect = item_rect(index)
num = w_num(item)
draw_item_name(item, rect.x, rect.y, enable?(item))
rect.width -= 4
draw_text(rect.x, rect.y, rect.width, rect.height, ": " + num.to_s, 2)
end
#--------------------------------------------------------------------------
# ■ 繪製所有項目
#--------------------------------------------------------------------------
def draw_all_items
item_max.times {|i| draw_item(i) }
end
#--------------------------------------------------------------------------
# ● 獲取焦點項目
#--------------------------------------------------------------------------
def get_item_now
return @data[self.index]
end
#--------------------------------------------------------------------------
# ● 獲取項目數據
#--------------------------------------------------------------------------
def get_data
return @data
end
#--------------------------------------------------------------------------
# ● 更新幫助內容
#--------------------------------------------------------------------------
def update_help
@help_window.set_item(get_item_now) if @help_window
end
#--------------------------------------------------------------------------
# ● 查詢此物品是否可以取出
#--------------------------------------------------------------------------
def enable?(item)
if $game_party.max_item_number(item) - $game_party.item_number(item) == 0
return false
else
return true
end
end
#結束定義
end
Window_WarehouseNumber
#encoding:utf-8 # ———————————————————————————————————— # 本腳本來自[url]www.66rpg.com[/url],轉載請保留此信息 # ———————————————————————————————————— #============================================================================== # ■ Window_WarehouseNumber #------------------------------------------------------------------------------ # 商店畫面中,輸入“物品買入/賣出數量”的窗口。 #============================================================================== class Window_WarehouseNumber < Window_Selectable #-------------------------------------------------------------------------- # ● 初始化對象 #-------------------------------------------------------------------------- def initialize(x, y, height) super(x, y, window_width, height) @item = nil [url=home.php?mod=space&uid=25307]@Max[/url] = 1 [url=home.php?mod=space&uid=27178]@Number[/url] = 1 end #-------------------------------------------------------------------------- # ● 獲取窗口的寬度 #-------------------------------------------------------------------------- def window_width return 304 end #-------------------------------------------------------------------------- # ● 設置物品、最大值 #-------------------------------------------------------------------------- def set(item, max) @item = item @max = max @number = 1 refresh end #-------------------------------------------------------------------------- # ● 設置狀態 #-------------------------------------------------------------------------- def save_item(action = true) @action = action end #-------------------------------------------------------------------------- # ● 取得狀態 #-------------------------------------------------------------------------- def action return @action end #-------------------------------------------------------------------------- # ● 獲得數值 #-------------------------------------------------------------------------- def get_num return @number end #-------------------------------------------------------------------------- # ● 獲得物品 #-------------------------------------------------------------------------- def get_item return @item end #-------------------------------------------------------------------------- # ● 獲得最大值 #-------------------------------------------------------------------------- def get_max return @max end #-------------------------------------------------------------------------- # ● 刷新 #-------------------------------------------------------------------------- def refresh contents.clear draw_item_name(@item, 0, item_y) draw_number end #-------------------------------------------------------------------------- # ● 繪製數量 #-------------------------------------------------------------------------- def draw_number change_color(normal_color) draw_text(cursor_x - 28, item_y, 22, line_height, "×") draw_text(cursor_x, item_y, cursor_width - 4, line_height, @number, 2) end #-------------------------------------------------------------------------- # ● 顯示物品名稱行的 Y 坐標 #-------------------------------------------------------------------------- def item_y return 8 end #-------------------------------------------------------------------------- # ● 獲取光標的寬度 #-------------------------------------------------------------------------- def cursor_width figures * 10 + 12 end #-------------------------------------------------------------------------- # ● 獲取光標的 X 坐標 #-------------------------------------------------------------------------- def cursor_x contents_width - cursor_width - 4 end #-------------------------------------------------------------------------- # ● 獲取數量顯示的最大列數 #-------------------------------------------------------------------------- def figures return 2 end #-------------------------------------------------------------------------- # ● 更新畫面 #-------------------------------------------------------------------------- def update super if active last_number = @number update_number if @number != last_number Sound.play_cursor refresh end end end #-------------------------------------------------------------------------- # ● 更新數量 #-------------------------------------------------------------------------- def update_number change_number(1) if Input.repeat?(:RIGHT) change_number(-1) if Input.repeat?(:LEFT) change_number(10) if Input.repeat?(:UP) change_number(-10) if Input.repeat?(:DOWN) end #-------------------------------------------------------------------------- # ● 更改數量 #-------------------------------------------------------------------------- def change_number(amount) @number = [[@number + amount, @max].min, 1].max end #-------------------------------------------------------------------------- # ● 更新光標 #-------------------------------------------------------------------------- def update_cursor cursor_rect.set(cursor_x, item_y, cursor_width, line_height) end end
#encoding:utf-8
# ————————————————————————————————————
# 本腳本來自[url]www.66rpg.com[/url],轉載請保留此信息
# ————————————————————————————————————
#==============================================================================
# ■ Window_WarehouseNumber
#------------------------------------------------------------------------------
# 商店畫面中,輸入“物品買入/賣出數量”的窗口。
#==============================================================================
class Window_WarehouseNumber < Window_Selectable
#--------------------------------------------------------------------------
# ● 初始化對象
#--------------------------------------------------------------------------
def initialize(x, y, height)
super(x, y, window_width, height)
@item = nil
[url=home.php?mod=space&uid=25307]@Max[/url] = 1
[url=home.php?mod=space&uid=27178]@Number[/url] = 1
end
#--------------------------------------------------------------------------
# ● 獲取窗口的寬度
#--------------------------------------------------------------------------
def window_width
return 304
end
#--------------------------------------------------------------------------
# ● 設置物品、最大值
#--------------------------------------------------------------------------
def set(item, max)
@item = item
@max = max
@number = 1
refresh
end
#--------------------------------------------------------------------------
# ● 設置狀態
#--------------------------------------------------------------------------
def save_item(action = true)
@action = action
end
#--------------------------------------------------------------------------
# ● 取得狀態
#--------------------------------------------------------------------------
def action
return @action
end
#--------------------------------------------------------------------------
# ● 獲得數值
#--------------------------------------------------------------------------
def get_num
return @number
end
#--------------------------------------------------------------------------
# ● 獲得物品
#--------------------------------------------------------------------------
def get_item
return @item
end
#--------------------------------------------------------------------------
# ● 獲得最大值
#--------------------------------------------------------------------------
def get_max
return @max
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh
contents.clear
draw_item_name(@item, 0, item_y)
draw_number
end
#--------------------------------------------------------------------------
# ● 繪製數量
#--------------------------------------------------------------------------
def draw_number
change_color(normal_color)
draw_text(cursor_x - 28, item_y, 22, line_height, "×")
draw_text(cursor_x, item_y, cursor_width - 4, line_height, @number, 2)
end
#--------------------------------------------------------------------------
# ● 顯示物品名稱行的 Y 坐標
#--------------------------------------------------------------------------
def item_y
return 8
end
#--------------------------------------------------------------------------
# ● 獲取光標的寬度
#--------------------------------------------------------------------------
def cursor_width
figures * 10 + 12
end
#--------------------------------------------------------------------------
# ● 獲取光標的 X 坐標
#--------------------------------------------------------------------------
def cursor_x
contents_width - cursor_width - 4
end
#--------------------------------------------------------------------------
# ● 獲取數量顯示的最大列數
#--------------------------------------------------------------------------
def figures
return 2
end
#--------------------------------------------------------------------------
# ● 更新畫面
#--------------------------------------------------------------------------
def update
super
if active
last_number = @number
update_number
if @number != last_number
Sound.play_cursor
refresh
end
end
end
#--------------------------------------------------------------------------
# ● 更新數量
#--------------------------------------------------------------------------
def update_number
change_number(1) if Input.repeat?(:RIGHT)
change_number(-1) if Input.repeat?(:LEFT)
change_number(10) if Input.repeat?(:UP)
change_number(-10) if Input.repeat?(:DOWN)
end
#--------------------------------------------------------------------------
# ● 更改數量
#--------------------------------------------------------------------------
def change_number(amount)
@number = [[@number + amount, @max].min, 1].max
end
#--------------------------------------------------------------------------
# ● 更新光標
#--------------------------------------------------------------------------
def update_cursor
cursor_rect.set(cursor_x, item_y, cursor_width, line_height)
end
end
Scene_Warehouse_Window
# ———————————————————————————————————— # 本腳本來自[url]www.66rpg.com[/url],轉載請保留此信息 # ———————————————————————————————————— #============================================================================== # ■ Scene_Warehouse #------------------------------------------------------------------------------ # 商店畫面 : 窗口管理 #============================================================================== class Scene_Warehouse < Scene_MenuBase #-------------------------------------------------------------------------- # ● 開始處理 :生成窗口 #-------------------------------------------------------------------------- def start super create_help_window create_command_window create_item_window create_number_window end #-------------------------------------------------------------------------- # ● 生成指令窗口 #-------------------------------------------------------------------------- def create_command_window @command_window = Window_WarehouseCommand.new(Graphics.width, @purchase_only) @command_window.viewport = @viewport @command_window.y = @help_window.height @command_window.set_handler(:save, method(:command_save)) @command_window.set_handler(:get, method(:command_get)) @command_window.set_handler(:cancel, method(:return_scene)) end #-------------------------------------------------------------------------- # ● 生成物品窗口 #-------------------------------------------------------------------------- def create_item_window y = @command_window.y + @command_window.height height = Graphics.height - @command_window.y - @command_window.height width = @help_window.width @item_window = Window_WarehouseItem.new(0, y, width, height) @item_window.viewport = @viewport @item_window.help_window = @help_window @item_window.set_action(0) @item_window.set_handler(:ok, method(:on_ok)) @item_window.set_handler(:cancel, method(:on_cancel)) end #-------------------------------------------------------------------------- # ● 生成輸入窗口 #-------------------------------------------------------------------------- def create_number_window @number_window = Window_WarehouseNumber.new((Graphics.width - 304)/2,(Graphics.height - 72)/2,72) @number_window.viewport = @viewport @number_window.hide @number_window.set_handler(:ok, method(:on_num_ok)) @number_window.set_handler(:cancel, method(:on_num_cancel)) end #============================================================================== # ■倉庫畫面 : 主指令管理 #============================================================================== #-------------------------------------------------------------------------- # ● 主界面 :存入 #-------------------------------------------------------------------------- def command_save @item_window.set_action(1) @command_window.deactivate # 凍結指令窗口 @item_window.activate # 激活物品窗口 @item_window.index = 0 @item_window.refresh @item_window.update_help end #-------------------------------------------------------------------------- # ● 主界面 :取出 #-------------------------------------------------------------------------- def command_get @item_window.set_action(2) @command_window.deactivate # 凍結指令窗口 @item_window.activate # 激活物品窗口 @item_window.index = 0 @item_window.refresh @item_window.update_help end #============================================================================== # ■倉庫畫面 : 指令管理 #============================================================================== #-------------------------------------------------------------------------- # ● 命令 :確定 #-------------------------------------------------------------------------- def on_ok item = @item_window.get_item_now if @item_window.enable?(item) || @item_window.action == 1 case @item_window.action when 1 @number_window.save_item @number_window.set(item,$game_party.item_number(item)) when 2 @number_window.save_item(false) i = $game_party.max_item_number(item) - $game_party.item_number(item) if i < $game_party.ware_num(item) @number_window.set(item, i) else @number_window.set(item,$game_party.ware_num(item)) end end @item_window.deactivate @number_window.show @number_window.activate else Sound.play_buzzer @help_window.set_text("背包內裝不下了~") @item_window.activate end end #-------------------------------------------------------------------------- # ● 命令 :取消 #-------------------------------------------------------------------------- def on_cancel @item_window.deactivate @item_window.set_action(0) @item_window.index = -1 @item_window.contents.clear @command_window.activate @help_window.clear end #============================================================================== # ■倉庫畫面 : 數值輸入指令管理 #============================================================================== #-------------------------------------------------------------------------- # ● 命令 :存入確定 #-------------------------------------------------------------------------- def on_num_ok @number_window.hide @number_window.deactivate case @number_window.action when true $game_party.ware_add(@number_window.get_item, @number_window.get_num) $game_party.lose_item(@number_window.get_item, @number_window.get_num) when false $game_party.ware_del(@number_window.get_item, @number_window.get_num) $game_party.gain_item(@number_window.get_item, @number_window.get_num) end # 更新畫面 @item_window.refresh if @number_window.get_num == @number_window.get_max && @item_window.index != 0 @item_window.index -= 1 end if @item_window.get_data == [] @command_window.activate @item_window.deactivate @item_window.index = -1 @help_window.clear else @item_window.activate end @command_window.refresh @number_window.refresh end #-------------------------------------------------------------------------- # ● 命令 :存入取消 #-------------------------------------------------------------------------- def on_num_cancel @number_window.refresh @number_window.hide @number_window.deactivate @item_window.activate end # 定義結束 end
# ————————————————————————————————————
# 本腳本來自[url]www.66rpg.com[/url],轉載請保留此信息
# ————————————————————————————————————
#==============================================================================
# ■ Scene_Warehouse
#------------------------------------------------------------------------------
# 商店畫面 : 窗口管理
#==============================================================================
class Scene_Warehouse < Scene_MenuBase
#--------------------------------------------------------------------------
# ● 開始處理 :生成窗口
#--------------------------------------------------------------------------
def start
super
create_help_window
create_command_window
create_item_window
create_number_window
end
#--------------------------------------------------------------------------
# ● 生成指令窗口
#--------------------------------------------------------------------------
def create_command_window
@command_window = Window_WarehouseCommand.new(Graphics.width, @purchase_only)
@command_window.viewport = @viewport
@command_window.y = @help_window.height
@command_window.set_handler(:save, method(:command_save))
@command_window.set_handler(:get, method(:command_get))
@command_window.set_handler(:cancel, method(:return_scene))
end
#--------------------------------------------------------------------------
# ● 生成物品窗口
#--------------------------------------------------------------------------
def create_item_window
y = @command_window.y + @command_window.height
height = Graphics.height - @command_window.y - @command_window.height
width = @help_window.width
@item_window = Window_WarehouseItem.new(0, y, width, height)
@item_window.viewport = @viewport
@item_window.help_window = @help_window
@item_window.set_action(0)
@item_window.set_handler(:ok, method(:on_ok))
@item_window.set_handler(:cancel, method(:on_cancel))
end
#--------------------------------------------------------------------------
# ● 生成輸入窗口
#--------------------------------------------------------------------------
def create_number_window
@number_window = Window_WarehouseNumber.new((Graphics.width - 304)/2,(Graphics.height - 72)/2,72)
@number_window.viewport = @viewport
@number_window.hide
@number_window.set_handler(:ok, method(:on_num_ok))
@number_window.set_handler(:cancel, method(:on_num_cancel))
end
#==============================================================================
# ■倉庫畫面 : 主指令管理
#==============================================================================
#--------------------------------------------------------------------------
# ● 主界面 :存入
#--------------------------------------------------------------------------
def command_save
@item_window.set_action(1)
@command_window.deactivate # 凍結指令窗口
@item_window.activate # 激活物品窗口
@item_window.index = 0
@item_window.refresh
@item_window.update_help
end
#--------------------------------------------------------------------------
# ● 主界面 :取出
#--------------------------------------------------------------------------
def command_get
@item_window.set_action(2)
@command_window.deactivate # 凍結指令窗口
@item_window.activate # 激活物品窗口
@item_window.index = 0
@item_window.refresh
@item_window.update_help
end
#==============================================================================
# ■倉庫畫面 : 指令管理
#==============================================================================
#--------------------------------------------------------------------------
# ● 命令 :確定
#--------------------------------------------------------------------------
def on_ok
item = @item_window.get_item_now
if @item_window.enable?(item) || @item_window.action == 1
case @item_window.action
when 1
@number_window.save_item
@number_window.set(item,$game_party.item_number(item))
when 2
@number_window.save_item(false)
i = $game_party.max_item_number(item) - $game_party.item_number(item)
if i < $game_party.ware_num(item)
@number_window.set(item, i)
else
@number_window.set(item,$game_party.ware_num(item))
end
end
@item_window.deactivate
@number_window.show
@number_window.activate
else
Sound.play_buzzer
@help_window.set_text("背包內裝不下了~")
@item_window.activate
end
end
#--------------------------------------------------------------------------
# ● 命令 :取消
#--------------------------------------------------------------------------
def on_cancel
@item_window.deactivate
@item_window.set_action(0)
@item_window.index = -1
@item_window.contents.clear
@command_window.activate
@help_window.clear
end
#==============================================================================
# ■倉庫畫面 : 數值輸入指令管理
#==============================================================================
#--------------------------------------------------------------------------
# ● 命令 :存入確定
#--------------------------------------------------------------------------
def on_num_ok
@number_window.hide
@number_window.deactivate
case @number_window.action
when true
$game_party.ware_add(@number_window.get_item, @number_window.get_num)
$game_party.lose_item(@number_window.get_item, @number_window.get_num)
when false
$game_party.ware_del(@number_window.get_item, @number_window.get_num)
$game_party.gain_item(@number_window.get_item, @number_window.get_num)
end
# 更新畫面
@item_window.refresh
if @number_window.get_num == @number_window.get_max && @item_window.index != 0
@item_window.index -= 1
end
if @item_window.get_data == []
@command_window.activate
@item_window.deactivate
@item_window.index = -1
@help_window.clear
else
@item_window.activate
end
@command_window.refresh
@number_window.refresh
end
#--------------------------------------------------------------------------
# ● 命令 :存入取消
#--------------------------------------------------------------------------
def on_num_cancel
@number_window.refresh
@number_window.hide
@number_window.deactivate
@item_window.activate
end
# 定義結束
end
Game_Party_Warehouse
#encoding:utf-8 #============================================================================== # ■ Game_Party #------------------------------------------------------------------------------ # 管理隊伍的類。保存有金錢及物品的信息。本類的實例請參考 $game_party 。 #============================================================================== class Game_Party < Game_Unit alias o_initialize initialize #-------------------------------------------------------------------------- # ● 追加:倉庫物品儲存 #-------------------------------------------------------------------------- def initialize o_initialize @warehouse_weapons = [] @warehouse_items = [] @warehouse_armors = [] # 初始化倉庫 : 防具 for i in 1...$data_armors.size @warehouse_armors.push($data_armors[i]) @warehouse_armors[i] = 0 end # 初始化倉庫 : 物品 for i in 1...$data_items.size @warehouse_items.push($data_items[i]) @warehouse_items[i] = 0 end # 初始化倉庫 : 武器 for i in 1...$data_weapons.size @warehouse_weapons.push($data_weapons[i]) @warehouse_weapons[i] = 0 end end #-------------------------------------------------------------------------- # ● 追加:添加進倉庫 #-------------------------------------------------------------------------- def ware_add(item,num) case item when RPG::Item @warehouse_items[item.id] += num when RPG::Weapon @warehouse_weapons[item.id] += num when RPG::Armor @warehouse_armors[item.id] += num end end #-------------------------------------------------------------------------- # ● 追加:查詢倉庫物品個數 #-------------------------------------------------------------------------- def ware_num(item) case item when RPG::Item return @warehouse_items[item.id] when RPG::Weapon return @warehouse_weapons[item.id] when RPG::Armor return @warehouse_armors[item.id] end end #-------------------------------------------------------------------------- # ● 追加:刪除倉庫物品 #-------------------------------------------------------------------------- def ware_del(item,num) case item when RPG::Item @warehouse_items[item.id] -= num when RPG::Weapon @warehouse_weapons[item.id] -= num when RPG::Armor @warehouse_armors[item.id] -= num end end # 定義結束 end
#encoding:utf-8
#==============================================================================
# ■ Game_Party
#------------------------------------------------------------------------------
# 管理隊伍的類。保存有金錢及物品的信息。本類的實例請參考 $game_party 。
#==============================================================================
class Game_Party < Game_Unit
alias o_initialize initialize
#--------------------------------------------------------------------------
# ● 追加:倉庫物品儲存
#--------------------------------------------------------------------------
def initialize
o_initialize
@warehouse_weapons = []
@warehouse_items = []
@warehouse_armors = []
# 初始化倉庫 : 防具
for i in 1...$data_armors.size
@warehouse_armors.push($data_armors[i])
@warehouse_armors[i] = 0
end
# 初始化倉庫 : 物品
for i in 1...$data_items.size
@warehouse_items.push($data_items[i])
@warehouse_items[i] = 0
end
# 初始化倉庫 : 武器
for i in 1...$data_weapons.size
@warehouse_weapons.push($data_weapons[i])
@warehouse_weapons[i] = 0
end
end
#--------------------------------------------------------------------------
# ● 追加:添加進倉庫
#--------------------------------------------------------------------------
def ware_add(item,num)
case item
when RPG::Item
@warehouse_items[item.id] += num
when RPG::Weapon
@warehouse_weapons[item.id] += num
when RPG::Armor
@warehouse_armors[item.id] += num
end
end
#--------------------------------------------------------------------------
# ● 追加:查詢倉庫物品個數
#--------------------------------------------------------------------------
def ware_num(item)
case item
when RPG::Item
return @warehouse_items[item.id]
when RPG::Weapon
return @warehouse_weapons[item.id]
when RPG::Armor
return @warehouse_armors[item.id]
end
end
#--------------------------------------------------------------------------
# ● 追加:刪除倉庫物品
#--------------------------------------------------------------------------
def ware_del(item,num)
case item
when RPG::Item
@warehouse_items[item.id] -= num
when RPG::Weapon
@warehouse_weapons[item.id] -= num
when RPG::Armor
@warehouse_armors[item.id] -= num
end
end
# 定義結束
end
|
|