def write_save_data(file) # 生成描绘存档文件用的角色图形 characters = [] for i in 0...$game_party.actors.size actor = $game_party.actors[i] characters.push([actor.character_name, actor.character_hue]) end # 写入描绘存档文件用的角色数据 Marshal.dump(characters, file) # 写入测量游戏时间用画面计数 Marshal.dump(Graphics.frame_count, file) # 增加 1 次存档次数 $game_system.save_count += 1 # 保存魔法编号 # (将编辑器保存的值以随机值替换) $game_system.magic_number = $data_system.magic_number # 写入各种游戏对像 Marshal.dump($game_system, file) Marshal.dump($game_switches, file) Marshal.dump($game_variables, file) Marshal.dump($game_self_switches, file) Marshal.dump($game_screen, file) Marshal.dump($game_actors, file) Marshal.dump($game_party, file) Marshal.dump($game_troop, file) Marshal.dump($game_map, file) Marshal.dump($game_player, file) Marshal.dump($xingbie, file) Marshal.dump($live, file) end
def read_save_data(file) # 读取描绘存档文件用的角色数据 characters = Marshal.load(file) # 读取测量游戏时间用画面计数 Graphics.frame_count = Marshal.load(file) # 读取各种游戏对像 $game_system = Marshal.load(file) $game_switches = Marshal.load(file) $game_variables = Marshal.load(file) $game_self_switches = Marshal.load(file) $game_screen = Marshal.load(file) $game_actors = Marshal.load(file) $game_party = Marshal.load(file) $game_troop = Marshal.load(file) $game_map = Marshal.load(file) $game_player = Marshal.load(file) $xingbie = Marshal.load(file) $live = Marshal.load(file) # 魔法编号与保存时有差异的情况下 # (加入编辑器的编辑过的数据) if $game_system.magic_number != $data_system.magic_number # 重新装载地图 $game_map.setup($game_map.map_id) $game_player.center($game_player.x, $game_player.y) end # 刷新同伴成员 $game_party.refresh
欢迎光临 Project1 (https://rpg.blue/) | Powered by Discuz! X3.1 |