#-------------------------------------------------------------------------------
# 时间流逝 by 876加几
#-------------------------------------------------------------------------------
class Window_Time < Window_Base
#--------------------------------------------------------------------------
# ● 初始化窗口
#--------------------------------------------------------------------------
def initialize
super(0, 0, 640, 64)
self.contents = Bitmap.new(width - 32, height - 32)
if $game_switches[3] != true
@year_index = -1 #这个可以随便改,但要符合实际(还要在下面计算出来)
@month_index = 1
@day_index = 1
@hour_index = 9
@minute_index = 0
@second_index = 0
@cycle_index = 1 #后面三个不用计算,并且要符合实际
@season_index = 4
@leap = false
$game_switches[3] = true
end
refresh
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh
self.contents.clear
#存储数据/读取数据
if @year_index != nil
$game_variables[1] = @year_index
else
@year_index = $game_variables[1]
end
if @month_index != nil
$game_variables[2] = @month_index
else
@month_index = $game_variables[2]
end
if @day_index != nil
$game_variables[3] = @day_index
else
@day_index = $game_variables[3]
end
if @cycle_index != nil
$game_variables[4] = @cycle_index
else
@cycle_index = $game_variables[4]
end
if @season_index != nil
$game_variables[5] = @season_index
else
@season_index = $game_variables[5]
end
if @leap != nil
$game_switches[1] = @leap
else
@leap = $game_switches[1]
end
#时间显示
time = sprintf("%02d:%02d:%02d", @hour_index, @minute_index, @second_index)
#判断这个月是什么月
if @month_index == 1
@judge_index = 1
elsif @month_index == 2
@judge_index = 3
elsif @month_index == 3
@judge_index = 1
elsif @month_index == 4
@judge_index = 2
elsif @month_index == 5
@judge_index = 1
elsif @month_index == 6
@judge_index = 2
elsif @month_index == 7
@judge_index = 1
elsif @month_index == 8
@judge_index = 1
elsif @month_index == 9
@judge_index = 2
elsif @month_index == 10
@judge_index = 1
elsif @month_index == 11
@judge_index = 2
elsif @month_index == 12
@judge_index = 1
end
#星期变更
if @hour_index == 23 and @minute_index == 59
case @cycle_index
when 1
@cycle_index = 2
when 2
@cycle_index = 3
when 3
@cycle_index = 4
when 4
@cycle_index = 5
when 5
@cycle_index = 6
when 6
@cycle_index = 7
when 7
@cycle_index = 1
end
end
#制造时间动力
@total_second = Graphics.frame_count * 50
@second_index = @total_second % 60
@minute_index = @total_second / 60 % 60
@hour_index = @total_second / 60 / 60 % 24
case @judge_index
when 1 #大月
@day_index = @total_second / 60 / 60 / 24 % 30 + 1
@month_index = @total_second / 60 / 60 / 24 / 30 % 11 + 1
when 2 #小月
@day_index = @total_second / 60 / 60 / 24 % 29
@month_index = @total_second / 60 / 60 / 24 / 29 % 11 + 1
when 3 #特殊月
if @leap == true
@day_index = @total_second / 60 / 60 / 24 % 28
@month_index = @total_second / 60 / 60 / 24 / 28 % 11 + 1
else
@day_index = @total_second / 60 / 60 / 24 % 27
@month_index = @total_second / 60 / 60 / 24 / 27 % 11 + 1
end
end
if @leap == true
@year_index = @total_second / 60 / 60 / 24 / 365 + 1
else
@year_index = @total_second / 60 / 60 / 24 / 364 + 1
end
#季度判断
case @month_index
when 2
@season_index = 1
when 5
@season_index = 2
when 8
@season_index = 3
when 11
@season_index = 4
end
self.contents.font.color = normal_color
self.contents.draw_text(360, 0, 120, 32, time, 2)
#判断是否为闰年
@leap_index = @year_index
@leap_index %= 4
if @leap_index == 0
@leap = true
else
@leap = false
end
#绘制
mx = self.contents.text_size(@month_index.to_s).width
dx = self.contents.text_size(@day_index.to_s).width
if @year_index < 0
@yearf_index = @year_index * (0 - 1)
yx = self.contents.text_size(@yearf_index.to_s).width
self.contents.draw_text(16, 0, 72, 32,"公元前")
self.contents.draw_text(82, 0, 72, 32, @yearf_index.to_s)
self.contents.draw_text(82+yx, 0, 32, 32, "年")
self.contents.draw_text(102+yx, 0, 20, 32, @month_index.to_s)
self.contents.draw_text(102+yx+mx, 0, 32, 32, "月")
self.contents.draw_text(122+yx+mx, 0, 20, 32, @day_index.to_s)
self.contents.draw_text(122+yx+mx+dx, 0, 32, 32, "日")
else
yx = self.contents.text_size(@year_index.to_s).width
self.contents.draw_text(16, 0, 72, 32,"公元")
self.contents.draw_text(60, 0, 72, 32, @year_index.to_s)
self.contents.draw_text(60+yx, 0, 32, 32, "年")
self.contents.draw_text(80+yx, 0, 20, 32, @month_index.to_s)
self.contents.draw_text(80+yx+mx, 0, 32, 32, "月")
self.contents.draw_text(100+yx+mx, 0, 20, 32, @day_index.to_s)
self.contents.draw_text(100+yx+mx+dx, 0, 32, 32, "日")
end
case @cycle_index
when 1 #星期一
self.contents.draw_text(296, 0, 72, 32, "星期一")
when 2 #星期二
self.contents.draw_text(296, 0, 72, 32, "星期二")
when 3
self.contents.draw_text(296, 0, 72, 32, "星期三")
when 4
self.contents.draw_text(296, 0, 72, 32, "星期四")
when 5
self.contents.draw_text(296, 0, 72, 32, "星期五")
when 6
self.contents.draw_text(296, 0, 72, 32, "星期六")
when 7
self.contents.draw_text(296, 0, 72, 32, "星期日")
end
case @season_index
when 1 # 春季
self.contents.draw_text(512, 0, 32, 32, "春")
when 2 # 夏季
self.contents.draw_text(512, 0, 32, 32, "夏")
when 3 # 秋季
self.contents.draw_text(512, 0, 32, 32, "秋")
when 4 # 冬季
self.contents.draw_text(512, 0, 32, 32, "冬")
end
#色相修改
case @season_index
when 1
if @hour_index == 7
$game_screen.start_tone_change(Tone.new(64,0,0,0),20)
elsif @hour_index == 8
$game_screen.start_tone_change(Tone.new(0,0,0,0),20)
elsif @hour_index == 19
$game_screen.start_tone_change(Tone.new(64,0,0,0),20)
elsif @hour_index == 20
$game_screen.start_tone_change(Tone.new(-64,-64,64,0),20)
elsif @hour_index == 0
$game_screen.start_tone_change(Tone.new(-128,-128,128,0),20)
end
when 2
if @hour_index == 6
$game_screen.start_tone_change(Tone.new(64,0,0,0),20)
elsif @hour_index == 7
$game_screen.start_tone_change(Tone.new(0,0,0,0),20)
elsif @hour_index == 20
$game_screen.start_tone_change(Tone.new(64,0,0,0),20)
elsif @hour_index == 21
$game_screen.start_tone_change(Tone.new(-64,-64,64,0),20)
elsif @hour_index == 0
$game_screen.start_tone_change(Tone.new(-128,-128,128,0),20)
end
when 3
if @hour_index == 7
$game_screen.start_tone_change(Tone.new(64,0,0,0),20)
elsif @hour_index == 8
$game_screen.start_tone_change(Tone.new(0,0,0,0),20)
elsif @hour_index == 19
$game_screen.start_tone_change(Tone.new(64,0,0,0),20)
elsif @hour_index == 20
$game_screen.start_tone_change(Tone.new(-64,-64,64,0),20)
elsif @hour_index == 0
$game_screen.start_tone_change(Tone.new(-128,-128,128,0),20)
end
when 4
if @hour_index == 8
$game_screen.start_tone_change(Tone.new(64,0,0,0),20)
elsif @hour_index == 9
$game_screen.start_tone_change(Tone.new(0,0,0,0),20)
elsif @hour_index == 18
$game_screen.start_tone_change(Tone.new(64,0,0,0),20)
elsif @hour_index == 19
$game_screen.start_tone_change(Tone.new(-64,-64,64,0),20)
elsif @hour_index == 0
$game_screen.start_tone_change(Tone.new(-128,-128,128,0),20)
end
end
end
#--------------------------------------------------------------------------
# ● 刷新画面
#--------------------------------------------------------------------------
def update
super
if Graphics.frame_count * 50 != @total_second
refresh
end
end
end