| 赞 | 0 |
| VIP | |
| 好人卡 | |
| 积分 | 16 |
| 经验 | |
| 最后登录 | 2024-5-15 |
| 在线时间 | 626 小时 |
- 梦石
- 0
- 星屑
- 1556
- 在线时间
- 626 小时
- 注册时间
- 2010-8-5
- 回帖
- 317
|
加入我们,或者,欢迎回来。
您需要 登录 才可以下载或查看,没有账号?注册会员
×
我不知道怎么整合..这个是我的物品界面.[pre lang="ruby" line="1"]#==============================================================================
# ■ System
#------------------------------------------------------------------------------
# 我的系统。
#==============================================================================
module System
#============================================================================
# ■ Interface
#----------------------------------------------------------------------------
# 游戏界面。
#============================================================================
class Interface
#------------------------------------------------------------------------
# ● 生成物品内容
#------------------------------------------------------------------------
def item_main
# 已经生成的情况下
unless @item_window.nil?
dispose_item
return
end
# 已经生成召唤兽的情况下
if Picture.exist?($图表[24])
# 释放召唤兽属性画面
dispose_baby
end
# 初始化对象
$活动窗口 = "物品"
$cash = true
# 生成窗口
$图表[22] = Picture.new("UI/道具行囊",0,0,600)
@item_window = Window_Item.new(@actor)
@item_window.z = 600
@equip_window = Window_Equip.new(@actor)
@equip_window.z = 600
# 关联帮助窗口
@item_window.help_window = Window_Help.new
@equip_window.help_window = Window_Help.new
# 生成按钮
@item_exit = Picture.new("UI/叉",291,6,600,[0,0,4,1])
@pack = Picture.new("UI/道具",27,410,600,[1.5,0,3,1])
@wallet = Picture.new("UI/行囊",72,410,600,[0,0,3,1])
@talisman = Picture.new("UI/法宝",117,410,600,[0,0,3,1])
@arrange = Picture.new("UI/整理",162,410,600,[0,0,3,1])
@cash = Picture.new("UI/现金",7,151,600,[0,0,3,1])
@select_cursor = Picture.new("UI/锁定",0,0,0)
@item_button = [@item_exit,@pack,@wallet,@talisman,@arrange,@cash]
@goos = @pack
end
#------------------------------------------------------------------------
# ● 刷新画面
#------------------------------------------------------------------------
def update_item
return if !Picture.exist?(@item_window) or $exit
# 刷新画面 Z 坐标
if @active_window[0] != $活动窗口
$图表[22].z = $活动窗口 != "物品" ? 500 : 600
for i in 0...@item_button.nitems
@item_button.z = $活动窗口 != "物品" ? 505 : 600
end
@item_window.z = @equip_window.z = $图表[22].z
@active_window[0] = $活动窗口
end
# 选中窗口为自身并按下鼠标左键的情况下
if $select_window[0] == $图表[22] and Mouse.trigger?(0x01)
$活动窗口 = "物品"
end
return if $活动窗口 == "任务"
# 刷新物品窗口
@item_window.update
# 刷新装备窗口
@equip_window.update
# 刷新物品选择
select_item
# 刷新装备选择
select_equip
# 刷新按钮
item_button
# 刷新物品窗口
@item_window.refresh if $item_refresh
# 刷新提示
@item_help.update if @item_help != nil and !@item_help.disposed?
# 当按下鼠标右键时
if @item_icon != nil or @equip_icon != nil and Mouse.trigger?(0x02)
# 还原选中物品
select_return
return
end
# 当鼠标在窗口内的情况下
if Mouse.in_rect?($图表[22]) and !@item_window.nil?
# 装备和物品窗口未激活的情况下
unless @item_window.active or @equip_window.active
if @old_x != @mouse_x or @old_y != @mouse_y
@count = 0
@old_x,@old_y = Mouse.get_mouse_pos
@item_help.dispose if @item_help != nil and !@item_help.disposed?
else
@count = @count.to_i + 1
if @count > 20
@item_help.dispose if @item_help != nil and !@item_help.disposed?
text = "右键点击界面边缘可以快速关闭界面。"
@item_help = Window_Warn.new(text,@mouse_x-10,@mouse_y-60)
@count = 0
end
end
# 当按下鼠标右键时
if Mouse.trigger?(0x02)
# 释放物品画面
dispose_item
return
end
else
@item_help.dispose if @item_help != nil and !@item_help.disposed?
end
else
# 当按下鼠标左键时
if @item_icon != nil or @equip_icon != nil and Mouse.trigger?(0x01)
# 丟失物品
lose_item(false)
end
@item_help.dispose if @item_help != nil and !@item_help.disposed?
end
# 刷新选中图标
if @item_icon != nil
@item_icon.x = @mouse_x - @initial_x
@item_icon.y = @mouse_y - @initial_y
elsif @equip_icon != nil
@equip_icon.x = @mouse_x - @initial_x
@equip_icon.y = @mouse_y - @initial_y
end
# 取消选中
if @item_icon.nil? and @equip_icon.nil?
@select_cursor.z = -10 if Picture.exist?(@select_cursor)
$select_item = false
end
# 刷新金钱
if @old_gold != [$data.cash,$data.store,$data.deposit]
# 刷新装备窗口
@equip_window.refresh
@old_gold = [$data.cash,$data.store,$data.deposit]
end
end
#------------------------------------------------------------------------
# ● 刷新按钮
#------------------------------------------------------------------------
def item_button
return if !Mouse.in_rect?($图表[22])
for i in 0...@item_button.nitems
System.update_button(@item_button,$事件)
if $事件[@item_button][1]
case i
when 0 # 退出
dispose_item
return
when 1 # 道具
# 没有点中的物品
if @item_icon.nil?
@goos = @pack
@item_window.data = $data.pack
else
# 行囊转物品
if @goos != @pack
if $data.pack.include?(nil)
if @select_item[0].is_a?(RPG::Item)
$data.gain_item(@select_item[0].standard, @select_item[1], $data.pack)
else
$data.pack[$data.empty($data.pack)] = @select_item
end
# 释放图标
Picture.dispose(@item_icon)
@item_icon = nil
else
text = "包裹已满!"
$help = Window_Warn.new(text,120,227,1500,14,true)
$help._width = 400
end
end
end
# 刷新物品窗口
@item_window.refresh
when 2 # 行囊
# 没有点中的物品
if @item_icon.nil?
@goos = @wallet
@item_window.data = $data.wallet
else
if @goos != @wallet
if $data.wallet.include?(nil)
if @select_item[0].is_a?(RPG::Item)
$data.gain_item(@select_item[0].standard, @select_item[1], $data.wallet)
else
$data.wallet[$data.empty($data.wallet)] = @select_item
end
# 释放图标
Picture.dispose(@item_icon)
@item_icon = nil
else
text = "行囊已满!"
$help = Window_Warn.new(text,120,227,1500,14,true)
$help._width = 400
end
end
end
# 刷新物品窗口
@item_window.refresh
when 3 # 法宝
# 没有点中的物品
if @item_icon.nil?
@goos = @talisman
@item_window.data = $data.talisman
else
if @goos != @talisman
if @select_item.is_a?(RPG::Weapon) and @select_item[0].element_set.include?(27)
if $data.talisman.include?(nil)
$data.talisman[$data.empty($data.talisman)] = @select_item
# 释放图标
Picture.dispose(@item_icon)
@item_icon = nil
else
text = "法宝已满!"
$help = Window_Warn.new(text,120,227,1500,14,true)
$help._width = 400
end
else
text = "选中物品不是法宝!"
$help = Window_Warn.new(text,120,227,1500,14,true)
$help._width = 400
end
end
end
# 刷新物品窗口
@item_window.refresh
when 4 # 整理
case @goos
when @pack
$data.pack = $data.item_arrange($data.pack)
@item_window.data = $data.pack
when @wallet
$data.wallet = $data.item_arrange($data.wallet)
@item_window.data = $data.wallet
when @talisman
$data.talisman = $data.item_arrange($data.talisman)
@item_window.data = $data.talisman
end
# 刷新物品窗口
@item_window.refresh
when 5 # 现金
@cash.bitmap.clear
@cash.bitmap = Bitmap.new($cash ? "UI/储备" : "UI/现金")
@cash.src_rect.set(0, 0, @cash.bitmap.width/3, @cash.bitmap.height)
$cash = $cash ? false : true
@equip_window.refresh
end
end
end
@goos.src_rect.set(86,0,43,22)
end
#------------------------------------------------------------------------
# ● 释放物品界面
#------------------------------------------------------------------------
def dispose_item
return if !Picture.exist?(@item_window)
# 还原物品
select_return
@item_window.dispose
@item_window.help_window.dispose
@item_window = nil
@equip_window.dispose
@equip_window.help_window.dispose
for i in @item_button
Picture.dispose(i)
end
Picture.dispose($图表[22])
Picture.dispose(@select_cursor)
@item_help.dispose if Picture.exist?(@item_help)
end
#------------------------------------------------------------------------
# ● 还原选中物品或装备
#------------------------------------------------------------------------
def select_return
if @item_icon != nil
# 恢复原物品
@item_window.data[@select_index] = @select_item
# 释放图标
Picture.dispose(@item_icon)
@item_icon = nil
# 刷新物品窗口
@item_window.refresh
end
if @equip_icon != nil
# 恢复原物品
@actor.armor2_id = @select_item.id if @select_index == 0
@actor.armor4_id = @select_item.id if @select_index == 1
@actor.weapon_id = @select_item.id if @select_index == 2
@actor.armor3_id = @select_item.id if @select_index == 3
@actor.armor1_id = @select_item.id if @select_index == 4
@actor.armor5_id = @select_item.id if @select_index == 5
# 释放图标
Picture.dispose(@equip_icon)
@equip_icon = nil
# 刷新装备窗口
@equip_window.refresh
end
end
#------------------------------------------------------------------------
# ● 刷新物品选择
#------------------------------------------------------------------------
def select_item
return if !@item_window.active
# 获取物品
item = @item_window.item
# 当按下鼠标左键时
if Mouse.trigger?(0x01)
#--------------------------------------------------------------------
# ● 拥有选中【物品】
#--------------------------------------------------------------------
# 拥有选中物品
if @item_icon != nil
# 对象存在物品的情况下
if item != nil and item[0].is_a?(RPG::Item) and @select_item[0].is_a?(RPG::Item)
# 不是特殊物品
unless item[0].element_set.include?(26)
# 当物品为同类物品的情况下
if item[0].standard == @select_item[0].standard and item[1] < 20
if item[1] + @select_item[1] <= 20
item[1] += @select_item[1]
# 释放图标
Picture.dispose(@item_icon)
@item_icon = nil
else
@select_item[1] -= (20 - item[1])
item[1] = 20
# 还原物品
select_return
end
# 刷新物品窗口
@item_window.refresh
return
end
end
end
# 选中物品与原选中物品兑换
@item_window.data[@select_index] = item
@item_window.data[@item_window.index] = @select_item
# 释放图标
Picture.dispose(@item_icon)
@item_icon = nil
# 刷新物品窗口
@item_window.refresh
return
end
#--------------------------------------------------------------------
# ● 没有选中
#--------------------------------------------------------------------
# 没有选中物品
if @item_icon.nil? and @equip_icon.nil? and item != nil
# 生成图片
@item_icon = Sprite.new
@item_icon.bitmap = RPG::Cache.icon(@item_window.item[0].icon_name)
@item_icon.z = 700
@initial_x = @mouse_x - (@item_window.cursor_rect.x + @item_window.x + 16) - (50 - @item_icon.bitmap.width) / 2
@initial_y = @mouse_y - (@item_window.cursor_rect.y + @item_window.y + 16) - (50 - @item_icon.bitmap.height) / 2
# 记忆选中物品
@select_index = @item_window.index
@select_item = item
# 选中光标
@select_cursor.x = @select_index % 5 * 51 + 11 + 16
@select_cursor.y = @select_index / 5 * 51 + 182 + 16
@select_cursor.z = 600
$select_item = true
# 选中物品消失
@item_window.data[@item_window.index] = nil
# 刷新物品窗口
@item_window.refresh
end
#--------------------------------------------------------------------
# ● 拥有选中【装备】
#--------------------------------------------------------------------
# 拥有选中装备
if @equip_icon != nil
return if @goos != @pack
# 对象存在物品的情况下
if item != nil
case item[0]
when RPG::Weapon # 武器
return if @select_index != 2
@actor.weapon_id = @select_item.id
when RPG::Armor # 防具
# 帽子@select_item
if item[0].guard_element_set.include?(6)
return if @select_index != 0
@actor.armor2_id = @select_item.id
# 项链
elsif item[0].guard_element_set.include?(7)
return if @select_index != 1
@actor.armor4_id = @select_item.id
# 衣服
elsif item[0].guard_element_set.include?(8)
return if @select_index != 3
@actor.armor3_id = @select_item.id
# 腰带
elsif item[0].guard_element_set.include?(9)
return if @select_index != 4
@actor.armor1_id = @select_item.id
# 鞋子
elsif item[0].guard_element_set.include?(10)
return if @select_index != 5
@actor.armor5_id = @select_item.id
end
end
# 变更装备
@actor.equip(@select_index, item[0].id)
else
# 变更物品
@item_window.data[@item_window.index] = [@select_item,1]
end
# 释放图标
Picture.dispose(@equip_icon)
@equip_icon = nil
# 刷新物品窗口
@item_window.refresh
# 刷新装备窗口
@equip_window.refresh
end
end
#----------------------------------------------------------------------
# ● 当按下鼠标右键时
#----------------------------------------------------------------------
# 当按下鼠标右键时
if Mouse.trigger?(0x02)
return if @goos != @pack
# 选中物品存在的情况下返回
return if @item_icon != nil or @equip_icon != nil or item.nil?
case item[0]
when RPG::Weapon # 武器
# 变更武器
@actor.equip(2, item[0].id)
when RPG::Armor # 防具
# 帽子
if item[0].guard_element_set.include?(6)
@actor.equip(0, item[0].id)
# 项链
elsif item[0].guard_element_set.include?(7)
@actor.equip(1, item[0].id)
# 衣服
elsif item[0].guard_element_set.include?(8)
@actor.equip(3, item[0].id)
# 腰带
elsif item[0].guard_element_set.include?(9)
@actor.equip(4, item[0].id)
# 鞋子
elsif item[0].guard_element_set.include?(10)
@actor.equip(5, item[0].id)
end
when RPG::Item # 物品
# 无法使用的情况下
if !$data.item_can_use?(item[0].id)
print "该物品无法使用!"
return
end
# 播放动画
$game_player.animation_id = item[0].animation2_id
# 消耗品的情况下
if item[0].consumable
# 减少物品数量
item[1] -= 1
if item[1] == 0
@item_window.data[@item_window.index] = nil
end
end
# 处理物品效果
$game_party.actors[0].item_effect(item[0]) # 普通物品
# 公共事件 ID 有效的情况下
if item[0].common_event_id > 0
# 预约调用公共事件
$game_temp.common_event_id = item[0].common_event_id
end
end
# 刷新物品窗口
@item_window.refresh
# 刷新装备窗口
@equip_window.refresh
end
end
#------------------------------------------------------------------------
# ● 刷新装备选择
#------------------------------------------------------------------------
def select_equip
return if !@equip_window.active
#----------------------------------------------------------------------
# ● 当按下鼠标左键时
#----------------------------------------------------------------------
# 当按下鼠标左键时
if Mouse.trigger?(0x01)
#--------------------------------------------------------------------
# ● 拥有选中【装备】
#--------------------------------------------------------------------
# 拥有选中装备
if @equip_icon != nil
if @select_index == @equip_window.index
# 还原装备
self.select_return
return
end
end
#----------------------------------------------------------------------
# ● 拥有选中【物品】
#----------------------------------------------------------------------
# 拥有选中物品
if @item_icon != nil
# 物品不在行囊中
return if @goos != @pack
# 获取物品
item = @select_item
case item[0]
when RPG::Weapon # 武器
return if @equip_window.index != 2
when RPG::Armor # 防具
# 帽子
if item[0].guard_element_set.include?(6)
return if @equip_window.index != 0
# 项链
elsif item[0].guard_element_set.include?(7)
return if @equip_window.index != 1
# 衣服
elsif item[0].guard_element_set.include?(8)
return if @equip_window.index != 3
# 腰带
elsif item[0].guard_element_set.include?(9)
return if @equip_window.index != 4
# 鞋子
elsif item[0].guard_element_set.include?(10)
return if @equip_window.index != 5
end
when RPG::Item # 物品
return
end
# 变更装备
@item_window.data[@select_index] = item
@actor.equip(@equip_window.index, item[0].id)
# 释放图标
Picture.dispose(@item_icon)
@item_icon = nil
# 刷新物品窗口
@item_window.refresh
# 刷新装备窗口
@equip_window.refresh
return
end
#--------------------------------------------------------------------
# ● 没有选中
#--------------------------------------------------------------------
# 没有选中物品
if @item_icon.nil? and @equip_icon.nil? and @equip_window.item != nil
# 生成图片
@equip_icon = Sprite.new
@equip_icon.bitmap = RPG::Cache.icon(@equip_window.item.icon_name)
@equip_icon.z = 700
@initial_x = @mouse_x - (@equip_window.cursor_rect.x + @equip_window.x + 16) - (50 - @equip_icon.bitmap.width) / 2
@initial_y = @mouse_y - (@equip_window.cursor_rect.y + @equip_window.y + 16) - (50 - @equip_icon.bitmap.height) / 2
# 记忆选中物品
@select_index = @equip_window.index
@select_item = @equip_window.item
# 选中光标
@select_cursor.x = @select_index % 2 * 54 + 181 + 16
@select_cursor.y = @select_index / 2 * 54 + 10 + 16
@select_cursor.z = 600
$select_item = true
# 选中装备消失
@actor.armor2_id = 0 if @equip_window.index == 0
@actor.armor4_id = 0 if @equip_window.index == 1
@actor.weapon_id = 0 if @equip_window.index == 2
@actor.armor3_id = 0 if @equip_window.index == 3
@actor.armor1_id = 0 if @equip_window.index == 4
@actor.armor5_id = 0 if @equip_window.index == 5
# 刷新物品窗口
@equip_window.refresh
end
end
#----------------------------------------------------------------------
# ● 当按下鼠标右键时
#----------------------------------------------------------------------
# 当按下鼠标右键时
if Mouse.trigger?(0x02)
# 选中物品存在的情况下返回
return if @item_icon != nil or @equip_icon != nil
# 获取物品
item = @equip_window.item
case item
when RPG::Weapon # 武器
# 变更武器
@actor.equip(2, 0)
when RPG::Armor # 防具
# 帽子
if item.guard_element_set.include?(6)
@actor.equip(0, 0)
# 项链
elsif item.guard_element_set.include?(7)
@actor.equip(1, 0)
# 衣服
elsif item.guard_element_set.include?(8)
@actor.equip(3, 0)
# 腰带
elsif item.guard_element_set.include?(9)
@actor.equip(4, 0)
# 鞋子
elsif item.guard_element_set.include?(10)
@actor.equip(5, 0)
end
end
# 刷新物品窗口
@item_window.refresh
# 刷新装备窗口
@equip_window.refresh
end
end
end
end[/pre]
这个是装备限制等级的..[pre lang="ruby" line="1"]#==============================================================================
# ■ Window_EquipItem
#------------------------------------------------------------------------------
# 装备画面、显示浏览变更装备的候补物品的窗口。
#==============================================================================
class Window_EquipItem < Window_Selectable
#--------------------------------------------------------------------------
# ● 初始化对像
# actor : 角色
# equip_type : 装备部位 (0~3)
#--------------------------------------------------------------------------
def initialize(actor, equip_type)
super(0, 256, 640, 224)
@actor = actor
@equip_type = equip_type
@column_max = 2
refresh
self.active = false
self.index = -1
end
#--------------------------------------------------------------------------
# ● 获取物品
#--------------------------------------------------------------------------
def item
return @data[self.index]
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh
if self.contents != nil
self.contents.dispose
self.contents = nil
end
@data = []
# 添加可以装备的武器
###########################################################################
# 将有限制装备等级的武器编号写在@LLW里面
@LLW = [2, 3, 4]
# 将有限制装备等级的防具编号写在@LLA里面
@LLA = [2, 3, 4]
###########################################################################
if @equip_type == 0
weapon_set = $data_classes[@actor.class_id].weapon_set
for i in 1...$data_weapons.size
if $game_party.weapon_number(i) > 0 and weapon_set.include?(i)
###########################################################################
for z in 0..@LLW.size
if @LLW[z] == i # 该武器限制等级
lol = true
end
end
if lol == true
case i # 这个其实是武器编号
when 2 # 武器编号为2
if @actor.level >= 5 #角色等级大于5编号2的武器才能装备
@data.push($data_weapons)
end
when 3 # 武器编号为3
if @actor.level >= 10 #角色等级大于10编号3的武器才能装备
@data.push($data_weapons)
end
when 4 # 武器编号为4
if @actor.level >= 20 #角色等级大于20编号4的武器才能装备
@data.push($data_weapons)
end
# 要多添加的话按着格式写就行,在@LLW里面出现的编号记得都要在这里设定。
end
lol = false
else
@data.push($data_weapons)
end
###########################################################################
end
end
end
# 添加可以装备的防具
if @equip_type != 0
armor_set = $data_classes[@actor.class_id].armor_set
for i in 1...$data_armors.size
if $game_party.armor_number(i) > 0 and armor_set.include?(i)
if $data_armors.kind == @equip_type-1
###########################################################################
for z in 0..@LLA.size
if @LLA[z] == i # 该防具限制等级
lol = true
end
end
if lol == true
case i # 这个其实是防具编号
when 2 # 防具编号为2
if @actor.level >= 10 #角色等级大于10编号2的防具才能装备
@data.push($data_armors)
end
when 3 # 防具编号为3
if @actor.level >= 20 #角色等级大于20编号3的防具才能装备
@data.push($data_armors)
end
when 4 # 防具编号为4
if @actor.level >= 30 #角色等级大于30编号4的防具才能装备
@data.push($data_armors)
end
# 要多添加的话按着格式写就行,在@LLA里面出现的编号记得都要在这里设定。
end
lol = false
else
@data.push($data_armors)
end
###########################################################################
end
end
end
end
# 添加空白
@data.push(nil)
# 生成位图、描绘全部项目
@item_max = @data.size
self.contents = Bitmap.new(width - 32, row_max * 32)
for i in 0...@item_max-1
draw_item(i)
end
end
#--------------------------------------------------------------------------
# ● 项目的描绘
# index : 项目符号
#--------------------------------------------------------------------------
def draw_item(index)
item = @data[index]
x = 4 + index % 2 * (288 + 32)
y = index / 2 * 32
case item
when RPG::Weapon
number = $game_party.weapon_number(item.id)
when RPG::Armor
number = $game_party.armor_number(item.id)
end
bitmap = RPG::Cache.icon(item.icon_name)
self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24))
self.contents.font.color = normal_color
self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
self.contents.draw_text(x + 240, y, 16, 32, ":", 1)
self.contents.draw_text(x + 256, y, 24, 32, number.to_s, 2)
end
#--------------------------------------------------------------------------
# ● 刷新帮助文本
#--------------------------------------------------------------------------
def update_help
@help_window.set_text(self.item == nil ? "" : self.item.description)
end
end
[/pre] |
|