赞 | 0 |
VIP | 0 |
好人卡 | 0 |
积分 | 4 |
经验 | 201687 |
最后登录 | 2024-7-14 |
在线时间 | 125 小时 |
Lv2.观梦者
- 梦石
- 0
- 星屑
- 431
- 在线时间
- 125 小时
- 注册时间
- 2006-11-2
- 帖子
- 1200
|
- class Scene_Menu
- # --------------------------------
- def initialize(menu_index = 0)
- @menu_index = menu_index
- @changer = 0
- @where = 0
- @checker = 0
- end
- # --------------------------------
- def main
- s1 = $data_system.words.item
- s2 = $data_system.words.skill
- s3 = $data_system.words.equip
- s4 = "状态"
- s5 = "储存进度"
- s6 = "读取进度"
- s7 = "离开游戏"
- s8 = "调整队伍"
- @command_window = Window_Command.new(160, [s1, s2, s3, s4, s5, s6, s7, s8])
- @command_window.index = @menu_index
- if $game_party.actors.size == 0
- @command_window.disable_item(0)
- @command_window.disable_item(1)
- @command_window.disable_item(2)
- @command_window.disable_item(3)
- end
- if $game_system.save_disabled
- @command_window.disable_item(4)
- end
- if $game_party.actors.size == 1
- @command_window.disable_item(7)
- end
- @playtime_window = Window_PlayTime.new
- @playtime_window.x = 0
- @playtime_window.y = 288
- @gold_window = Window_Gold.new
- @gold_window.x = 0
- @gold_window.y = 396
- @status_window = Window_MenuStatus.new
- @status_window.x = 160
- @status_window.y = 0
- Graphics.transition
- loop do
- Graphics.update
- Input.update
- update
- if $scene != self
- break
- end
- end
- Graphics.freeze
- @command_window.dispose
- @playtime_window.dispose
- @gold_window.dispose
- @status_window.dispose
- end
- # --------------------------------
- def update
- @command_window.update
- @playtime_window.update
- @gold_window.update
- @status_window.update
- if @command_window.active
- update_command
- return
- end
- if @status_window.active
- update_status
- return
- end
- end
- # --------------------------------
- def update_command
- if Input.trigger?(Input::B)
- $game_system.se_play($data_system.cancel_se)
- $scene = Scene_Map.new
- $game_player.character_name = $game_party.actors[0].character_name
- return
- end
- if Input.trigger?(Input::C)
- if $game_party.actors.size == 0 and @command_window.index < 4
- $game_system.se_play($data_system.buzzer_se)
- return
- end
- if $game_party.actors.size == 1 and @command_window.index ==7
- $game_system.se_play($data_system.buzzer_se)
- return
- end
- case @command_window.index
- when 0
- $game_system.se_play($data_system.decision_se)
- $scene = Scene_Item.new
- when 1
- $game_system.se_play($data_system.decision_se)
- @command_window.active = false
- @status_window.active = true
- @status_window.index = 0
- when 2
- $game_system.se_play($data_system.decision_se)
- @command_window.active = false
- @status_window.active = true
- @status_window.index = 0
- when 3
- $game_system.se_play($data_system.decision_se)
- @command_window.active = false
- @status_window.active = true
- @status_window.index = 0
- when 4
- if $game_system.save_disabled
- $game_system.se_play($data_system.buzzer_se)
- return
- end
- $game_system.se_play($data_system.decision_se)
- $scene = Scene_Save.new
- when 5
- $game_system.se_play($data_system.decision_se)
- $scene = Scene_Load2.new
- when 6
- $game_system.se_play($data_system.decision_se)
- $scene = Scene_End.new
- when 7
- $game_system.se_play($data_system.decision_se)
- @checker = 0
- @command_window.active = false
- @status_window.active = true
- @status_window.index = 0
- end
- return
- end
- end
- # --------------------------------
- def update_status
- if Input.trigger?(Input::B)
- $game_system.se_play($data_system.cancel_se)
- @command_window.active = true
- @status_window.active = false
- @status_window.index = -1
- return
- end
- if Input.trigger?(Input::C)
- case @command_window.index
- when 1
- if $game_party.actors[@status_window.index].restriction >= 2
- $game_system.se_play($data_system.buzzer_se)
- return
- end
- $game_system.se_play($data_system.decision_se)
- $scene = Scene_Skill.new(@status_window.index)
- when 2
- $game_system.se_play($data_system.decision_se)
- $scene = Scene_Equip.new(@status_window.index)
- when 3
- $game_system.se_play($data_system.decision_se)
- $scene = Scene_Status.new(@status_window.index)
- when 7
- $game_system.se_play($data_system.decision_se)
- if @checker == 0
- @changer = $game_party.actors[@status_window.index]
- @where = @status_window.index
- @checker = 1
- else
- $game_party.actors[@where] = $game_party.actors[@status_window.index]
- $game_party.actors[@status_window.index] = @changer
- @checker = 0
- @status_window.refresh
- end
- end
- return
- end
- end
- end
- #==============================================================================
- # 本脚本来自www.66RPG.com,使用和转载请保留此信息
- #==============================================================================
- #==============================================================================
- # ■ Scene_Load2
- #------------------------------------------------------------------------------
- # 处理读档画面的类。
- #==============================================================================
- class Scene_Load2 < Scene_File
- #--------------------------------------------------------------------------
- # ● 初始化对像
- #--------------------------------------------------------------------------
- def initialize
- # 再生成临时对像
- $game_temp = Game_Temp.new
- # 选择存档时间最新的文件
- $game_temp.last_file_index = 0
- latest_time = Time.at(0)
- for i in 0..3
- filename = make_filename(i)
- if FileTest.exist?(filename)
- file = File.open(filename, "r")
- if file.mtime > latest_time
- latest_time = file.mtime
- $game_temp.last_file_index = i
- end
- file.close
- end
- end
- super("要载入哪个文件?")
- end
- #--------------------------------------------------------------------------
- # ● 确定时的处理
- #--------------------------------------------------------------------------
- def on_decision(filename)
- # 文件不存在的情况下
- unless FileTest.exist?(filename)
- # 演奏冻结 SE
- $game_system.se_play($data_system.buzzer_se)
- return
- end
- # 演奏读档 SE
- $game_system.se_play($data_system.load_se)
- # 写入存档数据
- file = File.open(filename, "rb")
- read_save_data(file)
- file.close
- # 还原 BGM、BGS
- $game_system.bgm_play($game_system.playing_bgm)
- $game_system.bgs_play($game_system.playing_bgs)
- # 刷新地图 (执行并行事件)
- $game_map.update
- # 切换到地图画面
- $scene = Scene_Map.new
- end
- #--------------------------------------------------------------------------
- # ● 取消时的处理
- #--------------------------------------------------------------------------
- def on_cancel
- # 演奏取消 SE
- $game_system.se_play($data_system.cancel_se)
- # 切换到标题画面
- $scene = Scene_Menu.new(5)
- end
- #--------------------------------------------------------------------------
- # ● 读取存档数据
- # file : 读取用文件对像 (已经打开)
- #--------------------------------------------------------------------------
- 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)
- # 魔法编号与保存时有差异的情况下
- # (加入编辑器的编辑过的数据)
- 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
- ##==============================================================================
- # ■ Window_Gold
- #------------------------------------------------------------------------------
- # 显示金钱的窗口。
- #==============================================================================
- class Window_Gold < Window_Base
- #--------------------------------------------------------------------------
- # ● 初始化窗口
- #--------------------------------------------------------------------------
- def initialize
- super(0, 0, 160, 84)
- self.contents = Bitmap.new(width - 32, height - 32)
- refresh
- end
- #--------------------------------------------------------------------------
- # ● 刷新
- #--------------------------------------------------------------------------
- def refresh
- self.contents.clear
- cx = contents.text_size($data_system.words.gold).width
- self.contents.font.color = normal_color
- self.contents.draw_text(4, 0, 120-cx-2, 42, $game_party.gold.to_s, 2)
- self.contents.font.color = system_color
- self.contents.draw_text(124-cx, 0, cx, 42, $data_system.words.gold, 2)
- end
- end
- #==============================================================================
- # ■ Window_PlayTime
- #------------------------------------------------------------------------------
- # 菜单画面显示游戏时间的窗口。
- #==============================================================================
- class Window_PlayTime < Window_Base
- #--------------------------------------------------------------------------
- # ● 初始化对像
- #--------------------------------------------------------------------------
- def initialize
- super(0, 0, 160, 108)
- self.contents = Bitmap.new(width - 32, height - 32)
- refresh
- end
- #--------------------------------------------------------------------------
- # ● 刷新
- #--------------------------------------------------------------------------
- def refresh
- self.contents.clear
- self.contents.font.color = system_color
- self.contents.draw_text(4, 0, 120, 42, "游戏时间")
- @total_sec = Graphics.frame_count / Graphics.frame_rate
- hour = @total_sec / 60 / 60
- min = @total_sec / 60 % 60
- sec = @total_sec % 60
- text = sprintf("%02d:%02d:%02d", hour, min, sec)
- self.contents.font.color = normal_color
- self.contents.draw_text(4, 32, 120, 32, text, 2)
- end
- #--------------------------------------------------------------------------
- # ● 刷新画面
- #--------------------------------------------------------------------------
- def update
- super
- if Graphics.frame_count / Graphics.frame_rate != @total_sec
- refresh
- end
- end
- end
复制代码
搞定。
使用之前 把 Game_Character 1 中的attr_reader :character_name
改为attr_accessor :character_name |
|