Project1

标题: 灼眼的夏娜的时间系统,求修改 [打印本页]

作者: 叉叉    时间: 2009-12-21 12:38
标题: 灼眼的夏娜的时间系统,求修改
以下是翻到的内容,但是我想把季节、时间等代入变量。
本来想使用那个超自定义的……
可是我的游戏不需要那么麻烦,有星啊什么的……
可不可以用变量调以下脚本的时间?
比如某商店只在晚上开
  1. #==============================================================================
  2. # ■ Date模块
  3. #------------------------------------------------------------------------------
  4. #  时间日期系统模块
  5. #==============================================================================
  6. module Date
  7. #============================================================================
  8. # ● 常量设定
  9. #============================================================================

  10. RATE = Graphics.frame_rate#(可自行设置次值,但不能大于Graphics.frame_rate值)

  11. #============================================================================
  12. # ■ 1、更新画面色调
  13. #============================================================================
  14. def Date.change_screen_tone
  15.    case $game_map.date_season
  16.    when 1
  17.      if $game_map.date_hour <= 7
  18.        $game_screen.start_tone_change($bright_cq7, 420*Date::RATE)
  19.      elsif $game_map.date_hour > 7 && $game_map.date_hour <= 12
  20.        $game_screen.start_tone_change($bright_cq12, 300*Date::RATE)
  21.      elsif $game_map.date_hour > 12 && $game_map.date_hour <= 19
  22.        $game_screen.start_tone_change($bright_cq7, 420*Date::RATE)
  23.      else
  24.        $game_screen.start_tone_change($bright_cq0, 300*Date::RATE)
  25.      end
  26.    when 2
  27.      if $game_map.date_hour <= 6
  28.         $game_screen.start_tone_change($bright_x6, 360*Date::RATE)
  29.      elsif $game_map.date_hour > 6 && $game_map.date_hour <=14
  30.         $game_screen.start_tone_change($bright_x14, 480*Date::RATE)
  31.      elsif $game_map.date_hour > 14 && $game_map.date_hour <=19
  32.         $game_screen.start_tone_change($bright_x19, 300*Date::RATE)
  33.      elsif $game_map.date_hour > 19 && $game_map.date_hour <=21
  34.         $game_screen.start_tone_change($bright_x21, 120*Date::RATE)
  35.      else
  36.         $game_screen.start_tone_change($bright_x0, 180*Date::RATE)
  37.      end
  38.    when 3
  39.      if $game_map.date_hour <= 7
  40.        $game_screen.start_tone_change($bright_cq7, 420*Date::RATE)
  41.      elsif $game_map.date_hour > 7 && $game_map.date_hour <= 12
  42.        $game_screen.start_tone_change($bright_cq12, 300*Date::RATE)
  43.      elsif $game_map.date_hour > 12 && $game_map.date_hour <= 19
  44.        $game_screen.start_tone_change($bright_cq7, 420*Date::RATE)
  45.      else
  46.        $game_screen.start_tone_change($bright_cq0, 300*Date::RATE)
  47.      end
  48.    when 4
  49.      if $game_map.date_hour <= 8
  50.         $game_screen.start_tone_change($bright_d8, 480*Date::RATE)
  51.      elsif $game_map.date_hour > 8 && $game_map.date_hour <=12
  52.         $game_screen.start_tone_change($bright_d12, 240*Date::RATE)
  53.      elsif $game_map.date_hour > 12 && $game_map.date_hour <=18
  54.         $game_screen.start_tone_change($bright_d18, 360*Date::RATE)
  55.      else
  56.         $game_screen.start_tone_change($bright_d0, 360*Date::RATE)
  57.      end
  58.    end
  59. end
  60. #============================================================================
  61. # ■ 2、时间系统的运作
  62. #============================================================================
  63. def Date.run_date_system
  64.    if Graphics.frame_count%Date::RATE == 0
  65.      $game_map.date_minute += 1
  66.    end
  67.    if $game_map.date_minute >= 60
  68.      $game_map.date_minute = 0
  69.      $game_map.date_hour += 1
  70.    end
  71.    if $game_map.date_hour >= 24
  72.      $game_map.date_hour = 0
  73.      $game_map.date_day += 1
  74.      $game_map.date_week += 1
  75.    end
  76.    if $game_map.date_week >= 8
  77.      $game_map.date_week = 1
  78.    end
  79.    if $game_map.date_day > $game_map.every_month_days[$game_map.date_season-1]
  80.      $game_map.date_day = 1
  81.      $game_map.date_season += 1
  82.    end
  83.    if $game_map.date_season >= 5
  84.      $game_map.date_season = 1
  85.    end
  86. end
  87. #============================================================================
  88. # ■ 3、各种天气系统
  89. #============================================================================
  90. def Date.rand_weather_type
  91.    if $game_map.date_season == 1   
  92.      Date.judge_weather1(12,15,50)
  93.      if $game_map.date_day<=10
  94.        Date.judge_weather2(15,15,20)
  95.      end
  96.    elsif $game_map.date_season == 2
  97.      Date.judge_weather1(10,30,60)
  98.      Date.judge_weather2(10,25,0)
  99.    elsif $game_map.date_season == 3
  100.      Date.judge_weather1(12,15,50)
  101.      if $game_map.date_day>=20
  102.        Date.judge_weather2(15,15,20)
  103.      end
  104.    elsif $game_map.date_season == 4
  105.      Date.judge_weather1(8,8,20)
  106.      Date.judge_weather2(10,25,40)
  107.    end
  108. end
  109. # 雨
  110. def Date.judge_weather1(wait,pp,rate=30)
  111.    # 等待时间为零,清楚天气效果
  112.    if $game_map.waittime[0] == 0
  113.      $game_map.weather1[1] = 0
  114.      $game_map.weather1[0] = false
  115.      $game_system.bgs_restore
  116.    elsif $game_map.waittime[0]<=5
  117.      $game_system.bgs_fade(Integer(5*Date::RATE/Graphics.frame_rate))
  118.    end
  119.    # 等待时间不为零,则递减
  120.    if $game_map.waittime[0] > 0
  121.      if Graphics.frame_count%Date::RATE == 0
  122.        $game_map.waittime[0] -= 1
  123.      end
  124.      return
  125.    end
  126.    # 天气判断
  127.    if $game_map.weather1[0] == false
  128.      $game_map.waittime[0] = (wait+rand(wait))*60
  129.      if rand(100)<rate
  130.        $game_system.bgs_memorize
  131.        Audio.bgs_fade(1)
  132.        if pp>=30
  133.          name = "007-Rain03"
  134.          volume = 80
  135.        else
  136.          name = "005-Rain01"
  137.          volume = 60
  138.        end
  139.        Audio.bgs_play("Audio/BGS/" + name, volume, 50)
  140.        $game_map.weather1[0] = true
  141.        $game_map.weather1[1] = 1
  142.        $game_map.weather1[2] = pp + rand(40-pp)
  143.        return
  144.      end
  145.      $game_map.waittime[0] *= (100-rate)
  146.      $game_map.waittime[0] = Integer($game_map.waittime[0]/100)
  147.    end
  148. end
  149. # 雪
  150. def Date.judge_weather2(wait,pp,rate=30)
  151.    # 等待时间为零,清楚天气效果
  152.    if $game_map.waittime[1] == 0
  153.      $game_map.weather2[1] = 0
  154.      $game_map.weather2[0] = false
  155.    end
  156.    # 等待时间不为零,则递减
  157.    if $game_map.waittime[1] > 0
  158.      if Graphics.frame_count%Date::RATE == 0
  159.        $game_map.waittime[1] -= 1
  160.      end
  161.      return
  162.    end
  163.    # 天气判断
  164.    if $game_map.weather2[0] == false
  165.      $game_map.waittime[1] = (wait+rand(wait))*60
  166.      if rand(100)<rate
  167.        $game_map.weather2[0] = true
  168.        $game_map.weather2[1] = 3
  169.        $game_map.weather2[2] = pp + rand(40-pp)
  170.        return
  171.      end
  172.      $game_map.waittime[1] *= (100-rate)
  173.      $game_map.waittime[1] = Integer($game_map.waittime[1]/100)
  174.    end
  175. end  
  176. end

  177. class Spriteset_Map
  178. # 初始化第二天气效果
  179. alias initialize_old initialize
  180. def initialize
  181.    initialize_old
  182.    @weather1 = RPG::Weather.new(Viewport.new(0, 0, 640, 480))
  183.    @weather2 = RPG::Weather.new(Viewport.new(0, 0, 640, 480))
  184.    update
  185. end
  186. # 释放第二天气效果
  187. alias dispose_old dispose
  188. def dispose
  189.    if @weahter1 != nil
  190.      @weather1.dispose
  191.    end
  192.    if @weahter2 != nil
  193.      @weather2.dispose
  194.    end
  195.    dispose_old
  196. end
  197. # 更新第二天气效果
  198. alias update_old update
  199. def update
  200.    if @weather1 != nil
  201.      @weather1.type = $game_map.weather1[1]
  202.      @weather1.max = $game_map.weather1[2]
  203.      @weather1.update
  204.    end
  205.    if @weather2 != nil
  206.      @weather2.type = $game_map.weather2[1]
  207.      @weather2.max = $game_map.weather2[2]
  208.      @weather2.update
  209.    end
  210.    update_old
  211. end
  212. end

  213. class Interpreter
  214. def odw
  215.    $game_map.date_system_window_on_or_off = true
  216.    return
  217. end
  218. def cdw
  219.    $game_map.date_system_window_on_or_off = false
  220.    return
  221. end
  222. end
  223. #==============================================================================
  224. # ■ Window_TimeDate
  225. #------------------------------------------------------------------------------
  226. #  时间日期系统窗口
  227. #==============================================================================

  228. class Window_TimeDate < Window_Base
  229. #--------------------------------------------------------------------------
  230. # ● 初始化对像
  231. #--------------------------------------------------------------------------
  232. def initialize
  233.    super(0, 0, 228, 86)
  234.    self.contents = Bitmap.new(width - 32, height - 32)
  235.    self.opacity = 0
  236.    refresh
  237. end
  238. #--------------------------------------------------------------------------
  239. # ● 刷新
  240. #--------------------------------------------------------------------------
  241. def refresh
  242.    self.contents.clear
  243.    @fen_timedate = $game_map.date_minute  # 此变量用于刷新 画面
  244.    # 描绘 季节
  245.    if $game_map.date_season == 2
  246.      seasoncolor = Color.new(250,80,5)
  247.      wordj = "夏"
  248.    elsif $game_map.date_season == 4
  249.      seasoncolor = Color.new(150,170,250)
  250.      wordj = "冬"
  251.    elsif $game_map.date_season == 1
  252.      seasoncolor = Color.new(5,255,50)
  253.      wordj = "春"
  254.    else
  255.      seasoncolor = Color.new(228,208,38)
  256.      wordj = "秋"
  257.    end
  258.    self.contents.font.size = 52
  259.    self.contents.font.name = ["楷体_GB2312","黑体"]
  260.    self.contents.font.color = seasoncolor
  261.    self.contents.draw_text(0, 0, 52, 52, wordj)
  262.    # 描绘 号数
  263.    self.contents.font.size = 42     
  264.    self.contents.font.name = ["楷体_GB2312","黑体"]
  265.    self.contents.draw_text(56,10, 84, 42,$game_map.date_day.to_s)
  266.    # 描绘 星期
  267.    case $game_map.date_week
  268.    when 1
  269.      self.contents.font.color = Color.new(170,170,170,255)
  270.      wordx = "月"
  271.    when 2
  272.      self.contents.font.color = Color.new(50,100,240,255)
  273.      wordx = "火"
  274.    when 3
  275.      self.contents.font.color = Color.new(227,59,13,255)
  276.      wordx = "水"
  277.    when 4
  278.      self.contents.font.color = Color.new(74,4,4,255)
  279.      wordx = "木"
  280.    when 5
  281.      self.contents.font.color = Color.new(228,231,10,255)
  282.      wordx = "金"
  283.    when 6
  284.      self.contents.font.color = Color.new(155,50,36,255)
  285.      wordx = "土"
  286.    when 7
  287.      self.contents.font.color = Color.new(55,244,246,255)
  288.      wordx = "日"
  289.    end
  290.    self.contents.font.size = 24
  291.    self.contents.font.name = ["楷体_GB2312","黑体"]
  292.    self.contents.draw_text(112, 22, 128, 32, wordx)
  293.    self.contents.font.color = Color.new(0,0,0,255)
  294.    self.contents.draw_text(112+24, 22, 128, 32, "曜日")
  295.      
  296.    self.contents.font.size = 24
  297.    self.contents.font.color = Color.new(0,0,0,255)
  298.    # 描绘 时间
  299.    tt = sprintf("%2d点%2d分", $game_map.date_hour,$game_map.date_minute)
  300.    self.contents.draw_text(100, 0, 128, 32, tt)
  301. end

  302. def update
  303.    super
  304.    # 刷新窗口
  305.    if @fen_timedate != $game_map.date_minute
  306.      refresh
  307.    end
  308. end  
  309. end

  310. class Game_Temp
  311. #    春天 和 秋天
  312. # 分 0 - 7 点钟; 7 - 12 点; 12 - 7点; 7 - 0点;
  313. $bright_cq7 = Tone.new(-40, -40, -40, 0)
  314. $bright_cq12 = Tone.new(0, 0, 0, 0)
  315. $bright_cq19 = Tone.new(-40, -40, -40, 0)
  316. $bright_cq0 = Tone.new(-110, -110, -110, 0)
  317. #     夏天
  318. # 分 0 - 6 点; 6 - 14 点; 14 - 21 点; 21 - 0点
  319. $bright_x6 = Tone.new(-40, -40, -40, 0)
  320. $bright_x14 = Tone.new(30, 30, 30, 0)
  321. $bright_x19 = Tone.new(20, 0, 0, 0)
  322. $bright_x21 = Tone.new(-60, -60, -60, 0)
  323. $bright_x0 = Tone.new(-110, -110, -110, 0)
  324. #     冬天
  325. # 分 0 - 8 点;8 - 12 点; 12 - 6 点 ; 6 - 0点
  326. $bright_d8 = Tone.new(-45, -45, -45, 0)
  327. $bright_d12 = Tone.new(-10, -10, -10, 0)
  328. $bright_d18 = Tone.new(-45, -45, -45, 0)
  329. $bright_d0 = Tone.new(-115, -115, -115, 0)
  330. end

  331. class Game_Screen
  332. alias initialize_old initialize
  333. def initialize
  334.    initialize_old
  335.    @tone = $bright_cq7
  336. end
  337. end

  338. class Game_Map
  339. attr_accessor :date_minute
  340. attr_accessor :date_hour
  341. attr_accessor :date_day
  342. attr_accessor :date_week
  343. attr_accessor :date_season
  344. attr_reader   :every_month_days
  345. attr_accessor :date_system_window_on_or_off
  346. attr_accessor :weather1
  347. attr_accessor :weather2
  348. attr_accessor :waittime
  349. def initialize
  350.    @date_minute = 50
  351.    @date_hour = 7
  352.    @date_day = 25
  353.    @date_week = 5
  354.    @date_season = 4
  355.    @every_month_days = [31,31,30,28]
  356.    @date_system_window_on_or_off = true
  357.    @weather1 = [false,0,0]
  358.    @weather2 = [false,0,0]
  359.    @waittime = [0,0]
  360. end
  361. end

  362. class Scene_Map
  363. # 主处理
  364. alias main_old main
  365. def main
  366.    @tt = Window_TimeDate.new
  367.    if $game_map.date_system_window_on_or_off == false
  368.      @tt.visible = false
  369.    end
  370.    main_old
  371.    @tt.dispose
  372. end
  373. # 更新
  374. alias update_old update
  375. def update
  376.    @tt.visible = $game_map.date_system_window_on_or_off
  377.    #----------------------
  378.    Date.change_screen_tone
  379.    Date.run_date_system
  380.    Date.rand_weather_type
  381.    #----------------------
  382.    @tt.update
  383.    update_old
  384. end
  385. end

复制代码





欢迎光临 Project1 (https://rpg.blue/) Powered by Discuz! X3.1