查看: 3518|回复: 4

[有事请教] 如何让每小时变量+1

[复制链接]
梦石
0
星屑
110
在线时间
85 小时
注册时间
2010-8-19
回帖
98
发表于 2020-2-1 02:13:01 | 显示全部楼层 |阅读模式

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

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

×
我想做一个类似于年龄的功能,希望游戏时间每过一个小时,变量就加1。有什么办法实现,最好是不要用到计时器,因为计时器我想再其他地方用,谢谢!
梦石
0
星屑
3930
在线时间
1198 小时
注册时间
2016-8-9
回帖
2355

开拓者

发表于 2020-2-1 04:04:19 | 显示全部楼层
本帖最后由 白嫩白嫩的 于 2020-2-1 04:11 编辑

【二】【获取真实世界时间以及放置游戏必备的挂机产生资源系统】

这是小时:

fun();function fun() {var d=new Date(); var thour=d.getHours(); return thour ; }   

把这行代码带入变量

根据这个变量的变化计算另一个变量的增加
酸酸甜甜就④哇噢
回复

使用道具 举报

梦石
0
星屑
22879
在线时间
8598 小时
注册时间
2011-12-31
回帖
3270
发表于 2020-2-1 08:15:01 | 显示全部楼层
本帖最后由 tseyik 于 2020-2-1 09:13 编辑

大多数時間挿件
都有獲取時間
* 実時間連動機能と併せて使用することもできます。
* スイッチの場合はIDを、セルフスイッチの場合は種類(A,B,C,D)を指定します。
*
* C_SET_SWITCH_TIMER [分] [スイッチID] [ループ]
* 指定例(ゲーム内時間で30分経過後する度にスイッチ[10]をONにする)
* C_SET_SWITCH_TIMER 30 10 ON
*
* C_SET_SELF_SWITCH_TIMER [分] [セルフスイッチ種類] [ループ]
* 指定例(ゲーム内時間で3時間過後にセルフスイッチ[B](※)をONにする)
* C_SET_SELF_SWITCH_TIMER 180 B OFF
* ※対象イベントはプラグインコマンドを実行したイベントです。
*
* 途中で解除や一時停止する可能性がある場合は[タイマー名]を指定するコマンドを
* 実行してください。解除などの際にタイマー名を指定する必要があるためです。
*
* C_SET_SWITCH_NAMED_TIMER [タイマー名] [分] [スイッチID] [ループ]
* 指定例(ゲーム内時間で30分経過後する度にスイッチ[10]をONにする)
* C_SET_SWITCH_NAMED_TIMER timer 30 10 ON
*
* C_SET_SELF_SWITCH_NAMED_TIMER [タイマー名] [分] [セルフスイッチ種類] [ループ]
* 指定例(ゲーム内時間で3時間過後にセルフスイッチ[B](※)をONにする)
* C_SET_SELF_SWITCH_NAMED_TIMER timer 180 B OFF
* ※対象イベントはプラグインコマンドを実行したイベントです。
*
*可以與實時聯鎖功能結合使用。
*對於切換,請指定ID;對於自動切換,請指定類型(A,B,C,D)。
*
* C_SET_SWITCH_TIMER [分鐘] [開關ID] [循環]
*規格示例(遊戲時間每過30分鐘,開關[10]打開一次)
* C_SET_SWITCH_TIMER 30 10開啟
*
* C_SET_SELF_SWITCH_TIMER [分鐘] [自切換類型] [循環]
*規格示例(遊戲時間3小時後打開自動開關[B](*))
* C_SET_SELF_SWITCH_TIMER 180 B關
* *目標事件是執行插件命令的事件。
*
*如果中間有可能取消或暫停,請使用命令指定[定時器名稱]。
*請這樣做。這是因為釋放時必須指定計時器名稱。
*
* C_SET_SWITCH_NAMED_TIMER [計時器名稱] [分鐘] [開關ID] [循環]
*規格示例(遊戲時間每過30分鐘,開關[10]打開一次)
* C_SET_SWITCH_NAMED_TIMER計時器30 10 ON
*
* C_SET_SELF_SWITCH_NAMED_TIMER [計時器名稱] [分鐘] [自動開關類型] [循環]
*規格示例(遊戲時間3小時後打開自動開關[B](*))
* C_SET_SELF_SWITCH_NAMED_TIMER計時器關閉180 B
* *目標事件是執行插件命令的事件。



