Project1
标题:
灼眼的夏娜的时间系统,求修改
[打印本页]
作者:
叉叉
时间:
2009-12-21 12:38
标题:
灼眼的夏娜的时间系统,求修改
以下是翻到的内容,但是我想把季节、时间等代入变量。
本来想使用那个超自定义的……
可是我的游戏不需要那么麻烦,有星啊什么的……
可不可以用变量调以下脚本的时间?
比如某商店只在晚上开
#==============================================================================
# ■ Date模块
#------------------------------------------------------------------------------
# 时间日期系统模块
#==============================================================================
module Date
#============================================================================
# ● 常量设定
#============================================================================
RATE = Graphics.frame_rate#(可自行设置次值,但不能大于Graphics.frame_rate值)
#============================================================================
# ■ 1、更新画面色调
#============================================================================
def Date.change_screen_tone
case $game_map.date_season
when 1
if $game_map.date_hour <= 7
$game_screen.start_tone_change($bright_cq7, 420*Date::RATE)
elsif $game_map.date_hour > 7 && $game_map.date_hour <= 12
$game_screen.start_tone_change($bright_cq12, 300*Date::RATE)
elsif $game_map.date_hour > 12 && $game_map.date_hour <= 19
$game_screen.start_tone_change($bright_cq7, 420*Date::RATE)
else
$game_screen.start_tone_change($bright_cq0, 300*Date::RATE)
end
when 2
if $game_map.date_hour <= 6
$game_screen.start_tone_change($bright_x6, 360*Date::RATE)
elsif $game_map.date_hour > 6 && $game_map.date_hour <=14
$game_screen.start_tone_change($bright_x14, 480*Date::RATE)
elsif $game_map.date_hour > 14 && $game_map.date_hour <=19
$game_screen.start_tone_change($bright_x19, 300*Date::RATE)
elsif $game_map.date_hour > 19 && $game_map.date_hour <=21
$game_screen.start_tone_change($bright_x21, 120*Date::RATE)
else
$game_screen.start_tone_change($bright_x0, 180*Date::RATE)
end
when 3
if $game_map.date_hour <= 7
$game_screen.start_tone_change($bright_cq7, 420*Date::RATE)
elsif $game_map.date_hour > 7 && $game_map.date_hour <= 12
$game_screen.start_tone_change($bright_cq12, 300*Date::RATE)
elsif $game_map.date_hour > 12 && $game_map.date_hour <= 19
$game_screen.start_tone_change($bright_cq7, 420*Date::RATE)
else
$game_screen.start_tone_change($bright_cq0, 300*Date::RATE)
end
when 4
if $game_map.date_hour <= 8
$game_screen.start_tone_change($bright_d8, 480*Date::RATE)
elsif $game_map.date_hour > 8 && $game_map.date_hour <=12
$game_screen.start_tone_change($bright_d12, 240*Date::RATE)
elsif $game_map.date_hour > 12 && $game_map.date_hour <=18
$game_screen.start_tone_change($bright_d18, 360*Date::RATE)
else
$game_screen.start_tone_change($bright_d0, 360*Date::RATE)
end
end
end
#============================================================================
# ■ 2、时间系统的运作
#============================================================================
def Date.run_date_system
if Graphics.frame_count%Date::RATE == 0
$game_map.date_minute += 1
end
if $game_map.date_minute >= 60
$game_map.date_minute = 0
$game_map.date_hour += 1
end
if $game_map.date_hour >= 24
$game_map.date_hour = 0
$game_map.date_day += 1
$game_map.date_week += 1
end
if $game_map.date_week >= 8
$game_map.date_week = 1
end
if $game_map.date_day > $game_map.every_month_days[$game_map.date_season-1]
$game_map.date_day = 1
$game_map.date_season += 1
end
if $game_map.date_season >= 5
$game_map.date_season = 1
end
end
#============================================================================
# ■ 3、各种天气系统
#============================================================================
def Date.rand_weather_type
if $game_map.date_season == 1
Date.judge_weather1(12,15,50)
if $game_map.date_day<=10
Date.judge_weather2(15,15,20)
end
elsif $game_map.date_season == 2
Date.judge_weather1(10,30,60)
Date.judge_weather2(10,25,0)
elsif $game_map.date_season == 3
Date.judge_weather1(12,15,50)
if $game_map.date_day>=20
Date.judge_weather2(15,15,20)
end
elsif $game_map.date_season == 4
Date.judge_weather1(8,8,20)
Date.judge_weather2(10,25,40)
end
end
# 雨
def Date.judge_weather1(wait,pp,rate=30)
# 等待时间为零,清楚天气效果
if $game_map.waittime[0] == 0
$game_map.weather1[1] = 0
$game_map.weather1[0] = false
$game_system.bgs_restore
elsif $game_map.waittime[0]<=5
$game_system.bgs_fade(Integer(5*Date::RATE/Graphics.frame_rate))
end
# 等待时间不为零,则递减
if $game_map.waittime[0] > 0
if Graphics.frame_count%Date::RATE == 0
$game_map.waittime[0] -= 1
end
return
end
# 天气判断
if $game_map.weather1[0] == false
$game_map.waittime[0] = (wait+rand(wait))*60
if rand(100)<rate
$game_system.bgs_memorize
Audio.bgs_fade(1)
if pp>=30
name = "007-Rain03"
volume = 80
else
name = "005-Rain01"
volume = 60
end
Audio.bgs_play("Audio/BGS/" + name, volume, 50)
$game_map.weather1[0] = true
$game_map.weather1[1] = 1
$game_map.weather1[2] = pp + rand(40-pp)
return
end
$game_map.waittime[0] *= (100-rate)
$game_map.waittime[0] = Integer($game_map.waittime[0]/100)
end
end
# 雪
def Date.judge_weather2(wait,pp,rate=30)
# 等待时间为零,清楚天气效果
if $game_map.waittime[1] == 0
$game_map.weather2[1] = 0
$game_map.weather2[0] = false
end
# 等待时间不为零,则递减
if $game_map.waittime[1] > 0
if Graphics.frame_count%Date::RATE == 0
$game_map.waittime[1] -= 1
end
return
end
# 天气判断
if $game_map.weather2[0] == false
$game_map.waittime[1] = (wait+rand(wait))*60
if rand(100)<rate
$game_map.weather2[0] = true
$game_map.weather2[1] = 3
$game_map.weather2[2] = pp + rand(40-pp)
return
end
$game_map.waittime[1] *= (100-rate)
$game_map.waittime[1] = Integer($game_map.waittime[1]/100)
end
end
end
class Spriteset_Map
# 初始化第二天气效果
alias initialize_old initialize
def initialize
initialize_old
@weather1 = RPG::Weather.new(Viewport.new(0, 0, 640, 480))
@weather2 = RPG::Weather.new(Viewport.new(0, 0, 640, 480))
update
end
# 释放第二天气效果
alias dispose_old dispose
def dispose
if @weahter1 != nil
@weather1.dispose
end
if @weahter2 != nil
@weather2.dispose
end
dispose_old
end
# 更新第二天气效果
alias update_old update
def update
if @weather1 != nil
@weather1.type = $game_map.weather1[1]
@weather1.max = $game_map.weather1[2]
@weather1.update
end
if @weather2 != nil
@weather2.type = $game_map.weather2[1]
@weather2.max = $game_map.weather2[2]
@weather2.update
end
update_old
end
end
class Interpreter
def odw
$game_map.date_system_window_on_or_off = true
return
end
def cdw
$game_map.date_system_window_on_or_off = false
return
end
end
#==============================================================================
# ■ Window_TimeDate
#------------------------------------------------------------------------------
# 时间日期系统窗口
#==============================================================================
class Window_TimeDate < Window_Base
#--------------------------------------------------------------------------
# ● 初始化对像
#--------------------------------------------------------------------------
def initialize
super(0, 0, 228, 86)
self.contents = Bitmap.new(width - 32, height - 32)
self.opacity = 0
refresh
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh
self.contents.clear
@fen_timedate = $game_map.date_minute # 此变量用于刷新 画面
# 描绘 季节
if $game_map.date_season == 2
seasoncolor = Color.new(250,80,5)
wordj = "夏"
elsif $game_map.date_season == 4
seasoncolor = Color.new(150,170,250)
wordj = "冬"
elsif $game_map.date_season == 1
seasoncolor = Color.new(5,255,50)
wordj = "春"
else
seasoncolor = Color.new(228,208,38)
wordj = "秋"
end
self.contents.font.size = 52
self.contents.font.name = ["楷体_GB2312","黑体"]
self.contents.font.color = seasoncolor
self.contents.draw_text(0, 0, 52, 52, wordj)
# 描绘 号数
self.contents.font.size = 42
self.contents.font.name = ["楷体_GB2312","黑体"]
self.contents.draw_text(56,10, 84, 42,$game_map.date_day.to_s)
# 描绘 星期
case $game_map.date_week
when 1
self.contents.font.color = Color.new(170,170,170,255)
wordx = "月"
when 2
self.contents.font.color = Color.new(50,100,240,255)
wordx = "火"
when 3
self.contents.font.color = Color.new(227,59,13,255)
wordx = "水"
when 4
self.contents.font.color = Color.new(74,4,4,255)
wordx = "木"
when 5
self.contents.font.color = Color.new(228,231,10,255)
wordx = "金"
when 6
self.contents.font.color = Color.new(155,50,36,255)
wordx = "土"
when 7
self.contents.font.color = Color.new(55,244,246,255)
wordx = "日"
end
self.contents.font.size = 24
self.contents.font.name = ["楷体_GB2312","黑体"]
self.contents.draw_text(112, 22, 128, 32, wordx)
self.contents.font.color = Color.new(0,0,0,255)
self.contents.draw_text(112+24, 22, 128, 32, "曜日")
self.contents.font.size = 24
self.contents.font.color = Color.new(0,0,0,255)
# 描绘 时间
tt = sprintf("%2d点%2d分", $game_map.date_hour,$game_map.date_minute)
self.contents.draw_text(100, 0, 128, 32, tt)
end
def update
super
# 刷新窗口
if @fen_timedate != $game_map.date_minute
refresh
end
end
end
class Game_Temp
# 春天 和 秋天
# 分 0 - 7 点钟; 7 - 12 点; 12 - 7点; 7 - 0点;
$bright_cq7 = Tone.new(-40, -40, -40, 0)
$bright_cq12 = Tone.new(0, 0, 0, 0)
$bright_cq19 = Tone.new(-40, -40, -40, 0)
$bright_cq0 = Tone.new(-110, -110, -110, 0)
# 夏天
# 分 0 - 6 点; 6 - 14 点; 14 - 21 点; 21 - 0点
$bright_x6 = Tone.new(-40, -40, -40, 0)
$bright_x14 = Tone.new(30, 30, 30, 0)
$bright_x19 = Tone.new(20, 0, 0, 0)
$bright_x21 = Tone.new(-60, -60, -60, 0)
$bright_x0 = Tone.new(-110, -110, -110, 0)
# 冬天
# 分 0 - 8 点;8 - 12 点; 12 - 6 点 ; 6 - 0点
$bright_d8 = Tone.new(-45, -45, -45, 0)
$bright_d12 = Tone.new(-10, -10, -10, 0)
$bright_d18 = Tone.new(-45, -45, -45, 0)
$bright_d0 = Tone.new(-115, -115, -115, 0)
end
class Game_Screen
alias initialize_old initialize
def initialize
initialize_old
@tone = $bright_cq7
end
end
class Game_Map
attr_accessor :date_minute
attr_accessor :date_hour
attr_accessor :date_day
attr_accessor :date_week
attr_accessor :date_season
attr_reader :every_month_days
attr_accessor :date_system_window_on_or_off
attr_accessor :weather1
attr_accessor :weather2
attr_accessor :waittime
def initialize
@date_minute = 50
@date_hour = 7
@date_day = 25
@date_week = 5
@date_season = 4
@every_month_days = [31,31,30,28]
@date_system_window_on_or_off = true
@weather1 = [false,0,0]
@weather2 = [false,0,0]
@waittime = [0,0]
end
end
class Scene_Map
# 主处理
alias main_old main
def main
@tt = Window_TimeDate.new
if $game_map.date_system_window_on_or_off == false
@tt.visible = false
end
main_old
@tt.dispose
end
# 更新
alias update_old update
def update
@tt.visible = $game_map.date_system_window_on_or_off
#----------------------
Date.change_screen_tone
Date.run_date_system
Date.rand_weather_type
#----------------------
@tt.update
update_old
end
end
复制代码
欢迎光临 Project1 (https://rpg.blue/)
Powered by Discuz! X3.1