设为首页收藏本站|繁體中文

Project1

 找回密码
 注册会员
搜索
查看: 2988|回复: 18
打印 上一主题 下一主题

又来麻烦大家帮我改下脚本

 关闭 [复制链接]

Lv4.逐梦者 (暗夜天使)

名侦探小柯

梦石
10
星屑
4248
在线时间
3732 小时
注册时间
2006-9-6
帖子
37430

极短27获奖MZ评测员开拓者贵宾第3届短篇游戏大赛主流游戏组亚军第5届短篇游戏比赛亚军

跳转到指定楼层
1
发表于 2007-8-25 06:43:01 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有帐号?注册会员

x
  1. #==============================================================================
  2. # ■ 存取档合并脚本
  3. #------------------------------------------------------------------------------
  4. # BY:美兽
  5. #插入main之前,地图呼出方式$scene = Scene_Loadsave.new,主菜单里默认的也是该界面
  6. #不与默认的存取档功能冲突,方便个别地方只需存或者取的功能,虽然很简单,实际做起
  7. #来,考虑的地方还是比较多。 
  8. #==============================================================================
  9. #==============================================================================
  10. # ■ Scene_Load
  11. #------------------------------------------------------------------------------
  12. #  处理读档画面的类。
  13. #==============================================================================

  14. class Scene_Load < Scene_File
  15.   #--------------------------------------------------------------------------
  16.   # ● 初始化对像
  17.   #--------------------------------------------------------------------------
  18.   def initialize
  19.     # 再生成临时对像
  20.     $game_temp = Game_Temp.new
  21.     # 选择存档时间最新的文件
  22.     $game_temp.last_file_index = 0
  23.     latest_time = Time.at(0)
  24.     for i in 0..3
  25.       filename = make_filename(i)
  26.       if FileTest.exist?(filename)
  27.         file = File.open(filename, "r")
  28.         if file.mtime > latest_time
  29.           latest_time = file.mtime
  30.           $game_temp.last_file_index = i
  31.         end
  32.         file.close
  33.       end
  34.     end
  35.     super("要载入哪个文件?")
  36.   end
  37.   #--------------------------------------------------------------------------
  38.   # ● 确定时的处理
  39.   #--------------------------------------------------------------------------
  40.   def on_decision(filename)
  41.     # 文件不存在的情况下
  42.     unless FileTest.exist?(filename)
  43.       # 演奏冻结 SE
  44.       $game_system.se_play($data_system.buzzer_se)
  45.       return
  46.     end
  47.     $menu_call = false
  48.     # 演奏读档 SE
  49.     $game_system.se_play($data_system.load_se)
  50.     # 写入存档数据
  51.     file = File.open(filename, "rb")
  52.     read_save_data(file)
  53.     file.close
  54.     # 还原 BGM、BGS
  55.     $game_system.bgm_play($game_system.playing_bgm)
  56.     $game_system.bgs_play($game_system.playing_bgs)
  57.     # 刷新地图 (执行并行事件)
  58.     $game_map.update
  59.     # 切换到地图画面
  60.     $scene = Scene_Map.new
  61.   end
  62.   #--------------------------------------------------------------------------
  63.   # ● 取消时的处理
  64.   #--------------------------------------------------------------------------
  65.   def on_cancel
  66.     # 演奏取消 SE
  67.     $game_system.se_play($data_system.cancel_se)
  68.     # 切换到标题画面
  69.     $scene = Scene_Title.new
  70.   end
  71.   #--------------------------------------------------------------------------
  72.   # ● 读取存档数据
  73.   #     file : 读取用文件对像 (已经打开)
  74.   #--------------------------------------------------------------------------
  75.   def read_save_data(file)
  76.     # 读取描绘存档文件用的角色数据
  77.     characters = Marshal.load(file)
  78.     # 读取测量游戏时间用画面计数
  79.     Graphics.frame_count = Marshal.load(file)
  80.     # 读取各种游戏对像
  81.     $game_system        = Marshal.load(file)
  82.     $game_switches      = Marshal.load(file)
  83.     $game_variables     = Marshal.load(file)
  84.     $game_self_switches = Marshal.load(file)
  85.     $game_screen        = Marshal.load(file)
  86.     $game_actors        = Marshal.load(file)
  87.     $game_party         = Marshal.load(file)
  88.     $game_troop         = Marshal.load(file)
  89.     $game_map           = Marshal.load(file)
  90.     $game_player        = Marshal.load(file)
  91.     # 魔法编号与保存时有差异的情况下
  92.     # (加入编辑器的编辑过的数据)
  93.     if $game_system.magic_number != $data_system.magic_number
  94.       # 重新装载地图
  95.       $game_map.setup($game_map.map_id)
  96.       $game_player.center($game_player.x, $game_player.y)
  97.     end
  98.     # 刷新同伴成员
  99.     $game_party.refresh
  100.   end
  101. end
  102. #==============================================================================
  103. # ■ Window_LoadHelp
  104. #------------------------------------------------------------------------------
  105. #  存取档画面帮助信息的显示窗口。
  106. #==============================================================================

  107. class Window_LoadHelp < Window_Base
  108. #--------------------------------------------------------------------------
  109. #  初始化对象
  110. #--------------------------------------------------------------------------
  111. def initialize
  112.   super(0, 0, 320, 64)
  113.   self.contents = Bitmap.new(width - 32, height - 32)
  114.   self.contents.font.name = "黑体"
  115.   self.contents.font.size = 18
  116. end
  117. #--------------------------------------------------------------------------
  118. #  刷新文本
  119. #--------------------------------------------------------------------------
  120. def set_text(text, align = 1)
  121.   if text != @text or align != @align
  122.     self.contents.clear
  123.     self.contents.font.color = normal_color
  124.     self.contents.draw_text(4, 0, self.width - 40, 32, text, align)
  125.     @text = text
  126.     @align = align
  127.     @actor = nil
  128.   end
  129.   self.visible = true
  130. end
  131. end
  132. #==============================================================================
  133. #  Window_LoadCommand
  134. #------------------------------------------------------------------------------
  135. #  存取档画面选择按钮窗口
  136. #==============================================================================

  137. class Window_LoadCommand < Window_Selectable
  138. #--------------------------------------------------------------------------
  139. #  初始化对象
  140. #--------------------------------------------------------------------------
  141. def initialize
  142.   super(320, 0, 320, 64)
  143.   self.contents = Bitmap.new(width - 32, height - 32)
  144.   self.contents.font.name = "黑体"
  145.   self.contents.font.size = 18
  146.   @item_max = 2
  147.   @column_max = 2
  148.   @commands = ["读取", "存储"]
  149.   refresh
  150.   self.index = 0
  151. end
  152. #--------------------------------------------------------------------------
  153. #  刷新
  154. #--------------------------------------------------------------------------
  155. def refresh
  156.   self.contents.clear
  157.   for i in 0...@item_max
  158.     draw_item(i)
  159.   end
  160. end
  161. #--------------------------------------------------------------------------
  162. #  描画按钮文字
  163. #--------------------------------------------------------------------------
  164. def draw_item(index)
  165.   x = 4 + index * 160
  166.   self.contents.draw_text(x, 0, 144, 32, @commands[index])
  167. end
  168. #--------------------------------------------------------------------------
  169. # ● 项目无效化
  170. #     index : 项目编号
  171. #--------------------------------------------------------------------------
  172.   def disable_item(index)
  173.     draw_item(index, disabled_color)
  174.   end

  175. end

  176. #==============================================================================
  177. # ■ Scene_Menu
  178. #------------------------------------------------------------------------------
  179. #  处理菜单画面的类。
  180. #==============================================================================

  181. class Scene_Menu
  182.   #--------------------------------------------------------------------------
  183.   # ● 初始化对像
  184.   #     menu_index : 命令光标的初期位置
  185.   #--------------------------------------------------------------------------
  186.   def initialize(menu_index = 0)
  187.     @menu_index = menu_index
  188.   end
  189.   #--------------------------------------------------------------------------
  190.   # ● 主处理
  191.   #--------------------------------------------------------------------------
  192.   def main
  193.     # 生成命令窗口
  194.     s1 = $data_system.words.item
  195.     s2 = $data_system.words.skill
  196.     s3 = $data_system.words.equip
  197.     s4 = "状态"
  198.     s5 = "记录"
  199.     s6 = "结束游戏"
  200.     @command_window = Window_Command.new(160, [s1, s2, s3, s4, s5, s6])
  201.     @command_window.index = @menu_index
  202.     # 同伴人数为 0 的情况下
  203.     if $game_party.actors.size == 0
  204.       # 物品、特技、装备、状态无效化
  205.       @command_window.disable_item(0)
  206.       @command_window.disable_item(1)
  207.       @command_window.disable_item(2)
  208.       @command_window.disable_item(3)
  209.     end
  210.     # 生成游戏时间窗口
  211.     @playtime_window = Window_PlayTime.new
  212.     @playtime_window.x = 0
  213.     @playtime_window.y = 224
  214.     # 生成步数窗口
  215.     @steps_window = Window_Steps.new
  216.     @steps_window.x = 0
  217.     @steps_window.y = 320
  218.     # 生成金钱窗口
  219.     @gold_window = Window_Gold.new
  220.     @gold_window.x = 0
  221.     @gold_window.y = 416
  222.     # 生成状态窗口
  223.     @status_window = Window_MenuStatus.new
  224.     @status_window.x = 160
  225.     @status_window.y = 0
  226.     # 执行过渡
  227.     Graphics.transition
  228.     # 主循环
  229.     loop do
  230.       # 刷新游戏画面
  231.       Graphics.update
  232.       # 刷新输入信息
  233.       Input.update
  234.       # 刷新画面
  235.       update
  236.       # 如果切换画面就中断循环
  237.       if $scene != self
  238.         break
  239.       end
  240.     end
  241.     # 准备过渡
  242.     Graphics.freeze
  243.     # 释放窗口
  244.     @command_window.dispose
  245.     @playtime_window.dispose
  246.     @steps_window.dispose
  247.     @gold_window.dispose
  248.     @status_window.dispose
  249.   end
  250.   #--------------------------------------------------------------------------
  251.   # ● 刷新画面
  252.   #--------------------------------------------------------------------------
  253.   def update
  254.     # 刷新窗口
  255.     @command_window.update
  256.     @playtime_window.update
  257.     @steps_window.update
  258.     @gold_window.update
  259.     @status_window.update
  260.     # 命令窗口被激活的情况下: 调用 update_command
  261.     if @command_window.active
  262.       update_command
  263.       return
  264.     end
  265.     # 状态窗口被激活的情况下: 调用 update_status
  266.     if @status_window.active
  267.       update_status
  268.       return
  269.     end
  270.   end
  271.   #--------------------------------------------------------------------------
  272.   # ● 刷新画面 (命令窗口被激活的情况下)
  273.   #--------------------------------------------------------------------------
  274.   def update_command
  275.     # 按下 B 键的情况下
  276.     if Input.trigger?(Input::B)
  277.       # 演奏取消 SE
  278.       $game_system.se_play($data_system.cancel_se)
  279.       # 切换的地图画面
  280.       $scene = Scene_Map.new
  281.       return
  282.     end
  283.     # 按下 C 键的情况下
  284.     if Input.trigger?(Input::C)
  285.       # 同伴人数为 0、存档、游戏结束以外的场合
  286.       if $game_party.actors.size == 0 and @command_window.index < 4
  287.         # 演奏冻结 SE
  288.         $game_system.se_play($data_system.buzzer_se)
  289.         return
  290.       end
  291.       # 命令窗口的光标位置分支
  292.       case @command_window.index
  293.       when 0  # 物品
  294.         # 演奏确定 SE
  295.         $game_system.se_play($data_system.decision_se)
  296.         # 切换到物品画面
  297.         $scene = Scene_Item.new
  298.       when 1  # 特技
  299.         # 演奏确定 SE
  300.         $game_system.se_play($data_system.decision_se)
  301.         # 激活状态窗口
  302.         @command_window.active = false
  303.         @status_window.active = true
  304.         @status_window.index = 0
  305.       when 2  # 装备
  306.         # 演奏确定 SE
  307.         $game_system.se_play($data_system.decision_se)
  308.         # 激活状态窗口
  309.         @command_window.active = false
  310.         @status_window.active = true
  311.         @status_window.index = 0
  312.       when 3  # 状态
  313.         # 演奏确定 SE
  314.         $game_system.se_play($data_system.decision_se)
  315.         # 激活状态窗口
  316.         @command_window.active = false
  317.         @status_window.active = true
  318.         @status_window.index = 0
  319.       when 4  # 存档
  320.         # 演奏确定 SE
  321.         $game_system.se_play($data_system.decision_se)
  322.         # 切换到存取档画面
  323.         $menu_call = true
  324.         $scene = Scene_Loadsave.new
  325.       when 5  # 游戏结束
  326.         # 演奏确定 SE
  327.         $game_system.se_play($data_system.decision_se)
  328.         # 切换到游戏结束画面
  329.         $scene = Scene_End.new
  330.       end
  331.       return
  332.     end
  333.   end
  334.   end
  335. #==============================================================================
  336. #  Scene_Loadsave
  337. #------------------------------------------------------------------------------
  338. # 处理存取档画面的类。
  339. #==============================================================================

  340. class Scene_Loadsave
  341. #--------------------------------------------------------------------------
  342. # ● 初始化对像
  343. #     $last_savefile_index : 记录光标位置
  344. #--------------------------------------------------------------------------
  345. def initialize
  346.   $last_savefile_index = 0 if $last_savefile_index == nil
  347. end
  348. #--------------------------------------------------------------------------
  349. #  主处理
  350. #--------------------------------------------------------------------------
  351. def main
  352.   @savestate = 0
  353.   # 生成窗口
  354.   @help_window = Window_LoadHelp.new
  355.   @help_window.set_text("请选择.")
  356.   @option_window = Window_LoadCommand.new
  357.   @savefile_windows = []
  358.   for i in 0..3
  359.     @savefile_windows.push(Window_SaveFile.new(i, make_filename(i)))
  360.   end
  361.   @option_window.index = $last_savefile_index
  362.   @file_index = 0
  363.   # 执行过渡
  364.   Graphics.transition
  365.   # 主循环
  366.   loop do
  367.     # 刷新游戏画面
  368.     Graphics.update
  369.     # 刷新输入信息
  370.     Input.update
  371.     # 刷新画面
  372.     update
  373.     # 如果画面被切换的话就中断循环
  374.     if $scene != self
  375.       break
  376.     end
  377.   end
  378.   # 准备过渡
  379.   Graphics.freeze
  380.   # 释放窗口
  381.   @help_window.dispose
  382.   @option_window.dispose
  383.   for i in @savefile_windows
  384.     i.dispose
  385.   end
  386. end

  387. #--------------------------------------------------------------------------
  388. #  ● 刷新画面
  389. #--------------------------------------------------------------------------
  390. def update
  391.   # 刷新窗口
  392.   @help_window.update
  393.   @option_window.update
  394.   for i in @savefile_windows
  395.     i.update
  396.   end
  397.   
  398.   case @savestate
  399.   when 0
  400.       if Input.trigger?(Input::B)
  401.       $game_system.se_play($data_system.cancel_se)
  402.       # 淡入淡出 BGM
  403.       Audio.bgm_fade(800)
  404.       # 返回地图
  405.       if $menu_call == false
  406.       # 切换到地图画面
  407.       $scene = Scene_Map.new
  408.         return
  409.       end
  410.       # 切换到菜单画面
  411.       $menu_call = false
  412.       $scene = Scene_Menu.new(4)
  413.    end
  414.     if Input.trigger?(Input::C)
  415.       case @option_window.index
  416.       when 0
  417.         @savefile_windows[@file_index].selected = true
  418.         @option_window.active = false
  419.         @help_window.set_text("请选择一个文件进行读取.")
  420.         @savestate  = 1
  421.         return
  422.       when 1
  423.         @savefile_windows[@file_index].selected = true
  424.         @option_window.active = false
  425.         @help_window.set_text("请选择一个文件进行存储.")
  426.         @savestate = 2
  427.         return
  428.         return
  429.       end
  430.     end
  431.   when 1,2
  432.     if Input.trigger?(Input::C)
  433.       if @savestate == 1
  434.         $menu_call = false
  435.         load_file(make_filename(@file_index))
  436.         return
  437.       else
  438.         # 禁止存档的情况下
  439.         if $game_system.save_disabled
  440.           @help_window.set_text("抱歉,这里禁止存储.")
  441.           # 演奏冻结 SE
  442.           $game_system.se_play($data_system.buzzer_se)
  443.           return
  444.         end
  445.        $game_system.se_play($data_system.decision_se)
  446.        $last_savefile_index = @option_window.index
  447.        save_file(make_filename(@file_index))
  448.         return
  449.       end
  450.     end
  451.     # 取消
  452.     if Input.trigger?(Input::B)
  453.       $game_system.se_play($data_system.cancel_se)
  454.       @savefile_windows[@file_index].selected = false
  455.       @help_window.set_text("请选择.")
  456.       @savestate = 0
  457.       @option_window.active = true
  458.       return
  459.     end
  460.     # 向下选择
  461.     if Input.repeat?(Input::DOWN)
  462.       $game_system.se_play($data_system.cursor_se)
  463.       @savefile_windows[@file_index].selected = false
  464.       @file_index = (@file_index + 1) % 4
  465.       @savefile_windows[@file_index].selected = true
  466.       return
  467.     end
  468.     # 向上选择
  469.     if Input.repeat?(Input::UP)
  470.       $game_system.se_play($data_system.cursor_se)
  471.       @savefile_windows[@file_index].selected = false
  472.       @file_index = (@file_index + 3) % 4
  473.       @savefile_windows[@file_index].selected = true
  474.       return
  475.     end
  476.    
  477.     if Input.trigger?(Input::B)
  478.       $game_system.se_play($data_system.cancel_se)
  479.       @savestate = 2
  480.       @savefile_windows[@file_index].selected = true
  481.       return
  482.     end
  483.   end
  484. end
  485. #--------------------------------------------------------------------------
  486. # 建立记录文件索引
  487. #--------------------------------------------------------------------------
  488. def make_filename(file_index)
  489.   return "Save#{file_index + 1}.rxdata"
  490. end
  491. #--------------------------------------------------------------------------
  492. #  读取记录文件
  493. #     filename  : 被读取文件
  494. #--------------------------------------------------------------------------
  495. def load_file(filename)
  496.   # 文件不存在的情况下
  497.   unless FileTest.exist?(filename)
  498.     # 演奏冻结 SE
  499.     $game_system.se_play($data_system.buzzer_se)
  500.     return
  501.   end
  502.   # 演奏读档 SE
  503.   $game_system.se_play($data_system.load_se)
  504.   # 以二进制方式打开文件
  505.   # 写入存档数据
  506.   file = File.open(filename, "rb")
  507.   read_save_data(file)
  508.   file.close
  509.   # 演奏 BGM 与 BGS
  510.   $game_system.bgm_play($game_system.playing_bgm)
  511.   $game_system.bgs_play($game_system.playing_bgs)
  512.   # 刷新地图 (执行并行事件)
  513.   $game_map.update
  514.   # 切换到地图画面
  515.   $menu_call == false
  516.   $scene = Scene_Map.new
  517. end
  518. #--------------------------------------------------------------------------
  519. # ● 读取存档数据
  520. #     file : 读取用文件对像 (已经打开)
  521. #--------------------------------------------------------------------------
  522. def read_save_data(file)
  523.   # 读取描绘存档文件用的角色数据
  524.   characters = Marshal.load(file)
  525.   # 读取测量游戏时间用画面计数
  526.   Graphics.frame_count = Marshal.load(file)
  527.   # 读取各种游戏对像
  528.   $game_system        = Marshal.load(file)
  529.   $game_switches      = Marshal.load(file)
  530.   $game_variables     = Marshal.load(file)
  531.   $game_self_switches = Marshal.load(file)
  532.   $game_screen        = Marshal.load(file)
  533.   $game_actors        = Marshal.load(file)
  534.   $game_party         = Marshal.load(file)
  535.   $game_troop         = Marshal.load(file)
  536.   $game_map           = Marshal.load(file)
  537.   $game_player        = Marshal.load(file)
  538.     # 魔法编号与保存时有差异的情况下
  539.     # (加入编辑器的编辑过的数据)
  540.   if $game_system.magic_number != $data_system.magic_number
  541.     # 重新装载地图
  542.     $game_map.setup($game_map.map_id)
  543.     $game_player.center($game_player.x, $game_player.y)
  544.   end
  545.   # 刷新同伴成员
  546.   $game_party.refresh
  547. end
  548.   #--------------------------------------------------------------------------
  549.   # ● 写入存档文件
  550.   #--------------------------------------------------------------------------
  551.   def save_file(filename)
  552.     # 演奏存档 SE
  553.     $game_system.se_play($data_system.save_se)
  554.     # 写入存档数据
  555.     file = File.open(filename, "wb")
  556.     write_save_data(file)
  557.     file.close
  558.     # 切换到菜单画面
  559.     $scene = Scene_Loadsave.new
  560.   end
  561.   #--------------------------------------------------------------------------
  562.   # ● 写入存档数据
  563.   #     file : 写入用文件对像 (已经打开)
  564.   #--------------------------------------------------------------------------
  565.   def write_save_data(file)
  566.     # 生成描绘存档文件用的角色图形
  567.     characters = []
  568.     for i in 0...$game_party.actors.size
  569.       actor = $game_party.actors[i]
  570.       characters.push([actor.character_name, actor.character_hue])
  571.     end
  572.     # 写入描绘存档文件用的角色数据
  573.     Marshal.dump(characters, file)
  574.     # 写入测量游戏时间用画面计数
  575.     Marshal.dump(Graphics.frame_count, file)
  576.     # 增加 1 次存档次数
  577.     $game_system.save_count += 1
  578.     # 保存魔法编号
  579.     # (将编辑器保存的值以随机值替换)
  580.     $game_system.magic_number = $data_system.magic_number
  581.     # 写入各种游戏对像
  582.     Marshal.dump($game_system, file)
  583.     Marshal.dump($game_switches, file)
  584.     Marshal.dump($game_variables, file)
  585.     Marshal.dump($game_self_switches, file)
  586.     Marshal.dump($game_screen, file)
  587.     Marshal.dump($game_actors, file)
  588.     Marshal.dump($game_party, file)
  589.     Marshal.dump($game_troop, file)
  590.     Marshal.dump($game_map, file)
  591.     Marshal.dump($game_player, file)
  592.   end
  593. end