Chronus.js
  1. //=============================================================================
  2. // Chronus.js
  3. // ----------------------------------------------------------------------------
  4. // (C) 2015 Triacontane
  5. // This software is released under the MIT License.
  6. // [url]http://opensource.org/licenses/mit-license.php[/url]
  7. // ----------------------------------------------------------------------------
  8. // Version
  9. // 1.16.2 2019/11/17 1.15.0の修正以後、場所移動したときのタイルセット情報の取得が、移動前のものになっていた問題を修正
  10. // 1.16.1 2019/11/10 1.16.1で追加したアラーム機能で、アラームに設定した時間を超過して判定された場合、次回のインターバルが超過した時間からカウントされてしまう問題を修正
  11. // 1.16.0 2019/11/09 1.15.0で追加したアラーム機能にインターバル機能を追加
  12. // 1.15.0 2019/10/23 特定のゲーム内時刻になるとスイッチ操作されるアラーム機能を追加
  13. //                   タイルセット変更した場合に、新しいタイルセットの色調や天候有無の設定が反映されない問題を修正
  14. // 1.14.1 2019/10/17 ヘルプの記載漏れを修正
  15. // 1.14.0 2019/09/01 時間帯名称をカレンダーに表示する機能を追加
  16. // 1.13.1 2019/06/09 ニューゲーム時もしくはプロジェクト保存後のロード時に場所移動の時間が経過してしまう問題を修正
  17. // 1.13.0 2019/04/20 カレンダーを初期状態で非表示にできるパラメータを追加
  18. // 1.12.0 2018/12/27 カレンダー表示に行間を設定できる機能を追加
  19. // 1.11.1 2018/10/14 実時間表示に切り替えてから内部時間に反映されるまでにラグがある問題の修正
  20. // 1.11.0 2018/10/14 カレンダーの枠を非表示にできる機能を追加
  21. // 1.10.3 2018/10/08 プラグインコマンドで天候変化を無効にした場合でも、内部で制御している天候による色調の調整が反映されてしまう問題を修正
  22. // 1.10.2 2018/04/11 時間表示方法(実時間、ゲーム時間)を切り替えた直後に、時間変数の値が更新されない問題を修正
  23. // 1.10.1 2018/03/07 場所移動の際、移動先マップの色調有効フラグが異なっていた場合に、色調がリフレッシュされない問題を修正
  24. // 1.10.0 2018/02/24 日付フォーマットに基づいて計算した時間を変数に自動設定する機能を追加
  25. // 1.9.4 2018/02/19 カレンダーの初期表示をtrueに変更しました。
  26. // 1.9.3 2017/11/18 マップロード時に色調を時間に合わせて瞬間変更していた仕様を撤廃
  27. // 1.9.2 2017/11/02 イベント実行中に時間を変更した場合にアナログ時計の表示が変更されない問題を修正
  28. // 1.9.1 2017/11/02 時間経過の初期状態を「停止」から「開始」に変更
  29. // 1.9.0 2017/10/05 アナログ時計の画像を変更できる機能を追加
  30. //                  カレンダーウィンドウのフォントサイズと不透明度を変更できる機能を追加
  31. // 1.8.3 2017/07/18 タイマーの機能のプラグインコマンドに関する説明が一部間違っていた問題を修正
  32. // 1.8.2 2017/07/05 時間変動間隔を変更したときにアナログ時計が正しく表示されない問題を修正
  33. // 1.8.1 2017/06/29 1.8.0で追加した累計時間の初期化機能で、現在時間まで初期化されてしまう問題を修正
  34. // 1.8.0 2017/06/28 累計経過日数を格納するパラメータと、累計時間および日数を初期化できるプラグインコマンドを追加
  35. //                  パラメータの型指定に対応
  36. // 1.7.0 2017/06/01 実時間およびゲーム内時間と連動するタイマー機能を追加
  37. //                  時間が変動する間隔を自由に指定できる機能を追加
  38. // 1.6.0 2017/04/23 降雪マップをマップ単位でタイルセット単位で設定する機能を追加、降水確率を調整できる機能を追加
  39. // 1.5.0 2017/01/23 カレンダーに月名を表記する書式「MON」を追加
  40. // 1.4.0 2017/01/07 ゲーム開始からの累計時間(分単位)を指定したゲーム変数に格納する機能を追加
  41. // 1.3.3 2017/01/02 色調変更を禁止しているときにイベントで色調変更した場合、すぐにリセットされてしまう問題を修正
  42. // 1.3.2 2016/07/24 1.3.1でロード時にエラーになる問題の修正
  43. // 1.3.1 2016/07/23 イベント処理中の時間経過有無をイベントごとに設定できるよう変更
  44. //                  一部コードのリファクタリング
  45. // 1.3.0 2016/07/21 イベント処理中も時間が経過する設定を追加
  46. // 1.2.7 2016/07/10 自然時間加算が0の場合に色調や天候の変化が正しく行われない問題を修正
  47. // 1.2.6 2016/05/30 曜日に「Y」を含む文字列を指定できないバグを修正
  48. // 1.2.5 2016/04/29 createUpperLayerによる競合対策
  49. // 1.2.4 2016/03/13 アナログ時計を指定しないで起動した場合にエラーになる現象の修正
  50. // 1.2.3 2016/03/10 時間帯と時間帯ごとの色調をカスタマイズできるようにユーザ書き換え領域を作成
  51. // 1.2.2 2016/03/04 本体バージョン1.1.0の未使用素材の削除機能への対応
  52. // 1.2.1 2016/02/25 実時間表示設定でロードするとエラーが発生する現象の修正
  53. // 1.2.0 2016/02/14 アナログ時計の表示機能を追加
  54. //                  現実の時間を反映させる機能の追加
  55. // 1.1.3 2016/01/21 競合対策(YEP_MessageCore.js)
  56. // 1.1.2 2016/01/10 カレンダーウィンドウの表示位置をカスタマイズできる機能を追加
  57. // 1.1.1 2015/12/29 日の値に「1」を設定した場合に日付の表示がおかしくなる不具合を修正
  58. //                  一部コードのリファクタリング
  59. // 1.1.0 2015/12/01 天候と時間帯をゲーム変数に格納できるよう機能追加
  60. // 1.0.0 2015/11/27 初版
  61. // ----------------------------------------------------------------------------
  62. // [Blog]   : [url]https://triacontane.blogspot.jp/[/url]
  63. // [Twitter]: [url]https://twitter.com/triacontane/[/url]
  64. // [GitHub] : [url]https://github.com/triacontane/[/url]
  65. //=============================================================================

  66. /*:
  67. * @plugindesc ゲーム内時間の導入プラグイン
  68. * @author トリアコンタン
  69. *
  70. * @param 月ごとの日数配列
  71. * @desc 各月の日数の配列です。カンマ区切りで指定してください。個数は自由です。
  72. * @default 31,28,31,30,31,30,31,31,30,31,30,31
  73. *
  74. * @param 月名配列
  75. * @desc 月の名称配列です。カンマ区切りで指定してください。個数は自由です。
  76. * @default Jan.,Feb.,Mar.,Apr.,May.,Jun.,Jul.,Aug.,Sep.,Oct.,Nov.,Dec.
  77. *
  78. * @param 曜日配列
  79. * @desc 曜日の名称配列です。カンマ区切りで指定してください。個数は自由です。
  80. * @default (日),(月),(火),(水),(木),(金),(土)
  81. *
  82. * @param 自然時間加算
  83. * @type number
  84. * @desc 1秒(自然時間加算間隔で指定した間隔)ごとに加算されるゲーム時間(分単位)の値です。イベント処理中は無効です。
  85. * @default 5
  86. *
  87. * @param 自然時間加算間隔
  88. * @type number
  89. * @desc ゲーム時間の自然加算が行われる間隔(フレーム数)です。1F=1/60秒
  90. * @default 60
  91. *
  92. * @param 場所移動時間加算
  93. * @type number
  94. * @desc 1回の場所移動で加算されるゲーム時間(分単位)の値です。
  95. * @default 30
  96. *
  97. * @param 戦闘時間加算(固定)
  98. * @type number
  99. * @desc 1回の戦闘で加算されるゲーム時間(分単位)の値です。
  100. * @default 30
  101. *
  102. * @param 戦闘時間加算(ターン)
  103. * @type number
  104. * @desc 1回の戦闘で消費したターン数ごとに加算されるゲーム時間(分単位)の値です。
  105. * @default 5
  106. *
  107. * @param 年のゲーム変数
  108. * @type variable
  109. * @desc 指定した番号のゲーム変数に「年」の値が自動設定されます。
  110. * @default 0
  111. *
  112. * @param 月のゲーム変数
  113. * @type variable
  114. * @desc 指定した番号のゲーム変数に「月」の値が自動設定されます。
  115. * @default 0
  116. *
  117. * @param 日のゲーム変数
  118. * @type variable
  119. * @desc 指定した番号のゲーム変数に「日」の値が自動設定されます。
  120. * @default 0
  121. *
  122. * @param 曜日IDのゲーム変数
  123. * @type variable
  124. * @desc 指定した番号のゲーム変数に「曜日」のIDが自動設定されます。
  125. * @default 0
  126. *
  127. * @param 曜日名のゲーム変数
  128. * @type variable
  129. * @desc 指定した番号のゲーム変数に「曜日」の名称が自動設定されます。
  130. * ゲーム変数に文字列が入るので注意してください。
  131. * @default 0
  132. *
  133. * @param 時のゲーム変数
  134. * @type variable
  135. * @desc 指定した番号のゲーム変数に「時」の値が自動設定されます。
  136. * @default 0
  137. *
  138. * @param 分のゲーム変数
  139. * @type variable
  140. * @desc 指定した番号のゲーム変数に「分」の値が自動設定されます。
  141. * @default 0
  142. *
  143. * @param 累計時間のゲーム変数
  144. * @type variable
  145. * @desc 指定した番号のゲーム変数に「累計時間」(分単位)の値が自動設定されます。
  146. * @default 0
  147. *
  148. * @param 累計日数のゲーム変数
  149. * @type variable
  150. * @desc 指定した番号のゲーム変数に「累計日数」の値が自動設定されます。
  151. * @default 0
  152. *
  153. * @param 時間帯IDのゲーム変数
  154. * @type variable
  155. * @desc 指定した番号のゲーム変数に「時間帯」のIDが自動設定されます。
  156. * 0:深夜 1:早朝 2:朝 3:昼 4:夕方 5:夜
  157. * @default 0
  158. *
  159. * @param 天候IDのゲーム変数
  160. * @type variable
  161. * @desc 指定した番号のゲーム変数に「天候」のIDが自動設定されます。
  162. * 0:なし 1:雨 2:嵐 3:雪
  163. * @default 0
  164. *
  165. * @param フォーマット時間の変数
  166. * @type variable
  167. * @desc 「フォーマット時間の計算式」に基づいて計算した結果が自動設定されます。
  168. * @default 0
  169. *
  170. * @param フォーマット時間の計算式
  171. * @desc 日時フォーマットを使った計算式の内容です。
  172. * YYYY:年 MON:月名 MM:月 DD:日 など(詳細はヘルプ参照)
  173. * @default HH24 * 60 + MI
  174. *
  175. * @param 日時フォーマット1
  176. * @desc マップ上の日付ウィンドウ1行目に表示される文字列です。
  177. * YYYY:年 MON:月名 MM:月 DD:日 など(詳細はヘルプ参照)
  178. * @default YYYY年 MM月 DD日 DY
  179. *
  180. * @param 日時フォーマット2
  181. * @desc マップ上の日付ウィンドウ2行目に表示される文字列です。
  182. * YYYY:年 MON:月名 MM:月 DD:日 など(詳細はヘルプ参照)
  183. * @default AMHH時 MI分
  184. *
  185. * @param 日時フォーマット行間
  186. * @type number
  187. * @desc カレンダー表示の行間です。
  188. * @default 0
  189. *
  190. * @param カレンダー表示X座標
  191. * @type number
  192. * @desc カレンダーの表示 X 座標です。
  193. * @default 0
  194. *
  195. * @param カレンダー表示Y座標
  196. * @type number
  197. * @desc カレンダーの表示 Y 座標です。
  198. * @default 0
  199. *
  200. * @param カレンダーフォントサイズ
  201. * @type number
  202. * @desc カレンダーのフォントサイズです。0を指定するとデフォルトとなります。
  203. * @default 0
  204. *
  205. * @param カレンダー不透明度
  206. * @type number
  207. * @desc カレンダーの背景の不透明度(0-255)です。
  208. * @default 192
  209. *
  210. * @param カレンダー枠の非表示
  211. * @type boolean
  212. * @desc カレンダーのウィンドウ枠を非表示にします。
  213. * @default false
  214. *
  215. * @param カレンダーの非表示
  216. * @type boolean
  217. * @desc カレンダーを非表示します。プラグインコマンドから表示できます。
  218. * @default false
  219. *
  220. * @param カレンダー余白
  221. * @type number
  222. * @desc カレンダーの余白(8-)です。
  223. * @default 8
  224. *
  225. * @param 文字盤画像ファイル
  226. * @desc アナログ時計を表示する場合の文字盤画像ファイル名(拡張子は不要)です。
  227. * 画像は「img/pictures/」以下に保存してください。
  228. * @default
  229. * @require 1
  230. * @dir img/pictures/
  231. * @type file
  232. *
  233. * @param 長針画像ファイル
  234. * @desc アナログ時計を表示する場合の長針画像ファイル名(拡張子は不要)です。
  235. * 画像は「img/pictures/」以下に保存してください。
  236. * @default
  237. * @require 1
  238. * @dir img/pictures/
  239. * @type file
  240. *
  241. * @param 短針画像ファイル
  242. * @desc アナログ時計を表示する場合の長針画像ファイル名(拡張子は不要)です。
  243. * 画像は「img/pictures/」以下に保存してください。
  244. * @default
  245. * @require 1
  246. * @dir img/pictures/
  247. * @type file
  248. *
  249. * @param 時計X座標
  250. * @type number
  251. * @desc アナログ時計の表示X座標です。画像の中心座標を指定してください。
  252. * @default 84
  253. *
  254. * @param 時計Y座標
  255. * @type number
  256. * @desc アナログ時計の表示Y座標です。画像の中心座標を指定してください。
  257. * @default 156
  258. *
  259. * @param イベント中時間経過
  260. * @desc イベント実行中も時間経過するようになります。(ON/OFF)
  261. * @default false
  262. * @type boolean
  263. *
  264. * @help ゲーム内で時刻と天候の概念を表現できるプラグインです。
  265. * 自動、マップ移動、戦闘で時間が経過し、時間と共に天候と色調が変化します。
  266. * これらの時間は調節可能で、またイベント中は時間の進行が停止します。
  267. *
  268. * さらに、現実の時間をゲーム中に反映させる機能もあります。
  269. * 設定を有効にすると現実の時間がゲーム内とリンクします。
  270. *
  271. * 日付や曜日も記録し、曜日の数や名称を自由に設定できます。
  272. * 現在日付はフォーマットに従って、画面左上に表示されます。
  273. *
  274. * 日付フォーマットには以下を利用できます。
  275. * YYYY:年 MON:月名 MM:月 DD:日 HH24:時(24) HH:時(12)
  276. * AM:午前 or 午後 MI:分 DY:曜日 TZ 時間帯名称
  277. *
  278. * また、規格に沿った画像を用意すればアナログ時計も表示できます。
  279. * 表示位置は各画像の表示可否は調整できます。
  280. *
  281. * 画像の規格は以下の通りです。
  282. * ・文字盤 : 任意のサイズの正方形画像
  283. * ・長針  : 文字盤と同じサイズの画像で、上(0)を指している針の画像
  284. * ・短針  : 文字盤と同じサイズの画像で、上(0)を指している針の画像
  285. *
  286. * ツクマテにて規格に合った時計画像をリクエストしました。
  287. * 使用する場合は、以下のURLより利用規約を別途確認の上、ご使用ください。
  288. * [url]http://tm.lucky-duet.com/viewtopic.php?f=47&t=555&p=1615#p1615[/url]
  289. *
  290. * プラグインコマンド詳細
  291. *  イベントコマンド「プラグインコマンド」から実行。
  292. *  指定する値には制御文字\V[n]を使用できます。
  293. *  (引数の間は半角スペースで区切る)
  294. *
  295. * C_ADD_TIME [分] : 指定した値(分単位)だけ時間が経過します。
  296. * C_ADD_DAY [日] : 指定した値(日単位)だけ日数が経過します。
  297. * C_SET_TIME [時] [分] : 指定した時間に変更します。
  298. * C_SET_DAY [年] [月] [日] : 指定した日付に変更します。
  299. * C_STOP : 時間の進行を停止します。
  300. * C_START : 時間の進行を開始します。
  301. * C_SHOW : カレンダーを表示します。
  302. * C_HIDE : カレンダーを非表示にします。
  303. * C_DISABLE_TINT : 時間帯による色調の変更を禁止します。
  304. * C_ENABLE_TINT : 時間帯による色調の変更を許可します。
  305. * C_DISABLE_WEATHER : 時間経過による天候の変化を禁止します。
  306. * C_ENABLE_WEATHER : 時間経過による天候の変化を許可します。
  307. * C_SET_SNOW_LAND : 悪天候時に雪が降るようになります。
  308. * C_RESET_SNOW_LAND : 悪天候時に雨もしくは嵐が降るようになります。
  309. * C_SET_SPEED [分] : 実時間1秒あたりの時間の経過速度を設定します。
  310. * C_SHOW_CLOCK : アナログ時計を表示します。
  311. * C_HIDE_CLOCK : アナログ時計を非表示にします。
  312. * C_SET_TIME_REAL : 時間の取得方法を実時間に変更します。
  313. * C_SET_TIME_VIRTUAL : 時間の取得方法をゲーム内時間に変更します。
  314. * C_SET_RAINY_PERCENT [確率] : 降水確率(0-100)を設定します。
  315. * C_INIT_TOTAL_TIME : 累計時間、累計日数を初期化します。
  316. *
  317. * ・アナログ時計画像変更コマンド
  318. * アナログ時計の画像ファイル名(img/pictures)を変更できます。
  319. * ただし、実際に画像が変更されるのはマップを移動した後になります。
  320. * C_SET_CLOCK_BASE [ファイル名] : 文字盤画像のファイル名を変更します。
  321. * C_SET_HOUR_HAND [ファイル名] : 短針画像のファイル名を変更します。
  322. * C_SET_MINUTE_HAND [ファイル名] : 長針画像のファイル名を変更します。
  323. *
  324. * ・タイマー操作系コマンド
  325. * コマンド実行から指定した時間[分]が経過後にスイッチやセルフスイッチを
  326. * ONにできるコマンドです。
  327. * 実時間連動機能と併せて使用することもできます。
  328. * スイッチの場合はIDを、セルフスイッチの場合は種類(A,B,C,D)を指定します。
  329. *
  330. * C_SET_SWITCH_TIMER [分] [スイッチID] [ループ]
  331. * 指定例(ゲーム内時間で30分経過後する度にスイッチ[10]をONにする)
  332. * C_SET_SWITCH_TIMER 30 10 ON
  333. *
  334. * C_SET_SELF_SWITCH_TIMER [分] [セルフスイッチ種類] [ループ]
  335. * 指定例(ゲーム内時間で3時間過後にセルフスイッチ[B](※)をONにする)
  336. * C_SET_SELF_SWITCH_TIMER 180 B OFF
  337. * ※対象イベントはプラグインコマンドを実行したイベントです。
  338. *
  339. * 途中で解除や一時停止する可能性がある場合は[タイマー名]を指定するコマンドを
  340. * 実行してください。解除などの際にタイマー名を指定する必要があるためです。
  341. *
  342. * C_SET_SWITCH_NAMED_TIMER [タイマー名] [分] [スイッチID] [ループ]
  343. * 指定例(ゲーム内時間で30分経過後する度にスイッチ[10]をONにする)
  344. * C_SET_SWITCH_NAMED_TIMER timer 30 10 ON
  345. *
  346. * C_SET_SELF_SWITCH_NAMED_TIMER [タイマー名] [分] [セルフスイッチ種類] [ループ]
  347. * 指定例(ゲーム内時間で3時間過後にセルフスイッチ[B](※)をONにする)
  348. * C_SET_SELF_SWITCH_NAMED_TIMER timer 180 B OFF
  349. * ※対象イベントはプラグインコマンドを実行したイベントです。
  350. *
  351. * 解除、停止、再開のコマンドは以下の通りです。
  352. * C_CLEAR_TIMER timer # タイマー名「timer」を解除します。
  353. * C_STOP_TIMER timer  # タイマー名「timer」を一時停止します。
  354. * C_START_TIMER timer # タイマー名「timer」を再開します。
  355. *
  356. * 時間ではなく時刻指定でスイッチ操作できるアラーム機能です。
  357. * [年月時分]は、「YYYYMMDDHHMM」形式で指定してください。
  358. * 解除はタイマー用のコマンドを使います。
  359. * C_SET_SWITCH_ALARM [年月時分] [スイッチID] [インターバル]
  360. * C_SET_SELF_SWITCH_ALARM [年月時分] [セルフスイッチ種類] [インターバル]
  361. * C_SET_SWITCH_NAMED_ALARM [アラーム名] [年月時分] [スイッチID] [インターバル]
  362. * C_SET_SELF_SWITCH_NAMED_ALARM [アラーム名] [年月時分] [セルフスイッチ種類] [インターバル]
  363. *
  364. * 指定例(ゲーム内時間で2019/10/22 15:00を過ぎるとセルフスイッチ[B]をONにする)
  365. * C_SET_SELF_SWITCH_ALARM 201910221500 B
  366. *
  367. * インターバルを指定した場合、スイッチがONになった後も指定した期間が経過すると
  368. * 再度、スイッチがONになるようになります。単位は分ですが計算式が使えます。
  369. *
  370. * 指定例(ゲーム内時間で2019/10/22 15:00を過ぎるとセルフスイッチ[B]をONにする。
  371. *     その後、1日経過ごとに再度セルフスイッチ[B]をONにする)
  372. * C_SET_SELF_SWITCH_ALARM 201910221500 B 24*60
  373. *
  374. * メモ欄詳細
  375. *  タイトルセットおよびマップのメモ欄に以下を入力すると、
  376. *  一時的に天候と色調変化を自動で無効化できます。
  377. *  屋内マップやイベントシーンなどで一時的に無効化したい場合に利用できます。
  378. *  設定はマップのメモ欄が優先されます。
  379. *
  380. * <C_Tint:OFF>    # 色調の変更を一時的に無効化します。
  381. * <C_色調:OFF>    # 同上
  382. * <C_Weather:OFF> # 天候を一時的に無効化します。
  383. * <C_天候:OFF>    # 同上
  384. * <C_Snow:ON>     # 天候を雪に設定します。
  385. * <C_雪:ON>       # 同上
  386. *
  387. * イベント実行中にも時間経過するかどうかをイベントごとに設定できます。
  388. * この設定はパラメータの設定よりも優先されます。
  389. * イベントのメモ欄に以下を入力してください。
  390. * <C_時間経過:ON> # イベント実行中に時間経過します。(ON/OFF)
  391. * <C_NoStop:ON>   # 同上
  392. *
  393. * 高度な設定
  394. * ソースコード中の「ユーザ書き換え領域」を参照すると以下を変更できます。
  395. *  時間帯の情報(朝が何時から何時まで等)
  396. *  時間帯ごとの色調(ただし、悪天候の場合は補正が掛かります)
  397. *
  398. * 利用規約:
  399. *  作者に無断で改変、再配布が可能で、利用形態(商用、18禁利用等)
  400. *  についても制限はありません。
  401. *  このプラグインはもうあなたのものです。
  402. */

  403. /**
  404. * ゲーム内時間を扱うゲームオブジェクトです。
  405. * @constructor
  406. */
  407. function Game_Chronus() {
  408.     this.initialize.apply(this, arguments);
  409. }

  410. /**
  411. * ゲーム内タイマーを扱うゲームオブジェクトです。
  412. * @constructor
  413. */
  414. function Game_ChronusTimer() {
  415.     this.initialize.apply(this, arguments);
  416. }

  417. /**
  418. * 時計画像を扱うスプライトです。
  419. * @constructor
  420. */
  421. function Sprite_Chronicle_Clock() {
  422.     this.initialize.apply(this, arguments);
  423. }

  424. /**
  425. * ゲーム内時間を描画するウィンドウです。
  426. * @constructor
  427. */
  428. function Window_Chronus() {
  429.     this.initialize.apply(this, arguments);
  430. }

  431. (function() {
  432.     'use strict';
  433.     //=============================================================================
  434.     // ユーザ書き換え領域 - 開始 -
  435.     //=============================================================================
  436.     var settings = {
  437.         /* timeZone:時間帯 */
  438.         timeZone: [
  439.             /* name:時間帯名称 start:開始時刻 end:終了時刻 timeId:時間帯ID */
  440.             {name: '深夜', start: 0, end: 4, timeId: 0},
  441.             {name: '早朝', start: 5, end: 6, timeId: 1},
  442.             {name: '朝', start: 7, end: 11, timeId: 2},
  443.             {name: '昼', start: 12, end: 16, timeId: 3},
  444.             {name: '夕方', start: 17, end: 18, timeId: 4},
  445.             {name: '夜', start: 19, end: 21, timeId: 5},
  446.             {name: '深夜', start: 22, end: 24, timeId: 0}
  447.         ],
  448.         /* timeTone:時間帯ごとの色調 */
  449.         timeTone: [
  450.             /* timeId:時間帯ID value:色調[赤(-255...255),緑(-255...255),青(-255...255),グレー(0...255)] */
  451.             {timeId: 0, value: [-102, -102, -68, 102]},
  452.             {timeId: 1, value: [-68, -68, 0, 0]},
  453.             {timeId: 2, value: [0, 0, 0, 0]},
  454.             {timeId: 3, value: [34, 34, 34, 0]},
  455.             {timeId: 4, value: [68, -34, -34, 0]},
  456.             {timeId: 5, value: [-68, -68, 0, 68]}
  457.         ]
  458.     };
  459.     //=============================================================================
  460.     // ユーザ書き換え領域 - 終了 -
  461.     //=============================================================================
  462.     var pluginName    = 'Chronus';
  463.     var metaTagPrefix = 'C_';

  464.     var getParamString = function(paramNames) {
  465.         var value = getParamOther(paramNames);
  466.         return value === null ? '' : value;
  467.     };

  468.     var getParamNumber = function(paramNames, min, max) {
  469.         var value = getParamOther(paramNames);
  470.         if (arguments.length < 2) min = -Infinity;
  471.         if (arguments.length < 3) max = Infinity;
  472.         return (parseInt(value, 10) || 0).clamp(min, max);
  473.     };

  474.     var getParamOther = function(paramNames) {
  475.         if (!Array.isArray(paramNames)) paramNames = [paramNames];
  476.         for (var i = 0; i < paramNames.length; i++) {
  477.             var name = PluginManager.parameters(pluginName)[paramNames[i]];
  478.             if (name) return name;
  479.         }
  480.         return null;
  481.     };

  482.     var getParamBoolean = function(paramNames) {
  483.         var value = (getParamOther(paramNames) || '').toUpperCase();
  484.         return value === 'ON' || value === 'TRUE';
  485.     };

  486.     var isParamExist = function(paramNames) {
  487.         return getParamOther(paramNames) !== null;
  488.     };

  489.     var getParamArrayString = function(paramNames) {
  490.         var values = getParamString(paramNames).split(',');
  491.         for (var i = 0; i < values.length; i++) values[i] = values[i].trim();
  492.         return values;
  493.     };

  494.     var getParamArrayNumber = function(paramNames, min, max) {
  495.         var values = getParamArrayString(paramNames);
  496.         if (arguments.length < 2) min = -Infinity;
  497.         if (arguments.length < 3) max = Infinity;
  498.         for (var i = 0; i < values.length; i++) values[i] = (parseInt(values[i], 10) || 0).clamp(min, max);
  499.         return values;
  500.     };

  501.     var getCommandName = function(command) {
  502.         return (command || '').toUpperCase();
  503.     };

  504.     var getArgNumber = function(arg, min, max) {
  505.         if (arguments.length < 2) min = -Infinity;
  506.         if (arguments.length < 3) max = Infinity;
  507.         return parseIntStrict(convertEscapeCharacters(arg)).clamp(min, max);
  508.     };

  509.     var parseIntStrict = function(value, errorMessage) {
  510.         var result = parseInt(value, 10);
  511.         if (isNaN(result)) throw Error('指定した値[' + value + ']が数値ではありません。' + errorMessage);
  512.         return result;
  513.     };

  514.     var convertEscapeCharacters = function(text) {
  515.         if (text == null) text = '';
  516.         var window = SceneManager._scene._windowLayer.children[0];
  517.         return window ? window.convertEscapeCharacters(text) : text;
  518.     };

  519.     var getArgBoolean = function(arg) {
  520.         return (arg || '').toUpperCase() === 'ON' || (arg || '').toUpperCase() === 'TRUE';
  521.     };

  522.     var getMetaValue = function(object, name) {
  523.         var metaTagName = metaTagPrefix + (name ? name : '');
  524.         return object.meta.hasOwnProperty(metaTagName) ? object.meta[metaTagName] : undefined;
  525.     };

  526.     var getMetaValues = function(object, names) {
  527.         if (!Array.isArray(names)) return getMetaValue(object, names);
  528.         for (var i = 0, n = names.length; i < n; i++) {
  529.             var value = getMetaValue(object, names[i]);
  530.             if (value !== undefined) return value;
  531.         }
  532.         return undefined;
  533.     };

  534.     var _DataManager_extractSaveContents = DataManager.extractSaveContents;
  535.     DataManager.extractSaveContents      = function(contents) {
  536.         _DataManager_extractSaveContents.apply(this, arguments);
  537.         $gameSystem.onLoad();
  538.     };

  539.     //=============================================================================
  540.     // パラメータの取得と整形
  541.     //=============================================================================
  542.     var paramAutoAddInterval     = getParamNumber('自然時間加算間隔', 1) || 60;
  543.     var paramCalendarFontSize    = getParamNumber('カレンダーフォントサイズ', 0);
  544.     var paramCalendarOpacity     = getParamNumber('カレンダー不透明度', 0);
  545.     var paramCalendarPadding     = getParamNumber('カレンダー余白', 8);
  546.     var paramClockBaseFile       = getParamString('文字盤画像ファイル');
  547.     var paramMinutesHandFile     = getParamString('長針画像ファイル');
  548.     var paramHourHandFile        = getParamString('短針画像ファイル');
  549.     var paramCalendarFrameHidden = getParamBoolean('カレンダー枠の非表示');
  550.     var paramCalendarLineSpacing = getParamNumber('日時フォーマット行間', 0);
  551.     var paramCalendarHidden      = getParamBoolean('カレンダーの非表示');

  552.     //=============================================================================
  553.     // Game_Interpreter
  554.     //  プラグインコマンド[C_ADD_TIME]などを追加定義します。
  555.     //=============================================================================
  556.     var _Game_Interpreter_pluginCommand      = Game_Interpreter.prototype.pluginCommand;
  557.     Game_Interpreter.prototype.pluginCommand = function(command, args) {
  558.         _Game_Interpreter_pluginCommand.apply(this, arguments);
  559.         var commandPrefix = new RegExp('^' + metaTagPrefix);
  560.         if (!command.match(commandPrefix)) return;
  561.         this.pluginCommandChronus(command.replace(commandPrefix, ''), args);
  562.     };

  563.     Game_Interpreter.prototype.pluginCommandChronus = function(command, args) {
  564.         switch (getCommandName(command)) {
  565.             case 'ADD_TIME' :
  566.                 $gameSystem.chronus().addTime(getArgNumber(args[0], 0, 99999));
  567.                 break;
  568.             case 'ADD_DAY' :
  569.                 $gameSystem.chronus().addDay(getArgNumber(args[0], 0, 99999));
  570.                 break;
  571.             case 'SET_TIME' :
  572.                 var hour   = getArgNumber(args[0], 0, 23);
  573.                 var minute = getArgNumber(args[1], 0, 59);
  574.                 $gameSystem.chronus().setTime(hour, minute);
  575.                 break;
  576.             case 'SET_DAY' :
  577.                 var year  = getArgNumber(args[0], 1, 5000);
  578.                 var month = getArgNumber(args[1], 1, $gameSystem.chronus().getMonthOfYear());
  579.                 var day   = getArgNumber(args[2], 1, $gameSystem.chronus().getDaysOfMonth(month));
  580.                 $gameSystem.chronus().setDay(year, month, day);
  581.                 break;
  582.             case 'STOP' :
  583.                 $gameSystem.chronus().stop();
  584.                 break;
  585.             case 'START' :
  586.                 $gameSystem.chronus().start();
  587.                 break;
  588.             case 'SHOW' :
  589.                 $gameSystem.chronus().showCalendar();
  590.                 break;
  591.             case 'HIDE' :
  592.                 $gameSystem.chronus().hideCalendar();
  593.                 break;
  594.             case 'DISABLE_TINT':
  595.                 $gameSystem.chronus().disableTint();
  596.                 break;
  597.             case 'ENABLE_TINT':
  598.                 $gameSystem.chronus().enableTint();
  599.                 break;
  600.             case 'DISABLE_WEATHER':
  601.                 $gameSystem.chronus().disableWeather();
  602.                 break;
  603.             case 'ENABLE_WEATHER':
  604.                 $gameSystem.chronus().enableWeather();
  605.                 break;
  606.             case 'SET_SNOW_LAND':
  607.                 $gameSystem.chronus().setSnowLand();
  608.                 break;
  609.             case 'RESET_SNOW_LAND':
  610.                 $gameSystem.chronus().resetSnowLand();
  611.                 break;
  612.             case 'SET_SPEED':
  613.                 $gameSystem.chronus().setTimeAutoAdd(getArgNumber(args[0], 0, 99));
  614.                 break;
  615.             case 'SHOW_CLOCK':
  616.                 $gameSystem.chronus().showClock();
  617.                 break;
  618.             case 'HIDE_CLOCK':
  619.                 $gameSystem.chronus().hideClock();
  620.                 break;
  621.             case 'SET_TIME_REAL':
  622.                 $gameSystem.chronus().setTimeReal();
  623.                 break;
  624.             case 'SET_TIME_VIRTUAL':
  625.                 $gameSystem.chronus().setTimeVirtual();
  626.                 break;
  627.             case 'SET_RAINY_PERCENT':
  628.                 $gameSystem.chronus().setRainyPercent(getArgNumber(args[0], 0, 100));
  629.                 break;
  630.             case 'SET_SWITCH_TIMER':
  631.                 this.setSwitchTimer(args, false);
  632.                 break;
  633.             case 'SET_SWITCH_NAMED_TIMER':
  634.                 this.setSwitchTimer(args, true);
  635.                 break;
  636.             case 'SET_SELF_SWITCH_TIMER':
  637.                 this.setSwitchTimer(args, false, true);
  638.                 break;
  639.             case 'SET_SELF_SWITCH_NAMED_TIMER':
  640.                 this.setSwitchTimer(args, true, true);
  641.                 break;
  642.             case 'SET_SWITCH_ALARM':
  643.                 this.setSwitchAlarm(args, false);
  644.                 break;
  645.             case 'SET_SWITCH_NAMED_ALARM':
  646.                 this.setSwitchAlarm(args, true);
  647.                 break;
  648.             case 'SET_SELF_SWITCH_ALARM':
  649.                 this.setSwitchAlarm(args, false, true);
  650.                 break;
  651.             case 'SET_SELF_SWITCH_NAMED_ALARM':
  652.                 this.setSwitchAlarm(args, true, true);
  653.                 break;
  654.             case 'STOP_TIMER':
  655.                 $gameSystem.chronus().stopTimer(convertEscapeCharacters(args[0]));
  656.                 break;
  657.             case 'START_TIMER':
  658.                 $gameSystem.chronus().startTimer(convertEscapeCharacters(args[0]));
  659.                 break;
  660.             case 'CLEAR_TIMER':
  661.                 $gameSystem.chronus().clearTimer(convertEscapeCharacters(args[0]));
  662.                 break;
  663.             case 'INIT_TOTAL_TIME':
  664.                 $gameSystem.chronus().initTotalTime();
  665.                 break;
  666.             case 'SET_CLOCK_BASE':
  667.                 $gameSystem.chronus().setClockBaseFile(convertEscapeCharacters(args[0]));
  668.                 break;
  669.             case 'SET_MINUTE_HAND':
  670.                 $gameSystem.chronus().setMinuteHandFile(convertEscapeCharacters(args[0]));
  671.                 break;
  672.             case 'SET_HOUR_HAND':
  673.                 $gameSystem.chronus().setHourHandFile(convertEscapeCharacters(args[0]));
  674.                 break;
  675.         }
  676.     };

  677.     Game_Interpreter.prototype.setSwitchTimer = function(args, named, selfSwitch) {
  678.         var timerName = named ? convertEscapeCharacters(args.shift()) : null;
  679.         var timeout   = getArgNumber(args.shift(), 0);
  680.         var switchKey = this.getSwitchKey(args.shift(), selfSwitch);
  681.         var loop      = getArgBoolean(args.shift());
  682.         $gameSystem.chronus().makeTimer(timerName, timeout, switchKey, loop);
  683.     };

  684.     Game_Interpreter.prototype.setSwitchAlarm = function(args, named, selfSwitch) {
  685.         var timerName = named ? convertEscapeCharacters(args.shift()) : null;
  686.         var timeout   = getArgNumber(args.shift(), 0);
  687.         var switchKey = this.getSwitchKey(args.shift(), selfSwitch);
  688.         var interval = args.shift();
  689.         if (interval) {
  690.             interval = eval(convertEscapeCharacters(interval));
  691.         }
  692.         $gameSystem.chronus().makeAlarm(timerName, timeout, switchKey, interval);
  693.     };

  694.     Game_Interpreter.prototype.getSwitchKey = function(arg, selfSwitch) {
  695.         return selfSwitch ? [$gameMap.mapId(), this.eventId(), convertEscapeCharacters(arg).toUpperCase()] : getArgNumber(arg);
  696.     };

  697.     var _Game_Interpreter_command236      = Game_Interpreter.prototype.command236;
  698.     Game_Interpreter.prototype.command236 = function() {
  699.         var result = _Game_Interpreter_command236.call(this);
  700.         if (!$gameParty.inBattle()) {
  701.             var chronus = $gameSystem.chronus();
  702.             chronus.setWeatherType(Game_Chronus.weatherTypes.indexOf(this._params[0]));
  703.             chronus.setWeatherPower(this._params[1]);
  704.             chronus.refreshTint(true);
  705.             chronus.forceSetBatWeatherLevel(this._params[0], this._params[1]);
  706.         }
  707.         return result;
  708.     };

  709.     var _Game_Interpreter_command282 = Game_Interpreter.prototype.command282;
  710.     Game_Interpreter.prototype.command282 = function() {
  711.         var result =  _Game_Interpreter_command282.apply(this, arguments);
  712.         if (!$gameParty.inBattle()) {
  713.             var chronus = $gameSystem.chronus();
  714.             chronus.refreshTint(true);
  715.             chronus.refreshWeather(true);
  716.         }
  717.         return result;
  718.     };

  719.     //=============================================================================
  720.     // Game_System
  721.     //  ゲーム内時間を扱うクラス「Game_Chronus」を追加定義します。
  722.     //=============================================================================
  723.     var _Game_System_initialize      = Game_System.prototype.initialize;
  724.     Game_System.prototype.initialize = function() {
  725.         _Game_System_initialize.call(this);
  726.         this._chronus = new Game_Chronus();
  727.     };

  728.     Game_System.prototype.chronus = function() {
  729.         return this._chronus;
  730.     };

  731.     Game_System.prototype.onBattleEnd = function() {
  732.         this.chronus().onBattleEnd();
  733.     };

  734.     var _Game_System_onLoad      = Game_System.prototype.onLoad;
  735.     Game_System.prototype.onLoad = function() {
  736.         if (_Game_System_onLoad) _Game_System_onLoad.apply(this, arguments);
  737.         if (!this.chronus()) this._chronus = new Game_Chronus();
  738.         this._chronus.onLoad();
  739.     };

  740.     //=============================================================================
  741.     // Game_Map
  742.     //  マップ及びタイルセットから、色調変化無効フラグを取得します。
  743.     //=============================================================================
  744.     Game_Map.prototype.isDisableTint = function() {
  745.         return !this.isChronicleMetaInfo(['Tint', '色調'], true);
  746.     };

  747.     Game_Map.prototype.isDisableWeather = function() {
  748.         return !this.isChronicleMetaInfo(['Weather', '天候'], true);
  749.     };

  750.     Game_Map.prototype.isSnowLand = function() {
  751.         return this.isChronicleMetaInfo(['Snow', '雪'], false);
  752.     };

  753.     Game_Map.prototype.isChronicleMetaInfo = function(tagNames, defaultValue) {
  754.         if (DataManager.isBattleTest() || DataManager.isEventTest()) return false;
  755.         var metaValue1 = getMetaValues($dataMap, tagNames);
  756.         if (metaValue1 !== undefined) {
  757.             return getArgBoolean(metaValue1);
  758.         }
  759.         var tileset = $gamePlayer.isTransferring() ? $dataTilesets[$dataMap.tilesetId] : this.tileset();
  760.         var metaValue2 = getMetaValues(tileset, tagNames);
  761.         if (metaValue2 !== undefined) {
  762.             return getArgBoolean(metaValue2);
  763.         }
  764.         return defaultValue;
  765.     };

  766.     Game_Map.prototype.isTimeStopEventRunning = function() {
  767.         if (this.isEventRunning()) {
  768.             if (!this._isTimeStopEventRunning) this._isTimeStopEventRunning = this.getTimeStopEventRunning();
  769.         } else {
  770.             this._isTimeStopEventRunning = false;
  771.         }
  772.         return this._isTimeStopEventRunning;
  773.     };

  774.     Game_Map.prototype.getTimeStopEventRunning = function() {
  775.         var event = this.event(this._interpreter.eventId());
  776.         if (!event) return false;
  777.         var stop = getMetaValues(event.event(), ['時間経過', 'NoStop']);
  778.         if (stop) {
  779.             return !getArgBoolean(stop);
  780.         } else {
  781.             return !getParamBoolean('イベント中時間経過');
  782.         }
  783.     };

  784.     //=============================================================================
  785.     // Game_Player
  786.     //  場所移動時の時間経過を追加定義します。
  787.     //=============================================================================
  788.     var _Game_Player_performTransfer      = Game_Player.prototype.performTransfer;
  789.     Game_Player.prototype.performTransfer = function() {
  790.         var realTransfer = this._newMapId !== $gameMap.mapId() && $gameMap.mapId() > 0;
  791.         $gameSystem.chronus().transfer(realTransfer);
  792.         _Game_Player_performTransfer.call(this);
  793.     };

  794.     //=============================================================================
  795.     // Scene_Map
  796.     //  Game_Chronusの更新を追加定義します。
  797.     //=============================================================================
  798.     var _Scene_Map_onMapLoaded      = Scene_Map.prototype.onMapLoaded;
  799.     Scene_Map.prototype.onMapLoaded = function() {
  800.         $gameSystem.chronus().onMapLoaded();
  801.         _Scene_Map_onMapLoaded.apply(this, arguments);
  802.     };

  803.     var _Scene_Map_updateMain      = Scene_Map.prototype.updateMain;
  804.     Scene_Map.prototype.updateMain = function() {
  805.         _Scene_Map_updateMain.apply(this, arguments);
  806.         $gameSystem.chronus().update();
  807.     };

  808.     var _Scene_Map_createAllWindows      = Scene_Map.prototype.createAllWindows;
  809.     Scene_Map.prototype.createAllWindows = function() {
  810.         this.createChronusWindow();
  811.         _Scene_Map_createAllWindows.apply(this, arguments);
  812.     };

  813.     Scene_Map.prototype.createChronusWindow = function() {
  814.         this._chronusWindow = new Window_Chronus();
  815.         this.addWindow(this._chronusWindow);
  816.     };

  817.     //=============================================================================
  818.     // BattleManager
  819.     //  戦闘終了時のゲーム内時間経過処理を追加定義します。
  820.     //=============================================================================
  821.     var _BattleManager_endBattle = BattleManager.endBattle;
  822.     BattleManager.endBattle      = function(result) {
  823.         $gameSystem.onBattleEnd();
  824.         _BattleManager_endBattle.call(this, result);
  825.     };

  826.     //=============================================================================
  827.     // Window_Chronus
  828.     //  ゲーム内時間情報を描画するウィンドウです。
  829.     //=============================================================================
  830.     Window_Chronus.prototype             = Object.create(Window_Base.prototype);
  831.     Window_Chronus.prototype.constructor = Window_Chronus;

  832.     var _Window_Chronus_initialize      = Window_Chronus.prototype.initialize;
  833.     Window_Chronus.prototype.initialize = function() {
  834.         _Window_Chronus_initialize.call(this, 0, 0, this.getDefaultWidth(), this.getDefaultHeight());
  835.         this.createContents();
  836.         this.x = getParamNumber('カレンダー表示X座標');
  837.         this.y = getParamNumber('カレンダー表示Y座標');
  838.         if (paramCalendarFrameHidden) {
  839.             this.opacity = 0;
  840.         }
  841.         this.refresh();
  842.     };

  843.     Window_Chronus.prototype.getDefaultWidth = function() {
  844.         var bitmap      = new Bitmap();
  845.         bitmap.fontSize = this.standardFontSize();
  846.         var width1      = bitmap.measureTextWidth(this.getDateFormat(1));
  847.         var width2      = bitmap.measureTextWidth(this.getDateFormat(2));
  848.         return Math.max(width1, width2) + this.standardPadding() * 2;
  849.     };

  850.     Window_Chronus.prototype.getDefaultHeight = function() {
  851.         return this.standardFontSize() * (this.getDateFormat(2) ? 2 : 1) + this.standardPadding() * 2 + paramCalendarLineSpacing;
  852.     };

  853.     Window_Chronus.prototype.standardPadding = function() {
  854.         return paramCalendarPadding;
  855.     };

  856.     Window_Chronus.prototype.standardBackOpacity = function() {
  857.         return paramCalendarOpacity;
  858.     };

  859.     Window_Chronus.prototype.lineHeight = function() {
  860.         return this.standardFontSize();
  861.     };

  862.     var _Window_Chronus_standardFontSize      = Window_Chronus.prototype.standardFontSize;
  863.     Window_Chronus.prototype.standardFontSize = function() {
  864.         return paramCalendarFontSize || _Window_Chronus_standardFontSize.apply(this, arguments);
  865.     };

  866.     Window_Chronus.prototype.refresh = function() {
  867.         this.contents.clear();
  868.         var width  = this.contents.width;
  869.         var height = this.lineHeight();
  870.         this.contents.drawText(this.getDateFormat(1), 0, 0, width, height, 'left');
  871.         this.contents.drawText(this.getDateFormat(2), 0, height + paramCalendarLineSpacing, width, height, 'left');
  872.     };

  873.     Window_Chronus.prototype.update = function() {
  874.         if (this.chronus().isShowingCalendar()) {
  875.             this.show();
  876.             if (this.chronus().isNeedRefresh()) this.refresh();
  877.         } else {
  878.             this.hide();
  879.         }
  880.     };

  881.     Window_Chronus.prototype.chronus = function() {
  882.         return $gameSystem.chronus();
  883.     };

  884.     Window_Chronus.prototype.getDateFormat = function(lineNumber) {
  885.         return this.chronus().getDateFormat(lineNumber);
  886.     };

  887.     //=============================================================================
  888.     // Sprite_Chronicle_Clock
  889.     //  アナログ時計表示スプライトクラスです。
  890.     //=============================================================================
  891.     Sprite_Chronicle_Clock.prototype             = Object.create(Sprite.prototype);
  892.     Sprite_Chronicle_Clock.prototype.constructor = Sprite_Chronicle_Clock;

  893.     var _Sprite_Chronicle_Clock_initialize      = Sprite_Chronicle_Clock.prototype.initialize;
  894.     Sprite_Chronicle_Clock.prototype.initialize = function() {
  895.         _Sprite_Chronicle_Clock_initialize.apply(this, arguments);
  896.         this.x        = getParamNumber('時計X座標');
  897.         this.y        = getParamNumber('時計Y座標');
  898.         this.anchor.x = 0.5;
  899.         this.anchor.y = 0.5;
  900.         this.bitmap   = ImageManager.loadPicture(this.chronus().getClockBaseFile());
  901.         this.createHourHandSprite();
  902.         this.createMinuteHandSprite();
  903.     };

  904.     Sprite_Chronicle_Clock.prototype.createHourHandSprite = function() {
  905.         var handName        = this.chronus().getHourHandFile();
  906.         var handSprite      = new Sprite();
  907.         handSprite.anchor.x = 0.5;
  908.         handSprite.anchor.y = 0.5;
  909.         handSprite.bitmap   = handName ? ImageManager.loadPicture(handName) : ImageManager.loadEmptyBitmap();
  910.         handSprite.visible  = !!handName;
  911.         this.hourHandSprite = handSprite;
  912.         this.addChild(this.hourHandSprite);
  913.     };

  914.     Sprite_Chronicle_Clock.prototype.createMinuteHandSprite = function() {
  915.         var handName          = this.chronus().getMinuteHandFile();
  916.         var handSprite        = new Sprite();
  917.         handSprite.anchor.x   = 0.5;
  918.         handSprite.anchor.y   = 0.5;
  919.         handSprite.bitmap     = handName ? ImageManager.loadPicture(handName) : ImageManager.loadEmptyBitmap();
  920.         handSprite.visible    = !!handName;
  921.         this.minuteHandSprite = handSprite;
  922.         this.addChild(this.minuteHandSprite);
  923.     };

  924.     Sprite_Chronicle_Clock.prototype.update = function() {
  925.         this.visible = this.chronus().isShowingClock();
  926.         if (this.visible) {
  927.             this.updateHourHand();
  928.             this.updateMinuteHand();
  929.         }
  930.     };

  931.     Sprite_Chronicle_Clock.prototype.updateHourHand = function() {
  932.         if (!this.hourHandSprite.visible) return;
  933.         this.hourHandSprite.rotation = this.chronus().getRotationHourHand();
  934.     };

  935.     Sprite_Chronicle_Clock.prototype.updateMinuteHand = function() {
  936.         if (!this.minuteHandSprite.visible) return;
  937.         this.minuteHandSprite.rotation = this.chronus().getRotationMinuteHand();
  938.     };

  939.     Sprite_Chronicle_Clock.prototype.chronus = function() {
  940.         return $gameSystem.chronus();
  941.     };

  942.     //=============================================================================
  943.     // Spriteset_Map
  944.     //  アナログ時計の画像を追加定義します。
  945.     //=============================================================================
  946.     var _Spriteset_Base_createUpperLayer      = Spriteset_Base.prototype.createUpperLayer;
  947.     Spriteset_Base.prototype.createUpperLayer = function() {
  948.         _Spriteset_Base_createUpperLayer.apply(this, arguments);
  949.         if (this instanceof Spriteset_Map) this.createClockSprite();
  950.     };

  951.     Spriteset_Map.prototype.createClockSprite = function() {
  952.         if (isParamExist('文字盤画像ファイル')) {
  953.             this._clockSprite = new Sprite_Chronicle_Clock();
  954.             this.addChild(this._clockSprite);
  955.         }
  956.     };

  957.     //=============================================================================
  958.     // Game_Chronus
  959.     //  時の流れを扱うクラスです。このクラスはGame_Systemクラスで生成されます。
  960.     //  セーブデータの保存対象のためグローバル領域に定義します。
  961.     //=============================================================================
  962.     Game_Chronus.weatherTypes         = ['none', 'rain', 'storm', 'snow'];
  963.     Game_Chronus.prototype.initialize = function() {
  964.         this._stop            = false;        // 停止フラグ(全ての加算に対して有効。ただし手動による加算は例外)
  965.         this._disableTint     = false;        // 色調変更禁止フラグ
  966.         this._calendarVisible = !paramCalendarHidden; // カレンダー表示フラグ
  967.         this._disableWeather  = false;        // 天候制御禁止フラグ
  968.         this._weatherType     = 0;            // 天候タイプ(0:なし 1:雨 2:嵐 :3雪)
  969.         this._weatherPower    = 0;            // 天候の強さ
  970.         this._weatherSnowLand = false;        // 降雪地帯フラグ
  971.         this._clockVisible    = true;         // アナログ時計表示フラグ
  972.         this._realTime        = false;        // 実時間フラグ
  973.         this._badWeaterLevel  = 0;            // 悪天候の度合い
  974.         this._frameCount      = 0;
  975.         this._demandRefresh   = false;
  976.         this._prevHour        = -1;
  977.         this._nowDate         = null;
  978.         this._clearTone       = false;
  979.         this._timeAutoAdd     = getParamNumber('自然時間加算', 0, 99);
  980.         this._timeTransferAdd = getParamNumber('場所移動時間加算', 0);
  981.         this._timeBattleAdd   = getParamNumber('戦闘時間加算(固定)', 0);
  982.         this._timeTurnAdd     = getParamNumber('戦闘時間加算(ターン)', 0);
  983.         this._weekNames       = getParamArrayString('曜日配列');
  984.         this._monthNames      = getParamArrayString('月名配列');
  985.         this._daysOfMonth     = getParamArrayNumber('月ごとの日数配列');
  986.         this._clockBaseFile   = null;
  987.         this._minuteHandFile  = null;
  988.         this._hourHandFile    = null;
  989.         this._timeMeter       = 0;
  990.         this._dayMeter        = 0;
  991.         this._initDate        = Date.now();
  992.         this.initTotalTime();
  993.         this.onLoad();
  994.     };

  995.     Game_Chronus.prototype.initTotalTime = function() {
  996.         this._criterionTime = this._timeMeter;
  997.         this._criterionDay  = this._dayMeter;
  998.         this._initDate      = Date.now();
  999.     };

  1000.     Game_Chronus.prototype.onLoad = function() {
  1001.         this._nowDate = new Date();
  1002.         if (!this._frameCount) this._frameCount = 0;
  1003.         if (!this._timers) this._timers = [];
  1004.         if (!this._namedTimers) this._namedTimers = {};
  1005.     };

  1006.     Game_Chronus.prototype.onMapLoaded = function() {
  1007.         this.updateWeatherType();
  1008.         this.updateWeatherPower();
  1009.         this.refreshWeather(true);
  1010.     };

  1011.     Game_Chronus.prototype.update = function() {
  1012.         this.updateTimer();
  1013.         this.updateEffect();
  1014.         if (this.isTimeStop()) return;
  1015.         this._frameCount++;
  1016.         if (this._frameCount >= paramAutoAddInterval) {
  1017.             if (this.isRealTime()) {
  1018.                 this.updateRealTime();
  1019.             }
  1020.             this.addTime();
  1021.         }
  1022.     };

  1023.     Game_Chronus.prototype.updateRealTime = function() {
  1024.         this._nowDate.setTime(Date.now());
  1025.     };

  1026.     Game_Chronus.prototype.updateTimer = function() {
  1027.         for (var timerName in this._namedTimers) {
  1028.             if (this._namedTimers.hasOwnProperty(timerName)) {
  1029.                 var valid = this._namedTimers[timerName].update();
  1030.                 if (!valid) this.clearTimer(timerName);
  1031.             }
  1032.         }
  1033.         this._timers = this._timers.filter(function(timer) {
  1034.             return timer.update();
  1035.         });
  1036.     };

  1037.     Game_Chronus.prototype.isRealTime = function() {
  1038.         return this._realTime;
  1039.     };

  1040.     Game_Chronus.prototype.isTimeStop = function() {
  1041.         return this.isStop() || $gameMap.isTimeStopEventRunning();
  1042.     };

  1043.     Game_Chronus.prototype.updateEffect = function() {
  1044.         var hour = this.getHour();
  1045.         if (this._prevHour !== hour) {
  1046.             this.updateWeather();
  1047.             this.refreshTint(false);
  1048.             this._prevHour = this.getHour();
  1049.         }
  1050.     };

  1051.     Game_Chronus.prototype.refreshTint = function(swift) {
  1052.         if (this.isEnableTint()) {
  1053.             this.setTint(this.getTimeZone(), swift);
  1054.             this._clearTone = false;
  1055.         } else if (!this._clearTone) {
  1056.             $gameScreen.clearTone();
  1057.             this._clearTone = true;
  1058.         }
  1059.     };

  1060.     Game_Chronus.prototype.setTint = function(timeId, swift) {
  1061.         var tone = [0, 0, 0, 0];
  1062.         settings.timeTone.forEach(function(toneInfo) {
  1063.             if (toneInfo.timeId === timeId) {
  1064.                 tone = toneInfo.value.clone();
  1065.                 if (tone.length < 4) throw new Error('色調の値が不正です。:' + tone);
  1066.             }
  1067.         }.bind(this));
  1068.         if (this.getWeatherTypeId() !== 0) {
  1069.             tone[0] = tone[0] > 0 ? tone[0] / 7 : tone[0] - 14;
  1070.             tone[1] = tone[1] > 0 ? tone[1] / 7 : tone[1] - 14;
  1071.             tone[2] = tone[2] > 0 ? tone[2] / 7 : tone[1] - 14;
  1072.             tone[3] = tone[3] === 0 ? 68 : tone[3] + 14;
  1073.         }
  1074.         $gameScreen.startTint(tone, swift ? 0 : this.getEffectDuration());
  1075.     };

  1076.     Game_Chronus.prototype.setWeatherType = function(value) {
  1077.         this._weatherType = value.clamp(0, Game_Chronus.weatherTypes.length - 1);
  1078.     };

  1079.     Game_Chronus.prototype.setWeatherPower = function(value) {
  1080.         this._weatherPower = value.clamp(0, 10);
  1081.     };

  1082.     Game_Chronus.prototype.setTimeAutoAdd = function(value) {
  1083.         this._timeAutoAdd = value.clamp(0, 99);
  1084.     };

  1085.     Game_Chronus.prototype.updateWeather = function() {
  1086.         if (!this._disableWeather) {
  1087.             this.updateBatWeatherLevel();
  1088.         } else {
  1089.             this._weatherType  = 0;
  1090.             this._weatherPower = 0;
  1091.         }
  1092.         this.refreshWeather(false);
  1093.     };

  1094.     Game_Chronus.prototype.updateBatWeatherLevel = function() {
  1095.         var frequency = this.getChangeWeatherFrequency();
  1096.         var max       = this.getBadWeatherLevelMax();
  1097.         var newLevel  = (this._badWeaterLevel || 0).clamp(frequency, max - frequency);
  1098.         if (Math.randomInt(10) <= 1) frequency *= 5;
  1099.         this._badWeaterLevel = (newLevel + (Math.randomInt(frequency * 2) - frequency)).clamp(0, max);
  1100.         this.updateWeatherType();
  1101.         this.updateWeatherPower();
  1102.     };

  1103.     Game_Chronus.prototype.forceSetBatWeatherLevel = function(type, power) {
  1104.         var newLevel = 0;
  1105.         switch (type) {
  1106.             case Game_Chronus.weatherTypes[1]:
  1107.                 newLevel = this.getBadWeatherLevelRainy() + power;
  1108.                 break;
  1109.             case Game_Chronus.weatherTypes[2]:
  1110.                 newLevel = this.getBadWeatherLevelHeavyRainy() + power;
  1111.                 break;
  1112.             case Game_Chronus.weatherTypes[3]:
  1113.                 newLevel = this.getBadWeatherLevelRainy() + power * 2;
  1114.                 break;
  1115.         }
  1116.         this._badWeaterLevel = newLevel;
  1117.     };

  1118.     Game_Chronus.prototype.updateWeatherType = function() {
  1119.         var type        = 0;
  1120.         var border      = this.getBadWeatherLevelRainy();
  1121.         var heavyBorder = this.getBadWeatherLevelHeavyRainy();
  1122.         if (this._badWeaterLevel >= border) {
  1123.             type = (this.isSnowLand() ? 3 : this._badWeaterLevel >= heavyBorder ? 2 : 1);
  1124.         }
  1125.         this.setWeatherType(type);
  1126.     };

  1127.     Game_Chronus.prototype.updateWeatherPower = function() {
  1128.         var power  = 0;
  1129.         var border = this.getBadWeatherLevelRainy();
  1130.         if (this._badWeaterLevel >= border) {
  1131.             power = Math.floor((this._badWeaterLevel - border) / 2);
  1132.         }
  1133.         this.setWeatherPower(power);
  1134.     };

  1135.     Game_Chronus.prototype.getBadWeatherLevelMax = function() {
  1136.         return this._badWeaterLevelMax || 40;
  1137.     };

  1138.     Game_Chronus.prototype.getBadWeatherLevelRainy = function() {
  1139.         return this.getBadWeatherLevelMax() - 20;
  1140.     };

  1141.     Game_Chronus.prototype.getBadWeatherLevelHeavyRainy = function() {
  1142.         return this.getBadWeatherLevelMax() - 10;
  1143.     };

  1144.     Game_Chronus.prototype.getChangeWeatherFrequency = function() {
  1145.         return 4;
  1146.     };

  1147.     Game_Chronus.prototype.refreshWeather = function(swift) {
  1148.         if (this.isEnableWeather()) {
  1149.             this.setScreenWeather(swift);
  1150.         } else {
  1151.             $gameScreen.changeWeather(0, 0, 0);
  1152.         }
  1153.     };

  1154.     Game_Chronus.prototype.setScreenWeather = function(swift) {
  1155.         $gameScreen.changeWeather(this.getWeatherType(), this._weatherPower, swift ? 0 : this.getEffectDuration());
  1156.     };

  1157.     Game_Chronus.prototype.getEffectDuration = function() {
  1158.         if (this.isRealTime()) {
  1159.             return 600;
  1160.         }
  1161.         return this._timeAutoAdd === 0 ? 1 : Math.floor(60 * 5 / (this.getRealAddSpeed() / 10));
  1162.     };

  1163.     Game_Chronus.prototype.getRealAddSpeed = function() {
  1164.         return this._timeAutoAdd * 60 / paramAutoAddInterval;
  1165.     };

  1166.     Game_Chronus.prototype.disableTint = function() {
  1167.         this._disableTint = true;
  1168.         this.refreshTint(true);
  1169.     };

  1170.     Game_Chronus.prototype.enableTint = function() {
  1171.         this._disableTint = false;
  1172.         this.refreshTint(true);
  1173.     };

  1174.     Game_Chronus.prototype.isEnableTint = function() {
  1175.         return !this._disableTint && !$gameMap.isDisableTint();
  1176.     };

  1177.     Game_Chronus.prototype.disableWeather = function() {
  1178.         this._disableWeather = true;
  1179.         this.refreshWeather(true);
  1180.     };

  1181.     Game_Chronus.prototype.enableWeather = function() {
  1182.         this._disableWeather = false;
  1183.         this.refreshWeather(true);
  1184.     };

  1185.     Game_Chronus.prototype.isEnableWeather = function() {
  1186.         return !this._disableWeather && !$gameMap.isDisableWeather();
  1187.     };

  1188.     Game_Chronus.prototype.setSnowLand = function() {
  1189.         this._weatherSnowLand = true;
  1190.         this.updateWeatherType();
  1191.         this.refreshWeather(true);
  1192.     };

  1193.     Game_Chronus.prototype.resetSnowLand = function() {
  1194.         this._weatherSnowLand = false;
  1195.         this.updateWeatherType();
  1196.         this.refreshWeather(true);
  1197.     };

  1198.     Game_Chronus.prototype.setRainyPercent = function(value) {
  1199.         this._badWeaterLevelMax = (value > 0 ? 2000 / value : Infinity);
  1200.         this.updateWeather();
  1201.     };

  1202.     Game_Chronus.prototype.setTimeReal = function() {
  1203.         this._realTime = true;
  1204.         this.updateRealTime();
  1205.         this.setGameVariable();
  1206.     };

  1207.     Game_Chronus.prototype.setTimeVirtual = function() {
  1208.         this._realTime = false;
  1209.         this.setGameVariable();
  1210.     };

  1211.     Game_Chronus.prototype.onBattleEnd = function() {
  1212.         if (this.isStop()) return;
  1213.         this.addTime(this._timeBattleAdd + this._timeTurnAdd * $gameTroop.turnCount());
  1214.     };

  1215.     Game_Chronus.prototype.transfer = function(realTransfer) {
  1216.         if (this.isStop()) return;
  1217.         if (realTransfer) {
  1218.             this.addTime(this._timeTransferAdd);
  1219.         }
  1220.         this.demandRefresh(true);
  1221.     };

  1222.     Game_Chronus.prototype.stop = function() {
  1223.         this._stop = true;
  1224.     };

  1225.     Game_Chronus.prototype.start = function() {
  1226.         this._stop = false;
  1227.     };

  1228.     Game_Chronus.prototype.isStop = function() {
  1229.         return this._stop;
  1230.     };

  1231.     Game_Chronus.prototype.showCalendar = function() {
  1232.         this._calendarVisible = true;
  1233.     };

  1234.     Game_Chronus.prototype.hideCalendar = function() {
  1235.         this._calendarVisible = false;
  1236.     };

  1237.     Game_Chronus.prototype.isShowingCalendar = function() {
  1238.         return this._calendarVisible;
  1239.     };

  1240.     Game_Chronus.prototype.isSnowLand = function() {
  1241.         return this._weatherSnowLand || $gameMap.isSnowLand();
  1242.     };

  1243.     Game_Chronus.prototype.showClock = function() {
  1244.         this._clockVisible = true;
  1245.     };

  1246.     Game_Chronus.prototype.hideClock = function() {
  1247.         this._clockVisible = false;
  1248.     };

  1249.     Game_Chronus.prototype.isShowingClock = function() {
  1250.         return this._clockVisible;
  1251.     };

  1252.     Game_Chronus.prototype.addTime = function(value) {
  1253.         if (arguments.length === 0) value = this._timeAutoAdd;
  1254.         this._timeMeter += value;
  1255.         while (this._timeMeter >= 60 * 24) {
  1256.             this.addDay();
  1257.             this._timeMeter -= 60 * 24;
  1258.         }
  1259.         this.demandRefresh(false);
  1260.     };

  1261.     Game_Chronus.prototype.setTime = function(hour, minute) {
  1262.         var time = hour * 60 + minute;
  1263.         if (this._timeMeter > time) this.addDay();
  1264.         this._timeMeter = time;
  1265.         this.demandRefresh(true);
  1266.     };

  1267.     Game_Chronus.prototype.addDay = function(value) {
  1268.         if (arguments.length === 0) value = 1;
  1269.         this._dayMeter += value;
  1270.         this.demandRefresh(false);
  1271.     };

  1272.     Game_Chronus.prototype.setDay = function(year, month, day) {
  1273.         this._dayMeter = this.calcNewDay(year, month, day);
  1274.         this.demandRefresh(true);
  1275.     };

  1276.     Game_Chronus.prototype.calcNewDay = function(year, month, day) {
  1277.         var newDay = (year - 1) * this.getDaysOfYear();
  1278.         for (var i = 1; i < month; i++) {
  1279.             newDay += this.getDaysOfMonth(i);
  1280.         }
  1281.         newDay += day - 1;
  1282.         return newDay;
  1283.     };

  1284.     Game_Chronus.prototype.demandRefresh = function(effectRefreshFlg) {
  1285.         this._demandRefresh = true;
  1286.         this._frameCount    = 0;
  1287.         this.setGameVariable();
  1288.         if (effectRefreshFlg) {
  1289.             this.refreshTint(true);
  1290.             this.updateWeather();
  1291.         }
  1292.     };

  1293.     Game_Chronus.prototype.isNeedRefresh = function() {
  1294.         var needRefresh     = this._demandRefresh;
  1295.         this._demandRefresh = false;
  1296.         return needRefresh;
  1297.     };

  1298.     Game_Chronus.prototype.getDaysOfWeek = function() {
  1299.         return this._weekNames.length;
  1300.     };

  1301.     Game_Chronus.prototype.getDaysOfMonth = function(month) {
  1302.         return this._daysOfMonth[month - 1];
  1303.     };

  1304.     Game_Chronus.prototype.getDaysOfYear = function() {
  1305.         var result = 0;
  1306.         this._daysOfMonth.forEach(function(days) {
  1307.             result += days;
  1308.         });
  1309.         return result;
  1310.     };

  1311.     Game_Chronus.prototype.setGameVariable = function() {
  1312.         this.setGameVariableSub('年のゲーム変数', this.getYear.bind(this));
  1313.         this.setGameVariableSub('月のゲーム変数', this.getMonth.bind(this));
  1314.         this.setGameVariableSub('日のゲーム変数', this.getDay.bind(this));
  1315.         this.setGameVariableSub('曜日IDのゲーム変数', this.getWeekIndex.bind(this));
  1316.         this.setGameVariableSub('曜日名のゲーム変数', this.getWeekName.bind(this));
  1317.         this.setGameVariableSub('時のゲーム変数', this.getHour.bind(this));
  1318.         this.setGameVariableSub('分のゲーム変数', this.getMinute.bind(this));
  1319.         this.setGameVariableSub('時間帯IDのゲーム変数', this.getTimeZone.bind(this));
  1320.         this.setGameVariableSub('天候IDのゲーム変数', this.getWeatherTypeId.bind(this));
  1321.         this.setGameVariableSub('累計時間のゲーム変数', this.getTotalTime.bind(this));
  1322.         this.setGameVariableSub('累計日数のゲーム変数', this.getTotalDay.bind(this));
  1323.         this.setGameVariableSub('フォーマット時間の変数', this.getFormatTimeFormula.bind(this));
  1324.     };

  1325.     Game_Chronus.prototype.setGameVariableSub = function(paramName, callBack) {
  1326.         var index = getParamNumber(paramName, 0);
  1327.         if (index !== 0) {
  1328.             $gameVariables.setValue(index, callBack());
  1329.         }
  1330.     };

  1331.     Game_Chronus.prototype.getMonthOfYear = function() {
  1332.         return this._daysOfMonth.length;
  1333.     };

  1334.     Game_Chronus.prototype.getWeekName = function() {
  1335.         return this._weekNames[this.getWeekIndex()];
  1336.     };

  1337.     Game_Chronus.prototype.getWeekIndex = function() {
  1338.         return this.isRealTime() ? this._nowDate.getDay() : this._dayMeter % this.getDaysOfWeek();
  1339.     };

  1340.     Game_Chronus.prototype.getYear = function() {
  1341.         return this.isRealTime() ? this._nowDate.getFullYear() : Math.floor(this._dayMeter / this.getDaysOfYear()) + 1;
  1342.     };

  1343.     Game_Chronus.prototype.getMonth = function() {
  1344.         if (this.isRealTime()) return this._nowDate.getMonth() + 1;
  1345.         var days = this._dayMeter % this.getDaysOfYear();
  1346.         for (var i = 0; i < this._daysOfMonth.length; i++) {
  1347.             days -= this._daysOfMonth[i];
  1348.             if (days < 0) return i + 1;
  1349.         }
  1350.         return null;
  1351.     };

  1352.     Game_Chronus.prototype.getDay = function() {
  1353.         if (this.isRealTime()) return this._nowDate.getDate();
  1354.         var days = this._dayMeter % this.getDaysOfYear();
  1355.         for (var i = 0; i < this._daysOfMonth.length; i++) {
  1356.             if (days < this._daysOfMonth[i]) return days + 1;
  1357.             days -= this._daysOfMonth[i];
  1358.         }
  1359.         return null;
  1360.     };

  1361.     Game_Chronus.prototype.getHour = function() {
  1362.         return this.isRealTime() ? this._nowDate.getHours() : Math.floor(this._timeMeter / 60);
  1363.     };

  1364.     Game_Chronus.prototype.getMinute = function() {
  1365.         return this.isRealTime() ? this._nowDate.getMinutes() : this._timeMeter % 60;
  1366.     };

  1367.     Game_Chronus.prototype.getFormatTimeFormula = function() {
  1368.         this._disablePadding = true;
  1369.         var formula          = this.convertDateFormatText(getParamString('フォーマット時間の計算式'));
  1370.         this._disablePadding = false;
  1371.         return eval(formula);
  1372.     };

  1373.     Game_Chronus.prototype.getDateFormat = function(index) {
  1374.         return this.convertDateFormatText(getParamString('日時フォーマット' + String(index)));
  1375.     };

  1376.     Game_Chronus.prototype.convertDateFormatText = function(format) {
  1377.         format = format.replace(/(YYYY)/gi, function() {
  1378.             return this.getValuePadding(this.getYear(), arguments[1].length);
  1379.         }.bind(this));
  1380.         format = format.replace(/MON/gi, function() {
  1381.             return this._monthNames[this.getMonth() - 1];
  1382.         }.bind(this));
  1383.         format = format.replace(/MM/gi, function() {
  1384.             return this.getValuePadding(this.getMonth(), String(this.getMonthOfYear()).length);
  1385.         }.bind(this));
  1386.         format = format.replace(/DD/gi, function() {
  1387.             return this.getValuePadding(this.getDay(),
  1388.                 String(this.getDaysOfMonth(this.getMonth())).length);
  1389.         }.bind(this));
  1390.         format = format.replace(/HH24/gi, function() {
  1391.             return this.getValuePadding(this.getHour(), 2);
  1392.         }.bind(this));
  1393.         format = format.replace(/HH/gi, function() {
  1394.             return this.getValuePadding(this.getHour() % 12, 2);
  1395.         }.bind(this));
  1396.         format = format.replace(/AM/gi, function() {
  1397.             return Math.floor(this.getHour() / 12) === 0 ?
  1398.                 $gameSystem.isJapanese() ? '午前' : 'Morning  ' :
  1399.                 $gameSystem.isJapanese() ? '午後' : 'Afternoon';
  1400.         }.bind(this));
  1401.         format = format.replace(/MI/gi, function() {
  1402.             return this.getValuePadding(this.getMinute(), 2);
  1403.         }.bind(this));
  1404.         format = format.replace(/DY/gi, function() {
  1405.             return this.getWeekName();
  1406.         }.bind(this));
  1407.         format = format.replace(/TZ/gi, function() {
  1408.             return this.getTimeZoneName();
  1409.         }.bind(this));
  1410.         return format;
  1411.     };

  1412.     Game_Chronus.prototype.getTimeZone = function() {
  1413.         var timeId = 0;
  1414.         settings.timeZone.forEach(function(zoneInfo) {
  1415.             if (this.isHourInRange(zoneInfo.start, zoneInfo.end)) timeId = zoneInfo.timeId;
  1416.         }.bind(this));
  1417.         return timeId;
  1418.     };

  1419.     Game_Chronus.prototype.getTimeZoneName = function() {
  1420.         var timeId = this.getTimeZone();
  1421.         return settings.timeZone.filter(function(zoneInfo) {
  1422.             return zoneInfo.timeId === timeId;
  1423.         })[0].name;
  1424.     };

  1425.     Game_Chronus.prototype.getWeatherTypeId = function() {
  1426.         return this._weatherType;
  1427.     };

  1428.     Game_Chronus.prototype.getWeatherType = function() {
  1429.         return Game_Chronus.weatherTypes[this.getWeatherTypeId()];
  1430.     };

  1431.     Game_Chronus.prototype.getValuePadding = function(value, digit, padChar) {
  1432.         if (this._disablePadding) {
  1433.             return value;
  1434.         }
  1435.         if (arguments.length === 2) padChar = '0';
  1436.         var result = '';
  1437.         for (var i = 0; i < digit; i++) result += padChar;
  1438.         result += value;
  1439.         return result.substr(-digit);
  1440.     };

  1441.     Game_Chronus.prototype.isHourInRange = function(min, max) {
  1442.         var hour = this.getHour();
  1443.         return hour >= min && hour <= max;
  1444.     };

  1445.     Game_Chronus.prototype.getAnalogueHour = function() {
  1446.         return this.getHour() + (this.getAnalogueMinute() / 60);
  1447.     };

  1448.     Game_Chronus.prototype.getAnalogueMinute = function() {
  1449.         return this.getMinute() + (this.isRealTime() ? 0 : this._frameCount / paramAutoAddInterval * this._timeAutoAdd);
  1450.     };

  1451.     Game_Chronus.prototype.getRotationHourHand = function() {
  1452.         return (this.getAnalogueHour() % 12) * (360 / 12) * Math.PI / 180;
  1453.     };

  1454.     Game_Chronus.prototype.getRotationMinuteHand = function() {
  1455.         return this.getAnalogueMinute() * (360 / 60) * Math.PI / 180;
  1456.     };

  1457.     Game_Chronus.prototype.getTotalTime = function() {
  1458.         if (this.isRealTime()) {
  1459.             return (this._nowDate - this._initDate) / (1000 * 60);
  1460.         } else {
  1461.             var dayMeter  = this._dayMeter - (this._criterionDay || 0);
  1462.             var timeMeter = this._timeMeter - (this._criterionTime || 0);
  1463.             return dayMeter * 24 * 60 + timeMeter;
  1464.         }
  1465.     };

  1466.     Game_Chronus.prototype.getTotalDay = function() {
  1467.         return this.getTotalTime() / (24 * 60);
  1468.     };

  1469.     Game_Chronus.prototype.makeAlarm = function(timerName, timeNumber, switchKey, interval) {
  1470.         var baseTime   = this.getTotalTime();
  1471.         var min        = timeNumber % 100;
  1472.         var hour       = Math.floor(timeNumber / 100) % 100;
  1473.         var timeMeter  = hour * 60 + min - (this._criterionTime || 0);
  1474.         var day        = Math.floor(timeNumber / 10000) % 100;
  1475.         var month      = Math.floor(timeNumber / 1000000) % 100;
  1476.         var year       = Math.floor(timeNumber / 100000000);
  1477.         var dayMeter   = this.calcNewDay(year, month, day) - (this._criterionDay || 0);
  1478.         var targetTime = dayMeter * 24 * 60 + timeMeter;
  1479.         this.makeTimer(timerName, (targetTime - baseTime) || 0, switchKey, true, interval);
  1480.     };

  1481.     Game_Chronus.prototype.makeTimer = function(timerName, timeout, switchKey, loop, interval) {
  1482.         var timer = new Game_ChronusTimer(timeout, switchKey, loop, interval);
  1483.         if (timerName) {
  1484.             this._namedTimers[timerName] = timer;
  1485.         } else {
  1486.             this._timers.push(timer);
  1487.         }
  1488.     };

  1489.     Game_Chronus.prototype.clearTimer = function(timerName) {
  1490.         delete this._namedTimers[timerName];
  1491.     };

  1492.     Game_Chronus.prototype.stopTimer = function(timerName) {
  1493.         var timer = this._namedTimers[timerName];
  1494.         if (timer) {
  1495.             timer.stop();
  1496.         }
  1497.     };

  1498.     Game_Chronus.prototype.startTimer = function(timerName) {
  1499.         var timer = this._namedTimers[timerName];
  1500.         if (timer) {
  1501.             timer.start();
  1502.         }
  1503.     };

  1504.     Game_Chronus.prototype.getClockBaseFile = function() {
  1505.         return this._clockBaseFile || paramClockBaseFile;
  1506.     };

  1507.     Game_Chronus.prototype.getMinuteHandFile = function() {
  1508.         return this._minuteHandFile || paramMinutesHandFile;
  1509.     };

  1510.     Game_Chronus.prototype.getHourHandFile = function() {
  1511.         return this._hourHandFile || paramHourHandFile;
  1512.     };

  1513.     Game_Chronus.prototype.setClockBaseFile = function(name) {
  1514.         this._clockBaseFile = name;
  1515.     };

  1516.     Game_Chronus.prototype.setMinuteHandFile = function(name) {
  1517.         this._minuteHandFile = name;
  1518.     };

  1519.     Game_Chronus.prototype.setHourHandFile = function(name) {
  1520.         this._hourHandFile = name;
  1521.     };

  1522.     //=============================================================================
  1523.     // Game_ChronusTimer
  1524.     //  ゲーム内時間のタイマーを扱うクラスです。このクラスはGame_Chronusクラスで生成されます。
  1525.     //  セーブデータの保存対象のためグローバル領域に定義します。
  1526.     //=============================================================================
  1527.     Game_ChronusTimer.prototype             = Object.create(Game_ChronusTimer.prototype);
  1528.     Game_ChronusTimer.prototype.constructor = Game_ChronusTimer;

  1529.     Game_ChronusTimer.prototype.initialize = function(timeout, switchKey, loop, interval) {
  1530.         this._timeout = timeout;
  1531.         this._interval = interval || timeout;
  1532.         this._loop    = loop;
  1533.         this._baseTime = this.getTotalTime();
  1534.         if (Array.isArray(switchKey)) {
  1535.             this.setCallBackSelfSwitch(switchKey);
  1536.         } else {
  1537.             this.setCallBackSwitch(switchKey);
  1538.         }
  1539.         this.start();
  1540.     };

  1541.     Game_ChronusTimer.prototype.start = function() {
  1542.         this._start = true;
  1543.     };

  1544.     Game_ChronusTimer.prototype.stop = function() {
  1545.         this._start = false;
  1546.     };

  1547.     Game_ChronusTimer.prototype.getTotalTime = function() {
  1548.         return $gameSystem.chronus().getTotalTime();
  1549.     };

  1550.     Game_ChronusTimer.prototype.setCallBackSwitch = function(switchId) {
  1551.         this._callBackSwitchId = switchId;
  1552.     };

  1553.     Game_ChronusTimer.prototype.setCallBackSelfSwitch = function(selfSwitchKey) {
  1554.         this._callBackSelfSwitchKey = selfSwitchKey;
  1555.     };

  1556.     Game_ChronusTimer.prototype.update = function() {
  1557.         if (!this._start || !this.isTimeout()) {
  1558.             return true;
  1559.         }
  1560.         this.onTimeout();
  1561.         if (this._loop) {
  1562.             this.resetBaseTime();
  1563.             return true;
  1564.         } else {
  1565.             return false;
  1566.         }
  1567.     };

  1568.     Game_ChronusTimer.prototype.resetBaseTime = function() {
  1569.         while(this.isTimeout()) {
  1570.             this._baseTime += this._timeout;
  1571.             this._timeout = this._interval;
  1572.         }
  1573.     };

  1574.     Game_ChronusTimer.prototype.isTimeout = function() {
  1575.         return this._baseTime + this._timeout <= this.getTotalTime();
  1576.     };

  1577.     Game_ChronusTimer.prototype.onTimeout = function() {
  1578.         if (this._callBackSwitchId) {
  1579.             $gameSwitches.setValue(this._callBackSwitchId, true);
  1580.         }
  1581.         if (this._callBackSelfSwitchKey) {
  1582.             $gameSelfSwitches.setValue(this._callBackSelfSwitchKey, true);
  1583.         }
  1584.     };
  1585. })();
复制代码

点评

666666  发表于 2020-2-1 10:01
回复

使用道具 举报

梦石
0
星屑
3930
在线时间
1198 小时
注册时间
2016-8-9
回帖
2355

开拓者

发表于 2020-2-1 21:47:39 | 显示全部楼层
其实,可以并行一个事件,等待216000 →变量a +1
酸酸甜甜就④哇噢
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

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

在本版发帖返回顶部