Project1
标题:
事件的穿透性變得奇奇怪怪的
[打印本页]
作者:
PCNinja
时间:
2012-3-24 21:57
标题:
事件的穿透性變得奇奇怪怪的
因為在[慕色輪回.光影的彼岸] copy過來的遮罩及光影效果,改了以下腳本
Spriteset_Map
<code>
#==============================================================================
# ■ Spriteset_Map
#------------------------------------------------------------------------------
# 处理地图画面活动块和元件的类。本类在
# Scene_Map 类的内部使用。
#==============================================================================
class Spriteset_Map
#--------------------------------------------------------------------------
# ● 初始化对像
#--------------------------------------------------------------------------
def initialize
# 生成显示端口
@viewport1 = Viewport.new(0, 0, 640, 480)
@viewport2 = Viewport.new(0, 0, 640, 480)
@viewport3 = Viewport.new(0, 0, 640, 480)
@viewport2.z = 200
@viewport3.z = 5000
# 生成元件地图
@tilemap = Tilemap.new(@viewport1)
@tilemap.tileset = RPG::Cache.tileset($game_map.tileset_name)
for i in 0..6
autotile_name = $game_map.autotile_names[i]
@tilemap.autotiles[i] = RPG::Cache.autotile(autotile_name)
end
@tilemap.map_data = $game_map.data
@tilemap.priorities = $game_map.priorities
# 生成远景平面
@panorama = Plane.new(@viewport1)
@panorama.z = -1000
# 生成雾平面
@fog = Plane.new(@viewport1)
@fog.z = 3000
# 生成角色活动块
@character_sprites = []
for i in $game_map.events.keys.sort
sprite = Sprite_Character.new(@viewport1, $game_map.events[i])
@character_sprites.push(sprite)
end
@mask_sprites = []
@object_sprites = []
for i in $game_map.objects.keys.sort
sprite = Sprite_Character.new(@viewport1, $game_map.objects[i], $game_map.objects[i].name)
@object_sprites.push(sprite)
# マスクの設定
if $game_map.events[i].name[/Mask/]
for list in $game_map.objects[i].list
parameter = list.parameters[0]
if parameter != nil
if parameter[/"(\d+), (\d+), (\d+)"/]
color = Color.new($1.to_i, $2.to_i, $3.to_i)
else
# マスクスプライトの作成
sprite = Sprite.new(@viewport1)
parameter[/\((\d+), (\d+), (\d+), (\d+)\)/]
# マスクスプライトの描画座標を設定
sprite.x = $1.to_i * 32 + 16
sprite.y = $2.to_i * 32 + 16
sprite.z = 2000
# マスクスプライトのビットマップを設定
sprite.bitmap = Bitmap.new(
($3.to_i - $1.to_i) * 32, ($4.to_i - $2.to_i) * 32)
sprite.bitmap.fill_rect(0, 0, sprite.bitmap.width,
sprite.bitmap.height, color)
if parameter[/<(\d+), (\d+), (\d+), (\d+)>/]
sprite.bitmap.fill_rect($1.to_i * 32 - sprite.x + 16,
$2.to_i * 32 - sprite.y + 16, ($3.to_i - $1.to_i) * 32,
($4.to_i - $2.to_i) * 32, Color.new(0, 0, 0, 0))
end
# 各マスク設定の取得
parameter[/\[(\d+), (\d+), (\d+), (\d+)\]/]
mask = [sprite, [$1.to_i, $2.to_i, $3.to_i, $4.to_i], []]
if parameter[/{(\d+), (\d+), (\d+), (\d+)}/]
mask[2] = [$1.to_i, $2.to_i, $3.to_i, $4.to_i]
end
# 透過度の設定
if (mask[1][0]..mask[1][2]) === $game_player.x and
(mask[1][1]..mask[1][3]) === $game_player.y and
(mask[2].empty? or
not ((mask[2][0]..mask[2][2]) === $game_player.x and
(mask[2][1]..mask[2][3]) === $game_player.y))
mask[0].opacity = 0
else
mask[0].opacity = 255
end
# マスクスプライトセットにマスクを追加
@mask_sprites.push(mask)
end
end
end
end
end
@character_sprites.push(Sprite_Character.new(@viewport1, $game_player))
# 生成天气
@weather = RPG::Weather.new(@viewport1)
@mask = Sprite.new(@viewport1)
@mask_name = $game_map.mask_name
if $game_map.mask_name != ""
@mask.blend_type = $game_map.mask_blend_type
@mask.bitmap = RPG::Cache.fog($game_map.mask_name, 0)
if $game_map.time < 10
@mask.x = $game_player.screen_x
@mask.y = $game_player.screen_y - 16
else
@mask.x = 0
@mask.y = 0
end
@mask.z = 3000
@mask.ox = @mask.bitmap.width / 2
@mask.oy = @mask.bitmap.height / 2
end
@text_picture = []
# 生成图片
@picture_sprites = []
for i in 1..50
@picture_sprites.push(Sprite_Picture.new(@viewport2,
$game_screen.pictures[i]))
end
# 生成计时器块
@timer_sprite = Sprite_Timer.new
# 刷新画面
update
end
#--------------------------------------------------------------------------
# ● 释放
#--------------------------------------------------------------------------
def dispose
# 释放元件地图
@tilemap.tileset.dispose
for i in 0..6
@tilemap.autotiles[i].dispose
end
@tilemap.dispose
# 释放远景平面
@panorama.dispose
# 释放雾平面
@fog.dispose
# 释放角色活动块
for sprite in @character_sprites
sprite.dispose
end
# 释放天候
@weather.dispose
# 释放图片
for sprite in @picture_sprites
sprite.dispose
end
if @mask.bitmap != nil
@mask.bitmap.dispose
end
@mask.dispose
for sprite in @text_picture.reverse
sprite.dispose
@text_picture.delete(sprite)
end
# 释放计时器块
@timer_sprite.dispose
# 释放显示端口
@viewport1.dispose
@viewport2.dispose
@viewport3.dispose
end
#--------------------------------------------------------------------------
# ● 刷新画面
#--------------------------------------------------------------------------
def update
# 远景与现在的情况有差异发生的情况下
if @panorama_name != $game_map.panorama_name or
@panorama_hue != $game_map.panorama_hue
@panorama_name = $game_map.panorama_name
@panorama_hue = $game_map.panorama_hue
if @panorama.bitmap != nil
@panorama.bitmap.dispose
@panorama.bitmap = nil
end
if @panorama_name != ""
@panorama.bitmap = RPG::Cache.panorama(@panorama_name, @panorama_hue)
end
Graphics.frame_reset
end
# 雾与现在的情况有差异的情况下
if (@fog_name != $game_map.fog_name or @fog_hue != $game_map.fog_hue)
@fog_name = $game_map.fog_name
@fog_hue = $game_map.fog_hue
if @fog.bitmap != nil
@fog.bitmap.dispose
@fog.bitmap = nil
end
if @fog_name != ""
@fog.bitmap = RPG::Cache.fog(@fog_name, @fog_hue)
end
Graphics.frame_reset
end
# 刷新元件地图
@tilemap.ox = $game_map.display_x / 4
@tilemap.oy = $game_map.display_y / 4
@tilemap.update
for mask in @mask_sprites
mask[0].ox = $game_map.display_x / 4
mask[0].oy = $game_map.display_y / 4
# 透過度の設定
if (mask[1][0]..mask[1][2]) === $game_player.x and
(mask[1][1]..mask[1][3]) === $game_player.y and
(mask[2].empty? or
not ((mask[2][0]..mask[2][2]) === $game_player.x and
(mask[2][1]..mask[2][3]) === $game_player.y))
mask[0].opacity -= 16 if mask[0].opacity > 0
else
mask[0].opacity += 8 if mask[0].opacity < 255
end
end
# 刷新远景平面
@panorama.ox = $game_map.display_x / 8
@panorama.oy = $game_map.display_y / 8
# 刷新雾平面
@fog.zoom_x = $game_map.fog_zoom / 100.0
@fog.zoom_y = $game_map.fog_zoom / 100.0
@fog.opacity = $game_map.fog_opacity
@fog.blend_type = $game_map.fog_blend_type
@fog.ox = $game_map.display_x / 4 + $game_map.fog_ox
@fog.oy = $game_map.display_y / 4 + $game_map.fog_oy
@fog.tone = $game_map.fog_tone
# 刷新角色活动块
for sprite in @character_sprites
sprite.update
end
# 刷新天候图形
@weather.type = $game_screen.weather_type
@weather.max = $game_screen.weather_max
@weather.ox = $game_map.display_x / 4
@weather.oy = $game_map.display_y / 4
@weather.update
# 刷新图片
for sprite in @picture_sprites
sprite.update
end
for sprite in @text_picture.reverse
sprite.update
@text_picture.delete(sprite) if sprite.disposed?
end
# 刷新计时器块
@timer_sprite.update
# 设置画面的色调与震动位置
@viewport1.tone = $game_screen.tone
@viewport1.ox = $game_screen.shake_x
@viewport1.oy = $game_screen.shake_y
# マスクの設定
if @mask_name != $game_map.mask_name
if @mask.bitmap != nil
@mask.bitmap.dispose
@mask.bitmap = nil
end
@mask_name = $game_map.mask_name
if @mask_name != ""
@mask.bitmap = Bitmap.new("Graphics/Fogs/" + @mask_name)
@mask.blend_type = $game_map.mask_blend_type
@mask.z = 3000
@mask.ox = @mask.bitmap.width / 2
@mask.oy = @mask.bitmap.height / 2
end
end
@mask.opacity = $game_map.mask_opacity
case @mask_name
when "Mask_01"
@mask.x = $game_player.screen_x
@mask.y = $game_player.screen_y - 16
when "Mask_02"
@mask.x = $game_player.screen_x
@mask.y = $game_player.screen_y - 16
when "Mask_03"
@mask.x = @light.x
@mask.y = @light.y
when "Mask_04"
@mask.x = $game_player.screen_x
@mask.y = $game_player.screen_y - 16
when "Mask_05"
@mask.x = @light.x
@mask.y = @light.y
when "Mask_06"
@mask.x = 320
@mask.y = 240
when "Mask_07"
@mask.x = @light.x
@mask.y = @light.y
end
# 设置画面的闪烁色
@viewport3.color = $game_screen.flash_color
# 刷新显示端口
@viewport1.update
@viewport3.update
#@c.update
end
end
复制代码
==============================================================================
Game_Map
#==============================================================================
# ■ Game_Map
#------------------------------------------------------------------------------
# 处理地图的类。包含卷动以及可以通行的判断功能。
# 本类的实例请参考 $game_map 。
#==============================================================================
class Game_Map
#--------------------------------------------------------------------------
# ● 定义实例变量
#--------------------------------------------------------------------------
attr_accessor :tileset_name # 元件 文件名
attr_accessor :autotile_names # 自动元件 文件名
attr_accessor :panorama_name # 全景 文件名
attr_accessor :panorama_hue # 全景 色相
attr_accessor :fog_name # 雾 文件名
attr_accessor :fog_hue # 雾 色相
attr_accessor :fog_opacity # 雾 不透明度
attr_accessor :fog_blend_type # 雾 混合方式
attr_accessor :fog_zoom # 雾 放大率
attr_accessor :fog_sx # 雾 SX
attr_accessor :fog_sy # 雾 SY
attr_accessor :battleback_name # 战斗背景 文件名
attr_accessor :display_x # 显示 X 坐标 * 128
attr_accessor :display_y # 显示 Y 坐标 * 128
attr_accessor :need_refresh # 刷新要求标志
attr_reader :passages # 通行表
attr_reader :priorities # 优先表
attr_reader :terrain_tags # 地形标记表
attr_reader :events # 事件
attr_reader :fog_ox # 雾 原点 X 坐标
attr_reader :fog_oy # 雾 原点 Y 坐标
attr_reader :fog_tone # 雾 色调
attr_reader :mask_name # マスク
attr_reader :mask_opacity # マスク不透過度
attr_reader :mask_blend_type # マスクブレンドタイプ
attr_reader :objects
#--------------------------------------------------------------------------
# ● 初始化条件
#--------------------------------------------------------------------------
def initialize
@map_id = 0
@display_x = 0
@display_y = 0
end
#--------------------------------------------------------------------------
# ● 设置
# map_id : 地图 ID
#--------------------------------------------------------------------------
def setup(map_id)
# 地图 ID 记录到 @map_id
@map_id = map_id
# 地图文件装载后、设置到 @map
@map = load_data(sprintf("Data/Map%03d.rxdata", @map_id))
# 定义实例变量设置地图元件信息
tileset = $data_tilesets[@map.tileset_id]
@tileset_name = tileset.tileset_name
@autotile_names = tileset.autotile_names
@panorama_name = tileset.panorama_name
@panorama_hue = tileset.panorama_hue
@fog_name = tileset.fog_name
@fog_hue = tileset.fog_hue
@fog_opacity = tileset.fog_opacity
@fog_blend_type = tileset.fog_blend_type
@fog_zoom = tileset.fog_zoom
@fog_sx = tileset.fog_sx
@fog_sy = tileset.fog_sy
@battleback_name = tileset.battleback_name
@passages = tileset.passages
@priorities = tileset.priorities
@terrain_tags = tileset.terrain_tags
# 初始化显示坐标
@display_x = 0
@display_y = 0
# 清除刷新要求标志
@need_refresh = false
# 设置地图事件数据
@events = {}
@objects = {}
for i in @map.events.keys
@events[i] = Game_Event.new(@map_id, @map.events[i])
if events[i].name[/Object/] != nil
@objects[i] = @events[i]
end
end
# 设置公共事件数据
@common_events = {}
for i in 1...$data_common_events.size
@common_events[i] = Game_CommonEvent.new(i)
end
@mask_name = ""
@mask_opacity = 255
@mask_blend_type = 0
# 初始化雾的各种信息
@fog_ox = 0
@fog_oy = 0
@fog_tone = Tone.new(0, 0, 0, 0)
@fog_tone_target = Tone.new(0, 0, 0, 0)
@fog_tone_duration = 0
@fog_opacity_duration = 0
@fog_opacity_target = 0
# 初始化滚动信息
@scroll_direction = 2
@scroll_rest = 0
@scroll_speed = 4
end
#--------------------------------------------------------------------------
# ● 获取地图 ID
#--------------------------------------------------------------------------
def map_id
return @map_id
end
#--------------------------------------------------------------------------
# ● 获取宽度
#--------------------------------------------------------------------------
def width
return @map.width
end
#--------------------------------------------------------------------------
# ● 获取高度
#--------------------------------------------------------------------------
def height
return @map.height
end
#--------------------------------------------------------------------------
# ● 获取遇敌列表
#--------------------------------------------------------------------------
def encounter_list
return @map.encounter_list
end
#--------------------------------------------------------------------------
# ● 获取遇敌步数
#--------------------------------------------------------------------------
def encounter_step
return @map.encounter_step
end
#--------------------------------------------------------------------------
# ● 获取地图数据
#--------------------------------------------------------------------------
def data
return @map.data
end
#--------------------------------------------------------------------------
# ● BGM / BGS 自动切换
#--------------------------------------------------------------------------
def autoplay
if @map.autoplay_bgm && $game_switches[6]==false
$game_system.bgm_play(@map.bgm)
end
if @map.autoplay_bgs
$game_system.bgs_play(@map.bgs)
end
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh
# 地图 ID 有效
if @map_id > 0
# 刷新全部的地图事件
for event in @events.values
event.refresh
end
# 刷新全部的公共事件
for common_event in @common_events.values
common_event.refresh
end
end
# 清除刷新要求标志
@need_refresh = false
end
#--------------------------------------------------------------------------
# ● 向下滚动
# distance : 滚动距离
#--------------------------------------------------------------------------
def scroll_down(distance)
@display_y = [@display_y + distance, (self.height - 15) * 128].min
end
#--------------------------------------------------------------------------
# ● 向左滚动
# distance : 滚动距离
#--------------------------------------------------------------------------
def scroll_left(distance)
@display_x = [@display_x - distance, 0].max
end
#--------------------------------------------------------------------------
# ● 向右滚动
# distance : 滚动距离
#--------------------------------------------------------------------------
def scroll_right(distance)
@display_x = [@display_x + distance, (self.width - 20) * 128].min
end
#--------------------------------------------------------------------------
# ● 向上滚动
# distance : 滚动距离
#--------------------------------------------------------------------------
def scroll_up(distance)
@display_y = [@display_y - distance, 0].max
end
#--------------------------------------------------------------------------
# ● 有效坐标判定
# x : X 坐标
# y : Y 坐标
#--------------------------------------------------------------------------
def valid?(x, y)
return (x >= 0 and x < width and y >= 1 and y < height-1)
end
#--------------------------------------------------------------------------
# ● 可以通行判定
# x : X 坐标
# y : Y 坐标
# d : 方向 (0,2,4,6,8,10)
# ※ 0,10 = 全方向不能通行的情况的判定 (跳跃等)
# self_event : 自己 (判定事件可以通行的情况下)
#--------------------------------------------------------------------------
def passable?(x, y, d, self_event = nil)
# 被给予的坐标地图外的情况下
unless valid?(x, y)
# 不能通行
return false
end
# 方向 (0,2,4,6,8,10) 与障碍物接触 (0,1,2,4,8,0) 后变换
bit = (1 << (d / 2 - 1)) & 0x0f
# 循环全部的事件
for event in events.values
# 自己以外的元件与坐标相同的情况
if event.tile_id >= 0 and event != self_event and
event.x == x and event.y == y and not event.through
# 如果障碍物的接触被设置的情况下
if @passages[event.tile_id] & bit != 0
# 不能通行
return false
# 如果全方向的障碍物的接触被设置的情况下
elsif @passages[event.tile_id] & 0x0f == 0x0f
# 不能通行
return false
# 这以外的优先度为 0 的情况下
elsif @priorities[event.tile_id] == 0
# 可以通行
return true
end
end
end
# 从层按从上到下的顺序调查循环
for i in [2, 1, 0]
# 取得元件 ID
tile_id = data[x, y, i]
# 取得元件 ID 失败
if tile_id == nil
# 不能通行
return false
# 如果障碍物的接触被设置的情况下
elsif @passages[tile_id] & bit != 0
# 不能通行
return false
# 如果全方向的障碍物的接触被设置的情况下
elsif @passages[tile_id] & 0x0f == 0x0f
# 不能通行
return false
# 这以外的优先度为 0 的情况下
elsif @priorities[tile_id] == 0
# 可以通行
return true
end
end
# 可以通行
return true
end
#--------------------------------------------------------------------------
# ● 茂密判定
# x : X 坐标
# y : Y 坐标
#--------------------------------------------------------------------------
def bush?(x, y)
if @map_id != 0
for i in [2, 1, 0]
tile_id = data[x, y, i]
if tile_id == nil
return false
elsif @passages[tile_id] & 0x40 == 0x40
return true
end
end
end
return false
end
#--------------------------------------------------------------------------
# ● 柜台判定
# x : X 坐标
# y : Y 坐标
#--------------------------------------------------------------------------
def counter?(x, y)
if @map_id != 0
for i in [2, 1, 0]
tile_id = data[x, y, i]
if tile_id == nil
return false
elsif @passages[tile_id] & 0x80 == 0x80
return true
end
end
end
return false
end
#--------------------------------------------------------------------------
# ● 获取地形标志
# x : X 坐标
# y : Y 坐标
#--------------------------------------------------------------------------
def terrain_tag(x, y)
if @map_id != 0
for i in [2, 1, 0]
tile_id = data[x, y, i]
if tile_id == nil or @terrain_tags[tile_id] == nil
return 0
elsif @terrain_tags[tile_id] > 0 #bug tabris
return @terrain_tags[tile_id]
end
end
end
return 0
end
#--------------------------------------------------------------------------
# ● 获取指定位置的事件 ID
# x : X 坐标
# y : Y 坐标
#--------------------------------------------------------------------------
def check_event(x, y)
for event in $game_map.events.values
if event.x == x and event.y == y
return event.id
end
end
end
#--------------------------------------------------------------------------
# ● 滚动开始
# direction : 滚动方向
# distance : 滚动距离
# speed : 滚动速度
#--------------------------------------------------------------------------
def start_scroll(direction, distance, speed)
@scroll_direction = direction
@scroll_rest = distance * 128
@scroll_speed = speed
end
#--------------------------------------------------------------------------
# ● 滚动中判定
#--------------------------------------------------------------------------
def scrolling?
return @scroll_rest > 0
end
#--------------------------------------------------------------------------
# ● 开始变更雾的色调
# tone : 色调
# duration : 时间
#--------------------------------------------------------------------------
def start_fog_tone_change(tone, duration)
@fog_tone_target = tone.clone
@fog_tone_duration = duration
if @fog_tone_duration == 0
@fog_tone = @fog_tone_target.clone
end
end
#--------------------------------------------------------------------------
# ● 开始变更雾的不透明度
# opacity : 不透明度
# duration : 时间
#--------------------------------------------------------------------------
def start_fog_opacity_change(opacity, duration)
@fog_opacity_target = opacity * 1.0
@fog_opacity_duration = duration
if @fog_opacity_duration == 0
@fog_opacity = @fog_opacity_target
end
end
#--------------------------------------------------------------------------
# ● 刷新画面
#--------------------------------------------------------------------------
def update
# 还原必要的地图
if $game_map.need_refresh
refresh
end
# 滚动中的情况下
if @scroll_rest > 0
# 滚动速度变化为地图坐标系的距离
distance = 2 ** @scroll_speed
# 执行滚动
case @scroll_direction
when 2 # 下
scroll_down(distance)
when 4 # 左
scroll_left(distance)
when 6 # 右
scroll_right(distance)
when 8 # 上
scroll_up(distance)
end
# 滚动距离的减法运算
@scroll_rest -= distance
end
# 更新地图事件
for event in @events.values
event.update
end
# 更新公共事件
for common_event in @common_events.values
common_event.update
end
# 处理雾的滚动
@fog_ox -= @fog_sx / 8.0
@fog_oy -= @fog_sy / 8.0
# 处理雾的色调变更
if @fog_tone_duration >= 1
d = @fog_tone_duration
target = @fog_tone_target
@fog_tone.red = (@fog_tone.red * (d - 1) + target.red) / d
@fog_tone.green = (@fog_tone.green * (d - 1) + target.green) / d
@fog_tone.blue = (@fog_tone.blue * (d - 1) + target.blue) / d
@fog_tone.gray = (@fog_tone.gray * (d - 1) + target.gray) / d
@fog_tone_duration -= 1
end
# 处理雾的不透明度变更
if @fog_opacity_duration >= 1
d = @fog_opacity_duration
@fog_opacity = (@fog_opacity * (d - 1) + @fog_opacity_target) / d
@fog_opacity_duration -= 1
end
end
end
复制代码
spriteset_character
def initialize(viewport, character = nil , name = "")
@name = name
@character = character
super(viewport)
update
end
复制代码
只改了這部份
game_event (只改了這部份)
attr_reader :trigger # 目标
attr_reader :list # 执行内容
attr_reader :starting # 启动中标志
attr_reader :name
复制代码
加入light effect
# ? Light Effects
#================================
# ?By: Near Fantastica
# Date: 28.06.05
# Version: 3
#================================
class Spriteset_Map
#class Scene_Map
#--------------------------------------------------------------
alias les_spriteset_map_initalize initialize
alias les_spriteset_map_dispose dispose
alias les_spriteset_map_update update
#--------------------------------------------------------------
def initialize
@light_effects = []
setup_lights
les_spriteset_map_initalize
update
end
#--------------------------------------------------------------
def dispose
les_spriteset_map_dispose
for effect in @light_effects
effect.light.dispose
end
@light_effects = []
end
#--------------------------------------------------------------
def update
les_spriteset_map_update
update_light_effects
end
#--------------------------------------------------------------
def setup_lights
for event in $game_map.events.values
next if event.list == nil
for i in 0...event.list.size
if event.list[i].code == 108 and event.list[i].parameters == ["Light Effects"]
type = event.list[i+1].parameters.to_s
case type.upcase!
when "GROUND"
light_effects = Light_Effect.new(event,type)
light_effects.light.zoom_x = 400 / 100.0
light_effects.light.zoom_y = 400 / 100.0
light_effects.light.opacity = 200
@light_effects.push(light_effects)
when "NIGHT"
light_effects = Light_Effect.new(event,type)
light_effects.light.zoom_x = 200 / 100.0
light_effects.light.zoom_y = 200 / 100.0
light_effects.light.opacity = 0
@light_effects.push(light_effects)
when "FIRE"
light_effects = Light_Effect.new(event,type)
light_effects.light.zoom_x = 300 / 100.0
light_effects.light.zoom_y = 300 / 100.0
light_effects.light.opacity = 255
@light_effects.push(light_effects)
when "LAMPPOST"
light_effects = Light_Effect.new(event,"LEFT LAMP POST")
light_effects.light.opacity = 100
@light_effects.push(light_effects)
light_effects = Light_Effect.new(event,"RIGHT LAMP POST")
light_effects.light.opacity = 100
@light_effects.push(light_effects)
when "LEFTLANTERN"
light_effects = Light_Effect.new(event,type)
light_effects.light.opacity = 150
@light_effects.push(light_effects)
when "RIGHTLANTERN"
light_effects = Light_Effect.new(event,type)
light_effects.light.opacity = 150
@light_effects.push(light_effects)
when "DARK"
light_effects = Dark_Effect.new(event,type)
light_effects.light.opacity = 150
@light_effects.push(light_effects)
end
end
end
end
for effect in @light_effects
case effect.type
when "GROUND"
effect.light.x = (effect.event.real_x - 450 - $game_map.display_x) / 4
effect.light.y = (effect.event.real_y - 400 - $game_map.display_y) / 4
when "FIRE"
effect.light.x = (effect.event.real_x - 300 - $game_map.display_x) / 4
effect.light.y = (effect.event.real_y - 300 - $game_map.display_y) / 4
when "NIGHT"
effect.light.x = (effect.event.real_x - 300 - $game_map.display_x) / 4
effect.light.y = (effect.event.real_y - 300 - $game_map.display_y) / 4
when "LEFT LAMP POST"
effect.light.x = (-0.25 * $game_map.display_x) + (effect.event.x * 32) - 5
effect.light.y = (-0.25 * $game_map.display_y) + (effect.event.y * 32) - 15
when "RIGHT LAMP POST"
effect.light.x = (-0.25 * $game_map.display_x) + (effect.event.x * 32) - 25
effect.light.y = (-0.25 * $game_map.display_y) + (effect.event.y * 32) - 15
when "LEFTLANTERN"
effect.light.x = (-0.25 * $game_map.display_x) + (effect.event.x * 32) - 20
effect.light.y = (-0.25 * $game_map.display_y) + (effect.event.y * 32) - 5
when "RIGHTLANTERN"
effect.light.x = (-0.25 * $game_map.display_x) + (effect.event.x * 32) - 10
effect.light.y = (-0.25 * $game_map.display_y) + (effect.event.y * 32) - 5
when "DARK"
effect.light.x = $game_player.screen_x - 640
effect.light.y = $game_player.screen_y - 480
end
end
end
#--------------------------------------------------------------
def update_light_effects
for effect in @light_effects
next if not in_range?(effect.event)
case effect.type
when "GROUND"
effect.light.x = (effect.event.real_x - 450 - $game_map.display_x) / 4
effect.light.y = (effect.event.real_y - 400 - $game_map.display_y) / 4
when "NIGHT"
effect.light.x = (effect.event.real_x - 180 - $game_map.display_x) / 4
effect.light.y = (effect.event.real_y - 200 - $game_map.display_y) / 4
case $game_system.daynight_phase
when 0
effect.light.opacity = 0
when 1
effect.light.opacity = 130
when 2
effect.light.opacity = 200
when 3
effect.light.opacity = 0
end
when "FIRE"
effect.light.x = (effect.event.real_x - 300 - $game_map.display_x) / 4
effect.light.y = (effect.event.real_y - 300 - $game_map.display_y) / 4
when "LEFT LAMP POST"
effect.light.x = (-0.25 * $game_map.display_x) + (effect.event.x * 32) - 5
effect.light.y = (-0.25 * $game_map.display_y) + (effect.event.y * 32) - 15
when "RIGHT LAMP POST"
effect.light.x = (-0.25 * $game_map.display_x) + (effect.event.x * 32) - 25
effect.light.y = (-0.25 * $game_map.display_y) + (effect.event.y * 32) - 15
when "LEFTLANTERN"
effect.light.x = (-0.25 * $game_map.display_x) + (effect.event.x * 32) - 20
effect.light.y = (-0.25 * $game_map.display_y) + (effect.event.y * 32) - 5
when "RIGHTLANTERN"
effect.light.x = (-0.25 * $game_map.display_x) + (effect.event.x * 32) - 10
effect.light.y = (-0.25 * $game_map.display_y) + (effect.event.y * 32) - 5
when "DARK"
effect.light.x = $game_player.screen_x - 640
effect.light.y = $game_player.screen_y - 480
end
end
end
#--------------------------------------------------------------
def in_range?(object)
screne_x = $game_map.display_x
screne_x -= 256
screne_y = $game_map.display_y
screne_y -= 256
screne_width = $game_map.display_x
screne_width += 2816
screne_height = $game_map.display_y
screne_height += 2176
return false if object.real_x <= screne_x
return false if object.real_x >= screne_width
return false if object.real_y <= screne_y
return false if object.real_y >= screne_height
return true
end
end
#================================
# ? Light Effects Class
#================================
class Light_Effect
#--------------------------------------------------------------
attr_accessor :light
attr_accessor :event
attr_accessor :type
#--------------------------------------------------------------
def initialize(event, type)
@light = Sprite.new(@viewport1)
@light.bitmap = RPG::Cache.title("le.png")
@light.visible = true
@light.z = 1
@light.blend_type = 1
@event = event
@type = type
end
end
class Dark_Effect
#--------------------------------------------------------------
attr_accessor :light
attr_accessor :event
attr_accessor :type
#--------------------------------------------------------------
def initialize(event, type)
@light=Sprite.new
@light.bitmap = RPG::Cache.title("dark.jpg")
@light.blend_type = 2
@light.z = 2
#@light.opacity = 180
@event = event
@type = type
end
end
复制代码
效果是不錯,不過奇怪地有些場所移動的事件明明設定了可被穿透,不過卻不能被穿透,是有甚麼問題嗎?
dsu_plus_rewardpost_czw
欢迎光临 Project1 (https://rpg.blue/)
Powered by Discuz! X3.1