复制代码


改成只能用调用的办法才能使用……

不要替换原来的,
不然我那个菜单会变掉的……
不定期回归 ~ 游戏开发之旅
———————————————————————————————

Lv4.逐梦者 (暗夜天使)

名侦探小柯

梦石
10
星屑
4248
在线时间
3732 小时
注册时间
2006-9-6
帖子
37430

极短27获奖MZ评测员开拓者贵宾第3届短篇游戏大赛主流游戏组亚军第5届短篇游戏比赛亚军

2
 楼主| 发表于 2007-8-25 06:43:01 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有帐号?注册会员

x
  1. #==============================================================================
  2. # ■ 存取档合并脚本
  3. #------------------------------------------------------------------------------
  4. # BY:美兽
  5. #插入main之前,地图呼出方式$scene = Scene_Loadsave.new,主菜单里默认的也是该界面
  6. #不与默认的存取档功能冲突,方便个别地方只需存或者取的功能,虽然很简单,实际做起
  7. #来,考虑的地方还是比较多。 
  8. #==============================================================================
  9. #==============================================================================
  10. # ■ Scene_Load
  11. #------------------------------------------------------------------------------
  12. #  处理读档画面的类。
  13. #==============================================================================

  14. class Scene_Load < Scene_File
  15.   #--------------------------------------------------------------------------
  16.   # ● 初始化对像
  17.   #--------------------------------------------------------------------------
  18.   def initialize
  19.     # 再生成临时对像
  20.     $game_temp = Game_Temp.new
  21.     # 选择存档时间最新的文件
  22.     $game_temp.last_file_index = 0
  23.     latest_time = Time.at(0)
  24.     for i in 0..3
  25.       filename = make_filename(i)
  26.       if FileTest.exist?(filename)
  27.         file = File.open(filename, "r")
  28.         if file.mtime > latest_time
  29.           latest_time = file.mtime
  30.           $game_temp.last_file_index = i
  31.         end
  32.         file.close
  33.       end
  34.     end
  35.     super("要载入哪个文件?")
  36.   end
  37.   #--------------------------------------------------------------------------
  38.   # ● 确定时的处理
  39.   #--------------------------------------------------------------------------
  40.   def on_decision(filename)
  41.     # 文件不存在的情况下
  42.     unless FileTest.exist?(filename)
  43.       # 演奏冻结 SE
  44.       $game_system.se_play($data_system.buzzer_se)
  45.       return
  46.     end
  47.     $menu_call = false
  48.     # 演奏读档 SE
  49.     $game_system.se_play($data_system.load_se)
  50.     # 写入存档数据
  51.     file = File.open(filename, "rb")
  52.     read_save_data(file)
  53.     file.close
  54.     # 还原 BGM、BGS
  55.     $game_system.bgm_play($game_system.playing_bgm)
  56.     $game_system.bgs_play($game_system.playing_bgs)
  57.     # 刷新地图 (执行并行事件)
  58.     $game_map.update
  59.     # 切换到地图画面
  60.     $scene = Scene_Map.new
  61.   end
  62.   #--------------------------------------------------------------------------
  63.   # ● 取消时的处理
  64.   #--------------------------------------------------------------------------
  65.   def on_cancel
  66.     # 演奏取消 SE
  67.     $game_system.se_play($data_system.cancel_se)
  68.     # 切换到标题画面
  69.     $scene = Scene_Title.new
  70.   end
  71.   #--------------------------------------------------------------------------
  72.   # ● 读取存档数据
  73.   #     file : 读取用文件对像 (已经打开)
  74.   #--------------------------------------------------------------------------
  75.   def read_save_data(file)
  76.     # 读取描绘存档文件用的角色数据
  77.     characters = Marshal.load(file)
  78.     # 读取测量游戏时间用画面计数
  79.     Graphics.frame_count = Marshal.load(file)
  80.     # 读取各种游戏对像
  81.     $game_system        = Marshal.load(file)
  82.     $game_switches      = Marshal.load(file)
  83.     $game_variables     = Marshal.load(file)
  84.     $game_self_switches = Marshal.load(file)
  85.     $game_screen        = Marshal.load(file)
  86.     $game_actors        = Marshal.load(file)
  87.     $game_party         = Marshal.load(file)
  88.     $game_troop         = Marshal.load(file)
  89.     $game_map           = Marshal.load(file)
  90.     $game_player        = Marshal.load(file)
  91.     # 魔法编号与保存时有差异的情况下
  92.     # (加入编辑器的编辑过的数据)
  93.     if $game_system.magic_number != $data_system.magic_number
  94.       # 重新装载地图
  95.       $game_map.setup($game_map.map_id)
  96.       $game_player.center($game_player.x, $game_player.y)
  97.     end
  98.     # 刷新同伴成员
  99.     $game_party.refresh
  100.   end
  101. end
  102. #==============================================================================
  103. # ■ Window_LoadHelp
  104. #------------------------------------------------------------------------------
  105. #  存取档画面帮助信息的显示窗口。
  106. #==============================================================================

  107. class Window_LoadHelp < Window_Base
  108. #--------------------------------------------------------------------------
  109. #  初始化对象
  110. #--------------------------------------------------------------------------
  111. def initialize
  112.   super(0, 0, 320, 64)
  113.   self.contents = Bitmap.new(width - 32, height - 32)
  114.   self.contents.font.name = "黑体"
  115.   self.contents.font.size = 18
  116. end
  117. #--------------------------------------------------------------------------
  118. #  刷新文本
  119. #--------------------------------------------------------------------------
  120. def set_text(text, align = 1)
  121.   if text != @text or align != @align
  122.     self.contents.clear
  123.     self.contents.font.color = normal_color
  124.     self.contents.draw_text(4, 0, self.width - 40, 32, text, align)
  125.     @text = text
  126.     @align = align
  127.     @actor = nil
  128.   end
  129.   self.visible = true
  130. end
  131. end
  132. #==============================================================================
  133. #  Window_LoadCommand
  134. #------------------------------------------------------------------------------
  135. #  存取档画面选择按钮窗口
  136. #==============================================================================

  137. class Window_LoadCommand < Window_Selectable
  138. #--------------------------------------------------------------------------
  139. #  初始化对象
  140. #--------------------------------------------------------------------------
  141. def initialize
  142.   super(320, 0, 320, 64)
  143.   self.contents = Bitmap.new(width - 32, height - 32)
  144.   self.contents.font.name = "黑体"
  145.   self.contents.font.size = 18
  146.   @item_max = 2
  147.   @column_max = 2
  148.   @commands = ["读取", "存储"]
  149.   refresh
  150.   self.index = 0
  151. end
  152. #--------------------------------------------------------------------------
  153. #  刷新
  154. #--------------------------------------------------------------------------
  155. def refresh
  156.   self.contents.clear
  157.   for i in 0...@item_max
  158.     draw_item(i)
  159.   end
  160. end
  161. #--------------------------------------------------------------------------
  162. #  描画按钮文字
  163. #--------------------------------------------------------------------------
  164. def draw_item(index)
  165.   x = 4 + index * 160
  166.   self.contents.draw_text(x, 0, 144, 32, @commands[index])
  167. end
  168. #--------------------------------------------------------------------------
  169. # ● 项目无效化
  170. #     index : 项目编号
  171. #--------------------------------------------------------------------------
  172.   def disable_item(index)
  173.     draw_item(index, disabled_color)
  174.   end

  175. end

  176. #==============================================================================
  177. # ■ Scene_Menu
  178. #------------------------------------------------------------------------------
  179. #  处理菜单画面的类。
  180. #==============================================================================

  181. class Scene_Menu
  182.   #--------------------------------------------------------------------------
  183.   # ● 初始化对像
  184.   #     menu_index : 命令光标的初期位置
  185.   #--------------------------------------------------------------------------
  186.   def initialize(menu_index = 0)
  187.     @menu_index = menu_index
  188.   end
  189.   #--------------------------------------------------------------------------
  190.   # ● 主处理
  191.   #--------------------------------------------------------------------------
  192.   def main
  193.     # 生成命令窗口
  194.     s1 = $data_system.words.item
  195.     s2 = $data_system.words.skill
  196.     s3 = $data_system.words.equip
  197.     s4 = "状态"
  198.     s5 = "记录"
  199.     s6 = "结束游戏"
  200.     @command_window = Window_Command.new(160, [s1, s2, s3, s4, s5, s6])
  201.     @command_window.index = @menu_index
  202.     # 同伴人数为 0 的情况下
  203.     if $game_party.actors.size == 0
  204.       # 物品、特技、装备、状态无效化
  205.       @command_window.disable_item(0)
  206.       @command_window.disable_item(1)
  207.       @command_window.disable_item(2)
  208.       @command_window.disable_item(3)
  209.     end
  210.     # 生成游戏时间窗口
  211.     @playtime_window = Window_PlayTime.new
  212.     @playtime_window.x = 0
  213.     @playtime_window.y = 224
  214.     # 生成步数窗口
  215.     @steps_window = Window_Steps.new
  216.     @steps_window.x = 0
  217.     @steps_window.y = 320
  218.     # 生成金钱窗口
  219.     @gold_window = Window_Gold.new
  220.     @gold_window.x = 0
  221.     @gold_window.y = 416
  222.     # 生成状态窗口
  223.     @status_window = Window_MenuStatus.new
  224.     @status_window.x = 160
  225.     @status_window.y = 0
  226.     # 执行过渡
  227.     Graphics.transition
  228.     # 主循环
  229.     loop do
  230.       # 刷新游戏画面
  231.       Graphics.update
  232.       # 刷新输入信息
  233.       Input.update
  234.       # 刷新画面
  235.       update
  236.       # 如果切换画面就中断循环
  237.       if $scene != self
  238.         break
  239.       end
  240.     end
  241.     # 准备过渡
  242.     Graphics.freeze
  243.     # 释放窗口
  244.     @command_window.dispose
  245.     @playtime_window.dispose
  246.     @steps_window.dispose
  247.     @gold_window.dispose
  248.     @status_window.dispose
  249.   end
  250.   #--------------------------------------------------------------------------
  251.   # ● 刷新画面
  252.   #--------------------------------------------------------------------------
  253.   def update
  254.     # 刷新窗口
  255.     @command_window.update
  256.     @playtime_window.update
  257.     @steps_window.update
  258.     @gold_window.update
  259.     @status_window.update
  260.     # 命令窗口被激活的情况下: 调用 update_command
  261.     if @command_window.active
  262.       update_command
  263.       return
  264.     end
  265.     # 状态窗口被激活的情况下: 调用 update_status
  266.     if @status_window.active
  267.       update_status
  268.       return
  269.     end
  270.   end
  271.   #--------------------------------------------------------------------------
  272.   # ● 刷新画面 (命令窗口被激活的情况下)
  273.   #--------------------------------------------------------------------------
  274.   def update_command
  275.     # 按下 B 键的情况下
  276.     if Input.trigger?(Input::B)
  277.       # 演奏取消 SE
  278.       $game_system.se_play($data_system.cancel_se)
  279.       # 切换的地图画面
  280.       $scene = Scene_Map.new
  281.       return
  282.     end
  283.     # 按下 C 键的情况下
  284.     if Input.trigger?(Input::C)
  285.       # 同伴人数为 0、存档、游戏结束以外的场合
  286.       if $game_party.actors.size == 0 and @command_window.index < 4
  287.         # 演奏冻结 SE
  288.         $game_system.se_play($data_system.buzzer_se)
  289.         return
  290.       end
  291.       # 命令窗口的光标位置分支
  292.       case @command_window.index
  293.       when 0  # 物品
  294.         # 演奏确定 SE
  295.         $game_system.se_play($data_system.decision_se)
  296.         # 切换到物品画面
  297.         $scene = Scene_Item.new
  298.       when 1  # 特技
  299.         # 演奏确定 SE
  300.         $game_system.se_play($data_system.decision_se)
  301.         # 激活状态窗口
  302.         @command_window.active = false
  303.         @status_window.active = true
  304.         @status_window.index = 0
  305.       when 2  # 装备
  306.         # 演奏确定 SE
  307.         $game_system.se_play($data_system.decision_se)
  308.         # 激活状态窗口
  309.         @command_window.active = false
  310.         @status_window.active = true
  311.         @status_window.index = 0
  312.       when 3  # 状态
  313.         # 演奏确定 SE
  314.         $game_system.se_play($data_system.decision_se)
  315.         # 激活状态窗口
  316.         @command_window.active = false
  317.         @status_window.active = true
  318.         @status_window.index = 0
  319.       when 4  # 存档
  320.         # 演奏确定 SE
  321.         $game_system.se_play($data_system.decision_se)
  322.         # 切换到存取档画面
  323.         $menu_call = true
  324.         $scene = Scene_Loadsave.new
  325.       when 5  # 游戏结束
  326.         # 演奏确定 SE
  327.         $game_system.se_play($data_system.decision_se)
  328.         # 切换到游戏结束画面
  329.         $scene = Scene_End.new
  330.       end
  331.       return
  332.     end
  333.   end
  334.   end
  335. #==============================================================================
  336. #  Scene_Loadsave
  337. #------------------------------------------------------------------------------
  338. # 处理存取档画面的类。
  339. #==============================================================================

  340. class Scene_Loadsave
  341. #--------------------------------------------------------------------------
  342. # ● 初始化对像
  343. #     $last_savefile_index : 记录光标位置
  344. #--------------------------------------------------------------------------
  345. def initialize
  346.   $last_savefile_index = 0 if $last_savefile_index == nil
  347. end
  348. #--------------------------------------------------------------------------
  349. #  主处理
  350. #--------------------------------------------------------------------------
  351. def main
  352.   @savestate = 0
  353.   # 生成窗口
  354.   @help_window = Window_LoadHelp.new
  355.   @help_window.set_text("请选择.")
  356.   @option_window = Window_LoadCommand.new
  357.   @savefile_windows = []
  358.   for i in 0..3
  359.     @savefile_windows.push(Window_SaveFile.new(i, make_filename(i)))
  360.   end
  361.   @option_window.index = $last_savefile_index
  362.   @file_index = 0
  363.   # 执行过渡
  364.   Graphics.transition
  365.   # 主循环
  366.   loop do
  367.     # 刷新游戏画面
  368.     Graphics.update
  369.     # 刷新输入信息
  370.     Input.update
  371.     # 刷新画面
  372.     update
  373.     # 如果画面被切换的话就中断循环
  374.     if $scene != self
  375.       break
  376.     end
  377.   end
  378.   # 准备过渡
  379.   Graphics.freeze
  380.   # 释放窗口
  381.   @help_window.dispose
  382.   @option_window.dispose
  383.   for i in @savefile_windows
  384.     i.dispose
  385.   end
  386. end

  387. #--------------------------------------------------------------------------
  388. #  ● 刷新画面
  389. #--------------------------------------------------------------------------
  390. def update
  391.   # 刷新窗口
  392.   @help_window.update
  393.   @option_window.update
  394.   for i in @savefile_windows
  395.     i.update
  396.   end
  397.   
  398.   case @savestate
  399.   when 0
  400.       if Input.trigger?(Input::B)
  401.       $game_system.se_play($data_system.cancel_se)
  402.       # 淡入淡出 BGM
  403.       Audio.bgm_fade(800)
  404.       # 返回地图
  405.       if $menu_call == false
  406.       # 切换到地图画面
  407.       $scene = Scene_Map.new
  408.         return
  409.       end
  410.       # 切换到菜单画面
  411.       $menu_call = false
  412.       $scene = Scene_Menu.new(4)
  413.    end
  414.     if Input.trigger?(Input::C)
  415.       case @option_window.index
  416.       when 0
  417.         @savefile_windows[@file_index].selected = true
  418.         @option_window.active = false
  419.         @help_window.set_text("请选择一个文件进行读取.")
  420.         @savestate  = 1
  421.         return
  422.       when 1
  423.         @savefile_windows[@file_index].selected = true
  424.         @option_window.active = false
  425.         @help_window.set_text("请选择一个文件进行存储.")
  426.         @savestate = 2
  427.         return
  428.         return
  429.       end
  430.     end
  431.   when 1,2
  432.     if Input.trigger?(Input::C)
  433.       if @savestate == 1
  434.         $menu_call = false
  435.         load_file(make_filename(@file_index))
  436.         return
  437.       else
  438.         # 禁止存档的情况下
  439.         if $game_system.save_disabled
  440.           @help_window.set_text("抱歉,这里禁止存储.")
  441.           # 演奏冻结 SE
  442.           $game_system.se_play($data_system.buzzer_se)
  443.           return
  444.         end
  445.        $game_system.se_play($data_system.decision_se)
  446.        $last_savefile_index = @option_window.index
  447.        save_file(make_filename(@file_index))
  448.         return
  449.       end
  450.     end
  451.     # 取消
  452.     if Input.trigger?(Input::B)
  453.       $game_system.se_play($data_system.cancel_se)
  454.       @savefile_windows[@file_index].selected = false
  455.       @help_window.set_text("请选择.")
  456.       @savestate = 0
  457.       @option_window.active = true
  458.       return
  459.     end
  460.     # 向下选择
  461.     if Input.repeat?(Input::DOWN)
  462.       $game_system.se_play($data_system.cursor_se)
  463.       @savefile_windows[@file_index].selected = false
  464.       @file_index = (@file_index + 1) % 4
  465.       @savefile_windows[@file_index].selected = true
  466.       return
  467.     end
  468.     # 向上选择
  469.     if Input.repeat?(Input::UP)
  470.       $game_system.se_play($data_system.cursor_se)
  471.       @savefile_windows[@file_index].selected = false
  472.       @file_index = (@file_index + 3) % 4
  473.       @savefile_windows[@file_index].selected = true
  474.       return
  475.     end
  476.    
  477.     if Input.trigger?(Input::B)
  478.       $game_system.se_play($data_system.cancel_se)
  479.       @savestate = 2
  480.       @savefile_windows[@file_index].selected = true
  481.       return
  482.     end
  483.   end
  484. end
  485. #--------------------------------------------------------------------------
  486. # 建立记录文件索引
  487. #--------------------------------------------------------------------------
  488. def make_filename(file_index)
  489.   return "Save#{file_index + 1}.rxdata"
  490. end
  491. #--------------------------------------------------------------------------
  492. #  读取记录文件
  493. #     filename  : 被读取文件
  494. #--------------------------------------------------------------------------
  495. def load_file(filename)
  496.   # 文件不存在的情况下
  497.   unless FileTest.exist?(filename)
  498.     # 演奏冻结 SE
  499.     $game_system.se_play($data_system.buzzer_se)
  500.     return
  501.   end
  502.   # 演奏读档 SE
  503.   $game_system.se_play($data_system.load_se)
  504.   # 以二进制方式打开文件
  505.   # 写入存档数据
  506.   file = File.open(filename, "rb")
  507.   read_save_data(file)
  508.   file.close
  509.   # 演奏 BGM 与 BGS
  510.   $game_system.bgm_play($game_system.playing_bgm)
  511.   $game_system.bgs_play($game_system.playing_bgs)
  512.   # 刷新地图 (执行并行事件)
  513.   $game_map.update
  514.   # 切换到地图画面
  515.   $menu_call == false
  516.   $scene = Scene_Map.new
  517. end
  518. #--------------------------------------------------------------------------
  519. # ● 读取存档数据
  520. #     file : 读取用文件对像 (已经打开)
  521. #--------------------------------------------------------------------------
  522. def read_save_data(file)
  523.   # 读取描绘存档文件用的角色数据
  524.   characters = Marshal.load(file)
  525.   # 读取测量游戏时间用画面计数
  526.   Graphics.frame_count = Marshal.load(file)
  527.   # 读取各种游戏对像
  528.   $game_system        = Marshal.load(file)
  529.   $game_switches      = Marshal.load(file)
  530.   $game_variables     = Marshal.load(file)
  531.   $game_self_switches = Marshal.load(file)
  532.   $game_screen        = Marshal.load(file)
  533.   $game_actors        = Marshal.load(file)
  534.   $game_party         = Marshal.load(file)
  535.   $game_troop         = Marshal.load(file)
  536.   $game_map           = Marshal.load(file)
  537.   $game_player        = Marshal.load(file)
  538.     # 魔法编号与保存时有差异的情况下
  539.     # (加入编辑器的编辑过的数据)
  540.   if $game_system.magic_number != $data_system.magic_number
  541.     # 重新装载地图
  542.     $game_map.setup($game_map.map_id)
  543.     $game_player.center($game_player.x, $game_player.y)
  544.   end
  545.   # 刷新同伴成员
  546.   $game_party.refresh
  547. end
  548.   #--------------------------------------------------------------------------
  549.   # ● 写入存档文件
  550.   #--------------------------------------------------------------------------
  551.   def save_file(filename)
  552.     # 演奏存档 SE
  553.     $game_system.se_play($data_system.save_se)
  554.     # 写入存档数据
  555.     file = File.open(filename, "wb")
  556.     write_save_data(file)
  557.     file.close
  558.     # 切换到菜单画面
  559.     $scene = Scene_Loadsave.new
  560.   end
  561.   #--------------------------------------------------------------------------
  562.   # ● 写入存档数据
  563.   #     file : 写入用文件对像 (已经打开)
  564.   #--------------------------------------------------------------------------
  565.   def write_save_data(file)
  566.     # 生成描绘存档文件用的角色图形
  567.     characters = []
  568.     for i in 0...$game_party.actors.size
  569.       actor = $game_party.actors[i]
  570.       characters.push([actor.character_name, actor.character_hue])
  571.     end
  572.     # 写入描绘存档文件用的角色数据
  573.     Marshal.dump(characters, file)
  574.     # 写入测量游戏时间用画面计数
  575.     Marshal.dump(Graphics.frame_count, file)
  576.     # 增加 1 次存档次数
  577.     $game_system.save_count += 1
  578.     # 保存魔法编号
  579.     # (将编辑器保存的值以随机值替换)
  580.     $game_system.magic_number = $data_system.magic_number
  581.     # 写入各种游戏对像
  582.     Marshal.dump($game_system, file)
  583.     Marshal.dump($game_switches, file)
  584.     Marshal.dump($game_variables, file)
  585.     Marshal.dump($game_self_switches, file)
  586.     Marshal.dump($game_screen, file)
  587.     Marshal.dump($game_actors, file)
  588.     Marshal.dump($game_party, file)
  589.     Marshal.dump($game_troop, file)
  590.     Marshal.dump($game_map, file)
  591.     Marshal.dump($game_player, file)
  592.   end
  593. end
