|
|
楼主 |
发表于 2018-7-1 02:12:13
|
显示全部楼层
点击展开/收起#==============================================================================
# ★ RGSS3_时间效果 Ver1.01
#==============================================================================
=begin
作者:tomoaky
webサイト:ひきも記は閉鎖しました。 (http://hikimoki.sakura.ne.jp/)
根据时间,自动改变画面色调。
开启16号开关时,隐藏时钟。(初始设定)
开启17号开关时,暂停时钟。(初始设定)
10、11号变量用于存储"时"和"分"。(初始设定)
可用脚本:
set_time(h, m)
修改时间。
例)set_time(15, 30) # 时间变为下午3点半
地图备注: <时间显示无效> 则该地图不会随时间流逝而改变色调。
在使用此备注的时候,如果你想要自动改变地图的色调请使用脚本『RGSS3_自动色调』
使用开关(初始設定)
0016, 0017
使用变量(初始設定)
0010, 0011
必要图片
Graphics/System/hour_hand.png
Graphics/System/minute_hand.png
2014.10.14 Ver1.01
・『RGSS3_自動色調』に合わせて <時刻演出無効> タグの仕様を変更
2014.10.07 Ver1.0
・公開
=end
#==============================================================================
# □ 設定項目
#==============================================================================
module TMTIMEC
TIME_START = 7 # 游戏开始时的时间
TIME_RATE = 60 # 游戏内时间的速率(60则与现实相同)
TIME_SPEED = 1000 # 时间流逝的速度(高速为测试效果)
TONE_DURATION = 300 # 色调变化的时间(帧)
SW_CLOCK_HIDDEN = 45 # 隐藏时钟的开关
SW_CLOCK_STOP = 46 # 暂停时间的开关
VN_TIME_H = 10 # 存储时间(时)的变量
VN_TIME_M = 11 # 存储时间(分)的变量
CLOCK_X = Graphics.width - 64 - 8 # 时钟X坐标
CLOCK_Y = 8 # 时钟Y坐标
# 时钟数字的字体
CLOCK_FONT_NAME = ["黑体", "宋体"]
end
#==============================================================================
# □ コマンド
#==============================================================================
module TMTIMEC
module Commands
#--------------------------------------------------------------------------
# ○ 時間の強制変更
#--------------------------------------------------------------------------
def set_time(h = TIME_START, m = 0)
$game_map.set_time(h, m)
end
end
end # module TMTIMEC
#==============================================================================
# ■ Game_Map
#==============================================================================
class Game_Map
#--------------------------------------------------------------------------
# ● 公開インスタンス変数
#--------------------------------------------------------------------------
attr_reader :day_time # 時刻
#--------------------------------------------------------------------------
# ● オブジェクト初期化
#--------------------------------------------------------------------------
alias tmtimec_game_map_initialize initialize
def initialize
tmtimec_game_map_initialize
init_time
end
#--------------------------------------------------------------------------
# ○ 時刻の初期化
#--------------------------------------------------------------------------
def init_time
@day_time = TMTIMEC::TIME_START * 3600 * TMTIMEC::TIME_RATE
end
#--------------------------------------------------------------------------
# ● セットアップ
#--------------------------------------------------------------------------
alias tmtimec_game_map_setup setup
def setup(map_id)
tmtimec_game_map_setup(map_id)
refresh_time(0)
end
#--------------------------------------------------------------------------
# ○ 指定した時間に変更する
#--------------------------------------------------------------------------
def set_time(h = TMTIMEC::START_TIME, m = 0)
@day_time = [[h, 0].max, 23].min * 3600 * TMTIMEC::TIME_RATE
@day_time += [[h, 0].max, 59].min * 60 * TMTIMEC::TIME_RATE
refresh_time(0)
end
#--------------------------------------------------------------------------
# ○ スクリーンの時間をリフレッシュ
#--------------------------------------------------------------------------
def refresh_time(duration = TMTIMEC::TONE_DURATION)
return if /<时间显示无效>/ =~ @map.note
case @day_time / (3600 * TMTIMEC::TIME_RATE)
when 0; @screen.start_tone_change(Tone.new(-68, -68, 0, 68), duration)
when 1; @screen.start_tone_change(Tone.new(-68, -68, 0, 68), duration)
when 2; @screen.start_tone_change(Tone.new(-68, -68, 0, 68), duration)
when 3; @screen.start_tone_change(Tone.new(-68, -68, 0, 68), duration)
when 4; @screen.start_tone_change(Tone.new(-68, -68, 0, 68), duration)
when 5; @screen.start_tone_change(Tone.new(-68, -68, 0, 68), duration)
when 6; @screen.start_tone_change(Tone.new(-17, 0, 17, 17), duration)
when 7; @screen.start_tone_change(Tone.new(-17, 0, 17, 17), duration)
when 8; @screen.start_tone_change(Tone.new(-17, 0, 17, 17), duration)
when 9; @screen.start_tone_change(Tone.new(0, 0, 0, 0), duration)
when 10; @screen.start_tone_change(Tone.new(0, 0, 0, 0), duration)
when 11; @screen.start_tone_change(Tone.new(0, 0, 0, 0), duration)
when 12; @screen.start_tone_change(Tone.new(0, 0, 0, 0), duration)
when 13; @screen.start_tone_change(Tone.new(0, 0, 0, 0), duration)
when 14; @screen.start_tone_change(Tone.new(0, 0, 0, 0), duration)
when 15; @screen.start_tone_change(Tone.new(17, -34, -34, 0), duration)
when 16; @screen.start_tone_change(Tone.new(17, -34, -34, 0), duration)
when 17; @screen.start_tone_change(Tone.new(17, -34, -34, 0), duration)
when 18; @screen.start_tone_change(Tone.new(-68, -68, 0, 68), duration)
when 19; @screen.start_tone_change(Tone.new(-68, -68, 0, 68), duration)
when 20; @screen.start_tone_change(Tone.new(-68, -68, 0, 68), duration)
when 21; @screen.start_tone_change(Tone.new(-68, -68, 0, 68), duration)
when 22; @screen.start_tone_change(Tone.new(-68, -68, 0, 68), duration)
when 23; @screen.start_tone_change(Tone.new(-68, -68, 0, 68), duration)
end
end
#--------------------------------------------------------------------------
# ● フレーム更新
# main : インタプリタ更新フラグ
#--------------------------------------------------------------------------
alias tmtimec_game_map_update update
def update(main = false)
update_time
tmtimec_game_map_update(main)
end
#--------------------------------------------------------------------------
# ○ 時刻の更新
#--------------------------------------------------------------------------
def update_time
return if $game_switches[TMTIMEC::SW_CLOCK_STOP]
last_time = @day_time / (3600 * TMTIMEC::TIME_RATE)
@day_time += TMTIMEC::TIME_SPEED
h = (@day_time / (3600 * TMTIMEC::TIME_RATE)) % 24
if last_time != h
@day_time = 0 if h == 0
$game_variables[TMTIMEC::VN_TIME_H] = h
refresh_time
@need_refresh = true
end
$game_variables[TMTIMEC::VN_TIME_M] = (@day_time / (60 * TMTIMEC::TIME_RATE)) % 60
end
end
#==============================================================================
# ■ Game_Event
#==============================================================================
class Game_Event
include TMTIMEC::Commands
end
#==============================================================================
# ■ Game_Interpreter
#==============================================================================
class Game_Interpreter
include TMTIMEC::Commands
end
#==============================================================================
# ■ Sprite_Clock
#==============================================================================
class Sprite_Clock < Sprite
#--------------------------------------------------------------------------
# ● オブジェクト初期化
#--------------------------------------------------------------------------
def initialize(viewport = nil)
super(viewport)
self.bitmap = Bitmap.new(64, 64)
self.bitmap.font.size = 12
self.bitmap.font.name = TMTIMEC::CLOCK_FONT_NAME
self.x = TMTIMEC::CLOCK_X
self.y = TMTIMEC::CLOCK_Y
self.z = 210
create_hour_hand
create_minute_hand
refresh
end
#--------------------------------------------------------------------------
# ● 表示フラグの設定
#--------------------------------------------------------------------------
def visible=(visible)
super
@hour_hand.visible = self.visible if @hour_hand
@minute_hand.visible = self.visible if @minute_hand
end
#--------------------------------------------------------------------------
# ● 短針の作成
#--------------------------------------------------------------------------
def create_hour_hand
@hour_hand = Sprite.new
@hour_hand.bitmap = Cache.system("hour_hand")
@hour_hand.ox = 19
@hour_hand.oy = 32
@hour_hand.x = self.x + 32
@hour_hand.y = self.y + 32
@hour_hand.z = self.z + 1
end
#--------------------------------------------------------------------------
# ● 長身の作成
#--------------------------------------------------------------------------
def create_minute_hand
@minute_hand = Sprite.new
@minute_hand.bitmap = Cache.system("minute_hand")
@minute_hand.ox = 19
@minute_hand.oy = 32
@minute_hand.x = self.x + 32
@minute_hand.y = self.y + 32
@minute_hand.z = self.z + 2
end
#--------------------------------------------------------------------------
# ● 解放
#--------------------------------------------------------------------------
def dispose
@hour_hand.dispose
@minute_hand.dispose
self.bitmap.dispose
super
end
#--------------------------------------------------------------------------
# ● リフレッシュ
#--------------------------------------------------------------------------
def refresh
self.bitmap.clear
pi = Math::PI * 3
(1..12).each do |i|
x = 32 + (Math.sin(pi - Math::PI * 2 * i / 12) * 26).to_i - 12
y = 32 + (Math.cos(pi - Math::PI * 2 * i / 12) * 26).to_i - 6
self.bitmap.draw_text(x, y, 24, 12, i, 1)
end
end
#--------------------------------------------------------------------------
# ● フレーム更新
#--------------------------------------------------------------------------
def update
self.visible = !$game_switches[TMTIMEC::SW_CLOCK_HIDDEN]
@hour_hand.visible = self.visible if @hour_hand
@minute_hand.visible = self.visible if @minute_hand
super
time = $game_map.day_time / 60 / TMTIMEC::TIME_RATE
@minute_hand.angle = 360 - time % 60 * 360 / 60
@hour_hand.angle = 360 - time % 720 * 360 / 720
end
end
#==============================================================================
# ■ Spriteset_Map
#==============================================================================
class Spriteset_Map
#--------------------------------------------------------------------------
# ● オブジェクト初期化
#--------------------------------------------------------------------------
alias tmtimec_spriteset_map_initialize initialize
def initialize
tmtimec_spriteset_map_initialize
create_clock
update_clock
end
#--------------------------------------------------------------------------
# ○ 時計スプライトの作成
#--------------------------------------------------------------------------
def create_clock
@clock_sprite = Sprite_Clock.new(@viewport2)
end
#--------------------------------------------------------------------------
# ● 解放
#--------------------------------------------------------------------------
alias tmtimec_spriteset_map_dispose dispose
def dispose
dispose_clock
tmtimec_spriteset_map_dispose
end
#--------------------------------------------------------------------------
# ○ 時計スプライトの解放
#--------------------------------------------------------------------------
def dispose_clock
@clock_sprite.dispose
end
#--------------------------------------------------------------------------
# ● フレーム更新
#--------------------------------------------------------------------------
alias tmtimec_spriteset_map_update update
def update
update_clock
tmtimec_spriteset_map_update
end
#--------------------------------------------------------------------------
# ○ 時計スプライトの更新
#--------------------------------------------------------------------------
def update_clock
@clock_sprite.update if @clock_sprite
end
end
|
|