| 赞 | 425 |
| VIP | |
| 好人卡 | |
| 积分 | 422 |
| 经验 | |
| 最后登录 | 2026-8-20 |
| 在线时间 | 6017 小时 |
- 梦石
- 0
- 星屑
- 42235
- 在线时间
- 6017 小时
- 注册时间
- 2006-11-10
- 回帖
- 6966
|
发表于 2025-7-23 10:21:56
|
显示全部楼层
- #---------
- #已经移植到RPG MAKER VX ACE
- #Lanza
- #---------
- #==============================================================================
- # ★ 多组多功能计时器 ★ -> by 芯☆淡茹水
- #==============================================================================
- # ● 使用方法:1,复制脚本,插入到 main 前。
- #
- # 2,启动计时:
- #
- # PS:注意这里!!!!!!!!!!!!!!
- # 改为了$game_timer 而非原版$game_system
- #
- # 事件 -> 脚本 :$game_timer.start_time(tit, min, switch, add)
- #
- # 括号里的参数:tit -> 标题 。比如:双倍经验时间;副本时间,等
- # 代入的参数为 字符串 。由于计时窗口宽度
- # 有限,标题最好不要超过 5 个汉字。
- #
- # min -> 计时时间X分钟。(注意是分钟,可以是小数)
- #
- # switch -> 计时完成后打开的开关ID。
- #
- # add -> 正计时标志。需要正计时写 true ,不需要
- # 时可不写。
- #
- # 3,中途取消计时:
- #
- # 事件 -> 脚本:$game_system.end_time(switch_id)
- #
- # 括号里的参数:switch_id -> 对应的计时器打开的开关ID。
- #==============================================================================
- # ● 说明:
- # 该计时器理论上可同时无限个计时。
- #
- # 计时窗口只在地图场景显示,战斗场景不显示计时窗口,但仍然会计时,
- # 其他场景不计时。
- #
- # 计时完成后自动打开启动计时时设置的开关,需要实现什么功能可通过事件,
- # 开关,公共事件,等,来协调完成。这个就自己开脑洞。
- # 可参照范例工程的示范(事件,公共事件)。
- #
- #==============================================================================
- # ● 设置:
- module X☆R
- #--------------------------------------------------------------------------
- # 计时窗口 X 坐标。
- TM_WINDOW_X = 280
-
- #--------------------------------------------------------------------------
- # 计时窗口 Y 坐标。
- TM_WINDOW_Y = 15
-
- #--------------------------------------------------------------------------
- # 计时窗口标题字体颜色。
- TM_TIT_COLOR = Color.new(255,0,0)
-
- #--------------------------------------------------------------------------
- # 计时窗时间字体颜色(30 秒以上)。
- TM_TIME_COLOR1 = Color.new(255,0,0)
-
- #--------------------------------------------------------------------------
- # 计时窗时间字体颜色(10 - 30 秒)。
- TM_TIME_COLOR2 = Color.new(255,0,0)
-
- #--------------------------------------------------------------------------
- # 计时窗时间字体颜色(0 - 10 秒)。
- TM_TIME_COLOR3 = Color.new(255,0,0)
-
- #--------------------------------------------------------------------------
- # 最后 10 秒是否声音提示?
- TM_SOUND_TIP = false
-
- #--------------------------------------------------------------------------
- # 声音提示的 SE 文件名。
- TM_SOUND = "Switch1"
- end
- #==============================================================================
- class Time_Meter
- attr_reader :switch_id, :title, :add_count
- attr_accessor :sec, :max_sec
- #--------------------------------------------------------------------------
- def initialize(title, min, switch_id, add)
- @title = title
- @max_sec = @sec = Integer(min * 60)
- @sec = 0 if add
- @switch_id = switch_id
- @add_count = add ? 1 : -1
- end
- #--------------------------------------------------------------------------
- def sec_judge
- return @add_count > 0 ? @sec < @max_sec : @sec > 0
- end
- #--------------------------------------------------------------------------
- def update
- @sec += @add_count if sec_judge and Graphics.frame_count % Graphics.frame_rate == 0
- unless sec_judge
- $game_switches[@switch_id] = true
- $game_map.need_refresh = true
- end
- if @data_sec != @sec and @add_count < 0
- @data_sec = @sec
- if @sec < 10 and X☆R::TM_SOUND_TIP and $scene.is_a?(Scene_Map)
- Audio.se_play("Audio/SE/#{X☆R::TM_SOUND}", 80, 100)
- end
- end
- end
- end
- #==============================================================================
- class Window_Tm < Sprite
- #--------------------------------------------------------------------------
- def initialize(x, y, time)
- super()
- self.x = x
- self.y = y
- self.z = 9999
- @time = time
- bitmap = Cache.character($game_player.character_name)
- @b_width = bitmap.width / 8
- @b_height = bitmap.height / 4
- end
- #--------------------------------------------------------------------------
- def dispose
- self.bitmap.dispose if self.bitmap
- super
- end
- #--------------------------------------------------------------------------
- def refresh
- self.bitmap.dispose if self.bitmap
- self.bitmap = Bitmap.new("Graphics/Pictures/Time_meter_back")
- self.bitmap.font.size = 18
- self.bitmap.font.bold = true
- cx = self.bitmap.text_size(@time.title).width
- self.bitmap.font.color = X☆R::TM_TIT_COLOR
- self.bitmap.draw_text(35, 0, cx, 30, @time.title)
- if @time.add_count > 0
- color = X☆R::TM_TIME_COLOR1
- else
- color = @time.sec >= 30 ? X☆R::TM_TIME_COLOR1 :
- (@time.sec >= 10 ? X☆R::TM_TIME_COLOR2 : X☆R::TM_TIME_COLOR3)
- end
- min = @time.sec / 60
- sec = @time.sec % 60
- fra = Graphics.frame_count % Graphics.frame_rate
- text = sprintf("%02d:%02d:%02d", min, sec,fra)
- self.bitmap.font.color = color
- self.bitmap.draw_text(130, 0, 90, 30, text, 2)
- end
- #--------------------------------------------------------------------------
- def update
- return if self.disposed?
- super
- refresh
- if self.x < $game_player.screen_x + @b_width and
- self.x + 240 > $game_player.screen_x - @b_width and
- self.y + 30 < $game_player.screen_y and
- self.y > $game_player.screen_y - @b_height
- self.opacity = 80
- else
- self.opacity = 255 if self.opacity < 255
- end
- dispose unless @time.sec_judge
- end
- end
- #==============================================================================
- class Game_Timer
- #--------------------------------------------------------------------------
- alias add_initialize_xr initialize
- def initialize
- add_initialize_xr
- @time_meters = []
- end
- #--------------------------------------------------------------------------
- def time_meters
- return @time_meters
- end
- #--------------------------------------------------------------------------
- def start_time(title="", min=0, switch_id=0, add=false)
- return if min == 0 or switch_id == 0
- for t in @time_meters
- if t.switch_id == switch_id
- t.add_count > 0 ? t.max_sec += Integer(min * 60) : t.sec += Integer(min * 60)
- return
- end
- end
- @time_meters.push(Time_Meter.new(title, min, switch_id, add))
- end
- #--------------------------------------------------------------------------
- def end_time(switch_id)
- for t in @time_meters
- if t.switch_id == switch_id
- @time_meters.delete(t)
- end
- end
- end
- #--------------------------------------------------------------------------
- alias old_update_xr update
- def update
- unless @time_meters.empty?
- for time in @time_meters
- time.update
- unless time.sec_judge
- @time_meters.delete(time)
- next
- end
- end
- end
- old_update_xr
- end
- end
- #==============================================================================
- class Scene_Map
- #--------------------------------------------------------------------------
- alias old_main_xr main
- def main
- @time_window = []
- old_main_xr
- @time_window.each{|t| t.dispose}
- end
- #--------------------------------------------------------------------------
- alias old_update_xr update
- def update
- if @data_time != $game_timer.time_meters
- @data_time = $game_timer.time_meters.clone
- @time_window.each{|t| t.dispose}
- unless $game_timer.time_meters.empty?
- for i in 0...$game_timer.time_meters.size
- time = $game_timer.time_meters[i]
- nx = X☆R::TM_WINDOW_X > 320 ? -240 : 240
- nx = i / 8 * nx
- x = X☆R::TM_WINDOW_X + nx ; y = i % 8 * 30 + X☆R::TM_WINDOW_Y
- @time_window[i] = Window_Tm.new(x, y, time)
- end
- end
- end
- unless @time_window.empty?
- for w in @time_window
- w.update
- @time_window.delete(w) if w.disposed?
- end
- end
- old_update_xr
- end
- end
复制代码
换成它吧, 不过提醒下, 每帧draw可是很浪费资源的, 要自重 |
|