复制代码


改成只能用调用的办法才能使用……

不要替换原来的,
不然我那个菜单会变掉的……
不定期回归 ~ 游戏开发之旅
———————————————————————————————

Lv4.逐梦者

梦石
0
星屑
8003
在线时间
1184 小时
注册时间
2007-7-29
帖子
2057
3
发表于 2007-8-25 06:58:11 | 只看该作者
你是说RM自带的脚本要保留吗?

还有你说的调用是事件还是菜单里?
回复 支持 反对

使用道具 举报

Lv2.观梦者

梦石
0
星屑
764
在线时间
574 小时
注册时间
2006-5-17
帖子
84
4
发表于 2007-8-25 07:09:04 | 只看该作者
LZ的意思是指...比如按F7就能调用该脚本么?
回复 支持 反对

使用道具 举报

Lv2.观梦者

梦石
0
星屑
431
在线时间
125 小时
注册时间
2006-11-2
帖子
1200
5
发表于 2007-8-25 17:15:58 | 只看该作者
单纯求人帮助还是建议去应援区.
和记忆一起封存着的ID...
回复 支持 反对

使用道具 举报

Lv4.逐梦者 (暗夜天使)

名侦探小柯

梦石
10
星屑
4248
在线时间
3732 小时
注册时间
2006-9-6
帖子
37430

