class Game_Event < Game_Character
#--------------------------------------------------------------------------
# ● 定义实例变量
#--------------------------------------------------------------------------
attr_reader :trigger # 目标
attr_reader :list # 执行内容
attr_reader :starting # 启动中标志
attr_accessor :pagenum #事件页的编号
attr_accessor :startpage #要转到的事件页编号
#--------------------------------------------------------------------------
# ● 初始化对像
# map_id : 地图 ID
# event : 事件 (RPG::Event)
#--------------------------------------------------------------------------
def initialize(map_id, event)
super()
@map_id = map_id
@event = event
@id = @event.id
@erased = false
@starting = false
@through = true
# 初期位置的移动
moveto(@event.x, @event.y)
@pagenum = nil
@startpage = 0
refresh
end
#--------------------------------------------------------------------------
# ● 启动事件
#--------------------------------------------------------------------------
# 启动事件的某事件页
def start(num = nil)
@startpage = num if num != nil
refresh if num != nil
# 执行内容不为空的情况下
if @list != nil and @list.size > 1
@starting = true
end
end
# 变成事件的某事件页
def stpage(num = nil)
@startpage = num if num != nil
refresh if num != nil
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh
# 初始化本地变量 new_page
new_page = nil
# 无法暂时消失的情况下
unless @erased
# 从编号大的事件页按顺序调查
@pagenum = @event.pages.size + 1
for page in @event.pages.reverse
@pagenum -= 1
new_page = page if @startpage == @pagenum
break if @startpage == @pagenum
next if @startpage != 0
# 可以参考事件条件 c
c = page.condition
# 确认开关条件 1
if c.switch1_valid
if $game_switches[c.switch1_id] == false
next
end
end
# 确认开关条件 2
if c.switch2_valid
if $game_switches[c.switch2_id] == false
next
end
end
# 确认变量条件
if c.variable_valid
if $game_variables[c.variable_id] < c.variable_value
next
end
end
# 确认独立开关条件
if c.self_switch_valid
key = [@map_id, @event.id, c.self_switch_ch]
if $game_self_switches[key] != true
next
end
end
# 设置本地变量 new_page
new_page = page
# 跳出循环
break
end
end
# 与上次同一事件页的情况下
if new_page == @page
# 过程结束
return
end
# @page 设置为现在的事件页
@page = new_page
# 清除启动中标志
clear_starting
# 没有满足条件的页面的时候
if @page == nil
# 设置各实例变量
@tile_id = 0
@character_name = ""
@character_hue = 0
@move_type = 0
@through = true
@trigger = nil
@list = nil
@interpreter = nil
# 过程结束
return
end
# 设置各实例变量
@tile_id = @page.graphic.tile_id
@character_name = @page.graphic.character_name
@character_hue = @page.graphic.character_hue
if @original_direction != @page.graphic.direction
@direction = @page.graphic.direction
@original_direction = @direction
@prelock_direction = 0
end
if @original_pattern != @page.graphic.pattern
@pattern = @page.graphic.pattern
@original_pattern = @pattern
end
@opacity = @page.graphic.opacity
@blend_type = @page.graphic.blend_type
@move_type = @page.move_type
@move_speed = @page.move_speed
@move_frequency = @page.move_frequency
@move_route = @page.move_route
@move_route_index = 0
@move_route_forcing = false
@walk_anime = @page.walk_anime
@step_anime = @page.step_anime
@direction_fix = @page.direction_fix
@through = @page.through
@always_on_top = @page.always_on_top
@trigger = @page.trigger
@list = @page.list
@interpreter = nil
# 目标是 [并行处理] 的情况下
if @trigger == 4
# 生成并行处理用解释器
@interpreter = Interpreter.new
end
# 自动事件启动判定
check_event_trigger_auto
end
end