#_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
#_/ ◆昼夜切り替え - KGC_DayNight◆
#_/----------------------------------------------------------------------------
#_/ ゲーム中に昼夜の概念を作成します。
#_/ Makes the concept of day and night in the game.
#_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
#==============================================================================
# ★ カスタマイズ項目 - Customize ★
#==============================================================================
module KGC
#不显示色相开关编号
GBDT = 5
#室内编号,室内不显示色相
GBDTBH = [1,340,341,342,343,316,317,314,315,311,312,313]
# 战斗界面是否适用昼夜效果
DAYNIGHT_TONE_BACK_ONLY = false
# 最初状态 0:白天 1:傍晚 2:晚上 3:早上
DAYNIGHT_PASS_PHASE = 3
#昼夜效果切换的时间
DAYNIGHT_DURATION = 10
# ◆昼夜の色調(よく分からない場合はこのまま)
DAYNIGHT_TONE = [Tone.new(0, 0, 0),
Tone.new(-32, -96, -96),
Tone.new(-128, -128, -32),
Tone.new(-48, -48, -16)]
end
#★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
$imported = {} if $imported == nil
$imported["DayNight"] = true
module DayNight
#--------------------------------------------------------------------------
# ● 変数初期化
#--------------------------------------------------------------------------
def self._init_var_
$game_system.daynight_count = 0 if $game_system.daynight_count == nil
$game_system.daynight_phase = 0 if $game_system.daynight_phase == nil
$game_system.daynight_pass_days = 0 if $game_system.daynight_pass_days == nil
end
#--------------------------------------------------------------------------
# ● 現在の状態
#--------------------------------------------------------------------------
def self.now
# 現在の状態を返す
return $game_system.daynight_phase
end
#--------------------------------------------------------------------------
# ● 昼夜手動切り替え
# phase : 切り替え後の状態INDEX
# duration : 切り替え時間(フレーム) (省略時 : KGC::DAYNIGHT_DURATION)
# pass_days : 経過させる日数 (省略時:0)
#--------------------------------------------------------------------------
def self.change(phase, duration = KGC::DAYNIGHT_DURATION, pass_days = 0)
# カウント初期化
$game_system.daynight_count = 0
# フェーズ更新
$game_system.daynight_phase = phase
# 手動切り替え有効
$game_temp.manual_daynight_change = duration
# 日数経過
$game_system.daynight_pass_days += pass_days
end
#--------------------------------------------------------------------------
# ● 次の状態へ移行
# duration : 切り替え時間(フレーム) (省略時 : KGC::DAYNIGHT_DURATION)
#--------------------------------------------------------------------------
def self.change_next(duration = KGC::DAYNIGHT_DURATION)
$game_screen.change_daynight_next(duration)
end
#--------------------------------------------------------------------------
# ● デフォルトの状態(0, 0, 0)に戻す
# duration : 切り替え時間(フレーム) (省略時 : KGC::DAYNIGHT_DURATION)
#--------------------------------------------------------------------------
def self.set_default(duration = KGC::DAYNIGHT_DURATION)
$game_screen.set_daynight_default(duration)
end
#--------------------------------------------------------------------------
# ● 現在の状態を適用
# duration : 切り替え時間(フレーム) (省略時 : KGC::DAYNIGHT_DURATION)
#--------------------------------------------------------------------------
def self.apply(duration = KGC::DAYNIGHT_DURATION)
$game_screen.apply_daynight(duration)
end
end
#★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
#==============================================================================
# ■ Game_Temp
#==============================================================================
class Game_Temp
attr_accessor :manual_daynight_change
#--------------------------------------------------------------------------
# ● オブジェクト初期化
#--------------------------------------------------------------------------
alias initialize_KGC_DayNight initialize
def initialize
# 元の処理を実行
initialize_KGC_DayNight
@manual_daynight_change = false
end
end
#★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
#==============================================================================
# ■ Game_System
#==============================================================================
class Game_System
attr_accessor :daynight_count, :daynight_phase, :daynight_pass_days,
:daynight_change, :daynight_change_battle
#--------------------------------------------------------------------------
# ● オブジェクト初期化
#--------------------------------------------------------------------------
alias initialize_KGC_DayNight initialize
def initialize
initialize_KGC_DayNight
@daynight_count = @daynight_phase = @daynight_pass_days = 0
@daynight_change = true
@daynight_change_battle = true
end
end
#★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
#==============================================================================
# ■ Game_Screen
#==============================================================================
class Game_Screen
attr_reader :daynight_tone
#--------------------------------------------------------------------------
# ● オブジェクト初期化
#--------------------------------------------------------------------------
alias initialize_KGC_DayNight initialize
def initialize
# 元の処理を実行
initialize_KGC_DayNight
# とりあえず現在の状態に設定
@default_tone = Tone.new(0, 0, 0)
@tone = KGC::DAYNIGHT_TONE[$game_system.daynight_phase].clone
@daynight_tone = @tone.clone
# 移動判定用座標
@x = @y = 0
# フレーム更新用カウント初期化
@frame_count = Graphics.frame_count
@daynight_tone_duration = 0
end
#--------------------------------------------------------------------------
# ● 色調の取得
#--------------------------------------------------------------------------
def tone
if $game_temp.in_battle && KGC::DAYNIGHT_TONE_BACK_ONLY
return @default_tone
else
return @tone
end
end
#--------------------------------------------------------------------------
# ● 色調変更の開始
# tone : 色調
# duration : 時間
#--------------------------------------------------------------------------
alias start_tone_change_KGC_DayNight start_tone_change
def start_tone_change(tone, duration)
start_tone_change_KGC_DayNight(tone, duration)
@daynight_tone_target = tone.clone
@daynight_tone_duration = duration
if @daynight_tone_duration == 0
@daynight_tone = @daynight_tone_target.clone
end
end
#--------------------------------------------------------------------------
# ● フレーム更新
#--------------------------------------------------------------------------
alias update_KGC_DayNight update
def update
update_KGC_DayNight
if @daynight_tone_duration >= 1
d = @daynight_tone_duration
@daynight_tone.red =
(@daynight_tone.red * (d - 1) + @daynight_tone_target.red) / d
@daynight_tone.green =
(@daynight_tone.green * (d - 1) + @daynight_tone_target.green) / d
@daynight_tone.blue =
(@daynight_tone.blue * (d - 1) + @daynight_tone_target.blue) / d
@daynight_tone.gray =
(@daynight_tone.gray * (d - 1) + @daynight_tone_target.gray) / d
@daynight_tone_duration -= 1
end
# 昼夜切り替え判定
if (!$game_temp.in_battle && $game_system.daynight_change) ||
($game_temp.in_battle && $game_system.daynight_change &&
$game_system.daynight_change_battle)
update_daynight_real_time
end
# 手動切り替えが行われた場合
if $game_temp.manual_daynight_change != nil
# 色調切り替え
start_tone_change(KGC::DAYNIGHT_TONE[$game_system.daynight_phase],
KGC::DAYNIGHT_DURATION)
# 手動切り替え解除
$game_temp.manual_daynight_change = nil
end
end
#--------------------------------------------------------------------------
# ● 更新 : 現実時間
#--------------------------------------------------------------------------
def update_daynight_real_time
if Time.now.hour >= 5 and $game_switches[KGC::GBDT] != true
start_tone_change(KGC::DAYNIGHT_TONE[3],KGC::DAYNIGHT_DURATION)
end
if Time.now.hour >= 8 or $game_switches[KGC::GBDT] == true
start_tone_change(KGC::DAYNIGHT_TONE[0],KGC::DAYNIGHT_DURATION)
end
if Time.now.hour >= 17 and $game_switches[KGC::GBDT] != true
start_tone_change(KGC::DAYNIGHT_TONE[1],KGC::DAYNIGHT_DURATION)
end
if Time.now.hour >= 19 or Time.now.hour < 5 and $game_switches[KGC::GBDT] != true
start_tone_change(KGC::DAYNIGHT_TONE[2],KGC::DAYNIGHT_DURATION)
end
if $game_switches[KGC::GBDT] != true
for i in 0...KGC::GBDTBH.size
if $game_map.map_id == KGC::GBDTBH[i]
start_tone_change(KGC::DAYNIGHT_TONE[0],KGC::DAYNIGHT_DURATION)
break
end
end
end
end
private :update_daynight_real_time
#--------------------------------------------------------------------------
# ● 次の状態へ移行
#--------------------------------------------------------------------------
def change_daynight_next(duration = KGC::DAYNIGHT_DURATION)
$game_system.daynight_count = 0
$game_system.daynight_phase += 1
# 最後の状態に達した場合
if $game_system.daynight_phase >= KGC::DAYNIGHT_TONE.size
# 最初の状態に戻す
$game_system.daynight_phase = 0
end
# 日数経過判定
if $game_system.daynight_phase == KGC::DAYNIGHT_PASS_PHASE
$game_system.daynight_pass_days += 1
end
# 色調切り替え
start_tone_change(KGC::DAYNIGHT_TONE[$game_system.daynight_phase],
duration)
end
#--------------------------------------------------------------------------
# ● デフォルトの状態(0, 0, 0)に戻す
#--------------------------------------------------------------------------
def set_daynight_default(duration)
start_tone_change(Tone.new(0, 0, 0), duration)
end
#--------------------------------------------------------------------------
# ● 現在の状態を適用
#--------------------------------------------------------------------------
def apply_daynight(duration)
start_tone_change(KGC::DAYNIGHT_TONE[$game_system.daynight_phase], duration)
end
end
#★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
#==============================================================================
# ■ Game_Map
#==============================================================================
class Game_Map
#--------------------------------------------------------------------------
# ● エンカウントリストの取得
#--------------------------------------------------------------------------
alias encounter_list_KGC_DayNight encounter_list
def encounter_list
# 元の処理を実行
list = encounter_list_KGC_DayNight.dup
# 出現条件判定
list.each_index { |i|
appear = false
troop = $data_troops[list[i]]
# 出現条件が無い場合は次へ
next unless troop.name =~ /\[DN((?:[ ]*[\-]?\d+(?:,[ ]*)?)+)\]/i
# 出現条件を適用
$1.split(/,/).each { |dn|
dn.gsub!(/[ ]/) {""}
appear |= dn[0, 1] == "-" ?
$game_system.daynight_phase != dn.to_i.abs :
$game_system.daynight_phase == dn.to_i
}
list[i] = nil unless appear
}
return list.compact
end
end
#★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
#==============================================================================
# ■ Spriteset_Battle
#==============================================================================
if KGC::DAYNIGHT_TONE_BACK_ONLY
class Spriteset_Battle
#--------------------------------------------------------------------------
# ● フレーム更新
#--------------------------------------------------------------------------
alias update_KGC_DayNight update
def update
update_KGC_DayNight
@battleback_sprite.tone = $game_screen.daynight_tone
end
end
end
#★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
#==============================================================================
# ■ Scene_Map
#==============================================================================
class Scene_Map
#--------------------------------------------------------------------------
# ● メイン処理
#--------------------------------------------------------------------------
alias main_KGC_DayNight main
def main
DayNight._init_var_
main_KGC_DayNight
end
end