极短27获奖MZ评测员开拓者贵宾第3届短篇游戏大赛主流游戏组亚军第5届短篇游戏比赛亚军

6
 楼主| 发表于 2007-8-25 18:50:38 | 只看该作者
就是说……

只能用调用方法来使用该脚本%……{/gg}
不定期回归 ~ 游戏开发之旅
———————————————————————————————
回复 支持 反对

使用道具 举报

Lv3.寻梦者 (暗夜天使)

精灵族の天使

梦石
0
星屑
1712
在线时间
3039 小时
注册时间
2007-3-16
帖子
33731

开拓者贵宾

7
发表于 2007-8-25 18:56:20 | 只看该作者
原来是纯调用的方式,防止自定义菜单冲突吧。
建议应援区。
回复 支持 反对

使用道具 举报

头像被屏蔽

Lv1.梦旅人 (禁止发言)

梦石
0
星屑
50
在线时间
0 小时
注册时间
2007-8-25
帖子
6
8
发表于 2007-8-25 19:58:16 | 只看该作者
提示: 作者被禁止或删除 内容自动屏蔽
回复 支持 反对

使用道具 举报

Lv4.逐梦者 (暗夜天使)

名侦探小柯

梦石
10
星屑
4248
在线时间
3732 小时
注册时间
2006-9-6
帖子
37430

极短27获奖MZ评测员开拓者贵宾第3届短篇游戏大赛主流游戏组亚军第5届短篇游戏比赛亚军

9
 楼主| 发表于 2007-8-25 21:33:02 | 只看该作者
没明白LS写些什么……
不定期回归 ~ 游戏开发之旅
———————————————————————————————
回复 支持 反对

使用道具 举报

头像被屏蔽

Lv1.梦旅人 (禁止发言)

梦石
0
星屑
50
在线时间
0 小时
注册时间
2007-8-25
帖子
6
10
发表于 2007-8-25 21:37:30 | 只看该作者
提示: 作者被禁止或删除 内容自动屏蔽
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作

GMT+8, 2026-6-24 06:13

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表