Project1
标题:
有木有背包容量和物品仓库脚本?
[打印本页]
作者:
欧买歌
时间:
2014-5-10 15:34
标题:
有木有背包容量和物品仓库脚本?
我在做一个生存游戏,我想让游戏更真实些。
作者:
欧买歌
时间:
2014-5-10 21:10
@芯☆淡茹水
背包最大种类数(吧?)
作者:
芯☆淡茹水
时间:
2014-5-10 21:20
欧买歌 发表于 2014-5-10 21:10
@芯☆淡茹水 背包最大种类数(吧?)
吾试试。如果背包满,再增加物品的话,就对话框提示。
作者:
芯☆淡茹水
时间:
2014-5-10 22:25
这个:
背包物品限制.rar
(189.62 KB, 下载次数: 173)
2014-5-10 22:25 上传
点击文件名下载附件
作者:
欧买歌
时间:
2014-5-11 13:18
芯☆淡茹水 发表于 2014-5-10 22:25
这个:
可是,还有仓库脚本吗?
如果没有,那我就不用了。
作者:
【凌】
时间:
2014-5-12 21:29
这个仓库脚本可能对您有帮助:
#==============================================================================
# 本脚本来自www.66rpg.com,转载和使用请保留此信息
#==============================================================================
# 物品银行 V1.1完美版,制作+强化:IKKI,此脚本修改自真实商店脚本。
# 调用:$scene = Scene_Shop_Vb.new(1)
#
#==============================================================================
# ■ Scene_Shop
#------------------------------------------------------------------------------
# 处理商店画面的类。
#==============================================================================
class Game_System
attr_accessor :goods
alias vaule_shop_66RPG_initialize initialize
def initialize
vaule_shop_66RPG_initialize
@goods = []
###########################################################################
# 初期的时候的商店物品,编号顺序:种类,ID,可卖数量
@goods[1] = [[-1,-1,-1]]
###########################################################################
end
def shop_change(shop,kind,id,delnumber)
dl = delnumber
for dt in $game_system.goods[shop]
if (dt[0]==kind) and (dt[1]==id)
dt[2] -= dl
dt[2] = [dt[2],99].min
if dt[2] == 0
$game_system.goods[shop].delete(dt)
end
return
end
end
$game_system.goods[shop].push([kind,id,-delnumber])
end
end
class Scene_Shop_Vb
def initialize(shop_number)
# 当前商店编号
@shop_now = shop_number
end
#--------------------------------------------------------------------------
# ● 主处理
#--------------------------------------------------------------------------
def main
# 生成帮助窗口
@help_window = Window_Help_Vb.new
# 生成指令窗口
@command_window = Window_ShopCommand_Vb.new
# 生成金钱窗口
@gold_window = Window_Gold_Vb.new
@gold_window.x = 480
@gold_window.y = 64
# 生成游戏时间窗口
@playtime_window = Window_PlayTime_Vb.new
@playtime_window.x = 380
@playtime_window.y = 0
# 生成时间窗口
@dummy_window = Window_Base.new(0, 128, 640, 352)
# 生成购买窗口
@buy_window = Window_ShopBuy_Vb.new($game_system.goods[@shop_now])
@buy_window.active = false
@buy_window.visible = false
@buy_window.help_window = @help_window
# 生成卖出窗口
@sell_window = Window_ShopSell_Vb.new
@sell_window.active = false
@sell_window.visible = false
@sell_window.help_window = @help_window
# 生成数量输入窗口
@number_window = Window_ShopNumber_Vb.new
@number_window.active = false
@number_window.visible = false
# 生成状态窗口
@status_window = Window_ShopStatus_Vb.new
@status_window.visible = true
# 执行过渡
Graphics.transition
# 主循环
loop do
# 刷新游戏画面
Graphics.update
# 刷新输入信息
Input.update
# 刷新画面
update
# 如果画面切换的话就中断循环
if $scene != self
break
end
end
# 准备过渡
Graphics.freeze
# 释放窗口
@help_window.dispose
@command_window.dispose
@playtime_window.dispose
@gold_window.dispose
@dummy_window.dispose
@buy_window.dispose
@sell_window.dispose
@number_window.dispose
@status_window.dispose
end
#--------------------------------------------------------------------------
# ● 刷新画面
#--------------------------------------------------------------------------
def update
# 刷新窗口
@help_window.update
@command_window.update
@playtime_window.update
@gold_window.update
@dummy_window.update
@buy_window.update
@sell_window.update
@number_window.update
@status_window.update
# 指令窗口激活的情况下: 调用 update_command
if @command_window.active
update_command
return
end
# 购买窗口激活的情况下: 调用 update_buy
if @buy_window.active
update_buy
return
end
# 卖出窗口激活的情况下: 调用 update_sell
if @sell_window.active
update_sell
return
end
# 个数输入窗口激活的情况下: 调用 update_number
if @number_window.active
update_number
return
end
end
#--------------------------------------------------------------------------
# ● 刷新画面 (指令窗口激活的情况下)
#--------------------------------------------------------------------------
def update_command
# 按下 B 键的情况下
if Input.trigger?(Input::B)
# 演奏取消 SE
$game_system.se_play($data_system.cancel_se)
# 切换到地图画面
$scene = Scene_Map.new
return
end
# 按下 C 键的情况下
if Input.trigger?(Input::C)
# 命令窗口光标位置分支
case @command_window.index
when 1 # 购买
# 演奏确定 SE
$game_system.se_play($data_system.decision_se)
# 窗口状态转向购买模式
@command_window.active = false
@dummy_window.visible = false
@buy_window.active = true
@buy_window.visible = true
@buy_window.refresh
@status_window.visible = true
when 0 # 卖出
# 演奏确定 SE
$game_system.se_play($data_system.decision_se)
# 窗口状态转向卖出模式
@command_window.active = false
@dummy_window.visible = false
@sell_window.active = true
@sell_window.visible = true
@sell_window.refresh
@status_window.visible = true
when 2 # 取消
# 演奏确定 SE
$game_system.se_play($data_system.decision_se)
# 切换到地图画面
$scene = Scene_Map.new
end
return
end
end
#--------------------------------------------------------------------------
# ● 刷新画面 (购买窗口激活的情况下)
#--------------------------------------------------------------------------
def update_buy
# 设置状态窗口的物品
@status_window.item = @buy_window.item
# 按下 B 键的情况下
if Input.trigger?(Input::B)
# 演奏取消 SE
$game_system.se_play($data_system.cancel_se)
# 窗口状态转向初期模式
@command_window.active = true
@dummy_window.visible = true
@buy_window.active = false
@buy_window.visible = false
@status_window.visible = true
@status_window.item = nil
# 删除帮助文本
@help_window.set_text("")
return
end
# 按下 C 键的情况下
if Input.trigger?(Input::C)
# 获取物品
@item = @buy_window.item
# 物品无效的情况下、或者价格在所持金以上的情况下
if @item == nil# or @item.price > $game_party.gold
# 演奏冻结 SE
$game_system.se_play($data_system.buzzer_se)
return
end
# 获取物品所持数
case @item
when RPG::Item
number = $game_party.item_number(@item.id)
when RPG::Weapon
number = $game_party.weapon_number(@item.id)
when RPG::Armor
number = $game_party.armor_number(@item.id)
end
# 如果已经拥有了 99 个情况下
if number == 99
# 演奏冻结 SE
$game_system.se_play($data_system.buzzer_se)
return
end
# 演奏确定 SE
$game_system.se_play($data_system.decision_se)
# 计算可以最多购买的数量
max = @item.price == 0 ? 99 : $game_party.gold / @item.price
max = [[max, 99 - number].min,@buy_window.item_number].min
# 窗口状态转向数值输入模式
@buy_window.active = false
@buy_window.visible = false
@number_window.set(@item, max, @item.price)
@number_window.active = true
@number_window.visible = true
end
end
#--------------------------------------------------------------------------
# ● 画面更新 (卖出窗口激活的情况下)
#--------------------------------------------------------------------------
def update_sell
# 按下 B 键的情况下
if Input.trigger?(Input::B)
# 演奏取消 SE
$game_system.se_play($data_system.cancel_se)
# 窗口状态转向初期模式
@command_window.active = true
@dummy_window.visible = true
@sell_window.active = false
@sell_window.visible = false
@status_window.visible = true
@status_window.item = nil
# 删除帮助文本
@help_window.set_text("")
return
end
# 按下 C 键的情况下
if Input.trigger?(Input::C)
# 获取物品
@item = @sell_window.item
# 物品无效的情况下、或者价格为 0 (不能卖出) 的情况下
if @item == nil# or @item.price == 0
# 演奏冻结 SE
$game_system.se_play($data_system.buzzer_se)
return
end
# 如果金钱为 0 G情况下
if $game_party.gold == 0
# 演奏冻结 SE
$game_system.se_play($data_system.buzzer_se)
$game_temp.message_text = "老大,没有钱不要来存东西好不好?"
# 切换到地图画面
$scene = Scene_Map.new
return
end
# 演奏确定 SE
$game_system.se_play($data_system.decision_se)
# 获取物品的所持数
case @item
when RPG::Item
number = $game_party.item_number(@item.id)
when RPG::Weapon
number = $game_party.weapon_number(@item.id)
when RPG::Armor
number = $game_party.armor_number(@item.id)
end
# 最大卖出个数 = 物品的所持数
max = number
# 窗口状态转向个数输入模式
@sell_window.active = false
@sell_window.visible = false
@number_window.set(@item, max, @item.price / 2)
@number_window.active = true
@number_window.visible = true
@status_window.visible = true
end
end
#--------------------------------------------------------------------------
# ● 刷新画面 (个数输入窗口激活的情况下)
#--------------------------------------------------------------------------
def update_number
# 按下 B 键的情况下
if Input.trigger?(Input::B)
# 演奏取消 SE
$game_system.se_play($data_system.cancel_se)
# 设置个数输入窗口为不活动·非可视状态
@number_window.active = false
@number_window.visible = false
# 命令窗口光标位置分支
case @command_window.index
when 1 # 购买
# 窗口状态转向购买模式
@buy_window.active = true
@buy_window.visible = true
when 0 # 卖出
# 窗口状态转向卖出模式
@sell_window.active = true
@sell_window.visible = true
end
return
end
# 按下 C 键的情况下
if Input.trigger?(Input::C)
# 演奏商店 SE
$game_system.se_play($data_system.shop_se)
# 设置个数输入窗口为不活动·非可视状态
@number_window.active = false
@number_window.visible = false
# 命令窗口光标位置分支
case @command_window.index
when 1 # 购买
# 购买处理
temp = 0
case @item
when RPG::Item
$game_party.gain_item(@item.id, @number_window.number)
when RPG::Weapon
$game_party.gain_weapon(@item.id, @number_window.number)
temp = 1
when RPG::Armor
$game_party.gain_armor(@item.id, @number_window.number)
temp = 2
end
goods_del(temp,@item.id,@number_window.number)
# 刷新各窗口
@buy_window = Window_ShopBuy_Vb.new($game_system.goods[@shop_now])
@buy_window.help_window = @help_window
@gold_window.refresh
@buy_window.refresh
@status_window.refresh
# 窗口状态转向购买模式
@buy_window.active = true
@buy_window.visible = true
when 0 # 卖出
# 卖出处理
$game_party.lose_gold(@number_window.number)
temp = 0
case @item
when RPG::Item
$game_party.lose_item(@item.id, @number_window.number)
when RPG::Weapon
$game_party.lose_weapon(@item.id, @number_window.number)
temp = 1
when RPG::Armor
$game_party.lose_armor(@item.id, @number_window.number)
temp = 2
end
# 刷新各窗口
goods_del(temp,@item.id,-@number_window.number)
@buy_window = Window_ShopBuy_Vb.new($game_system.goods[@shop_now])
@buy_window.active = false
@buy_window.visible = false
@buy_window.help_window = @help_window
@gold_window.refresh
@sell_window.refresh
@status_window.refresh
# 窗口状态转向卖出模式
@sell_window.active = true
@sell_window.visible = true
end
return
end
end
# 删除可出售商品内容
def goods_del(kind,id,delnumber)
dl = delnumber
for dt in $game_system.goods[@shop_now]
if (dt[0]==kind) and (dt[1]==id)
dt[2] -= dl
dt[2] = [dt[2],99].min
if dt[2] == 0
$game_system.goods[@shop_now].delete(dt)
end
return
end
end
$game_system.goods[@shop_now].push([kind,id,-delnumber])
end
end
#==============================================================================
# ■ Window_PlayTime_Vb
#------------------------------------------------------------------------------
# 菜单画面显示游戏时间的窗口。
#==============================================================================
class Window_PlayTime_Vb < Window_Base
#--------------------------------------------------------------------------
# ● 初始化对像
#--------------------------------------------------------------------------
def initialize
super(0, 0, 260, 64)
self.contents = Bitmap.new(width - 32, height - 32)
refresh
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh
self.contents.clear
self.contents.font.color = system_color
self.contents.draw_text(4, 0, 120, 32, "游戏时间")
@total_sec = Graphics.frame_count / Graphics.frame_rate
hour = @total_sec / 60 / 60
min = @total_sec / 60 % 60
sec = @total_sec % 60
text = sprintf("%02d:%02d:%02d", hour, min, sec)
self.contents.font.color = normal_color
self.contents.draw_text(124, 0, 120, 32, text, 0)
end
#--------------------------------------------------------------------------
# ● 刷新画面
#--------------------------------------------------------------------------
def update
super
if Graphics.frame_count / Graphics.frame_rate != @total_sec
refresh
end
end
end
#==============================================================================
# ■ Window_Selectable_Vb
#------------------------------------------------------------------------------
# 拥有光标的移动以及滚动功能的窗口类。
#==============================================================================
class Window_Selectable_Vb < Window_Base
#--------------------------------------------------------------------------
# ● 定义实例变量
#--------------------------------------------------------------------------
attr_reader :index # 光标位置
attr_reader :help_window # 帮助窗口
#--------------------------------------------------------------------------
# ● 初始画对像
# x : 窗口的 X 坐标
# y : 窗口的 Y 坐标
# width : 窗口的宽
# height : 窗口的高
#--------------------------------------------------------------------------
def initialize(x, y, width, height)
super(x, y, width, height)
@item_max = 1
@column_max = 1
[url=home.php?mod=space&uid=370741]@Index[/url] = -1
end
#--------------------------------------------------------------------------
# ● 设置光标的位置
# index : 新的光标位置
#--------------------------------------------------------------------------
def index=(index)
@index = index
# 刷新帮助文本 (update_help 定义了继承目标)
if self.active and @help_window != nil
update_help
end
# 刷新光标矩形
update_cursor_rect
end
#--------------------------------------------------------------------------
# ● 获取行数
#--------------------------------------------------------------------------
def row_max
# 由项目数和列数计算出行数
return (@item_max + @column_max - 1) / @column_max
end
#--------------------------------------------------------------------------
# ● 获取开头行
#--------------------------------------------------------------------------
def top_row
# 将窗口内容的传送源 Y 坐标、1 行的高 32 等分
return self.oy / 32
end
#--------------------------------------------------------------------------
# ● 设置开头行
# row : 显示开头的行
#--------------------------------------------------------------------------
def top_row=(row)
# row 未满 0 的场合更正为 0
if row < 0
row = 0
end
# row 超过 row_max - 1 的情况下更正为 row_max - 1
if row > row_max - 1
row = row_max - 1
end
# row 1 行高的 32 倍、窗口内容的传送源 Y 坐标
self.oy = row * 32
end
#--------------------------------------------------------------------------
# ● 获取 1 页可以显示的行数
#--------------------------------------------------------------------------
def page_row_max
# 窗口的高度,设置画面的高度减去 32 ,除以 1 行的高度 32
return (self.height - 32) / 32
end
#--------------------------------------------------------------------------
# ● 获取 1 页可以显示的项目数
#--------------------------------------------------------------------------
def page_item_max
# 将行数 page_row_max 乘上列数 @column_max
return page_row_max * @column_max
end
#--------------------------------------------------------------------------
# ● 帮助窗口的设置
# help_window : 新的帮助窗口
#--------------------------------------------------------------------------
def help_window=(help_window)
@help_window = help_window
# 刷新帮助文本 (update_help 定义了继承目标)
if self.active and @help_window != nil
update_help
end
end
#--------------------------------------------------------------------------
# ● 更新光标举行
#--------------------------------------------------------------------------
def update_cursor_rect
# 光标位置不满 0 的情况下
if @index < 0
self.cursor_rect.empty
return
end
# 获取当前的行
row = @index / @column_max
# 当前行被显示开头行前面的情况下
if row < self.top_row
# 从当前行向开头行滚动
self.top_row = row
end
# 当前行被显示末尾行之后的情况下
if row > self.top_row + (self.page_row_max - 1)
# 从当前行向末尾滚动
self.top_row = row - (self.page_row_max - 1)
end
# 计算光标的宽
cursor_width = self.width / @column_max - 32
# 计算光标坐标
x = @index % @column_max * (cursor_width + 32)
y = @index / @column_max * 32 - self.oy
# 更新国标矩形
self.cursor_rect.set(x, y, cursor_width, 32)
end
#--------------------------------------------------------------------------
# ● 刷新画面
#--------------------------------------------------------------------------
def update
super
# 可以移动光标的情况下
if self.active and @item_max > 0 and @index >= 0
# 方向键下被按下的情况下
if Input.repeat?(Input::DOWN)
# 列数不是 1 并且方向键的下的按下状态不是重复的情况、
# 或光标位置在(项目数-列数)之前的情况下
if (@column_max == 1 and Input.trigger?(Input::DOWN)) or
@index < @item_max - @column_max
# 光标向下移动
$game_system.se_play($data_system.cursor_se)
@index = (@index + @column_max) % @item_max
end
end
# 方向键上被按下的情况下
if Input.repeat?(Input::UP)
# 列数不是 1 并且方向键的下的按下状态不是重复的情况、
# 或光标位置在列之后的情况下
if (@column_max == 1 and Input.trigger?(Input::UP)) or
@index >= @column_max
# 光标向上移动
$game_system.se_play($data_system.cursor_se)
@index = (@index - @column_max + @item_max) % @item_max
end
end
# 方向键右被按下的情况下
if Input.repeat?(Input::RIGHT)
if @column_max >= 2 and @index == @item_max - 1
$game_system.se_play($data_system.cursor_se)
@index = -1
end
# 列数为 2 以上并且、光标位置在(项目数 - 1)之前的情况下
if @column_max >= 2 and @index < @item_max - 1
# 光标向右移动
$game_system.se_play($data_system.cursor_se)
@index += 1
end
end
# 方向键左被按下的情况下
if Input.repeat?(Input::LEFT)
if @column_max >= 2 and @index == 0
$game_system.se_play($data_system.cursor_se)
@index = @item_max
end
# 列数为 2 以上并且、光标位置在 0 之后的情况下
if @column_max >= 2 and @index > 0
# 光标向左移动
$game_system.se_play($data_system.cursor_se)
@index -= 1
end
end
# R 键被按下的情况下
if Input.repeat?(Input::R)
# 显示的最后行在数据中最后行上方的情况下
if self.top_row + (self.page_row_max - 1) < (self.row_max - 1)
# 光标向后移动一页
$game_system.se_play($data_system.cursor_se)
@index = [@index + self.page_item_max, @item_max - 1].min
self.top_row += self.page_row_max
end
end
# L 键被按下的情况下
if Input.repeat?(Input::L)
# 显示的开头行在位置 0 之后的情况下
if self.top_row > 0
# 光标向前移动一页
$game_system.se_play($data_system.cursor_se)
@index = [@index - self.page_item_max, 0].max
self.top_row -= self.page_row_max
end
end
end
# 刷新帮助文本 (update_help 定义了继承目标)
if self.active and @help_window != nil
update_help
end
# 刷新光标矩形
update_cursor_rect
end
end
#==============================================================================
# ■ Window_Help_Vb
#------------------------------------------------------------------------------
# 特技及物品的说明、角色的状态显示的窗口。
#==============================================================================
class Window_Help_Vb < Window_Base
#--------------------------------------------------------------------------
# ● 初始化对像
#--------------------------------------------------------------------------
def initialize
super(0, 0, 380, 64)
self.contents = Bitmap.new(width - 32, height - 32)
end
#--------------------------------------------------------------------------
# ● 设置文本
# text : 窗口显示的字符串
# align : 对齐方式 (0..左对齐、1..中间对齐、2..右对齐)
#--------------------------------------------------------------------------
def set_text(text, align = 0)
# 如果文本和对齐方式的至少一方与上次的不同
if text != @text or align != @align
# 再描绘文本
self.contents.clear
self.contents.font.color = normal_color
self.contents.draw_text(4, 0, self.width - 40, 32, text, align)
@text = text
@align = align
[url=home.php?mod=space&uid=95897]@actor[/url] = nil
end
self.visible = true
end
#--------------------------------------------------------------------------
# ● 设置角色
# actor : 要显示状态的角色
#--------------------------------------------------------------------------
def set_actor(actor)
if actor != @actor
self.contents.clear
draw_actor_name(actor, 4, 0)
draw_actor_state(actor, 140, 0)
draw_actor_hp(actor, 284, 0)
draw_actor_sp(actor, 460, 0)
@actor = actor
@text = nil
self.visible = true
end
end
#--------------------------------------------------------------------------
# ● 设置敌人
# enemy : 要显示名字和状态的敌人
#--------------------------------------------------------------------------
def set_enemy(enemy)
text = enemy.name
state_text = make_battler_state_text(enemy, 112, false)
if state_text != ""
text += " " + state_text
end
set_text(text, 1)
end
end
#==============================================================================
# ■ Window_Gold_Vb
#------------------------------------------------------------------------------
# 显示金钱的窗口。
#==============================================================================
class Window_Gold_Vb < Window_Base
#--------------------------------------------------------------------------
# ● 初始化窗口
#--------------------------------------------------------------------------
def initialize
super(0, 0, 160, 64)
self.contents = Bitmap.new(width - 32, height - 32)
refresh
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh
self.contents.clear
cx = contents.text_size($data_system.words.gold).width
self.contents.font.size = 17
self.contents.font.color = system_color
self.contents.draw_text(4, 0, 120, 17, "钱包",1)
self.contents.font.color = normal_color
self.contents.draw_text(4, 17, 120-cx-2, 17, $game_party.gold.to_s, 2)
self.contents.font.color = system_color
self.contents.draw_text(124-cx, 17, cx, 17, $data_system.words.gold, 2)
end
end
#==============================================================================
# ■ Window_ShopBuy_Vb
#------------------------------------------------------------------------------
# 商店画面、浏览显示可以购买的商品的窗口。
#==============================================================================
class Window_ShopBuy_Vb < Window_Selectable_Vb
attr_accessor :shop_goods
#--------------------------------------------------------------------------
# ● 初始化对像
# shop_goods : 商品
#--------------------------------------------------------------------------
def initialize(shop_goods)
super(0, 128, 368, 352)
@shop_goods = shop_goods
refresh
self.index = 0
end
#--------------------------------------------------------------------------
# ● 获取物品
#--------------------------------------------------------------------------
def item
return @data[self.index]
end
#--------------------------------------------------------------------------
# ● 获取物品
#--------------------------------------------------------------------------
def item_number
return @data_number[self.index]
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh
if self.contents != nil
self.contents.dispose
self.contents = nil
end
@data = []
@data_number = []
for goods_item in @shop_goods
case goods_item[0]
when 0
item = $data_items[goods_item[1]]
when 1
item = $data_weapons[goods_item[1]]
when 2
item = $data_armors[goods_item[1]]
end
if (item != nil) and (goods_item[2] != 0)
@data.push(item)
@data_number.push(goods_item[2])
else
@data.delete(item)
end
end
# 如果项目数不是 0 就生成位图、描绘全部项目
@item_max = @data.size
if @item_max > 0
self.contents = Bitmap.new(width - 32, row_max * 32)
for i in 0...@item_max
draw_item(i)
end
end
end
#--------------------------------------------------------------------------
# ● 描绘羡慕
# index : 项目编号
#--------------------------------------------------------------------------
def draw_item(index)
item = @data[index]
# 获取物品所持数
case item
when RPG::Item
number = $game_party.item_number(item.id)
when RPG::Weapon
number = $game_party.weapon_number(item.id)
when RPG::Armor
number = $game_party.armor_number(item.id)
end
x = 4
y = index * 32
rect = Rect.new(x, y, self.width - 32, 32)
self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
bitmap = RPG::Cache.icon(item.icon_name)
opacity = self.contents.font.color == normal_color ? 255 : 128
self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
self.contents.draw_text(x + 240, y, 88, 32, "存有 ", 2)
self.contents.draw_text(x + 240, y, 88, 32, @data_number[index].to_s, 2)
end
#--------------------------------------------------------------------------
# ● 刷新帮助文本
#--------------------------------------------------------------------------
def update_help
@help_window.set_text(self.item == nil ? "" : self.item.description)
end
end
#==============================================================================
# ■ Window_ShopCommand_Vb
#------------------------------------------------------------------------------
# 商店画面、选择要做的事的窗口
#==============================================================================
class Window_ShopCommand_Vb < Window_Selectable_Vb
#--------------------------------------------------------------------------
# ● 初始化对像
#--------------------------------------------------------------------------
def initialize
super(0, 64, 480, 64)
self.contents = Bitmap.new(width - 32, height - 32)
@item_max = 3
@column_max = 3
@commands = ["存入物品", "取出物品", "离开银行"]
refresh
self.index = 0
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh
self.contents.clear
for i in 0...@item_max
draw_item(i)
end
end
#--------------------------------------------------------------------------
# ● 描绘项目
# index : 项目编号
#--------------------------------------------------------------------------
def draw_item(index)
x = 4 + index * 160
self.contents.draw_text(x, 0, 128, 32, @commands[index])
end
end
#==============================================================================
# ■ Window_ShopSell_Vb
#------------------------------------------------------------------------------
# 商店画面、浏览显示可以卖掉的商品的窗口。
#==============================================================================
class Window_ShopSell_Vb < Window_Selectable_Vb
#--------------------------------------------------------------------------
# ● 初始化对像
# shop_goods : 商品
#--------------------------------------------------------------------------
def initialize
super(0, 128, 368, 352)
refresh
self.index = 0
end
#--------------------------------------------------------------------------
# ● 获取物品
#--------------------------------------------------------------------------
def item
return @data[self.index]
end
#--------------------------------------------------------------------------
# ● 获取物品
#--------------------------------------------------------------------------
def item_number
return @data_number[self.index]
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh
if self.contents != nil
self.contents.dispose
self.contents = nil
end
@data = []
for i in 1...$data_items.size
if $game_party.item_number(i) > 0
@data.push($data_items[i])
end
end
for i in 1...$data_weapons.size
if $game_party.weapon_number(i) > 0
@data.push($data_weapons[i])
end
end
for i in 1...$data_armors.size
if $game_party.armor_number(i) > 0
@data.push($data_armors[i])
end
end
# 如果项目数不是 0 就生成位图、描绘全部项目
@item_max = @data.size
if @item_max > 0
self.contents = Bitmap.new(width - 32, row_max * 32)
for i in 0...@item_max
draw_item(i)
end
end
end
#--------------------------------------------------------------------------
# ● 描绘羡慕
# index : 项目编号
#--------------------------------------------------------------------------
def draw_item(index)
item = @data[index]
# 获取物品所持数
case item
when RPG::Item
number = $game_party.item_number(item.id)
when RPG::Weapon
number = $game_party.weapon_number(item.id)
when RPG::Armor
number = $game_party.armor_number(item.id)
end
x = 4
y = index * 32
rect = Rect.new(x, y, self.width - 32, 32)
self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
bitmap = RPG::Cache.icon(item.icon_name)
opacity = self.contents.font.color == normal_color ? 255 : 128
self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
self.contents.draw_text(x + 240, y, 88, 32, "带有 ", 2)
self.contents.draw_text(x + 240, y, 88, 32, number.to_s, 2)
end
#--------------------------------------------------------------------------
# ● 刷新帮助文本
#--------------------------------------------------------------------------
def update_help
@help_window.set_text(self.item == nil ? "" : self.item.description)
end
end
#==============================================================================
# ■ Window_ShopNumber_Vb
#------------------------------------------------------------------------------
# 商店画面、输入买卖数量的窗口。
#==============================================================================
class Window_ShopNumber_Vb < Window_Base
#--------------------------------------------------------------------------
# ● 初始化对像
#--------------------------------------------------------------------------
def initialize
super(0, 128, 368, 352)
self.contents = Bitmap.new(width - 32, height - 32)
@item = nil
[url=home.php?mod=space&uid=25307]@Max[/url] = 1
@price = 0
[url=home.php?mod=space&uid=27178]@Number[/url] = 1
end
#--------------------------------------------------------------------------
# ● 设置物品、最大个数、价格
#--------------------------------------------------------------------------
def set(item, max, price)
@item = item
@max = max
@price = price
@number = 1
refresh
end
#--------------------------------------------------------------------------
# ● 被输入的件数设置
#--------------------------------------------------------------------------
def number
return @number
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh
self.contents.clear
draw_item_name(@item, 4, 96)
self.contents.font.color = normal_color
self.contents.draw_text(272, 96, 32, 32, "×")
self.contents.draw_text(308, 96, 24, 32, @number.to_s, 2)
self.cursor_rect.set(304, 96, 32, 32)
end
#--------------------------------------------------------------------------
# ● 刷新画面
#--------------------------------------------------------------------------
def update
super
if self.active
# 光标右 (+1)
if Input.repeat?(Input::RIGHT) and @number < @max
$game_system.se_play($data_system.cursor_se)
@number += 1
refresh
end
# 光标左 (-1)
if Input.repeat?(Input::LEFT) and @number > 1
$game_system.se_play($data_system.cursor_se)
@number -= 1
refresh
end
# 光标上 (+10)
if Input.repeat?(Input::UP) and @number < @max
$game_system.se_play($data_system.cursor_se)
@number = [@number + 10, @max].min
refresh
end
# 光标下 (-10)
if Input.repeat?(Input::DOWN) and @number > 1
$game_system.se_play($data_system.cursor_se)
@number = [@number - 10, 1].max
refresh
end
end
end
end
#==============================================================================
# ■ Window_ShopStatus_Vb
#------------------------------------------------------------------------------
# 商店画面、显示物品所持数与角色装备的窗口。
#==============================================================================
class Window_ShopStatus_Vb < Window_Base
#--------------------------------------------------------------------------
# ● 初始化对像
#--------------------------------------------------------------------------
def initialize
super(368, 128, 272, 352)
self.contents = Bitmap.new(width - 32, height - 32)
@item = nil
refresh
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh
self.contents.clear
self.contents.font.color = system_color
self.contents.draw_text(0, 0, 202, 32, "每存入一件物品都要收取1元的保管费!")
self.contents.draw_text(0, 34, 202, 32, "不过,您来取物品的话,我们不收钱!")
end
#--------------------------------------------------------------------------
# ● 设置物品
# item : 新的物品
#--------------------------------------------------------------------------
def item=(item)
if @item != item
@item = item
refresh
end
end
end
复制代码
作者:
芯☆淡茹水
时间:
2014-5-19 11:36
谢谢,但是我那个游戏已经损坏了,.
搞了半天,俺们白忙活了。
欢迎光临 Project1 (https://rpg.blue/)
Powered by Discuz! X3.1