def self.call(id)
for i in 0...self.item_set.size
if id == self.item_set[0]
time = self.item_set[1]
@@fly_name = self.item_set[2]
@@battle_name = self.item_set[3]
break
end
end
$game_player.fly_time = time
self.change_graphics
end
def self.change_graphics
self.save
actor = $game_actors[1]
if actor != nil
actor.set_graphic(@@fly_name,CHARACTER_HUE,@@battle_name,BATTLE_HUE)
end
$game_player.refresh
end
def self.time_over
@@fly_name = ""
$game_player.fly_time = -1
self.load
end
def self.fly_name
return @@fly_name
end
def self.battle_name
return @@battle_name
end
def self.opacity
return WINDOW_OPACITY
end
def self.visible
return WINDOW_VISIBLE
end
def self.window_text
return WINDOW_TEXT
end
def self.time
return $game_player.fly_time
end
def self.save
actor = $game_actors[1]
@@character_name = actor.character_name
@@character_hue = actor.character_hue
@@battler_name = actor.battler_name
@@battler_hue = actor.battler_hue
end
def self.load
actor = $game_actors[1]
if actor != nil
actor.set_graphic(@@character_name,@@character_hue,@@battler_name,@@battler_hue)
end
$game_player.refresh
end
end
class Game_Player < Game_Character
attr_accessor :fly_time
def initialize
super
@fly_time = -1
end
#--------------------------------------------------------------------------
# ● 可以通行判定
# x : X 坐标
# y : Y 坐标
# d : 方向 (0,2,4,6,8) ※ 0 = 全方向不能通行的情况判定 (跳跃用)
#--------------------------------------------------------------------------
def passable?(x, y, d)
# 求得新的坐标
new_x = x + (d == 6 ? 1 : d == 4 ? -1 : 0)
new_y = y + (d == 2 ? 1 : d == 8 ? -1 : 0)
# 坐标在地图外的情况下
unless $game_map.valid?(new_x, new_y)
# 不能通行
return false
end
# 调试模式为 ON 并且 按下 CTRL 键的情况下
if $DEBUG and Input.press?(Input::CTRL)
# 可以通行
return true
end
if @fly_time > 0
return true
end
super
end
alias orig_update update
def update
orig_update
@fly_time -= 1 if @fly_time > 0
FLY.time_over if @fly_time == 0
end
end
class Scene_Item
#--------------------------------------------------------------------------
# ● 刷新画面 (目标窗口被激活的情况下)
#--------------------------------------------------------------------------
def update_target
# 按下 B 键的情况下
if Input.trigger?(Input::B)
# 演奏取消 SE
$game_system.se_play($data_system.cancel_se)
# 由于物品用完而不能使用的场合
unless $game_party.item_can_use?(@item.id)
# 再次生成物品窗口的内容
@item_window.refresh
end
# 删除目标窗口
@item_window.active = true
@target_window.visible = false
@target_window.active = false
return
end
# 按下 C 键的情况下
if Input.trigger?(Input::C)
# 如果物品用完的情况下
if $game_party.item_number(@item.id) == 0
# 演奏冻结 SE
$game_system.se_play($data_system.buzzer_se)
return
end
# 目标是全体的情况下
if @target_window.index == -1
# 对同伴全体应用物品使用效果
used = false
for i in $game_party.actors
used |= i.item_effect(@item)
end
end
# 目标是单体的情况下
if @target_window.index >= 0
# 对目标角色应用物品的使用效果
target = $game_party.actors[@target_window.index]
used = target.item_effect(@item)
end
# 使用物品的情况下
if used
# 演奏物品使用时的 SE
$game_system.se_play(@item.menu_se)
# 消耗品的情况下
if @item.consumable
# 使用的物品数减 1
$game_party.lose_item(@item.id, 1)
# 再描绘物品窗口的项目
@item_window.draw_item(@item_window.index)
# 飞行系统
unless $scene.is_a?(Scene_Battle)
a = []
for i in 0...FLY.item_set.size
a.push(FLY.item_set[0])
end
if a.include?(@item.id)
FLY.call(@item.id)
end
end
#飞行系统
end
# 再生成目标窗口的内容
@target_window.refresh
# 全灭的情况下
if $game_party.all_dead?
# 切换到游戏结束画面
$scene = Scene_Gameover.new
return
end
# 公共事件 ID 有效的情况下
if @item.common_event_id > 0
# 预约调用公共事件
$game_temp.common_event_id = @item.common_event_id
# 切换到地图画面
$scene = Scene_Map.new
return
end
end
# 无法使用物品的情况下
unless used
# 演奏冻结 SE
$game_system.se_play($data_system.buzzer_se)
end
return
end
end
end
class Scene_Map
#--------------------------------------------------------------------------
# ● 主处理
#--------------------------------------------------------------------------
alias ori_main main
def main
@time = Window_Base.new(50,350,150,100)
@time.z = 100
@time.opacity = FLY.opacity
@time.visible = FLY.visible
@time.contents = Bitmap.new(150-32,100-32)
@time.contents.font.size = 15
ori_main
@time.dispose
end
alias ori_update update
def update
@time.contents.clear
@time.contents.draw_text(10,0,100,32,FLY.window_text)
if $game_player.fly_time > 0
@time.contents.draw_text(30,30,100,32,$game_player.fly_time.to_s)
else
@time.contents.draw_text(30,30,100,32,"无效果")
end
ori_update
end