module EnemyMoving # 定义类
def self.main # 新建实例对象时,将调用的东西
$game_map.events.each_pair do |_,event| # event将会依次成为每个事件
if event.instance_variable_get(:@event).name == "学生" then # 判定事件的名字
if (event.x - $game_player.x).abs <= 4 && (event.y - $game_player.y).abs <= 4 then
# && 相当于 and, 是“且”的意思
# 如果事件x坐标和y坐标与玩家的差的绝对值小于等于4
# 即事件在以主角为中心9x9方格中时
$game_self_switches[[$game_map.map_id,event.id,"A"]] = true
# 打开独立开关,event.id即事件id
else
$game_self_switches[[$game_map.map_id,event.id,"A"]] = false
# 否则关上
end
# 下面这种写法是“一行党”的:
# $game_self_switches[[$game_map.map_id,event.id,"A"]] =
# (event.x - $game_player.x).abs <= 4 && (event.y - $game_player.y).abs <= 4
end
end
end
end
module EnemyMoving # 定义类
def self.main # 新建实例对象时,将调用的东西
$game_map.events.each_pair do |_,event| # event将会依次成为每个事件
if event.instance_variable_get(:@event).name == "学生" then # 判定事件的名字
if (event.x - $game_player.x).abs <= 4 && (event.y - $game_player.y).abs <= 4 then
# && 相当于 and, 是“且”的意思
# 如果事件x坐标和y坐标与玩家的差的绝对值小于等于4
# 即事件在以主角为中心9x9方格中时
$game_self_switches[[$game_map.map_id,event.id,"A"]] = true
# 打开独立开关,event.id即事件id
else
$game_self_switches[[$game_map.map_id,event.id,"A"]] = false
# 否则关上
end
# 下面这种写法是“一行党”的:
# $game_self_switches[[$game_map.map_id,event.id,"A"]] =
# (event.x - $game_player.x).abs <= 4 && (event.y - $game_player.y).abs <= 4
end
end
end
end