赞 | 6 |
VIP | 1 |
好人卡 | 14 |
积分 | 7 |
经验 | 2666 |
最后登录 | 2018-6-28 |
在线时间 | 215 小时 |
Lv2.观梦者 仙木精灵
- 梦石
- 0
- 星屑
- 651
- 在线时间
- 215 小时
- 注册时间
- 2012-4-16
- 帖子
- 502
|
- #==============================================================================
- # ■ 日期時間顯示腳本
- # by 414447674
- #------------------------------------------------------------------------------
- # 在Main的上方插入一個頁,將本腳本複製到那頁中即可
- #==============================================================================
- #==============================================================================
- # ■ Window_Time
- #------------------------------------------------------------------------------
- # 顯示日期時間的視窗。
- #==============================================================================
- class Window_Time < Window_Base
- #--------------------------------------------------------------------------
- # ● 類常量定義
- #--------------------------------------------------------------------------
- # 日期、時間的變數
- $v_year = 1 #年份
- $v_month = 2 #月份
- $v_day = 3 #日期
- $v_hour = 4 #小時
- $v_min = 5 #分鐘
- $v_sec = 6 #秒鐘
- $v_battle_sec = 7 #戰鬥時遺留的時間
- $v_week = 8 #今天的星期數
-
- # 正常時是否顯示時間的開關
- $normal_switch = 1
-
- # 戰鬥時是否顯示時間的開關
- $battle_switch = 2
-
- # 開始時間流動的開關
- $start_time = 3
-
- # 戰鬥時時間是否流動的開關
- $battle_time = 4
-
- # 戰鬥時時間流動是正常的多少分之一
- $battle_flow_time = 60
-
- # 現實中一秒等於游戲裏的多少分鐘
- $min = 1
- # 常規設定
- $month = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
- $week_day_name = ["星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"]
- $start_date = [2012, 1, 1, 0, 0, 0, 0]
- # 起始時間 [年份, 月份, 日期, 小時, 分鐘, 秒鐘, 第一天星期幾]
-
- # 窗口位置設定
- NAME_X = 0 # 矩形左上頂點X座標
- NAME_Y = 0 # 矩形左上頂點Y座標
- NAME_W = 280 # 矩形寬
- NAME_H = 60 # 矩形高
-
- # 完全可見時的透明度設置
- OPACITY_1 = 244 # 邊框
- OPACITY_2 = 100 # 背景
- OPACITY_3 = 255 # 文字
-
- # 日曆的顏色
- TEXT_COLOR = Color.new(255, 255, 255, 255)
-
- #--------------------------------------------------------------------------
- # ● 初始化狀態
- #--------------------------------------------------------------------------
- def initialize
- super(NAME_X , NAME_Y, NAME_W, NAME_H)
- # 初始化窗口透明度
- self.opacity = 0
- self.back_opacity = 0
- self.z = 9999
- self.contents_opacity = 0
- self.contents = Bitmap.new(width - 32, height - 32)
- end
- #--------------------------------------------------------------------------
- # ● 輸出時間
- #--------------------------------------------------------------------------
- def settime(in_battle = false, see = true)
- self.contents.clear
- self.contents.font.color = TEXT_COLOR
- text = sprintf("%4d/%2d/%2d (", $game_variables[$v_year], $game_variables[$v_month], $game_variables[$v_day])
- text += $week_day_name[$game_variables[$v_week]]
- text += sprintf(") %02d:%02d", $game_variables[$v_hour], $game_variables[$v_min])
- if in_battle
- text += sprintf(":%02d", $game_variables[$v_sec])
- end
- # 描繪時間
- self.contents.draw_text(4, 0 , width - 40, 32, text, 1)
- # 窗口透明度
- if see
- self.opacity = OPACITY_1
- self.back_opacity = OPACITY_2
- self.contents_opacity = OPACITY_3
- else
- self.opacity = 0
- self.back_opacity = 0
- self.contents_opacity = 0
- end
- end
- end
- #==============================================================================
- # ■ Scene_Map
- #------------------------------------------------------------------------------
- # 處理地圖畫面的類。(追加定義)
- #==============================================================================
- class Scene_Map
-
- def date_refresh
- if $game_variables[$v_day] > $month[$game_variables[$v_month]] and $game_variables[$v_month] != 2
- $game_variables[$v_day] -= $month[$game_variables[$v_month]]
- $game_variables[$v_month] += 1
- elsif (($game_variables[$v_year] % 4 == 0 and $game_variables[$v_year] % 100 != 0) or $game_variables[$v_year] % 400 == 0) and $game_variables[$v_month] == 2 and $game_variables[$v_day] > 29
- $game_variables[$v_day] -= 29
- $game_variables[$v_month] = 3
- elsif ($game_variables[$v_year] % 4 != 0 or ($game_variables[$v_year] % 100 == 0 and $game_variables[$v_year] % 400 != 0)) and $game_variables[$v_month] == 2 and $game_variables[$v_day] > 28
- $game_variables[$v_day] -= 28
- $game_variables[$v_month] = 3
- end
- if $game_variables[$v_month] > 12
- $game_variables[$v_month] -= 12
- $game_variables[$v_year] += 1
- end
- if $game_variables[$v_day] < 0 and $game_variables[$v_month - 1] != 2
- $game_variables[$v_day] += $month[$game_variables[$v_month - 1]]
- $game_variables[$v_month] -= 1
- elsif (($game_variables[$v_year] % 4 == 0 and $game_variables[$v_year] % 100 != 0) or $game_variables[$v_year] % 400 == 0) and $game_variables[$v_month - 1] == 2 and $game_variables[$v_day] < 0
- $game_variables[$v_day] += 29
- $game_variables[$v_month] = 2
- elsif ($game_variables[$v_year] % 4 != 0 or ($game_variables[$v_year] % 100 == 0 and $game_variables[$v_year] % 400 != 0)) and $game_variables[$v_month - 1] == 2 and $game_variables[$v_day] < 0
- $game_variables[$v_day] += 28
- $game_variables[$v_month] = 2
- end
- if $game_variables[$v_month] < 0
- $game_variables[$v_month] += 12
- $game_variables[$v_year] -= 1
- end
- end
-
- def time_refresh
- while $game_variables[$v_sec] >= 60
- $game_variables[$v_sec] -= 60
- $game_variables[$v_min] += 1
- end
- while $game_variables[$v_min] >= 60
- $game_variables[$v_min] -= 60
- $game_variables[$v_hour] += 1
- end
- while $game_variables[$v_hour] >= 24
- $game_variables[$v_hour] -= 24
- $game_variables[$v_day] += 1
- $game_variables[$v_week] += 1
- $game_variables[$v_week] %= 7
- date_refresh
- end
- while $game_variables[$v_sec] < 0
- $game_variables[$v_sec] += 60
- $game_variables[$v_min] -= 1
- end
- while $game_variables[$v_min] < 0
- $game_variables[$v_min] += 60
- $game_variables[$v_hour] -= 1
- end
- while $game_variables[$v_hour] < 0
- $game_variables[$v_hour] += 24
- $game_variables[$v_day] -= 1
- $game_variables[$v_week] -= 1
- $game_variables[$v_week] += 7 if $game_variables[$v_week] < 0
- date_refresh
- end
- end
-
- alias day_start start
- def start
- @time = Window_Time.new
- day_start
- end
-
- alias day_dispose terminate
- def terminate
- day_dispose
- @time.dispose
- end
-
- alias day_update update
- def update
- day_update
- if $game_switches[$start_time]
- $game_variables[$v_sec] += $min
- if $game_variables[$v_sec] >= 60
- time_refresh
- end
- end
- if $game_switches[$normal_switch]
- @time.settime
- else
- @time.settime(false, false)
- end
- end
- end
- #==============================================================================
- # ** Scene_Title
- #------------------------------------------------------------------------------
- # 這個類用來執行顯示標題畫面的程式。(追加定義)
- #==============================================================================
- class Scene_Title < Scene_Base
-
- alias new_game command_new_game
- def command_new_game
- new_game
- $game_variables[$v_year] = $start_date[0]
- $game_variables[$v_month] = $start_date[1]
- $game_variables[$v_day] = $start_date[2]
- $game_variables[$v_hour] = $start_date[3]
- $game_variables[$v_min] = $start_date[4]
- $game_variables[$v_sec] = $start_date[5]
- $game_variables[$v_week] = $start_date[6]
- end
- end
- #==============================================================================
- # ** Scene_Battle
- #------------------------------------------------------------------------------
- # 這個類用來執行顯示作戰畫面的程式。(追加定義)
- #==============================================================================
- class Scene_Battle < Scene_Base
-
- alias day_start start
- def start
- @time = Window_Time.new
- day_start
- end
-
- alias day_update update_basic
- def update_basic(main = false)
- day_update(main)
- if $game_switches[$battle_time]
- $game_variables[$v_battle_sec] += $min
- if $game_variables[$v_battle_sec] >= $battle_flow_time
- @time2 = Scene_Map.new
- $game_variables[$v_battle_sec] -= $battle_flow_time
- $game_variables[$v_sec] += 1
- if $game_variables[$v_sec] >= 60
- @time2.time_refresh
- end
- end
- end
- if $game_switches[$battle_switch]
- @time.settime(true)
- else
- @time.settime(true, false)
- end
- end
- alias day_terminate terminate
- def terminate
- @time.dispose
- day_terminate
- end
- end
- #==============================================================================
- # ** Scene_File
- #------------------------------------------------------------------------------
- # 這個類用來執行顯示存取進度畫面的程式。(追加定義)
- #==============================================================================
- class Scene_File < Scene_Base
- def write_save_data(file)
- characters = []
- for actor in $game_party.members
- characters.push([actor.character_name, actor.character_index])
- end
- $game_system.save_count += 1
- $game_system.version_id = $data_system.version_id
- @last_bgm = RPG::BGM::last
- @last_bgs = RPG::BGS::last
- Marshal.dump(characters, file)
- Marshal.dump(Graphics.frame_count, file)
- Marshal.dump(@last_bgm, file)
- Marshal.dump(@last_bgs, file)
- Marshal.dump($game_system, file)
- Marshal.dump($game_message, file)
- Marshal.dump($game_switches, file)
- Marshal.dump($game_variables, file)
- Marshal.dump($game_self_switches, file)
- Marshal.dump($game_actors, file)
- Marshal.dump($game_party, file)
- Marshal.dump($game_troop, file)
- Marshal.dump($game_map, file)
- Marshal.dump($game_player, file)
- Marshal.dump($min, file)
- end
- def read_save_data(file)
- characters = Marshal.load(file)
- Graphics.frame_count = Marshal.load(file)
- @last_bgm = Marshal.load(file)
- @last_bgs = Marshal.load(file)
- $game_system = Marshal.load(file)
- $game_message = Marshal.load(file)
- $game_switches = Marshal.load(file)
- $game_variables = Marshal.load(file)
- $game_self_switches = Marshal.load(file)
- $game_actors = Marshal.load(file)
- $game_party = Marshal.load(file)
- $game_troop = Marshal.load(file)
- $game_map = Marshal.load(file)
- $game_player = Marshal.load(file)
- $min = Marshal.load(file)
- if $game_system.version_id != $data_system.version_id
- $game_map.setup($game_map.map_id)
- $game_player.center($game_player.x, $game_player.y)
- end
- end
- end
- #==============================================================================
- # ** Game_Interpreter
- #------------------------------------------------------------------------------
- # 這個類是用來執行事件指令的直譯器。
- # 這個類作為 Game_Map、Game_Troop 和 Game_Event 的內部類使用。(追加定義)
- #==============================================================================
- class Game_Interpreter
- def change_time(year, month, day, hour, min, sec)
- $game_variables[$v_year] += year
- $game_variables[$v_month] += month
- $game_variables[$v_day] += day
- $game_variables[$v_hour] += hour
- $game_variables[$v_min] += min
- $game_variables[$v_sec] += sec
- @time = Scene_Map.new
- @time.time_refresh
- end
- end
复制代码 |
|