查看: 1299|回复: 0

[已经过期] 这里有个时间天气脚本哪位帮忙看看

[复制链接]
梦石
0
星屑
50
在线时间
160 小时
注册时间
2010-11-7
回帖
16
发表于 2013-7-29 09:33:12 | 显示全部楼层 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有账号?注册会员

×
本帖最后由 394178110 于 2013-7-30 11:00 编辑

感觉功能上已经比较完善了 但是管日历窗口消失的83号开关 打开窗口可以正常消失 但是关闭后窗口却回不来了 有这个bug感觉好可惜 哪位可以帮帮忙看看这个能修复好吗
  CALENDER_WINDOW_HIDE_SID = 83
    # 日付ウィンドウを消すスイッチID
    # ウィンドウが消えていても止めない限り時間は経過します


  1. =begin  =======================================================================
  2.   ☆ カレンダー機能追加  by 白雪レイカ
  3. -------------------------------------------------------------------------------
  4.   プロジェクトに「時刻」の概念を加えます。
  5.   時間帯でBGMや画面の色調が切り替わり、季節ごとにランダムで天候が変化します。
  6.   主なデータはすべて変数に格納されるので、
  7.   それを使ってイベントを分岐させたりできます。
  8. -------------------------------------------------------------------------------

  9.   ◆使い方
  10.     基本的に設定項目をカスタマイズして導入するだけなのですが、
  11.     一部説明が必要な部分があるのでご説明します。
  12.    
  13.     ○時間帯について
  14.    
  15.        3:00 ~  5:59 => 早朝 (:early_morning)
  16.        6:00 ~ 10:59 => 朝   (:morning)
  17.       11:00 ~ 15:59 => 昼   (:noon)
  18.       16:00 ~ 18:59 => 夕方 (:evening)
  19.       19:00 ~ 22:59 => 夜   (:night)
  20.       23:00 ~  2:59 => 深夜 (:midnight)
  21.       
  22.       となっています。
  23.       
  24.    
  25.     ○時間帯ごとのBGM切り替え
  26.       マップ設定の「BGMの自動切換え」にチェックが入っているときのみ有効。
  27.       マップのメモ欄に以下のように記述してください。
  28.       
  29.       <早朝(またはearly) ファイル名, 音量, ピッチ>
  30.       
  31.       これで早朝のBGMが設定できます。
  32.       早朝 の部分を 朝(またはmorning)、昼(またはnoon)、夕方(またはevening)、
  33.       夜(またはnight)、深夜(またはmid)とすることで
  34.       対応する時間帯のBGMを設定することができます。
  35.       ファイル名の拡張子は省略することができます(例 Town1)。
  36.       
  37.       
  38.     ○イベントでの時刻etc設定
  39.       イベントコマンド「スクリプト」から実行
  40.       
  41.         set_time(hour, min)
  42.           # 時刻を hour:min に設定します。
  43.           # このメソッドによって日数が経過することはありません。
  44.         
  45.         set_date(month, date, day)
  46.           # カレンダーを month月 date日 day曜日に設定します。
  47.           # 曜日の経過とか完全に無視してしまうので非推奨です。
  48.           # 曜日はシンボルで設定します。
  49.          
  50.           # 日曜 => :Sun  月曜 => :Mon  火曜 => :Tue
  51.           # 水曜 => :Wed  木曜 => :Thr  金曜 => :Fri
  52.           # 土曜 => :Sat
  53.          
  54.         set_year(year)
  55.           # カレンダーをyear年に設定します。
  56.           # 上と同じく非推奨です。
  57.         
  58.         shift_date(date)
  59.           # カレンダーをdate日だけ進めます。
  60.           # こちらは曜日もちゃんと加味します。
  61.          
  62.         shift_month(month)
  63.           # カレンダーをmonth月だけ進め、
  64.           # 進めた月の1日に設定します。
  65.            
  66.          shift_year(year)
  67.           # カレンダーを指定した年数経過させます。
  68.           # shift_monthと違って日付は変わりません。
  69.          
  70.         shift_date_to(month, date[, year])
  71.           # カレンダーを指定した日付(year年 month月 date日)まで進めます。
  72.           # yearを省略した場合は現在の年と同じ値になります。
  73.           # 現在の日付よりも前の日付を設定すると、
  74.           # その日まで時間が巻き戻ります。
  75.            
  76.          set_weather(weather)
  77.           # 天候を設定します。
  78.           # weatherはシンボルで指定します。
  79.          
  80.           # 晴れ => :fine  雨 => :rain   雪 => :snow
  81.           # 雷 => :thunder 嵐 => :storm  晴れ(夜) => :star
  82.           # 吹雪 => :s_storm
  83.          
  84.   ◆おことわり
  85.     改造・再配布等自由です。
  86.     再配布の際には作者の明示をお願いします。
  87.     バグを発見したら速やかにご報告ください。
  88.    
  89. =end
  90. #==============================================================================
  91. # ■ 設定項目
  92. #==============================================================================
  93. module WhiteSnow
  94.   
  95.   # ↓↓ここから初期設定↓↓
  96.   
  97.   INITAL_MIN = 40
  98.     # ゲーム開始時の「分」の値
  99.    
  100.   INITAL_HOUR = 7
  101.     # ゲーム開始時の「時」の値
  102.    
  103.   INITAL_DATE = 6
  104.     # ゲーム開始時の「日」の値
  105.    
  106.   INITAL_DAY = :Sun
  107.     # ゲーム開始時の「曜日」の値
  108.    
  109.   INITAL_MONTH = 4
  110.     # ゲーム開始時の「月」の値
  111.    
  112.   INITAL_YEAR = 618
  113.     # ゲーム開始時の「年」の値
  114.    
  115.   # ↑↑ここまで初期設定↑↑
  116.   
  117.   
  118.   TIME_COUNT_FORBID_SID = 80
  119.     # 時間経過を禁止するスイッチID
  120.    
  121.   TONE_CHANGE_FORBID_SID = 81
  122.     # 時間経過による画面の色調変更を禁止するスイッチID
  123.    
  124.   WEATHER_EFFECT_FORBID_SID = 82
  125.     # 天候エフェクトを無効化するスイッチID
  126.    
  127.   CALENDER_WINDOW_HIDE_SID = 83
  128.     # 日付ウィンドウを消すスイッチID
  129.     # ウィンドウが消えていても止めない限り時間は経過します
  130.    
  131.   INSIDE_FLAG_SID = 84
  132.     # 屋内フラグを立てるスイッチID
  133.     # 色調変更、天候エフェクトをまとめて無効化します
  134.    
  135.   WEATHER_BGS_ENABLE = true
  136.     # 天候によるBGS機能を使用するか
  137.     # trueで使用する、falseで使用しないとなります
  138.   
  139.   INSIDE_BGS_TYPE = 1
  140.     # 屋内フラグまたは天候エフェクト無効フラグのスイッチがONになった
  141.     # ときのBGSのタイプ
  142.     # BGS機能を使用するときのみ有効
  143.     # 0で音を消す、1で音量を60%にして流す、2でそのまま流す
  144.     # となります。
  145.   
  146.   WEATHER_BGS_DISABLE = 15
  147.     # 天候BGS機能停止スイッチ
  148.    
  149.     # このスイッチIDがONのときは天候BGSは流れません。
  150.     # ただしこのスイッチ単体では、今流れているBGSの再生を止める効果はありません。
  151.     # あくまで一時的にBGS機能を無効化するだけです。
  152.     # 屋内フラグを切り替えるスイッチと一緒に使うなりしてください。
  153.    
  154.     # また、このスイッチがOFFになっても止まっていたBGSが再び流れるような
  155.     # ことはありません。
  156.    
  157.    
  158.   MIN_STORE_VID = 101
  159.     # 現在の「分」の値が格納される変数ID
  160.    
  161.   HOUR_STORE_VID = 102
  162.     # 現在の「時」の値が格納される変数ID
  163.    
  164.   TIME_ZONE_STORE_VID = 103
  165.     # 現在の「時間帯」が格納される変数ID
  166.     # 早朝に0、朝に1、昼に2、夕方に3、夜に4、深夜で5になります。
  167.    
  168.   DATE_STORE_VID = 104
  169.     # 現在の「日」の値が格納される変数ID
  170.    
  171.   DAY_STORE_VID = 105
  172.     # 現在の「曜日」が格納される変数ID
  173.     # 日曜のとき0、月曜のとき1、と続き土曜のとき6になります。
  174.    
  175.   MONTH_STORE_VID = 106
  176.     # 現在の「月」の値が格納される変数ID
  177.    
  178.   SEASON_STORE_VID = 107
  179.     # 現在の「季節」が格納される変数ID
  180.     # 春のとき0、夏のとき1、秋のとき2、冬のとき3になります。
  181.    
  182.   WEATHER_STORE_VID = 108
  183.     # 現在の「天候」が格納される変数ID
  184.     # 晴れのとき0、雨のとき1、雪のとき2、雷のとき3、
  185.     # 嵐のとき4、晴れ(夜)のとき5、吹雪のとき6になります。
  186.    
  187.   YEAR_STORE_VID = 109
  188.     # 現在の「年」の値が格納される変数ID
  189.    
  190.    
  191.   EARLY_MORNING_SCREEN_TONE = [15, 10, 0, 0]
  192.     # 早朝の画面の色調
  193.     # R, G, B, Darkの順に指定してください。
  194.   
  195.   MORNING_SCREEN_TONE = [0, 0, 0, 0]
  196.     # 朝の画面の色調
  197.     # R, G, B, Darkの順に指定してください。
  198.    
  199.   NOON_SCREEN_TONE = [15, 15, 15, 0]
  200.     # 昼の画面の色調
  201.     # R, G, B, Darkの順に指定してください。
  202.    
  203.   AFTERNOON_SCREEN_TONE = [32, -8, -32, 16]
  204.     # 夕方の画面の色調
  205.     # R, G, B, Darkの順に指定してください。
  206.    
  207.   NIGHT_SCREEN_TONE = [-64, -64, -16, 32]
  208.     # 夜の画面の色調
  209.     # R, G, B, Darkの順に指定してください。
  210.    
  211.   MIDNIGHT_SCREEN_TONE = [-72, -72, -20, 48]
  212.     # 深夜の画面の色調
  213.     # R, G, B, Darkの順に指定してください。
  214.    
  215.   
  216.   DAYS_TABLE = {0 => 31, 1 => 31, 2 => 28, 3 => 31, 4 => 30, 5 => 31, 6 => 30,
  217.                 7 => 31, 8 => 31, 9 => 30, 10 => 31, 11 => 30, 12 => 31}
  218.     # 月毎の日数のテーブル
  219.     # 基本的に変更しないでください。
  220.    
  221.    
  222.     # 以下天候リスト
  223.    
  224.     # 設定例
  225.     # WEATHER = {:icon => 天候アイコンインデックス,
  226.     #            :weather => [天候エフェクトの種類, 強さ]},
  227.     #            :bgs => ["ファイル名", 音量, ピッチ](設定しない場合はnil),
  228.     #
  229.     # 天候エフェクトの種類  :noneで「なし」、:rainで「雨」、
  230.     #                       :stormで「嵐」、:snowで「雪」となります。
  231.    
  232.   FINE = {:icon => 1, :weather => [:none, 0],
  233.           :bgs => nil}
  234.     # 天候:晴れ
  235.    
  236.   RAIN = {:icon => 2, :weather => [:rain, 5],
  237.           :bgs => ["Rain", 20, 90]}
  238.     # 天候:雨
  239.    
  240.   SNOW = {:icon => 3, :weather => [:snow, 4],
  241.           :bgs => nil}
  242.     # 天候:雪
  243.    
  244.   THUNDER = {:icon => 4, :weather => [:storm, 4],
  245.              :bgs => ["Storm", 60, 75],
  246.             
  247.              :flash => [255, 255, 200, 180, 12],
  248.              :se => ["Thunder9", 80, 95]}
  249.     # 天候:雷
  250.     # 雷エフェクト用の設定項目について
  251.     # :flash => [(フラッシュの色)R, G, B, Alpha, フラッシュの長さ]
  252.     # :se => フラッシュの後に鳴るSE
  253.    
  254.   STORM = {:icon => 5, :weather => [:storm, 8],
  255.            :bgs => ["Storm", 70, 100]}
  256.     # 天候:嵐
  257.    
  258.   STAR = {:icon => 6, :weather => [:none, 0],
  259.           :bgs => nil}
  260.     # 天候:晴れ(夜)
  261.    
  262.   S_STORM = {:icon => 7, :weather => [:snow, 9],
  263.              :bgs => ["Wind", 70, 95]}
  264.     # 天候:吹雪
  265. end
  266.   
  267. #==============================================================================
  268. # ■ Calender
  269. #------------------------------------------------------------------------------
  270. #  カレンダーのクラスです。
  271. #==============================================================================

  272. class Calender
  273.   #--------------------------------------------------------------------------
  274.   # ● 公開インスタンス変数
  275.   #--------------------------------------------------------------------------
  276.   attr_accessor :count
  277.   attr_accessor :min
  278.   attr_accessor :hour
  279.   attr_accessor :date
  280.   attr_accessor :day
  281.   attr_accessor :month
  282.   attr_accessor :season
  283.   attr_accessor :year
  284.   attr_accessor :weather
  285.   attr_accessor :weather_count
  286.   attr_accessor :time_zone
  287.   attr_reader   :interpreter
  288.   attr_accessor :thunder_count
  289.   #--------------------------------------------------------------------------
  290.   # ● オブジェクト初期化
  291.   #--------------------------------------------------------------------------
  292.   def initialize
  293.     @count = 0
  294.     @weather = :fine
  295.     @interpreter = Game_Interpreter.new
  296.     init_calender
  297.     change_weather
  298.   end
  299.   #--------------------------------------------------------------------------
  300.   # ● カレンダーの初期化
  301.   #--------------------------------------------------------------------------
  302.   def init_calender
  303.     [url=home.php?mod=space&uid=25749]@min[/url]    = WhiteSnow::INITAL_MIN
  304.     @hour   = WhiteSnow::INITAL_HOUR
  305.     @date   = WhiteSnow::INITAL_DATE
  306.     [url=home.php?mod=space&uid=11519]@day[/url]    = WhiteSnow::INITAL_DAY
  307.     [url=home.php?mod=space&uid=26122]@Month[/url]  = WhiteSnow::INITAL_MONTH
  308.     @year   = WhiteSnow::INITAL_YEAR
  309.     get_time_zone
  310.    
  311.     $game_variables[WhiteSnow::MIN_STORE_VID] = @min
  312.     $game_variables[WhiteSnow::HOUR_STORE_VID] = @hour
  313.     $game_variables[WhiteSnow::DATE_STORE_VID] = @date
  314.    
  315.     case @month
  316.     when 1..2
  317.       [url=home.php?mod=space&uid=31546]@season[/url] = :Winter
  318.       $game_variables[WhiteSnow::SEASON_STORE_VID] = 3
  319.     when 3..5
  320.       [url=home.php?mod=space&uid=31546]@season[/url] = :Spring
  321.       $game_variables[WhiteSnow::SEASON_STORE_VID] = 0
  322.     when 6..8
  323.       [url=home.php?mod=space&uid=31546]@season[/url] = :Summer
  324.       $game_variables[WhiteSnow::SEASON_STORE_VID] = 1
  325.     when 9..11
  326.       @season = :Autumn
  327.       $game_variables[WhiteSnow::SEASON_STORE_VID] = 2
  328.     when 12
  329.       @season = :Winter
  330.       $game_variables[WhiteSnow::SEASON_STORE_VID] = 3
  331.     end
  332.    
  333.     case @day
  334.     when :Sun
  335.       $game_variables[WhiteSnow::DAY_STORE_VID] = 0
  336.     when :Mon
  337.       $game_variables[WhiteSnow::DAY_STORE_VID] = 1
  338.     when :Tue
  339.       $game_variables[WhiteSnow::DAY_STORE_VID] = 2
  340.     when :Wed
  341.       $game_variables[WhiteSnow::DAY_STORE_VID] = 3
  342.     when :Thr
  343.       $game_variables[WhiteSnow::DAY_STORE_VID] = 4
  344.     when :Fri
  345.       $game_variables[WhiteSnow::DAY_STORE_VID] = 5
  346.     when :Sat
  347.       $game_variables[WhiteSnow::DAY_STORE_VID] = 6
  348.     end
  349.     $game_variables[WhiteSnow::MONTH_STORE_VID] = @month
  350.     $game_variables[WhiteSnow::YEAR_STORE_VID] = @year
  351.     change_tone_by_calender
  352.   end
  353.   #--------------------------------------------------------------------------
  354.   # ● 時間帯の取得
  355.   #--------------------------------------------------------------------------
  356.   def get_time_zone
  357.     case @hour
  358.     when 0..2
  359.       @time_zone = :midnight
  360.       $game_variables[WhiteSnow::TIME_ZONE_STORE_VID] = 5
  361.     when 3..5
  362.       @time_zone = :early_morning
  363.       $game_variables[WhiteSnow::TIME_ZONE_STORE_VID] = 0
  364.     when 6..10
  365.       @time_zone = :morning
  366.       $game_variables[WhiteSnow::TIME_ZONE_STORE_VID] = 1
  367.     when 11..15
  368.       @time_zone = :noon
  369.       $game_variables[WhiteSnow::TIME_ZONE_STORE_VID] = 2
  370.     when 16..18
  371.       @time_zone = :evening
  372.       $game_variables[WhiteSnow::TIME_ZONE_STORE_VID] = 3
  373.     when 19..22
  374.       @time_zone = :night
  375.       $game_variables[WhiteSnow::TIME_ZONE_STORE_VID] = 4
  376.     when 23..24
  377.       @time_zone = :midnight
  378.       $game_variables[WhiteSnow::TIME_ZONE_STORE_VID] = 5
  379.     end
  380.   end
  381.   #--------------------------------------------------------------------------
  382.   # ● 天候カウントの取得
  383.   #--------------------------------------------------------------------------
  384.   def randomize_weather_count
  385.     @weather_count = p_ex_rand(40, 100) + (109 - p_ex_rand(40, 110)) + 90
  386.   end
  387.   #--------------------------------------------------------------------------
  388.   # ● 画面の色調変更
  389.   #--------------------------------------------------------------------------
  390.   def change_tone_by_calender(dur = 60)
  391.     return if $game_switches[WhiteSnow::TONE_CHANGE_FORBID_SID]
  392.     return if $game_switches[WhiteSnow::INSIDE_FLAG_SID]
  393.     case @time_zone
  394.     when :early_morning
  395.       tone = WhiteSnow::EARLY_MORNING_SCREEN_TONE
  396.       @interpreter.change_tone(tone[0], tone[1], tone[2], tone[3], dur)
  397.     when :morning
  398.       tone = WhiteSnow::MORNING_SCREEN_TONE
  399.       @interpreter.change_tone(tone[0], tone[1], tone[2], tone[3], dur)
  400.     when :noon
  401.       tone = WhiteSnow::NOON_SCREEN_TONE
  402.       @interpreter.change_tone(tone[0], tone[1], tone[2], tone[3], dur)
  403.     when :evening
  404.       tone = WhiteSnow::AFTERNOON_SCREEN_TONE
  405.       @interpreter.change_tone(tone[0], tone[1], tone[2], tone[3], dur)
  406.     when :night
  407.       tone = WhiteSnow::NIGHT_SCREEN_TONE
  408.       @interpreter.change_tone(tone[0], tone[1], tone[2], tone[3], dur)
  409.     when :midnight
  410.       tone = WhiteSnow::MIDNIGHT_SCREEN_TONE
  411.       @interpreter.change_tone(tone[0], tone[1], tone[2], tone[3], dur)
  412.     end
  413.   end
  414.   #--------------------------------------------------------------------------
  415.   # ● 天候の変更
  416.   #--------------------------------------------------------------------------
  417.   def change_weather
  418.     srand
  419.     p_weather = @weather
  420.     case @month
  421.     when 1
  422.       case rand
  423.       when 0...0.2
  424.         if @hour >= 3 and @hour < 18
  425.           @weather = :fine
  426.         else
  427.           @weather = :star
  428.         end
  429.       when 0.2...0.8
  430.         @weather = :snow
  431.       when 0.8...1
  432.         @weather = :s_storm
  433.       end
  434.     when 2
  435.       case rand
  436.       when 0...0.3
  437.         if @hour >= 3 and @hour < 18
  438.           @weather = :fine
  439.         else
  440.           @weather = :star
  441.         end
  442.       when 0.3...0.8
  443.         @weather = :snow
  444.       when 0.8...0.9
  445.         @weather = :rain
  446.       when 0.9...1
  447.         @weather = :s_storm
  448.       end
  449.     when 3..4
  450.       case rand
  451.       when 0...0.8
  452.         if @hour >= 3 and @hour < 18
  453.           @weather = :fine
  454.         else
  455.           @weather = :star
  456.         end
  457.       when 0.8...0.9
  458.         @weather = :rain
  459.       when 0.9...1
  460.         @weather = :storm
  461.       end
  462.     when 5
  463.       case rand
  464.       when 0...0.7
  465.         if @hour >= 3 and @hour < 18
  466.           @weather = :fine
  467.         else
  468.           @weather = :star
  469.         end
  470.       when 0.7...0.8
  471.         @weather = :rain
  472.       when 0.8...0.9
  473.         @weather = :thunder
  474.       when 0.9...1
  475.         @weather = :storm
  476.       end
  477.     when 6
  478.       case rand
  479.       when 0...0.4
  480.         if @hour >= 3 and @hour < 18
  481.           @weather = :fine
  482.         else
  483.           @weather = :star
  484.         end
  485.       when 0.4...0.8
  486.         @weather = :rain
  487.       when 0.8...0.9
  488.         @weather = :thunder
  489.       when 0.9...1
  490.         @weather = :storm
  491.       end
  492.     when 7..8
  493.       case rand
  494.       when 0...0.6
  495.         if @hour >= 3 and @hour < 18
  496.           @weather = :fine
  497.         else
  498.           @weather = :star
  499.         end
  500.       when 0.6...0.7
  501.         @weather = :rain
  502.       when 0.7...0.9
  503.         @weather = :storm
  504.       when 0.9...1
  505.         @weather = :thunder
  506.       end
  507.     when 9..10
  508.       case rand
  509.       when 0...0.6
  510.         if @hour >= 3 and @hour < 18
  511.           @weather = :fine
  512.         else
  513.           @weather = :star
  514.         end
  515.       when 0.6...0.8
  516.         @weather = :storm
  517.       when 0.8...0.9
  518.         @weather = :rain
  519.       when 0.9...1
  520.         @weather = :thunder
  521.       end
  522.     when 11
  523.       if @date < 25
  524.         case rand
  525.         when 0...0.7
  526.           if @hour >= 3 and @hour < 18
  527.             @weather = :fine
  528.           else
  529.             @weather = :star
  530.           end
  531.         when 0.7...0.8
  532.           @weather = :storm
  533.         when 0.8...0.9
  534.           @weather = :rain
  535.         when 0.9...1
  536.           @weather = :thunder
  537.         end
  538.       else
  539.         case rand
  540.         when 0...0.6
  541.           if @hour >= 3 and @hour < 18
  542.             @weather = :fine
  543.           else
  544.             @weather = :star
  545.           end
  546.         when 0.6...0.7
  547.           @weather = :storm
  548.         when 0.7...0.8
  549.           @weather = :rain
  550.         when 0.8...0.9
  551.           @weather = :thunder
  552.         when 0.9...1
  553.           @weather = :snow
  554.         end
  555.       end
  556.     when 12
  557.       case rand
  558.       when 0...0.2
  559.         if @hour >= 3 and @hour < 18
  560.           @weather = :fine
  561.         else
  562.           @weather = :star
  563.         end
  564.       when 0.2...0.8
  565.         @weather = :snow
  566.       when 0.8...1
  567.         @weather = :s_storm
  568.       end
  569.     end
  570.     if @weather != p_weather
  571.       RPG::BGS.fade(10)
  572.       perform_weather_effect
  573.     end
  574.     randomize_weather_count
  575.   end
  576.   #--------------------------------------------------------------------------
  577.   # ● 天候エフェクト
  578.   #--------------------------------------------------------------------------
  579.   def perform_weather_effect(dur = 30)
  580.     return unless SceneManager.scene_is?(Scene_Map)
  581.     return if $game_switches[WhiteSnow::WEATHER_EFFECT_FORBID_SID]
  582.     return if $game_switches[WhiteSnow::INSIDE_FLAG_SID]
  583.     case @weather
  584.     when :fine
  585.       weather = WhiteSnow::FINE
  586.       @interpreter.change_weather(weather[:weather][0], weather[:weather][1], dur)
  587.       if weather[:bgs] and WhiteSnow::WEATHER_BGS_ENABLE and !$game_switches[WhiteSnow::WEATHER_BGS_DISABLE]
  588.         bgs = RPG::BGS.new(weather[:bgs][0], weather[:bgs][1], weather[:bgs][2])
  589.         bgs.play
  590.       end
  591.       $game_variables[WhiteSnow::WEATHER_STORE_VID] = 0
  592.       
  593.     when :rain
  594.       weather = WhiteSnow::RAIN
  595.       @interpreter.change_weather(weather[:weather][0], weather[:weather][1], dur)
  596.       if weather[:bgs] and WhiteSnow::WEATHER_BGS_ENABLE and !$game_switches[WhiteSnow::WEATHER_BGS_DISABLE]
  597.         bgs = RPG::BGS.new(weather[:bgs][0], weather[:bgs][1], weather[:bgs][2])
  598.         bgs.play
  599.       end
  600.       $game_variables[WhiteSnow::WEATHER_STORE_VID] = 1
  601.       
  602.     when :snow
  603.       weather = WhiteSnow::SNOW
  604.       @interpreter.change_weather(weather[:weather][0], weather[:weather][1], dur)
  605.       if weather[:bgs] and WhiteSnow::WEATHER_BGS_ENABLE and !$game_switches[WhiteSnow::WEATHER_BGS_DISABLE]
  606.         bgs = RPG::BGS.new(weather[:bgs][0], weather[:bgs][1], weather[:bgs][2])
  607.         bgs.play
  608.       end
  609.       $game_variables[WhiteSnow::WEATHER_STORE_VID] = 2
  610.       
  611.     when :thunder
  612.       weather = WhiteSnow::THUNDER
  613.       @interpreter.change_weather(weather[:weather][0], weather[:weather][1], dur)
  614.       if weather[:bgs] and WhiteSnow::WEATHER_BGS_ENABLE and !$game_switches[WhiteSnow::WEATHER_BGS_DISABLE]
  615.         bgs = RPG::BGS.new(weather[:bgs][0], weather[:bgs][1], weather[:bgs][2])
  616.         bgs.play
  617.       end
  618.       $game_variables[WhiteSnow::WEATHER_STORE_VID] = 3
  619.       
  620.     when :storm
  621.       weather = WhiteSnow::STORM
  622.       @interpreter.change_weather(weather[:weather][0], weather[:weather][1], dur)
  623.       if weather[:bgs] and WhiteSnow::WEATHER_BGS_ENABLE and !$game_switches[WhiteSnow::WEATHER_BGS_DISABLE]
  624.         bgs = RPG::BGS.new(weather[:bgs][0], weather[:bgs][1], weather[:bgs][2])
  625.         bgs.play
  626.       end
  627.       $game_variables[WhiteSnow::WEATHER_STORE_VID] = 4
  628.       
  629.     when :star
  630.       weather = WhiteSnow::STAR
  631.       @interpreter.change_weather(weather[:weather][0], weather[:weather][1], dur)
  632.       if weather[:bgs] and WhiteSnow::WEATHER_BGS_ENABLE and !$game_switches[WhiteSnow::WEATHER_BGS_DISABLE]
  633.         bgs = RPG::BGS.new(weather[:bgs][0], weather[:bgs][1], weather[:bgs][2])
  634.         bgs.play
  635.       end
  636.       $game_variables[WhiteSnow::WEATHER_STORE_VID] = 5
  637.       
  638.     when :s_storm
  639.       weather = WhiteSnow::S_STORM
  640.       @interpreter.change_weather(weather[:weather][0], weather[:weather][1], dur)
  641.       if weather[:bgs] and WhiteSnow::WEATHER_BGS_ENABLE and !$game_switches[WhiteSnow::WEATHER_BGS_DISABLE]
  642.         bgs = RPG::BGS.new(weather[:bgs][0], weather[:bgs][1], weather[:bgs][2])
  643.         bgs.play
  644.       end
  645.       $game_variables[WhiteSnow::WEATHER_STORE_VID] = 6
  646.     end
  647.   end
  648.   #--------------------------------------------------------------------------
  649.   # ● 屋内BGSの演奏
  650.   #--------------------------------------------------------------------------
  651.   def play_inside_bgs
  652.     case @weather
  653.     when :fine
  654.       weather = WhiteSnow::FINE
  655.       if weather[:bgs] and WhiteSnow::WEATHER_BGS_ENABLE and !$game_switches[WhiteSnow::WEATHER_BGS_DISABLE]
  656.         bgs = RPG::BGS.new(weather[:bgs][0], weather[:bgs][1] * 0.6, weather[:bgs][2])
  657.         bgs.play
  658.       end
  659.       
  660.     when :rain
  661.       weather = WhiteSnow::RAIN
  662.       if weather[:bgs] and WhiteSnow::WEATHER_BGS_ENABLE and !$game_switches[WhiteSnow::WEATHER_BGS_DISABLE]
  663.         bgs = RPG::BGS.new(weather[:bgs][0], weather[:bgs][1] * 0.7, weather[:bgs][2])
  664.         bgs.play
  665.       end
  666.       
  667.     when :snow
  668.       weather = WhiteSnow::SNOW
  669.       if weather[:bgs] and WhiteSnow::WEATHER_BGS_ENABLE and !$game_switches[WhiteSnow::WEATHER_BGS_DISABLE]
  670.         bgs = RPG::BGS.new(weather[:bgs][0], weather[:bgs][1] * 0.7, weather[:bgs][2])
  671.         bgs.play
  672.       end
  673.       
  674.     when :thunder
  675.       weather = WhiteSnow::THUNDER
  676.       if weather[:bgs] and WhiteSnow::WEATHER_BGS_ENABLE and !$game_switches[WhiteSnow::WEATHER_BGS_DISABLE]
  677.         bgs = RPG::BGS.new(weather[:bgs][0], weather[:bgs][1] * 0.7, weather[:bgs][2])
  678.         bgs.play
  679.       end
  680.       
  681.     when :storm
  682.       weather = WhiteSnow::STORM
  683.       if weather[:bgs] and WhiteSnow::WEATHER_BGS_ENABLE and !$game_switches[WhiteSnow::WEATHER_BGS_DISABLE]
  684.         bgs = RPG::BGS.new(weather[:bgs][0], weather[:bgs][1] * 0.7, weather[:bgs][2])
  685.         bgs.play
  686.       end
  687.       
  688.     when :star
  689.       weather = WhiteSnow::STAR
  690.       if weather[:bgs] and WhiteSnow::WEATHER_BGS_ENABLE and !$game_switches[WhiteSnow::WEATHER_BGS_DISABLE]
  691.         bgs = RPG::BGS.new(weather[:bgs][0], weather[:bgs][1] * 0.7, weather[:bgs][2])
  692.         bgs.play
  693.       end
  694.       
  695.     when :s_storm
  696.       weather = WhiteSnow::S_STORM
  697.       if weather[:bgs] and WhiteSnow::WEATHER_BGS_ENABLE and !$game_switches[WhiteSnow::WEATHER_BGS_DISABLE]
  698.         bgs = RPG::BGS.new(weather[:bgs][0], weather[:bgs][1] * 0.7, weather[:bgs][2])
  699.         bgs.play
  700.       end
  701.     end
  702.   end
  703.   #--------------------------------------------------------------------------
  704.   # ● 天候「雷」エフェクトの実行
  705.   #--------------------------------------------------------------------------
  706.   def perform_thunder_effect(r, g, b, alpha, dur)
  707.     @interpreter.perform_flash(r, g, b, alpha, dur)
  708.   end
  709.   #--------------------------------------------------------------------------
  710.   # ● 曜日の更新
  711.   #--------------------------------------------------------------------------
  712.   def shift_day
  713.     case @day
  714.     when :Sun
  715.       [url=home.php?mod=space&uid=11519]@day[/url] = :Mon
  716.       $game_variables[WhiteSnow::DAY_STORE_VID] = 1
  717.     when :Mon
  718.       [url=home.php?mod=space&uid=11519]@day[/url] = :Tue
  719.       $game_variables[WhiteSnow::DAY_STORE_VID] = 2
  720.     when :Tue
  721.       @day = :Wed
  722.       $game_variables[WhiteSnow::DAY_STORE_VID] = 3
  723.     when :Wed
  724.       @day = :Thr
  725.       $game_variables[WhiteSnow::DAY_STORE_VID] = 4
  726.     when :Thr
  727.       @day = :Fri
  728.       $game_variables[WhiteSnow::DAY_STORE_VID] = 5
  729.     when :Fri
  730.       @day = :Sat
  731.       $game_variables[WhiteSnow::DAY_STORE_VID] = 6
  732.     when :Sat
  733.       @day = :Sun
  734.       $game_variables[WhiteSnow::DAY_STORE_VID] = 0
  735.     end
  736.   end
  737.   #--------------------------------------------------------------------------
  738.   # ● 曜日を戻す
  739.   #--------------------------------------------------------------------------
  740.   def back_day
  741.     case @day
  742.     when :Sun
  743.       @day = :Sat
  744.       $game_variables[WhiteSnow::DAY_STORE_VID] = 1
  745.     when :Sat
  746.       @day = :Fri
  747.       $game_variables[WhiteSnow::DAY_STORE_VID] = 2
  748.     when :Fri
  749.       @day = :Thr
  750.       $game_variables[WhiteSnow::DAY_STORE_VID] = 3
  751.     when :Thr
  752.       @day = :Wed
  753.       $game_variables[WhiteSnow::DAY_STORE_VID] = 4
  754.     when :Wed
  755.       @day = :Tue
  756.       $game_variables[WhiteSnow::DAY_STORE_VID] = 5
  757.     when :Tue
  758.       @day = :Mon
  759.       $game_variables[WhiteSnow::DAY_STORE_VID] = 6
  760.     when :Mon
  761.       @day = :Sun
  762.       $game_variables[WhiteSnow::DAY_STORE_VID] = 0
  763.     end
  764.   end
  765.   #--------------------------------------------------------------------------
  766.   # ● 月の更新
  767.   #--------------------------------------------------------------------------
  768.   def shift_month
  769.     case @month
  770.     when 1
  771.       return unless @date > 31
  772.       [url=home.php?mod=space&uid=26122]@Month[/url] += 1
  773.       @date = 1
  774.     when 2
  775.       return unless @date > 28
  776.       [url=home.php?mod=space&uid=26122]@Month[/url] += 1
  777.       @season = :Spring
  778.       @date = 1
  779.       $game_variables[WhiteSnow::SEASON_STORE_VID] = 0
  780.     when 3
  781.       return unless @date > 31
  782.       @month += 1
  783.       @date = 1
  784.     when 4
  785.       return unless @date > 30
  786.       @month += 1
  787.       @date = 1
  788.     when 5
  789.       return unless @date > 31
  790.       @month += 1
  791.       @season = :Summer
  792.       @date = 1
  793.       $game_variables[WhiteSnow::SEASON_STORE_VID] = 1
  794.     when 6
  795.       return unless @date > 30
  796.       @month += 1
  797.       @date = 1
  798.     when 7
  799.       return unless @date > 31
  800.       @month += 1
  801.       @date = 1
  802.     when 8
  803.       return unless @date > 31
  804.       @month += 1
  805.       @season = :Autumn
  806.       @date = 1
  807.       $game_variables[WhiteSnow::SEASON_STORE_VID] = 2
  808.     when 9
  809.       return unless @date > 30
  810.       @month += 1
  811.       @date = 1
  812.     when 10
  813.       return unless @date > 31
  814.       @month += 1
  815.       @date = 1
  816.     when 11
  817.       return unless @date > 30
  818.       @month += 1
  819.       @season = :Winter
  820.       @date = 1
  821.       $game_variables[WhiteSnow::SEASON_STORE_VID] = 3
  822.     when 12
  823.       return unless @date > 31
  824.       @year += 1
  825.       @month = 1
  826.       @date = 1
  827.       $game_variables[WhiteSnow::YEAR_STORE_VID] = @year
  828.     end
  829.     $game_variables[WhiteSnow::DATE_STORE_VID] = @date
  830.     $game_variables[WhiteSnow::MONTH_STORE_VID] = @month
  831.   end
  832.   #--------------------------------------------------------------------------
  833.   # ● 月を戻す
  834.   #--------------------------------------------------------------------------
  835.   def back_month
  836.     return unless @date < 1
  837.     case @month
  838.     when 1
  839.       @month = 12
  840.       @date = 31
  841.       @year -= 1
  842.       $game_variables[WhiteSnow::YEAR_STORE_VID] = @year
  843.     when 2
  844.       @month -= 1
  845.       @date = 31
  846.     when 3
  847.       @month -= 1
  848.       @date = 28
  849.       @season = :Winter
  850.       $game_variables[WhiteSnow::SEASON_STORE_VID] = 3
  851.     when 4
  852.       @month -= 1
  853.       @date = 31
  854.     when 5
  855.       @month -= 1
  856.       @date = 30
  857.     when 6
  858.       @month -= 1
  859.       @date = 31
  860.       @season = :Spring
  861.       $game_variables[WhiteSnow::SEASON_STORE_VID] = 0
  862.     when 7
  863.       @month -= 1
  864.       @date = 30
  865.     when 8
  866.       @month -= 1
  867.       @date = 31
  868.     when 9
  869.       @month -= 1
  870.       @date = 31
  871.       @season = :Summer
  872.       $game_variables[WhiteSnow::SEASON_STORE_VID] = 1
  873.     when 10
  874.       @month -= 1
  875.       @date = 30
  876.     when 11
  877.       @month -= 1
  878.       @date = 31
  879.     when 12
  880.       @month -= 1
  881.       @date = 30
  882.       @season = :Autumn
  883.       $game_variables[WhiteSnow::SEASON_STORE_VID] = 2
  884.     end
  885.     $game_variables[WhiteSnow::DATE_STORE_VID] = @date
  886.     $game_variables[WhiteSnow::MONTH_STORE_VID] = @month
  887.   end
  888.   #--------------------------------------------------------------------------
  889.   # ● 日付を進める
  890.   #--------------------------------------------------------------------------
  891.   def shift_date
  892.     @date += 1
  893.     shift_day
  894.     shift_month
  895.     $game_variables[WhiteSnow::HOUR_STORE_VID] = @hour
  896.     $game_variables[WhiteSnow::DATE_STORE_VID] = @date
  897.   end
  898.   #--------------------------------------------------------------------------
  899.   # ● 日付を戻す
  900.   #--------------------------------------------------------------------------
  901.   def back_date
  902.     @date += 1
  903.     back_day
  904.     back_month
  905.     $game_variables[WhiteSnow::HOUR_STORE_VID] = @hour
  906.     $game_variables[WhiteSnow::DATE_STORE_VID] = @date
  907.   end
  908.   #--------------------------------------------------------------------------
  909.   # ● 指定された日時と現在の日時の差を求める
  910.   #--------------------------------------------------------------------------
  911.   def days_dif(y, m, d)
  912.     table = WhiteSnow::DAYS_TABLE
  913.     dy_n = (@year - 1) * 365
  914.     dy_s = (y - 1) * 365
  915.     dm_n = 0 ; 1.upto(@month - 1){|n| dm_n += table[n]} unless @month == 1
  916.     dm_s = 0 ; 1.upto(m - 1){|n| dm_s += table[n]} unless m == 1
  917.     d_n = @date - 1
  918.     d_s = d - 1
  919.     n = dy_n + dm_n + d_n
  920.     s = dy_s + dm_s + d_s
  921.     return s - n
  922.   end
  923. end

  924. #==============================================================================
  925. # ■ Window_Calender
  926. #------------------------------------------------------------------------------
  927. #  カレンダーの内容を表示するウィンドウです。
  928. #==============================================================================

  929. class Window_Calender < Window_Base
  930.   #--------------------------------------------------------------------------
  931.   # ● オブジェクト初期化
  932.   #--------------------------------------------------------------------------
  933.   def initialize(x = Graphics.width - 208, y = 0, w = 208)
  934.     super(x, y, w, fitting_height(2))
  935.     refresh
  936.   end
  937.   #--------------------------------------------------------------------------
  938.   # ● フレーム更新
  939.   #--------------------------------------------------------------------------
  940.   def update
  941.     self.visible = false if $game_switches[WhiteSnow::CALENDER_WINDOW_HIDE_SID]
  942.     super
  943.     refresh if $calender.count == 0
  944.   end
  945.   #--------------------------------------------------------------------------
  946.   # ● リフレッシュ
  947.   #--------------------------------------------------------------------------
  948.   def refresh
  949.     contents.clear
  950.     draw_year
  951.     draw_date
  952.     draw_time
  953.     draw_weather_icon
  954.   end
  955.   #--------------------------------------------------------------------------
  956.   # ● 年・季節の描画
  957.   #--------------------------------------------------------------------------
  958.   def draw_year
  959.     season = $calender.season.to_s
  960.     season.gsub!("Spring"){"春"}
  961.     season.gsub!("Summer"){"夏"}
  962.     season.gsub!("Autumn"){"秋"}
  963.     season.gsub!("Winter"){"冬"}
  964.     draw_text(0, 0, contents_width, line_height, "#{$calender.year}" + "年")
  965.     draw_text(0, 0, contents_width, line_height, season, 1)
  966.   end
  967.   #--------------------------------------------------------------------------
  968.   # ● 月・日付・曜日の描画
  969.   #--------------------------------------------------------------------------
  970.   def draw_date
  971.     w = contents_width
  972.     h = line_height
  973.     month = $calender.month
  974.     if (0..9).to_a.include?(month)
  975.       month = "0" + month.to_s
  976.     else
  977.       month = month.to_s
  978.     end
  979.     date = $calender.date
  980.     if (0..9).to_a.include?(date)
  981.       date = "0" + date.to_s
  982.     else
  983.       date = date.to_s
  984.     end
  985.     day = $calender.day.to_s
  986.     day.gsub!("Sun"){"\\c[2]日\\c[0]"}
  987.     day.gsub!("Mon"){"月"}
  988.     day.gsub!("Tue"){"火"}
  989.     day.gsub!("Wed"){"水"}
  990.     day.gsub!("Thr"){"木"}
  991.     day.gsub!("Fri"){"金"}
  992.     day.gsub!("Sat"){"土"}
  993.     draw_text_ex(0, h, month + "月" + date + "日" + "(" + day + ")")
  994.   end
  995.   #--------------------------------------------------------------------------
  996.   # ● 時・分の描画
  997.   #--------------------------------------------------------------------------
  998.   def draw_time
  999.     w = contents_width - 6
  1000.     h = line_height
  1001.     hour = "#{$calender.hour}"
  1002.     min = $calender.min
  1003.     if (0..9).to_a.include?(min)
  1004.       min = "0" + min.to_s
  1005.     else
  1006.       min = min.to_s
  1007.     end
  1008.     draw_text(0, h, w, h, hour + ":" + min, 2)
  1009.   end
  1010.   #--------------------------------------------------------------------------
  1011.   # ● 天候アイコンの描画
  1012.   #--------------------------------------------------------------------------
  1013.   def draw_weather_icon
  1014.     case $calender.weather
  1015.     when :fine
  1016.       icon_index = WhiteSnow::FINE[:icon]
  1017.     when :rain
  1018.       icon_index = WhiteSnow::RAIN[:icon]
  1019.     when :snow
  1020.       icon_index = WhiteSnow::SNOW[:icon]
  1021.     when :thunder
  1022.       icon_index = WhiteSnow::THUNDER[:icon]
  1023.     when :storm
  1024.       icon_index = WhiteSnow::STORM[:icon]
  1025.     when :star
  1026.       icon_index = WhiteSnow::STAR[:icon]
  1027.     when :s_storm
  1028.       icon_index = WhiteSnow::S_STORM[:icon]
  1029.     end
  1030.     draw_icon(icon_index, contents_width - 30, 0)
  1031.   end
  1032. end

  1033. #==============================================================================
  1034. # ■ Window_MenuCalender
  1035. #------------------------------------------------------------------------------
  1036. #  カレンダーの内容を表示するウィンドウです(メニュー画面用)。
  1037. #==============================================================================

  1038. class Window_MenuCalender < Window_Base
  1039.   #--------------------------------------------------------------------------
  1040.   # ● オブジェクト初期化
  1041.   #--------------------------------------------------------------------------
  1042.   def initialize(x = Graphics.width - 220, y = 0, w = 220)
  1043.     super(x, y, w, fitting_height(3))
  1044.     refresh
  1045.   end
  1046.   #--------------------------------------------------------------------------
  1047.   # ● リフレッシュ
  1048.   #--------------------------------------------------------------------------
  1049.   def refresh
  1050.     contents.clear
  1051.     draw_year
  1052.     draw_date
  1053.     draw_time
  1054.     draw_weather_icon
  1055.   end
  1056.   #--------------------------------------------------------------------------
  1057.   # ● 年の描画
  1058.   #--------------------------------------------------------------------------
  1059.   def draw_year
  1060.     season = $calender.season.to_s
  1061.     season.gsub!("Spring"){"春"}
  1062.     season.gsub!("Summer"){"夏"}
  1063.     season.gsub!("Autumn"){"秋"}
  1064.     season.gsub!("Winter"){"冬"}
  1065.     draw_text(0, 0, contents_width, line_height, "#{$calender.year}" + "年")
  1066.     draw_text(0, 0, contents_width + 12, line_height, season, 1)
  1067.   end
  1068.   #--------------------------------------------------------------------------
  1069.   # ● 月・日付・曜日の描画
  1070.   #--------------------------------------------------------------------------
  1071.   def draw_date
  1072.     w = contents_width
  1073.     h = line_height
  1074.     month = $calender.month
  1075.     if (0..9).to_a.include?(month)
  1076.       month = "0" + month.to_s
  1077.     else
  1078.       month = month.to_s
  1079.     end
  1080.     date = $calender.date
  1081.     if (0..9).to_a.include?(date)
  1082.       date = "0" + date.to_s
  1083.     else
  1084.       date = date.to_s
  1085.     end
  1086.     day = $calender.day.to_s
  1087.     day.gsub!("Sun"){"\\c[2]日\\c[0]"}
  1088.     day.gsub!("Mon"){"月"}
  1089.     day.gsub!("Tue"){"火"}
  1090.     day.gsub!("Wed"){"水"}
  1091.     day.gsub!("Thr"){"木"}
  1092.     day.gsub!("Fri"){"金"}
  1093.     day.gsub!("Sat"){"土"}
  1094.     draw_text_ex(12, h, month + "月" + date + "日" + "(" + day + ")")
  1095.   end
  1096.   #--------------------------------------------------------------------------
  1097.   # ● 時・分の描画
  1098.   #--------------------------------------------------------------------------
  1099.   def draw_time
  1100.     w = contents_width - 12
  1101.     h = line_height
  1102.     hour = "#{$calender.hour}"
  1103.     min = $calender.min
  1104.     if (0..9).to_a.include?(min)
  1105.       min = "0" + min.to_s
  1106.     else
  1107.       min = min.to_s
  1108.     end
  1109.     draw_text(0, h * 2, w, h, hour + ":" + min, 2)
  1110.   end
  1111.   #--------------------------------------------------------------------------
  1112.   # ● 天候アイコンの描画
  1113.   #--------------------------------------------------------------------------
  1114.   def draw_weather_icon
  1115.     case $calender.weather
  1116.     when :fine
  1117.       icon_index = WhiteSnow::FINE[:icon]
  1118.     when :rain
  1119.       icon_index = WhiteSnow::RAIN[:icon]
  1120.     when :snow
  1121.       icon_index = WhiteSnow::SNOW[:icon]
  1122.     when :thunder
  1123.       icon_index = WhiteSnow::THUNDER[:icon]
  1124.     when :storm
  1125.       icon_index = WhiteSnow::STORM[:icon]
  1126.     when :star
  1127.       icon_index = WhiteSnow::STAR[:icon]
  1128.     when :s_storm
  1129.       icon_index = WhiteSnow::S_STORM[:icon]
  1130.     end
  1131.     draw_icon(icon_index, contents_width - 30, 0)
  1132.   end
  1133. end

  1134. #==============================================================================
  1135. # ■ Scene_Map
  1136. #------------------------------------------------------------------------------
  1137. #  マップ画面の処理を行うクラスです。
  1138. #==============================================================================

  1139. class Scene_Map < Scene_Base
  1140.   #--------------------------------------------------------------------------
  1141.   # ● 全ウィンドウの作成
  1142.   #--------------------------------------------------------------------------
  1143.   alias calender_create_all_windows create_all_windows
  1144.   def create_all_windows
  1145.     calender_create_all_windows
  1146.     create_calender_window
  1147.   end
  1148.   #--------------------------------------------------------------------------
  1149.   # ● 日付表示ウィンドウの作成
  1150.   #--------------------------------------------------------------------------
  1151.   def create_calender_window
  1152.     @calender_window = Window_Calender.new
  1153.   end
  1154. end

  1155. #==============================================================================
  1156. # ■ Scene_Base
  1157. #------------------------------------------------------------------------------
  1158. #  ゲーム中の全てのシーンのスーパークラスです。
  1159. #==============================================================================

  1160. class Scene_Base
  1161.   #--------------------------------------------------------------------------
  1162.   # ● フレーム更新(基本)
  1163.   #--------------------------------------------------------------------------
  1164.   alias calender_update_basic update_basic
  1165.   def update_basic
  1166.     calender_update_basic
  1167.     update_calender
  1168.   end
  1169.   #--------------------------------------------------------------------------
  1170.   # ● 時刻の更新
  1171.   #--------------------------------------------------------------------------
  1172.   def update_calender
  1173.     return unless SceneManager.scene_is?(Scene_Map)
  1174.     return if $game_switches[10]
  1175.     $calender.count += 1
  1176.     if $calender.weather == :thunder and !($game_switches[WhiteSnow::WEATHER_EFFECT_FORBID_SID] or $game_switches[WhiteSnow::INSIDE_FLAG_SID])
  1177.       $calender.thunder_count ||= [Graphics.frame_rate * 5 + (rand * Graphics.frame_rate * 10).floor, false]
  1178.       $calender.thunder_count[0] -= 1
  1179.       if $calender.thunder_count[1]
  1180.         if $calender.thunder_count[0] == 0
  1181.           se = RPG::SE.new(WhiteSnow::THUNDER[:se][0], WhiteSnow::THUNDER[:se][1], WhiteSnow::THUNDER[:se][2])
  1182.           se.play
  1183.           $calender.thunder_count = nil
  1184.         end
  1185.       elsif $calender.thunder_count[0] < 12 + rand(43)
  1186.         flash = WhiteSnow::THUNDER[:flash]
  1187.         $calender.perform_thunder_effect(flash[0], flash[1], flash[2], flash[3], flash[4])
  1188.         $calender.thunder_count[1] = true
  1189.       end
  1190.     else
  1191.       $calender.thunder_count = nil
  1192.     end
  1193.     if $calender.count % Graphics.frame_rate == 0
  1194.       $calender.min += 1
  1195.       $calender.count = 0
  1196.       $game_variables[WhiteSnow::MIN_STORE_VID] = $calender.min
  1197.       $calender.weather_count -= 1
  1198.       $calender.change_weather if $calender.weather_count <= 0
  1199.     end
  1200.     if $calender.min == 60
  1201.       $calender.hour += 1
  1202.       $calender.min = 0
  1203.       if $calender.hour >= 3 and $calender.hour < 19
  1204.         $calender.weather = :fine if $calender.weather == :star
  1205.       else
  1206.         $calender.weather = :star if $calender.weather == :fine
  1207.       end
  1208.       $calender.get_time_zone
  1209.       $calender.change_tone_by_calender
  1210.       $game_map.autoplay
  1211.       $game_variables[WhiteSnow::MIN_STORE_VID] = $calender.min
  1212.       $game_variables[WhiteSnow::HOUR_STORE_VID] = $calender.hour
  1213.     end
  1214.     if $calender.hour == 24
  1215.       $calender.hour = 0
  1216.       $calender.shift_date
  1217.     end
  1218.   end
  1219. end

  1220. #==============================================================================
  1221. # ■ Scene_Menu
  1222. #------------------------------------------------------------------------------
  1223. #  メニュー画面の処理を行うクラスです。
  1224. #==============================================================================

  1225. class Scene_Menu
  1226.   #--------------------------------------------------------------------------
  1227.   # ● 開始処理
  1228.   #--------------------------------------------------------------------------
  1229.   alias calender_start start
  1230.   def start
  1231.     calender_start
  1232.     create_calender_window
  1233.   end
  1234.   #--------------------------------------------------------------------------
  1235.   # ● 日付ウィンドウの作成
  1236.   #--------------------------------------------------------------------------
  1237.   def create_calender_window
  1238.     x = 0
  1239.     w = @gold_window.width
  1240.     @calender_window = Window_MenuCalender.new(x, 0, w)
  1241.     @calender_window.y = Graphics.height - @gold_window.height - @calender_window.height
  1242.   end
  1243. end

  1244. #==============================================================================
  1245. # ■ DataManager
  1246. #------------------------------------------------------------------------------
  1247. #  データベースとゲームオブジェクトを管理するモジュールです。ゲームで使用する
  1248. # ほぼ全てのグローバル変数はこのモジュールで初期化されます。
  1249. #==============================================================================

  1250. module DataManager
  1251.   #--------------------------------------------------------------------------
  1252.   # ● エイリアス用特異メソッド
  1253.   #--------------------------------------------------------------------------
  1254.   class << self
  1255.     alias :calender_create_game_objects :create_game_objects
  1256.     alias :calender_extract_save_contents :extract_save_contents
  1257.   end
  1258.   #--------------------------------------------------------------------------
  1259.   # ● 各種ゲームオブジェクトの作成
  1260.   #--------------------------------------------------------------------------
  1261.   def self.create_game_objects
  1262.     calender_create_game_objects
  1263.     $calender = Calender.new
  1264.   end
  1265.   #--------------------------------------------------------------------------
  1266.   # ● セーブ内容の作成 (再定義)
  1267.   #--------------------------------------------------------------------------
  1268.   def self.make_save_contents
  1269.     contents = {}
  1270.     contents[:system]           = $game_system
  1271.     contents[:timer]            = $game_timer
  1272.     contents[:message]          = $game_message
  1273.     contents[:switches]         = $game_switches
  1274.     contents[:variables]        = $game_variables
  1275.     contents[:self_switches]    = $game_self_switches
  1276.     contents[:actors]           = $game_actors
  1277.     contents[:party]            = $game_party
  1278.     contents[:troop]            = $game_troop
  1279.     contents[:map]              = $game_map
  1280.     contents[:player]           = $game_player
  1281.     contents[:calender]         = $calender
  1282.     contents
  1283.   end
  1284.   #--------------------------------------------------------------------------
  1285.   # ● セーブ内容の作成
  1286.   #--------------------------------------------------------------------------
  1287.   def self.extract_save_contents(contents)
  1288.     calender_extract_save_contents(contents)
  1289.     $calender = contents[:calender]
  1290.   end
  1291. end

  1292. #==============================================================================
  1293. # ■ Game_Interpreter
  1294. #------------------------------------------------------------------------------
  1295. #  イベントコマンドを実行するインタプリタです。このクラスは Game_Map クラス、
  1296. # Game_Troop クラス、Game_Event クラスの内部で使用されます。
  1297. #==============================================================================

  1298. class Game_Interpreter
  1299.   #--------------------------------------------------------------------------
  1300.   # ● 画面の色調変更(引数指定)
  1301.   #--------------------------------------------------------------------------
  1302.   def change_tone(r, g, b, gray = 0, dur = 60)
  1303.     tone = Tone.new(r, g, b, gray)
  1304.     screen.start_tone_change(tone, dur)
  1305.   end
  1306.   #--------------------------------------------------------------------------
  1307.   # ● 天候の変更(引数指定)
  1308.   #--------------------------------------------------------------------------
  1309.   def change_weather(type, power, dur = 30)
  1310.     return if $game_party.in_battle
  1311.     screen.change_weather(type, power, dur)
  1312.   end
  1313.   #--------------------------------------------------------------------------
  1314.   # ● 時間を設定
  1315.   #--------------------------------------------------------------------------
  1316.   def set_time(hour, min)
  1317.     hour = 23 if hour > 23
  1318.     hour = 0 if hour < 0
  1319.     min = 59 if min > 59
  1320.     min = 0 if min < 0
  1321.     $calender.hour = hour
  1322.     $calender.min = min
  1323.     $calender.get_time_zone
  1324.     $game_variables[WhiteSnow::MIN_STORE_VID] = $calender.min
  1325.     $game_variables[WhiteSnow::HOUR_STORE_VID] = $calender.hour
  1326.     $game_variables[WhiteSnow::DATE_STORE_VID] = $calender.date
  1327.     $game_map.autoplay
  1328.     $calender.change_weather
  1329.     $calender.change_tone_by_calender
  1330.     if $calender.hour >= 3 and $calender.hour < 19
  1331.       $calender.weather = :fine if $calender.weather == :star
  1332.     else
  1333.       $calender.weather = :star if $calender.weather == :fine
  1334.     end
  1335.   end
  1336.   #--------------------------------------------------------------------------
  1337.   # ● 日付を設定
  1338.   #--------------------------------------------------------------------------
  1339.   def set_date(month, date, day)
  1340.     $calender.month = month
  1341.     $calender.date = date
  1342.     $calender.day = day
  1343.     $game_variables[WhiteSnow::MIN_STORE_VID] = $calender.month
  1344.     $game_variables[WhiteSnow::DATE_STORE_VID] = $calender.date
  1345.     case $calender.day
  1346.     when :Sun
  1347.       $game_variables[WhiteSnow::DAY_STORE_VID] = 0
  1348.     when :Mon
  1349.       $game_variables[WhiteSnow::DAY_STORE_VID] = 1
  1350.     when :Tue
  1351.       $game_variables[WhiteSnow::DAY_STORE_VID] = 2
  1352.     when :Wed
  1353.       $game_variables[WhiteSnow::DAY_STORE_VID] = 3
  1354.     when :Thr
  1355.       $game_variables[WhiteSnow::DAY_STORE_VID] = 4
  1356.     when :Fri
  1357.       $game_variables[WhiteSnow::DAY_STORE_VID] = 5
  1358.     when :Sat
  1359.       $game_variables[WhiteSnow::DAY_STORE_VID] = 6
  1360.     end
  1361.    
  1362.     case $calender.month
  1363.     when 1..2
  1364.       $calender.season = :Winter
  1365.       $game_variables[WhiteSnow::SEASON_STORE_VID] = 3
  1366.     when 3..5
  1367.       $calender.season = :Spring
  1368.       $game_variables[WhiteSnow::SEASON_STORE_VID] = 0
  1369.     when 6..8
  1370.       $calender.season = :Summer
  1371.       $game_variables[WhiteSnow::SEASON_STORE_VID] = 1
  1372.     when 9..11
  1373.       $calender.season = :Autumn
  1374.       $game_variables[WhiteSnow::SEASON_STORE_VID] = 2
  1375.     when 12
  1376.       $calender.season = :Winter
  1377.       $game_variables[WhiteSnow::SEASON_STORE_VID] = 3
  1378.     end
  1379.     $calender.change_weather
  1380.   end
  1381.   #--------------------------------------------------------------------------
  1382.   # ● 年を設定
  1383.   #--------------------------------------------------------------------------
  1384.   def set_year(year)
  1385.     $calender.year = year
  1386.     $game_variables[WhiteSnow::YEAR_STORE_VID] = year
  1387.     $calender.change_weather
  1388.   end
  1389.   #--------------------------------------------------------------------------
  1390.   # ● 天候を設定
  1391.   #--------------------------------------------------------------------------
  1392.   def set_weather(weather)
  1393.     $calender.weather = weather
  1394.     $calender.randomize_weather_count
  1395.     $calender.perform_weather_effect
  1396.     case weather
  1397.     when :fine
  1398.       $game_variables[WhiteSnow::WEATHER_STORE_VID] = 0
  1399.     when :rain
  1400.       $game_variables[WhiteSnow::WEATHER_STORE_VID] = 1
  1401.     when :snow
  1402.       $game_variables[WhiteSnow::WEATHER_STORE_VID] = 2
  1403.     when :thunder
  1404.       $game_variables[WhiteSnow::WEATHER_STORE_VID] = 3
  1405.     when :storm
  1406.       $game_variables[WhiteSnow::WEATHER_STORE_VID] = 4
  1407.     when :star
  1408.       $game_variables[WhiteSnow::WEATHER_STORE_VID] = 5
  1409.     when :s_storm
  1410.       $game_variables[WhiteSnow::WEATHER_STORE_VID] = 6
  1411.     end
  1412.   end
  1413.   #--------------------------------------------------------------------------
  1414.   # ● 天候エフェクトを発生させる
  1415.   #--------------------------------------------------------------------------
  1416.   def perform_weather_effect
  1417.     $calender.perform_weather_effect
  1418.   end
  1419.   #--------------------------------------------------------------------------
  1420.   # ● 画面のフラッシュ(引数指定)
  1421.   #--------------------------------------------------------------------------
  1422.   def perform_flash(r, g, b, alpha, dur = 12)
  1423.     color = Color.new(r, g, b, alpha)
  1424.     screen.start_flash(color, dur)
  1425.   end
  1426.   #--------------------------------------------------------------------------
  1427.   # ● 日付を進める
  1428.   #--------------------------------------------------------------------------
  1429.   def shift_date(num)
  1430.     num.times{$calender.shift_date}
  1431.     $calender.change_weather
  1432.   end
  1433.   #--------------------------------------------------------------------------
  1434.   # ● 月を進める
  1435.   #--------------------------------------------------------------------------
  1436.   def shift_month(num)
  1437.     table = WhiteSnow::DAYS_TABLE
  1438.     days = table[$calender.month] - $calender.date + 1
  1439.     for i in 1..num
  1440.       days += table[($calender.month + i) % 12]
  1441.     end
  1442.     days.times{$calender.shift_date}
  1443.     $calender.change_weather
  1444.   end
  1445.   #--------------------------------------------------------------------------
  1446.   # ● 年を進める
  1447.   #--------------------------------------------------------------------------
  1448.   def shift_year(num)
  1449.     (num * 365).times{$calender.shift_date}
  1450.     $calender.change_weather
  1451.   end
  1452.   #--------------------------------------------------------------------------
  1453.   # ● 指定した日まで日付を進める
  1454.   #--------------------------------------------------------------------------
  1455.   def shift_date_to(m, d, y = -1)
  1456.     y = $calender.year if y == -1
  1457.     if $calender.days_dif(y, m, d) > 0
  1458.       $calender.days_dif(y, m, d).times{$calender.shift_date}
  1459.     else
  1460.       $calender.days_dif(y, m, d).abs.times{$calender.back_date}
  1461.     end
  1462.     $calender.change_weather
  1463.   end
  1464. end

  1465. #==============================================================================
  1466. # ■ SceneManager
  1467. #------------------------------------------------------------------------------
  1468. #  シーン遷移を管理するモジュールです。たとえばメインメニューからアイテム画面
  1469. # を呼び出し、また戻るというような階層構造を扱うことができます。
  1470. #==============================================================================

  1471. module SceneManager
  1472.   #--------------------------------------------------------------------------
  1473.   # ● エイリアス用特異メソッド
  1474.   #--------------------------------------------------------------------------
  1475.   class << self
  1476.     alias :calender_goto   :goto
  1477.     alias :calender_call   :call
  1478.     alias :calender_return :return
  1479.   end
  1480.   #--------------------------------------------------------------------------
  1481.   # ● 直接遷移
  1482.   #--------------------------------------------------------------------------
  1483.   def self.goto(scene_class)
  1484.     calender_goto(scene_class)
  1485.     if scene_class == Scene_Map
  1486.       $calender.perform_weather_effect
  1487.       $calender.change_tone_by_calender
  1488.     end
  1489.   end
  1490.   #--------------------------------------------------------------------------
  1491.   # ● 呼び出し
  1492.   #--------------------------------------------------------------------------
  1493.   def self.call(scene_class)
  1494.     calender_call(scene_class)
  1495.     if scene_class == Scene_Map
  1496.       $calender.perform_weather_effect
  1497.       $calender.change_tone_by_calender
  1498.     end
  1499.   end
  1500.   #--------------------------------------------------------------------------
  1501.   # ● 呼び出し元へ戻る
  1502.   #--------------------------------------------------------------------------
  1503.   def self.return
  1504.     calender_return
  1505.     if @scene.class == Scene_Map
  1506.       $calender.perform_weather_effect
  1507.       $calender.change_tone_by_calender
  1508.     end
  1509.   end
  1510. end

  1511. #==============================================================================
  1512. # ■ Game_Switches
  1513. #------------------------------------------------------------------------------
  1514. #  スイッチを扱うクラスです。組み込みクラス Array のラッパーです。このクラス
  1515. # のインスタンスは $game_switches で参照されます。
  1516. #==============================================================================

  1517. class Game_Switches
  1518.   #--------------------------------------------------------------------------
  1519.   # ● スイッチの設定 (再定義)
  1520.   #     value : ON (true) / OFF (false)
  1521.   #--------------------------------------------------------------------------
  1522.   def []=(switch_id, value)
  1523.     @data[switch_id] = value
  1524.     on_change
  1525.     if switch_id == WhiteSnow::TONE_CHANGE_FORBID_SID or switch_id == WhiteSnow::INSIDE_FLAG_SID
  1526.       case value
  1527.       when true
  1528.         $calender.interpreter.change_tone(0, 0, 0, 0, 0)
  1529.       when false
  1530.         $calender.change_tone_by_calender(0)
  1531.       end
  1532.     end
  1533.     if switch_id == WhiteSnow::WEATHER_EFFECT_FORBID_SID or switch_id == WhiteSnow::INSIDE_FLAG_SID
  1534.       case value
  1535.       when true
  1536.         $calender.interpreter.change_weather(:none, 0, 0)
  1537.         RPG::BGS.stop if (WhiteSnow::WEATHER_BGS_ENABLE and [0, 1].include?(WhiteSnow::INSIDE_BGS_TYPE)) or $game_switches[WhiteSnow::WEATHER_BGS_DISABLE]
  1538.         $calender.play_inside_bgs if WhiteSnow::WEATHER_BGS_ENABLE and WhiteSnow::INSIDE_BGS_TYPE == 1 and !$game_switches[WhiteSnow::WEATHER_BGS_DISABLE]
  1539.       when false
  1540.         $calender.perform_weather_effect(0)
  1541.       end
  1542.     end
  1543.   end
  1544. end

  1545. #==============================================================================
  1546. # ■ Game_Player
  1547. #------------------------------------------------------------------------------
  1548. #  プレイヤーを扱うクラスです。イベントの起動判定や、マップのスクロールなどの
  1549. # 機能を持っています。このクラスのインスタンスは $game_player で参照されます。
  1550. #==============================================================================

  1551. class Game_Player
  1552.   #--------------------------------------------------------------------------
  1553.   # ● 場所移動の実行
  1554.   #--------------------------------------------------------------------------
  1555.   alias calender_perform_transfer perform_transfer
  1556.   def perform_transfer
  1557.     if transfer?
  1558.       $calender.perform_weather_effect(0)
  1559.       $calender.change_tone_by_calender(0)
  1560.     end
  1561.     calender_perform_transfer
  1562.   end
  1563. end

  1564. #==============================================================================
  1565. # ■ RPG::Map
  1566. #------------------------------------------------------------------------------
  1567. #  マップのデータクラスです。
  1568. #==============================================================================

  1569. class RPG::Map
  1570.   #--------------------------------------------------------------------------
  1571.   # ● マップBGM
  1572.   #--------------------------------------------------------------------------
  1573.   def bgm
  1574.     bgm = Hash.new(@bgm)
  1575.     @note.each_line do |line|
  1576.       case line
  1577.       when /<(?:早朝|early)\s*(.+)\s*\,\s*(\d+)\s*\,\s*(\d+)>/
  1578.         bgm[:early_morning] = RPG::BGM.new($1, $2.to_i, $3.to_i)
  1579.       when /<(?:朝|morning)\s*(.+)\s*\,\s*(\d+)\s*\,\s*(\d+)>/
  1580.         bgm[:morning] = RPG::BGM.new($1, $2.to_i, $3.to_i)
  1581.       when /<(?:昼|noon)\s*(.+)\s*\,\s*(\d+)\s*\,\s*(\d+)>/
  1582.         bgm[:noon] = RPG::BGM.new($1, $2.to_i, $3.to_i)
  1583.       when /<(?:夕方|evening)\s*(.+)\s*\,\s*(\d+)\s*\,\s*(\d+)>/
  1584.         bgm[:evening] = RPG::BGM.new($1, $2.to_i, $3.to_i)
  1585.       when /<(?:夜|night)\s*(.+)\s*\,\s*(\d+)\s*\,\s*(\d+)>/
  1586.         bgm[:night] = RPG::BGM.new($1, $2.to_i, $3.to_i)
  1587.       when /<(?:深夜|mid)\s*(.+)\s*\,\s*(\d+)\s*\,\s*(\d+)>/
  1588.         bgm[:midnight] = RPG::BGM.new($1, $2.to_i, $3.to_i)
  1589.       end
  1590.     end
  1591.     return bgm
  1592.   end
  1593. end

  1594. #==============================================================================
  1595. # ■ Game_Map
  1596. #------------------------------------------------------------------------------
  1597. #  マップを扱うクラスです。スクロールや通行可能判定などの機能を持っています。
  1598. # このクラスのインスタンスは $game_map で参照されます。
  1599. #==============================================================================

  1600. class Game_Map
  1601.   #--------------------------------------------------------------------------
  1602.   # ● BGM / BGS 自動切り替え (再定義)
  1603.   #--------------------------------------------------------------------------
  1604.   def autoplay
  1605.     case $calender.time_zone
  1606.     when :early_morning
  1607.       @map.bgm[:early_morning].play if @map.autoplay_bgm
  1608.     when :morning
  1609.       @map.bgm[:morning].play if @map.autoplay_bgm
  1610.     when :noon
  1611.       @map.bgm[:noon].play if @map.autoplay_bgm
  1612.     when :evening
  1613.       @map.bgm[:evening].play if @map.autoplay_bgm
  1614.     when :night
  1615.       @map.bgm[:night].play if @map.autoplay_bgm
  1616.     when :midnight
  1617.       @map.bgm[:midnight].play if @map.autoplay_bgm
  1618.     end
  1619.     @map.bgs.play if @map.autoplay_bgs
  1620.   end
  1621. end

  1622. module Kernel
  1623.   #--------------------------------------------------------------------------
  1624.   # ● 重み付きの乱数を生成
  1625.   #--------------------------------------------------------------------------
  1626.   def p_ex_rand(rate, n = 0)
  1627.     srand
  1628.     rate = 99 if rate == 100
  1629.     if n == 0
  1630.       r = 1 - rand ** (1 - rate * 0.01)
  1631.       if r == 1
  1632.         return 0
  1633.       else
  1634.         return r
  1635.       end
  1636.     else
  1637.       num = n.truncate
  1638.       r = 1 - rand ** (1 - rate * 0.01)
  1639.       r = 0 if r == 1
  1640.       return (r * num).floor
  1641.     end
  1642.   end
  1643. end
复制代码
  
您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部