#==============================================================================
# ■ 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])
[url=home.php?mod=space&uid=358351]@talisman[/url] = Picture.new("UI/法宝",117,410,600,[0,0,3,1])
@arrange = Picture.new("UI/整理",162,410,600,[0,0,3,1])
[url=home.php?mod=space&uid=333762]@cash[/url] = 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 [email]0...@item_button.nitems[/email]
@item_button[i].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 [email]0...@item_button.nitems[/email]
System.update_button(@item_button[i],$事件)
if $事件[@item_button[i]][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