赞 | 27 |
VIP | 400 |
好人卡 | 13 |
积分 | 17 |
经验 | 69730 |
最后登录 | 2023-6-12 |
在线时间 | 3038 小时 |
Lv3.寻梦者 (暗夜天使) 精灵族の天使
- 梦石
- 0
- 星屑
- 1697
- 在线时间
- 3038 小时
- 注册时间
- 2007-3-16
- 帖子
- 33731
|
加入我们,或者,欢迎回来。
您需要 登录 才可以下载或查看,没有帐号?注册会员
x
本帖最后由 精灵使者 于 2017-10-9 00:59 编辑
- #==============================================================================
- # ■ 只允许读的开关
- # 控制 $write_able来控制$temp_switches是否存入存档。
- # 使用$temp_switches作为游戏里开关变量。
- #==============================================================================
- class Window_SaveFile < Window_Base
- #--------------------------------------------------------------------------
- # ● 定义实例变量
- #--------------------------------------------------------------------------
- attr_reader :filename # 文件名
- attr_reader :selected # 选择状态
- #--------------------------------------------------------------------------
- # ● 初始化对像
- # file_index : 存档文件的索引 (0~3)
- # filename : 文件名
- #--------------------------------------------------------------------------
- def initialize(file_index, filename)
- super(0, 64 + file_index % 4 * 104, 640, 104)
- self.contents = Bitmap.new(width - 32, height - 32)
- @file_index = file_index
- @filename = "Save#{@file_index + 1}.rxdata"
- @time_stamp = Time.at(0)
- @file_exist = FileTest.exist?(@filename)
- if @file_exist
- file = File.open(@filename, "r")
- @switches = Marshal.load(file) #读取已经初始化过的$switches并读入存档。
- @time_stamp = file.mtime
- @characters = Marshal.load(file)
- @frame_count = Marshal.load(file)
- @game_system = Marshal.load(file)
- @game_switches = Marshal.load(file)
- @game_variables = Marshal.load(file)
- @total_sec = @frame_count / Graphics.frame_rate
- file.close
- end
- refresh
- @selected = false
- end
- end
- #==============================================================================
- # ■ Scene_Save
- #------------------------------------------------------------------------------
- # 处理存档画面的类。
- #==============================================================================
- class Scene_Save < Scene_File
- def write_save_data(file)
- #switches 开关初始化并存档
- @switches = false if @switches.nil?
- #当可写变量打开时,写入游戏开关存档
- if $write_able
- @switches = $temp_switches
- $write_able = false
- end
- Marshal.dump(@switches, 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)
- end
- end
- #==============================================================================
- # ■ Scene_Load
- #------------------------------------------------------------------------------
- # 处理读档画面的类。
- #==============================================================================
- class Scene_Load < Scene_File
- def read_save_data(file)
- @switches = Marshal.load(file) #读取已经初始化过的$switches并读入存档。
- $temp_switches = @switches
- # 读取描绘存档文件用的角色数据
- 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)
- # 魔法编号与保存时有差异的情况下
- # (加入编辑器的编辑过的数据)
- 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
- end
- end
- class Scene_Title
- #--------------------------------------------------------------------------
- # ● 命令 : 新游戏
- #--------------------------------------------------------------------------
- def command_new_game
- # 演奏确定 SE
- $game_system.se_play($data_system.decision_se)
- # 停止 BGM
- Audio.bgm_stop
- # 重置测量游戏时间用的画面计数器
- Graphics.frame_count = 0
- # 生成各种游戏对像
- $temp_switches = false
- $game_temp = Game_Temp.new
- $game_system = Game_System.new
- $game_switches = Game_Switches.new
- $game_variables = Game_Variables.new
- $game_self_switches = Game_SelfSwitches.new
- $game_screen = Game_Screen.new
- $game_actors = Game_Actors.new
- $game_party = Game_Party.new
- $game_troop = Game_Troop.new
- $game_map = Game_Map.new
- $game_player = Game_Player.new
- # 设置初期同伴位置
- $game_party.setup_starting_members
- # 设置初期位置的地图
- $game_map.setup($data_system.start_map_id)
- # 主角向初期位置移动
- $game_player.moveto($data_system.start_x, $data_system.start_y)
- # 刷新主角
- $game_player.refresh
- # 执行地图设置的 BGM 与 BGS 的自动切换
- $game_map.autoplay
- # 刷新地图 (执行并行事件)
- $game_map.update
- # 切换地图画面
- $scene = Scene_Map.new
- end
- end
复制代码
顾名思义,只允许读的开关。除非打开$write_able这个开关,否则$temp_switches不会存入存档。
这个可以做一些匪夷所思的东西用…… |
|