赞 | 3 |
VIP | 12 |
好人卡 | 3 |
积分 | 8 |
经验 | 45682 |
最后登录 | 2022-10-11 |
在线时间 | 173 小时 |
Lv2.观梦者
- 梦石
- 0
- 星屑
- 810
- 在线时间
- 173 小时
- 注册时间
- 2008-11-22
- 帖子
- 112
|
本帖最后由 wyongcan2008 于 2012-4-14 13:05 编辑
我想还可以优化一下,在泡泡的判断中
如果炮炮威力*4+1>地图事件数,
就循环所有事件来判断,
如果小于的话就循环判断泡泡炸到的位置有没有事件。
我按照的做eventinfo的想法自己写了段脚本,用到了提取放置物脚本简洁版。
不过你说的事件是移动的这一点还真没考虑到。- module Event
- def self.xy_tos (x,y)
- ox = x.to_s
- oy = y.to_s
- while ox.size < 3
- ox = "0" + ox
- end
- while oy.size < 3
- oy = "0" + oy
- end
- ox + oy
- end
- def self.id_byxy(x,y)
- $game_map.eventinfo[xy_tos(x,y)]
- end
- def self.id_byxys(xy)
- $game_map.eventinfo[xy]
- end
- def self.event_byxy(x,y)
- $game_map.events[$game_map.eventinfo[xy_tos(x,y)]]
- end
- def self.event_byxys(xy)
- $game_map.events[$game_map.eventinfo[xy]]
- end
- end
- module Drop_Item
- def self.make_events(map_id,event_id,item_x,item_y,save=false)
- return unless self.is_map?
- map = load_data(sprintf("Data/Map%03d.rxdata", map_id))
- temp = Marshal.load(Marshal.dump(map))
- if !$game_system.map_events_number
- $game_system.map_events_number = {}
- end
- sum = $game_system.map_events_number
- m_id = $game_map.map_id
- sum[m_id] == nil ? sum[m_id] = 2000 : sum[m_id] += 1
- new_event_id = sum[m_id]
- temp.events[event_id].id = new_event_id
- temp.events[event_id].x,temp.events[event_id].y = item_x,item_y
- $game_map.events[new_event_id] = Game_Event.new(m_id,temp.events[event_id])
- #在添加事件时将事件也添加到eventinfo
- $game_map.eventinfo[Event.xy_tos(item_x,item_y)] = new_event_id
- refresh_map
- end
-
- def self.delete_events(event_id)
- return unless self.is_map?
- #在删除事件时将eventinfo中的事件也删除
- $game_map.eventinfo.delete(Event.xy_tos($game_map.events[event_id].x,$game_map.events[event_id].y))
- $game_map.events.delete(event_id)
- self.refresh_map
- end
- end
- class Game_Map
- attr_reader :eventinfo # 事件信息
- #--------------------------------------------------------------------------
- # ● 设置
- # 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 = {}
- @eventinfo = {}
- for i in @map.events.keys
- @events[i] = Game_Event.new(@map_id, @map.events[i])
- @eventinfo[Event.xy_tos(@events[i].x,@events[i].y)] = i #####
- end
- # 设置公共事件数据
- @common_events = {}
- for i in 1...$data_common_events.size
- @common_events[i] = Game_CommonEvent.new(i)
- end
- # 初始化雾的各种信息
- @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
- end
- class Game_Event < Game_Character
- #--------------------------------------------------------------------------
- # ● 暂时消失****
- #--------------------------------------------------------------------------
- def erase
- @erased = true
- $game_map.eventinfo.delete(Event.xy_tos(@x,@y))
- refresh
- end
- end
复制代码 |
|