#=begin
#==============================================================================
#==============================================================================
#==============================================================================
#Day Night System updated(12-07-2011)
#==============================================================================
#==============================================================================
#==============================================================================
#=begin
#==============================================================================
#==============================================================================
#==============================================================================
#Light Circle Script v1.2b updated(29-07-2011)
#==============================================================================
#==============================================================================
#==============================================================================
class Scene_Save < Scene_File
alias alias_write_save_data write_save_data
def write_save_data(file)
alias_write_save_data(file)
Marshal.dump($sensitivity,file)
Marshal.dump($sensitivity_2,file)
Marshal.dump($light_switch,file)
Marshal.dump($flick,file)
end
end
#==============================================================================
class Scene_Load < Scene_File
alias t_read_save_data read_save_data
def read_save_data(file)
t_read_save_data(file)
$sensitivity = Marshal.load(file)
$sensitivity_2 = Marshal.load(file)
$light_switch = Marshal.load(file)
$flick = Marshal.load(file)
end
end
#==============================================================================
class Game_Player< Game_Character
def change_sensitivity(value,type)
case type
when "sensitivity"
$sensitivity=value
when "sensitivity_2"
$sensitivity_2[0]=value
end
end
end
#==============================================================================
class Scene_Map
def spriteset
return @spriteset
end
end
#==============================================================================
#==============================================================================
#==============================================================================
class Scene_Title
alias alias_main main
#--------------------------------------------------------------------------
# * change initial sensitivity here
#--------------------------------------------------------------------------
def main
$light_switch=1
$sensitivity_2=[]
$sensitivity_2[0]=100
$flick=0
alias_main
end
#--------------------------------------------------------------------------
# * change initial sensitivity here
#--------------------------------------------------------------------------
end
#==============================================================================
#==============================================================================
#==============================================================================
# ** Spriteset_Map
#------------------------------------------------------------------------------
# This class brings together map screen sprites, tilemaps, etc.
# It's used within the Scene_Map class.
#==============================================================================
#==============================================================================
#==============================================================================
class Spriteset_Map
attr_accessor :tone
attr_accessor :light_limit
attr_accessor :x_limit
attr_accessor :y_limit
alias alias_update update
alias alias_initialize initialize
alias alias_dispose dispose
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
#--------------------------------------------------------------------------
# * change initial setting
#--------------------------------------------------------------------------
@tone=40
@light_limit=15
@x_limit=20
@y_limit=15
#--------------------------------------------------------------------------
# * change initial setting
#--------------------------------------------------------------------------
@opacity=[]
@random=[]
@r_value=[]
@x_x=[]
@y_y=[]
@xx=[]
@yy=[]
@event_rx=[]
@event_ry=[]
@event_coor_x=[]
@event_coor_y=[]
@sensitivity=[]
@viewport=[]
@viewport[0]=[]
@viewport[1]=[]
@viewport[2]=[]
@viewport[3]=[]
@viewport[4]=[]
@d=6
@frame=3
@area_divide=14
@event_frame_x_highlimit=[]
@event_frame_y_highlimit=[]
@event_frame_x_lowlimit=[]
@event_frame_y_lowlimit=[]
get_event_data
#------------------------------------
for @y in 0..15
for @x in 0..20
@viewport[0][@y*21+@x] = Viewport.new(@x*32-16, @y*32-16, 32, 32)
@viewport[0][@y*21+@x].tone = Tone.new(-255, -255, -255, 0)
@viewport[0][@y*21+@x].z = 199
@viewport[1][@y*21+@x] = Viewport.new(@x*32-16+@d, @y*32+@d-16, 32, 32)
@viewport[1][@y*21+@x].tone = Tone.new(-255, -255, -255, 0)
@viewport[1][@y*21+@x].z = 199
@viewport[2][@y*21+@x] = Viewport.new(@x*32-16+@d*2, @y*32+@d*2-16, 32, 32)
@viewport[2][@y*21+@x].tone = Tone.new(-255, -255, -255, 0)
@viewport[2][@y*21+@x].z = 199
@viewport[3][@y*21+@x] = Viewport.new(@x*32-16-@d, @y*32-@d-16, 32, 32)
@viewport[3][@y*21+@x].tone = Tone.new(-255, -255, -255, 0)
@viewport[3][@y*21+@x].z = 199
@viewport[4][@y*21+@x] = Viewport.new(@x*32-16-@d*2, @y*32-@d*2-16, 32, 32)
@viewport[4][@y*21+@x].tone = Tone.new(-255, -255, -255, 0)
@viewport[4][@y*21+@x].z = 199
@opacity[@y*21+@x]=-@tone
end
end
alias_initialize
end
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
#--------------------------------------------------------------------------
# * Dispose
#--------------------------------------------------------------------------
def dispose
alias_dispose
for @y in 0..15
for @x in 0..20
for i in 0..4
@viewport[i][@y*21+@x].dispose
end
end
end
end
#--------------------------------------------------------------------------
# * Dispose
#--------------------------------------------------------------------------
#--------------------------------------------------------------------------
# * Event Data Setup(get information from events)
#--------------------------------------------------------------------------
def get_event_data
for event in $game_map.events.values
if event.list && event.list[0].code == 108
i=1
loop do
if event.list[0].parameters.to_s == i.to_s
@xx[i]=event.x*32
@yy[i]=event.y*32
$sensitivity_2[i]=event.list[1].parameters.to_s .to_i
@r_value[i]=rand(event.list[2].parameters.to_s .to_i+1)
end
break if i== @light_limit
i+=1
end
end
end
end
#--------------------------------------------------------------------------
# * Event Data Setup(get information from events)
#--------------------------------------------------------------------------
#--------------------------------------------------------------------------
# * Get Frame Rate
#--------------------------------------------------------------------------
def get_frame_rate
t = Time.now
@compare1=t.sec if @compare1==nil
if @compare1 != t.sec
@compare1= t.sec
count_on=true
end
@count_rate=0 if @count_rate==nil
if count_on==true
count_on=false
frame_rate,@count_rate=@count_rate,0
else
@count_rate+=1
end
return frame_rate
end
#--------------------------------------------------------------------------
# * Get Frame Rate
#--------------------------------------------------------------------------
#--------------------------------------------------------------------------
# * Frame Update (perform algorithms that calculate opacity of each coordinations)
#--------------------------------------------------------------------------
def update
frame_rate=get_frame_rate
@frame_rate==nil ? @frame_rate=0:nil
@frame_rate=frame_rate == nil ? @frame_rate: frame_rate
if @frame_rate>37
@frame=2
@area_divide=12
elsif @frame_rate<35
@frame=4
@area_divide=16
else
@frame=3
@area_divide=14
end
# $frame=@frame_rate
@ccc=0 if @ccc==nil
@ccc2=0 if @ccc2==nil
if @ccc2%@frame==0
if @ccc==0
if $light_switch==1
#@random[0]=rand($flick+1)
#------------------
get_event_data
#-------------------
# i=1
# loop do
# break if @r_value[i]==nil
#@random[i]=rand(@r_value[i]+1)
#i+=1
#end
#-------------------
@player_rx=($game_player.real_x-$game_map.display_x)/4
@player_ry=($game_player.real_y-$game_map.display_y)/4
@player_coor_x= (@player_rx+16)/32
@player_coor_y= (@player_ry+16)/32
@sensitivity[0]=$sensitivity_2[0]+rand($flick+1)
i=1
loop do
break if @xx[i]==nil
@event_rx[i]=(@xx[i]-$game_map.display_x/4)
@event_ry[i]=(@yy[i]-$game_map.display_y/4)
@event_coor_x[i]=(@event_rx[i]+16)/32
@event_coor_y[i]=(@event_ry[i]+16)/32
@sensitivity[i]=[$sensitivity_2[i]+@r_value[i],150].min
i+=1
end
#-------------------
@event_seq=1
for @y in 0..15
for @x in 0..20
@opacity[@y*21+@x] =@sensitivity[0]/((@x-@player_coor_x)**2+(@y-@player_coor_y)**2+5)
end
end
loop do
break if @xx[@event_seq]==nil
if (@player_coor_x-@event_coor_x[@event_seq]).abs<@x_limit && (@player_coor_y-@event_coor_y[@event_seq]).abs<@y_limit
#++++++
@area_limit=(@sensitivity[@event_seq]/@area_divide).to_i
@event_frame_x_highlimit[@event_seq]=[@event_coor_x[@event_seq]+@area_limit,20].min
@event_frame_x_lowlimit[@event_seq]=[@event_coor_x[@event_seq]-@area_limit,0].max
for @x in @event_frame_x_lowlimit[@event_seq]..@event_frame_x_highlimit[@event_seq]
@event_frame_y_lowlimit[@event_seq]=(@event_coor_y[@event_seq]-Math.sqrt(@area_limit**2-(@event_coor_x[@event_seq]-@x)**2)).to_i
@event_frame_y_highlimit[@event_seq]=[2*@event_coor_y[@event_seq]-@event_frame_y_lowlimit[@event_seq],15].min
@event_frame_y_lowlimit[@event_seq]=[0,@event_frame_y_lowlimit[@event_seq]].max
for @y in @event_frame_y_lowlimit[@event_seq]..@event_frame_y_highlimit[@event_seq]
@opacity[@y*21+@x] +=@sensitivity[@event_seq]/((@x-@event_coor_x[@event_seq])**2+(@y-@event_coor_y[@event_seq])**2+5)
end
end
end
#++++++
@event_seq+=1
end
#++++++
for @y in 0..15
for @x in 0..20
a=[[@opacity[@y*21+@x]-@tone,0].min,-@tone].max
@viewport[0][@y*21+@x].tone=Tone.new(a, a, a)
end
end
#++++++
#--------------------
@on=nil if @on != nil
else
#-------------------
if @on==nil
for @y in 0..15
for @x in 0..20
a=Tone.new(0,0,0)
for i in 0..4
@viewport[i][@y*21+@x].tone =a
end
end
end
@on=true
end
#-------------------
end
else
for @y in 0..15
@x=0
loop do
id=@y*21+@x
@viewport[@ccc][id].tone=@viewport[@ccc-1][id].tone
break if @x==20
@x+=1
end
end
#-------------------
end
@ccc+=1
@ccc=0 if @ccc==5
end
@ccc2+=1
@ccc2=0 if @ccc2==@frame
alias_update
end
#--------------------------------------------------------------------------
# * Frame Update (perform algorithms that calculate opacity of each coordinations)
#--------------------------------------------------------------------------
end
#==============================================================================
#==============================================================================
#==============================================================================
#=end
#==============================================================================
# ■ Window_PlayTime
#------------------------------------------------------------------------------
# 菜单画面显示游戏时间的窗口。
#==============================================================================
class Window_PlayTime < Window_Base
#--------------------------------------------------------------------------
# ● 初始化对像
#--------------------------------------------------------------------------
def initialize
super(0, 0, 160, 96)
self.contents = Bitmap.new(width - 32, height - 32)
refresh
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh
self.contents.clear
self.contents.font.size = 15
self.contents.font.color = system_color
self.contents.draw_text(4, 0, 120, 32, "Game Time")
@total_sec = Graphics.frame_count / Graphics.frame_rate
year = $day_night_system.year
month = $day_night_system.month
day = $day_night_system.day
hour = $day_night_system.hour
min = $day_night_system.min
text = sprintf("Time: %02d:%02d", hour, min)
self.contents.font.color = normal_color
self.contents.draw_text(-24, 16, 120, 32, text, 2)
text = sprintf("Date: %02d-%02d-%04d",day,month,year)
self.contents.font.color = normal_color
self.contents.draw_text(4, 32, 120, 32, text, 2)
end
#--------------------------------------------------------------------------
# ● 刷新画面
#--------------------------------------------------------------------------
def update
super
if Graphics.frame_count / Graphics.frame_rate != @total_sec
refresh
end
end
end
#==============================================================================
#==============================================================================
#==============================================================================
class Scene_Save < Scene_File
alias alias_write_save_data_t write_save_data
def write_save_data(file)
alias_write_save_data_t(file)
Marshal.dump($day_night_system,file)
end
end
#==============================================================================
class Scene_Load < Scene_File
alias t_read_save_data_t read_save_data
def read_save_data(file)
t_read_save_data_t(file)
$day_night_system = Marshal.load(file)
end
end
#==============================================================================
class Scene_Title
alias alias_main_t main
#--------------------------------------------------------------------------
# * change initial sensitivity here
#--------------------------------------------------------------------------
def main
$day_night_system=Day_Night_System.new(0,0,0,0,0)
alias_main_t
end
end
#==============================================================================
class Scene_Map
alias alias_update_t update
#--------------------------------------------------------------------------
# * change initial sensitivity here
#--------------------------------------------------------------------------
def update
$day_night_system.update
alias_update_t
end
end
#==============================================================================
#==============================================================================
#==============================================================================
#==============================================================================
#Day Night Script updated(15-07-2011)
#==============================================================================
#==============================================================================
#==============================================================================
class Day_Night_System
attr_accessor :year
attr_accessor :month
attr_accessor :day
attr_accessor :hour
attr_accessor :min
attr_accessor :count
attr_accessor :time_factor
attr_accessor :system_mode
#--------------------------------------------------------------------------
# * Initialize
#--------------------------------------------------------------------------
def initialize(year,month,day,hour,min)
@year=year
@month=month
@day=day
@hour=hour
@min=min
@count=0
@time_factor=1
@system_mode=0
@time_tone={
12=>9,#12 o clock afternoon>>9 represents the darkness of environment
11=>11,#11 o clock morning
10=>13,#10 o clock morning
9=>15,#9 o clock morning
8=>17,#8 o clock morning
7=>21,#7 o clock morning
6=>27,#6 o clock morning
5=>30,#5 o clock morning
4=>34,#4 o clock midnight
3=>38,#3 o clock midnight
2=>38,#2 o clock midnight
1=>39,#1 o clock midnight
0=>39,#12 o clock midnight
13=>11,#1 o clock afternoon
14=>13,#2 o clock afternoon
15=>15,#3 o clock afternoon
16=>17,#4 o clock afternoon
17=>21,#5 o clock evening
18=>27,#6 o clock evening
19=>30,#7 o clock evening
20=>34,#8 o clock night
21=>38,#9 o clock night
22=>38,#10 o clock night
23=>39,#11 o clock night
98=>9,#day sight
99=>45#dark sight
}
end
#--------------------------------------------------------------------------
# * Initialize
#--------------------------------------------------------------------------
#--------------------------------------------------------------------------
# * Initialize
#--------------------------------------------------------------------------
#--------------------------------------------------------------------------
# * Update
#--------------------------------------------------------------------------
def update
if @count<=40
@count+=@time_factor
else
@min+=1
if @min>=60
@hour+=1
if @hour>=24
@day+=1
if @day>= day_number(@month,@year)
@month+=1
if @month>=12
@year+=1
@month=0
end
@day=0
end
@hour=0
end
@min=0
end
@count=0
end
#--------------------------------------------------------------------------
# * Update
#--------------------------------------------------------------------------
#-------------------
#update light
#-------------------
day_night_cycle
#--------------------
end
#--------------------------------------------------------------------------
# * Update
#--------------------------------------------------------------------------
#--------------------------------------------------------------------------
# * Month
#--------------------------------------------------------------------------
def day_number(month,year)
if month == 1||3||5||7||8||10||12
return 31
elsif month==2
#----------------
if year%4==0
return 29
else
return 28
end
#----------------
else
return 30
end
end
#--------------------------------------------------------------------------
# * Month
#--------------------------------------------------------------------------
#--------------------------------------------------------------------------
# * Day Night Cycle
#--------------------------------------------------------------------------
def day_night_cycle
if $scene.is_a?(Scene_Map)
if @system_mode==0
$scene.spriteset.tone=@time_tone[@hour]
elsif @system_mode==1
$scene.spriteset.tone=@time_tone[98]
elsif @system_mode==2
$scene.spriteset.tone=@time_tone[99]
end
end
end
#--------------------------------------------------------------------------
# * Day Night Cycle
#--------------------------------------------------------------------------
end