赞 | 0 |
VIP | 0 |
好人卡 | 0 |
积分 | 1 |
经验 | 1012 |
最后登录 | 2018-10-28 |
在线时间 | 5 小时 |
Lv1.梦旅人 神之瞳
- 梦石
- 0
- 星屑
- 60
- 在线时间
- 5 小时
- 注册时间
- 2009-7-5
- 帖子
- 314
|
本帖最后由 上帝的眼睛 于 2009-10-1 21:11 编辑
提供范例……内附图片一张……
代码如下- =begin
- 大航海时代昼夜系统 v0.4
- 作者:秀秀
- 功能:1.地图显示时间
- 2.随时间变化 产生昼夜交替 房间内不会产生变化
- 3.自定义进入某地图会消耗时间
-
- 用法:设置模块常量 HOUSE 为房间属性(不会产生色相变化)
- 设置模块常量 HOUSE_TIME 为消耗时间
- 比如 1=>20 代表进入ID为1的地图 消耗时间20分钟
-
- 其他设置见脚本开始的其他模块常量
- 基本已经注释的非常清楚了
- 更新:v0.2
- 增加了事件中判断时间
- 可用于某房间(商店)在某时间段才开放
- 用法:在事件中插入条件分歧
- 在第四页脚本中输入:Time_System.kind_of_time(kind) == true
- kind 是时间段种类 比如kind设置为4 就判断是否为酒吧
- 具体看脚本开头的kind_of_time(kind)方法 可以自行添加修改
-
- 更新:v0.3
- 更新了通过事件脚本功能 Time_System.time = x
- 更改时间 x 为时间
- 此功能可以实现大航海时代睡觉选择 起床时间
- 用法见范例或者截图
-
- 更新:v0.4
- 新增了一些插件(非大航海用)(菜刀灯笼王的提议)
- 1. 时光倒流
- 2. 疯狂时钟功能,自定义时间流速。
- 3.时间闸门功能,时间流速为之前的几分之一。
- 4.时间银行功能,可以把时间存起来,需要的时候提取出来,这个时候时间停止
- 5.双重时间系统(精灵使者的提议)
-
- 使用方法
- 1.时光倒流
- HOUSE_TIME里面 时间改为负数就可以了 比如 1=> -20
- 2.疯狂时钟和时间闸门
- Time_System.time_speed=(x) x就是倍数 默认为1
- 3.时间银行
- Time_System.stop_time 设置为时间停止
- Time_System.start_time 设置为时间恢复运行
- 4.双重时间系统
- 模块常量 HOUSE_TIME2 设置世界2的 世界消耗
- Time_System.change_time_world1 还原世界世界
- Time_System.change_time_world2 改变时间世界
- =end
- module Time_System
- # 最大时间(分钟)
- MAX = 24 * 60
- # 初始时间
- INIT_TIME = 8 * 60
-
- # 窗口信息 x坐标 y坐标 是否在地图上显示
- X = 0
- Y = 0
- VISIBLE = true
- # 对应白天 黄昏 夜晚 的色调 自己设置
- DAY = Tone.new(0,0,0,0)
- EVE = Tone.new(-255,-85,68,0)
- DUSK = Tone.new(34,-17,-17,0)
- # 天气类型
- @@kind = -1
- # 真实时间
- @@time = 0
- # 文本
- @@text = ""
- # 时间流速(默认1倍速)
- @@time_speed = 1
- # 时间停止
- @@stop = false
- #保存双重时间(默认初始时间)
- @@time1 = 8 * 60
- @@time2 = 8 * 60
- @@time_world = 1
- #时间世界(用于双重时间系统)
- @@time_world = 1
- @@proc = Proc.new{ self.start }
- # 房间ID的数组(地图) 对应地图ID 不会改变天气色相
- HOUSE = [2,3,4,5,6]
- # 各个地图ID消耗时间表
- # 世界1
- HOUSE_TIME = { 1=>20,
- 2=>80,
- 3=>60,
- 4=>80,
- 5=>100,
- 6=>120,
- }
- # 世界2
- HOUSE_TIME2 = { 1=>10,
- 2=>20,
- 3=>30,
- 4=>40,
- 5=>50,
- 6=>60,
- }
-
- # 这里设置几种时间段 用于某房间或者商店何时可以进入
- def self.kind_of_time(kind)
- case kind
- when 1 #时间段1 上午8点到晚上8点
- if @@time >= 8*60 and @@time < 20*60
- return true
- end
- when 2 #时间段2 中午12点到晚上6点
- if @@time >= 12*60 and @@time < 18*60
- return true
- end
- when 3 #时间段3 晚上六点到晚上12点
- if @@time >= 18*60 and @@time < 24*60
- return true
- end
- when 4#时间段4 (酒吧分2个间段 0:00-6.00 , 20:00-24:00)
- if @@time >= 0*60 and @@time < 6*60
- return true
- end
- if @@time >= 20*60 and @@time < 24*60
- return true
- end
- end
- end
-
- def self.start
- $game_system.time_window_need_refresh = true
- self.time
- self.change
- end
-
- def self.load
- @@time = $game_system.change_time
- @@time_speed = $game_system.time_speed
- @@stop = $game_system.stop
- @@time1 = $game_system.time1
- @@time2 = $game_system.time2
- @@time_world = $game_system.time_world
- self.init_set_text
- self.change
- $game_system.time_window_need_refresh = true
- end
- def self.save_time
- $game_system.change_time = @@time
- $game_system.time_speed = @@time_speed
- $game_system.stop = @@stop
- $game_system.time1 = @@time1
- $game_system.time2 = @@time2
- $game_system.time_world = @@time_world
- end
- def self.start_time
- @@stop = false
- return
- end
- def self.stop_time
- @@stop = true
- return
- end
- def self.stop!
- return @@stop
- end
-
- def self.time_speed=(speed)
- return (@@time_speed = speed)
- end
-
- def self.change_time_world1
- @@time2 = @@time #保存世界2
- @@time = @@time1
- @@time_world = 1
- return
- end
- def self.change_time_world2
- @@time1 = @@time #保存世界1
- @@time = @@time2
- @@time_world = 2
- return
- end
- def self.init_set_text
- @@time = (@@time - MAX) if @@time >= MAX
- hour = @@time / 60
- min = @@time % 60
- @@text = sprintf("%02d:%02d", hour, min)
- end
- def self.time=(time)
- @@time = time * 60
- hour = @@time / 60
- min = @@time % 60
- @@text = sprintf("%02d:%02d", hour, min)
- $game_system.time_window_need_refresh = true
- end
-
- def self.time
- case @@time_world
- when 1
- time = HOUSE_TIME[$game_map.map_id]
- when 2
- time = HOUSE_TIME2[$game_map.map_id]
- end
- @@time += (time.to_i * @@time_speed) unless self.stop!
- @@time = (@@time - MAX) if @@time >= MAX
- hour = @@time / 60
- min = @@time % 60
- text = sprintf("%02d:%02d", hour, min)
- case hour
- when 6..15 # 白天
- @@kind = 0
- when 16..20 # 黄昏
- @@kind = 1
- when 21..23 #夜晚
- @@kind = 2
- when 0..5 #夜晚
- @@kind = 3
- end
- @@text = text
- $game_system.time_window_need_refresh = true
- end
-
- def self.set_text
- return @@text
- end
-
- def self.set_time
- return @@time
- end
-
- def self.change #改变天气(色相)
- case @@kind
- when 0
- $game_screen.start_tone_change(DAY,0)
- when 1
- $game_screen.start_tone_change(DUSK,0)
- when 2
- $game_screen.start_tone_change(EVE,0)
- when 3
- $game_screen.start_tone_change(EVE,0)
- end
- if HOUSE.include?($game_map.map_id)
- $game_screen.start_tone_change(DAY,0)
- end
- end
-
- def self.start_trace
- Kernel.trace_var :$game_temp.player_transferring,@@proc
- end
- def self.stop_trace
- Kernel.trace_var(:$game_temp.player_transferring,nil)
- end
- end
- class Game_System
- attr_accessor :change_time
- attr_accessor :time_window_need_refresh
- attr_accessor :time_speed
- attr_accessor :stop
- attr_accessor :time1
- attr_accessor :time2
- attr_accessor :time_world
- alias ori_initialize initialize
- def initialize
- ori_initialize
- @change_time = Time_System::INIT_TIME
- @time_window_need_refresh = false
- @time_speed = 1
- @stop = false
- @time1 = 8 * 60
- @time2 = 8 * 60
- @time_world = 1
- end
- end
- class Scene_Map
- #--------------------------------------------------------------------------
- # ● 主角的场所移动
- #--------------------------------------------------------------------------
- def transfer_player
- # 清除主角场所移动调试标志
- $game_temp.player_transferring = false
- # 移动目标与现在的地图有差异的情况下
- if $game_map.map_id != $game_temp.player_new_map_id
- # 设置新地图
- $game_map.setup($game_temp.player_new_map_id)
- end
-
- Time_System.start
-
- # 设置主角位置
- $game_player.moveto($game_temp.player_new_x, $game_temp.player_new_y)
- # 设置主角朝向
- case $game_temp.player_new_direction
- when 2 # 下
- $game_player.turn_down
- when 4 # 左
- $game_player.turn_left
- when 6 # 右
- $game_player.turn_right
- when 8 # 上
- $game_player.turn_up
- end
- # 矫正主角姿势
- $game_player.straighten
- # 刷新地图 (执行并行事件)
- $game_map.update
- # 在生成活动块
- @spriteset.dispose
- @spriteset = Spriteset_Map.new
- # 处理过渡中的情况下
- if $game_temp.transition_processing
- # 清除过渡处理中标志
- $game_temp.transition_processing = false
- # 执行过渡
- Graphics.transition(20)
- end
- # 执行地图设置的 BGM、BGS 的自动切换
- $game_map.autoplay
- # 设置画面
- Graphics.frame_reset
- # 刷新输入信息
- Input.update
- end
- end
- class Game_Map
- attr_reader :map_id
- end
- class Scene_Title
- alias ori_command_new_game command_new_game
- def command_new_game
- ori_command_new_game
- Time_System.load
-
- end
- end
- class Scene_Save < Scene_File
- def on_decision(filename)
- # 演奏存档 SE
- $game_system.se_play($data_system.save_se)
- Time_System.save_time
- # 写入存档数据
- file = File.open(filename, "wb")
- write_save_data(file)
- file.close
- # 如果被事件调用
- if $game_temp.save_calling
- # 清除存档调用标志
- $game_temp.save_calling = false
- # 切换到地图画面
- $scene = Scene_Map.new
- return
- end
- # 切换到菜单画面
- $scene = Scene_Menu.new(4)
- end
- end
- class Scene_Load < Scene_File
- def on_decision(filename)
- unless FileTest.exist?(filename)
- $game_system.se_play($data_system.buzzer_se)
- return
- end
- $game_system.se_play($data_system.load_se)
- file = File.open(filename, "rb")
- read_save_data(file)
- file.close
- $game_system.bgm_play($game_system.playing_bgm)
- $game_system.bgs_play($game_system.playing_bgs)
- $game_map.update
- Time_System.load
- $scene = Scene_Map.new
- end
- end
- class Scene_Map
- alias ori_main main
- def main
- @back_com = Sprite.new#修改
- @back_com.bitmap = RPG::Cache.picture("timeback.png")#修改
- @back_com.z=900#修改
- @time_window = Window_Base.new(0,0,100,64)
- @time_window.x = 90#修改坐标
- @time_window.y =10#修改坐标
- @time_window.z =901#修改
- @time_window.opacity = 0#此处修改~
- @time_window.visible = Time_System::VISIBLE
- @time_window.contents = Bitmap.new(64,32)
- $game_system.time_window_need_refresh = true
- ori_main
- @time_window.dispose
- @back_com.dispose#修改
- end
- alias ori_update update
- def update
- if $game_system.time_window_need_refresh
- time_window_refresh
- end
- ori_update
- end
- def time_window_refresh
- @time_window.contents.clear
- @time_window.contents.draw_text(0,0,100,32,Time_System.set_text)
- $game_system.time_window_need_refresh = false
- end
- end
复制代码@time_window_pic = Sprite.new
@time_window_pic.bitmap = Bitmap.new("Graphics/Pictures/图片")
@time_window_pic.y = 200
@time_window_pic.x = 0
@time_window_pic.dispose
显示不出来的原因很简单,z值太低,地图遮挡住了图片 |
|