查看: 6322|回复: 6

[已经解决] 求时间系统

[复制链接]
梦石
0
星屑
97
在线时间
308 小时
注册时间
2014-1-16
回帖
397
发表于 2016-2-29 18:44:55 | 显示全部楼层 |阅读模式

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

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

×
想要一个时间系统的插件,哪位有?
梦石
0
星屑
22879
在线时间
8598 小时
注册时间
2011-12-31
回帖
3270
发表于 2016-2-29 18:55:56 | 显示全部楼层
https://github.com/triacontane/RPGMakerMV
Mit
範本
https://github.com/triacontane/PluginDevelopment
1.jpg

Chronus
  1. //=============================================================================
  2. // Chronus.js
  3. // ----------------------------------------------------------------------------
  4. // Copyright (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.2.1 2016/02/25 実時間表示設定でロードするとエラーが発生する現象の修正
  10. // 1.2.0 2016/02/14 アナログ時計の表示機能を追加
  11. //                  現実の時間を反映させる機能の追加
  12. // 1.1.3 2016/01/21 競合対策(YEP_MessageCore.js)
  13. // 1.1.2 2016/01/10 カレンダーウィンドウの表示位置をカスタマイズできる機能を追加
  14. // 1.1.1 2015/12/29 日の値に「1」を設定した場合に日付の表示がおかしくなる不具合を修正
  15. //                  一部のコードを最適化
  16. // 1.1.0 2015/12/01 天候と時間帯をゲーム変数に格納できるよう機能追加
  17. // 1.0.0 2015/11/27 初版
  18. // ----------------------------------------------------------------------------
  19. // [Blog]   : [url]http://triacontane.blogspot.jp/[/url]
  20. // [Twitter]: [url]https://twitter.com/triacontane/[/url]
  21. // [GitHub] : [url]https://github.com/triacontane/[/url]
  22. //=============================================================================

  23. /*:
  24. * @plugindesc ゲーム内時間の導入プラグイン
  25. * @author トリアコンタン
  26. *
  27. * @param 月ごとの日数配列
  28. * @desc 各月の日数の配列です。カンマ区切りで指定してください。個数は自由です。
  29. * @default 31,28,31,30,31,30,31,31,30,31,30,31
  30. *
  31. * @param 曜日配列
  32. * @desc 曜日の名称配列です。カンマ区切りで指定してください。個数は自由です。
  33. * @default (日),(月),(火),(水),(木),(金),(土)
  34. *
  35. * @param 自然時間加算
  36. * @desc 1秒ごとに加算されるゲーム時間(分単位)の値です。イベント処理中は無効です。
  37. * @default 5
  38. *
  39. * @param 場所移動時間加算
  40. * @desc 1回の場所移動で加算されるゲーム時間(分単位)の値です。
  41. * @default 30
  42. *
  43. * @param 戦闘時間加算(固定)
  44. * @desc 1回の戦闘で加算されるゲーム時間(分単位)の値です。
  45. * @default 30
  46. *
  47. * @param 戦闘時間加算(ターン)
  48. * @desc 1回の戦闘で消費したターン数ごとに加算されるゲーム時間(分単位)の値です。
  49. * @default 5
  50. *
  51. * @param 年のゲーム変数
  52. * @desc 指定した番号のゲーム変数に「年」の値が自動設定されます。
  53. * @default 0
  54. *
  55. * @param 月のゲーム変数
  56. * @desc 指定した番号のゲーム変数に「月」の値が自動設定されます。
  57. * @default 0
  58. *
  59. * @param 日のゲーム変数
  60. * @desc 指定した番号のゲーム変数に「日」の値が自動設定されます。
  61. * @default 0
  62. *
  63. * @param 曜日IDのゲーム変数
  64. * @desc 指定した番号のゲーム変数に「曜日」のIDが自動設定されます。
  65. * @default 0
  66. *
  67. * @param 曜日名のゲーム変数
  68. * @desc 指定した番号のゲーム変数に「曜日」の名称が自動設定されます。
  69. * ゲーム変数に文字列が入るので注意してください。
  70. * @default 0
  71. *
  72. * @param 時のゲーム変数
  73. * @desc 指定した番号のゲーム変数に「時」の値が自動設定されます。
  74. * @default 0
  75. *
  76. * @param 分のゲーム変数
  77. * @desc 指定した番号のゲーム変数に「時」の値が自動設定されます。
  78. * @default 0
  79. *
  80. * @param 時間帯IDのゲーム変数
  81. * @desc 指定した番号のゲーム変数に「時間帯」のIDが自動設定されます。
  82. * 0:深夜 1:早朝 2:朝 3:昼 4:夕方 5:夜
  83. * @default 0
  84. *
  85. * @param 天候IDのゲーム変数
  86. * @desc 指定した番号のゲーム変数に「天候」のIDが自動設定されます。
  87. * 0:なし 1:雨 2:嵐 3:雪
  88. * @default 0
  89. *
  90. * @param 日時フォーマット1
  91. * @desc マップ上の日付ウィンドウ1行目に表示される文字列です。
  92. * YYYY:年 MM:月 DD:日 HH24:時(24) HH:時(12) AM:午前 or 午後 MI:分 DY:曜日
  93. * @default YYYY年 MM月 DD日 DY
  94. *
  95. * @param 日時フォーマット2
  96. * @desc マップ上の日付ウィンドウ2行目に表示される文字列です。
  97. * YYYY:年 MM:月 DD:日 HH24:時(24) HH:時(12) AM:午前 or 午後 MI:分 DY:曜日
  98. * @default AMHH時 MI分
  99. *
  100. * @param カレンダー表示X座標
  101. * @desc カレンダーの表示 X 座標です。
  102. * @default 0
  103. *
  104. * @param カレンダー表示Y座標
  105. * @desc カレンダーの表示 Y 座標です。
  106. * @default 0
  107. *
  108. * @param 文字盤画像ファイル
  109. * @desc アナログ時計を表示する場合の文字盤画像ファイル名(拡張子は不要)です。
  110. * 画像は「img/pictures/」以下に保存してください。
  111. * @default
  112. *
  113. * @param 長針画像ファイル
  114. * @desc アナログ時計を表示する場合の長針画像ファイル名(拡張子は不要)です。
  115. * 画像は「img/pictures/」以下に保存してください。
  116. * @default
  117. *
  118. * @param 短針画像ファイル
  119. * @desc アナログ時計を表示する場合の長針画像ファイル名(拡張子は不要)です。
  120. * 画像は「img/pictures/」以下に保存してください。
  121. * @default
  122. *
  123. * @param 時計X座標
  124. * @desc アナログ時計の表示X座標です。画像の中心座標を指定してください。
  125. * @default 84
  126. *
  127. * @param 時計Y座標
  128. * @desc アナログ時計の表示Y座標です。画像の中心座標を指定してください。
  129. * @default 156
  130. *
  131. * @help ゲーム内で時刻と天候の概念を表現できるプラグインです。
  132. * 自動、マップ移動、戦闘で時間が経過し、時間と共に天候と色調が変化します。
  133. * これらの時間は調節可能で、またイベント中は時間の進行が停止します。
  134. *
  135. * さらに、現実の時間をゲーム中に反映させる機能もあります。
  136. * 設定を有効にすると現実の時間がゲーム内とリンクします。
  137. *
  138. * 日付や曜日も記録し、曜日の数や名称を自由に設定できます。
  139. * 現在日付はフォーマットに従って、画面左上に表示されます。
  140. *
  141. * 日付フォーマットには以下を利用できます。
  142. * YYYY:年 MM:月 DD:日 HH24:時(24) HH:時(12) AM:午前 or 午後 MI:分 DY:曜日
  143. *
  144. * また、規格に沿った画像を用意すればアナログ時計も表示できます。
  145. * 表示位置は各画像の表示可否は調整できます。
  146. *
  147. * 画像の規格は以下の通りです。
  148. * ・文字盤 : 任意のサイズの正方形画像
  149. * ・長針  : 文字盤と同じサイズの画像で、上(0)を指している針の画像
  150. * ・短針  : 文字盤と同じサイズの画像で、上(0)を指している針の画像
  151. *
  152. * ツクマテにて規格に合った時計画像をリクエストしました。
  153. * 使用する場合は、以下のURLより利用規約を別途確認の上、ご使用ください。
  154. * [url]http://tm.lucky-duet.com/viewtopic.php?f=47&t=555&p=1615#p1615[/url]
  155. *
  156. * プラグインコマンド詳細
  157. *  イベントコマンド「プラグインコマンド」から実行。
  158. *  指定する値には制御文字\V[n]を使用できます。
  159. *  (引数の間は半角スペースで区切る)
  160. *
  161. * C_ADD_TIME [分] : 指定した値(分単位)だけ時間が経過します。
  162. * C_ADD_DAY [日] : 指定した値(日単位)だけ日数が経過します。
  163. * C_SET_TIME [時] [分] : 指定した時間に変更します。
  164. * C_SET_DAY [年] [月] [日] : 指定した日付に変更します。
  165. * C_STOP : 時間の進行を停止します。
  166. * C_START : 時間の進行を開始します。
  167. * C_SHOW : カレンダーを表示します。
  168. * C_HIDE : カレンダーを非表示にします。
  169. * C_DISABLE_TINT : 時間帯による色調の変更を禁止します。
  170. * C_ENABLE_TINT : 時間帯による色調の変更を許可します。
  171. * C_DISABLE_WEATHER : 時間経過による天候の変化を禁止します。
  172. * C_ENABLE_WEATHER : 時間経過による天候の変化を許可します。
  173. * C_SET_SNOW_LAND : 悪天候時に雪が降るようになります。
  174. * C_RESET_SNOW_LAND : 悪天候時に雨もしくは嵐が降るようになります。
  175. * C_SET_SPEED [分] : 実時間1秒あたりの時間の経過速度を設定します。
  176. * C_SHOW_CLOCK : アナログ時計を表示します。
  177. * C_HIDE_CLOCK : アナログ時計を非表示にします。
  178. * C_SET_TIME_REAL : 時間の取得方法を実時間に変更します。
  179. * C_SET_TIME_VIRTUAL : 時間の取得方法をゲーム内時間に変更します。
  180. *
  181. * メモ欄詳細
  182. *  タイトルセットおよびマップのメモ欄に以下を入力すると、一時的に天候と色調変化を自動で無効化できます。
  183. *  屋内マップやイベントシーンなどで一時的に無効化したい場合に利用できます。
  184. *
  185. * <C_Tint:OFF> : 色調の変更を一時的に無効化します。
  186. * <C_Weather:OFF> : 天候を一時的に無効化します。
  187. *
  188. * 利用規約:
  189. *  作者に無断で改変、再配布が可能で、利用形態(商用、18禁利用等)
  190. *  についても制限はありません。
  191. *  このプラグインはもうあなたのものです。
  192. */

  193. function Game_Chronus() {
  194.     this.initialize.apply(this, arguments);
  195. }

  196. (function () {
  197.     'use strict';
  198.     var pluginName = 'Chronus';

  199.     var getParamString = function(paramNames) {
  200.         var value = getParamOther(paramNames);
  201.         return value == null ? '' : value;
  202.     };

  203.     var getParamNumber = function(paramNames, min, max) {
  204.         var value = getParamOther(paramNames);
  205.         if (arguments.length < 2) min = -Infinity;
  206.         if (arguments.length < 3) max = Infinity;
  207.         return (parseInt(value, 10) || 0).clamp(min, max);
  208.     };

  209.     var getParamOther = function(paramNames) {
  210.         if (!Array.isArray(paramNames)) paramNames = [paramNames];
  211.         for (var i = 0; i < paramNames.length; i++) {
  212.             var name = PluginManager.parameters(pluginName)[paramNames[i]];
  213.             if (name) return name;
  214.         }
  215.         return null;
  216.     };

  217.     var isParamExist = function(paramNames) {
  218.         return getParamOther(paramNames) != null;
  219.     };

  220.     var getParamArrayString = function (paramNames) {
  221.         var values = getParamString(paramNames).split(',');
  222.         for (var i = 0; i < values.length; i++) values[i] = values[i].trim();
  223.         return values;
  224.     };

  225.     var getParamArrayNumber = function (paramNames, min, max) {
  226.         var values = getParamArrayString(paramNames);
  227.         if (arguments.length < 2) min = -Infinity;
  228.         if (arguments.length < 3) max = Infinity;
  229.         for (var i = 0; i < values.length; i++) values[i] = (parseInt(values[i], 10) || 0).clamp(min, max);
  230.         return values;
  231.     };

  232.     var getCommandName = function (command) {
  233.         return (command || '').toUpperCase();
  234.     };

  235.     var getArgNumber = function (arg, min, max) {
  236.         if (arguments.length < 2) min = -Infinity;
  237.         if (arguments.length < 3) max = Infinity;
  238.         return parseIntStrict(convertEscapeCharacters(arg)).clamp(min, max);
  239.     };

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

  245.     var convertEscapeCharacters = function(text) {
  246.         if (text == null) text = '';
  247.         var window = SceneManager._scene._windowLayer.children[0];
  248.         return window ? window.convertEscapeCharacters(text) : text;
  249.     };

  250.     var _DataManager_extractSaveContents = DataManager.extractSaveContents;
  251.     DataManager.extractSaveContents = function(contents) {
  252.         _DataManager_extractSaveContents.apply(this, arguments);
  253.         $gameSystem.onLoad();
  254.     };

  255.     //=============================================================================
  256.     // Game_Interpreter
  257.     //  プラグインコマンド[C_ADD_TIME]などを追加定義します。
  258.     //=============================================================================
  259.     var _Game_Interpreter_pluginCommand      = Game_Interpreter.prototype.pluginCommand;
  260.     Game_Interpreter.prototype.pluginCommand = function (command, args) {
  261.         _Game_Interpreter_pluginCommand.apply(this, arguments);
  262.         try {
  263.             this.pluginCommandChronus(command, args);
  264.         } catch (e) {
  265.             if ($gameTemp.isPlaytest() && Utils.isNwjs()) {
  266.                 var window = require('nw.gui').Window.get();
  267.                 var devTool = window.showDevTools();
  268.                 devTool.moveTo(0, 0);
  269.                 devTool.resizeTo(Graphics.width, Graphics.height);
  270.                 window.focus();
  271.             }
  272.             console.log('プラグインコマンドの実行中にエラーが発生しました。');
  273.             console.log('- コマンド名  : ' + command);
  274.             console.log('- コマンド引数 : ' + args);
  275.             console.log('- エラー原因   : ' + e.toString());
  276.         }
  277.     };

  278.     Game_Interpreter.prototype.pluginCommandChronus = function (command, args) {

  279.         switch (getCommandName(command)) {
  280.             case 'C_ADD_TIME' :
  281.                 $gameSystem.chronus().addTime(getArgNumber(args[0], 0, 99999));
  282.                 break;
  283.             case 'C_ADD_DAY' :
  284.                 $gameSystem.chronus().addDay(getArgNumber(args[0], 0, 99999));
  285.                 break;
  286.             case 'C_SET_TIME' :
  287.                 var hour = getArgNumber(args[0], 0, 23);
  288.                 var minute = getArgNumber(args[1], 0, 59);
  289.                 $gameSystem.chronus().setTime(hour, minute);
  290.                 break;
  291.             case 'C_SET_DAY' :
  292.                 var year = getArgNumber(args[0], 1, 5000);
  293.                 var month = getArgNumber(args[1], 1, $gameSystem.chronus().getMonthOfYear());
  294.                 var day = getArgNumber(args[2], 1, $gameSystem.chronus().getDaysOfMonth(month));
  295.                 $gameSystem.chronus().setDay(year, month, day);
  296.                 break;
  297.             case 'C_STOP' :
  298.                 $gameSystem.chronus().stop();
  299.                 break;
  300.             case 'C_START' :
  301.                 $gameSystem.chronus().start();
  302.                 break;
  303.             case 'C_SHOW' :
  304.                 $gameSystem.chronus().showCalendar();
  305.                 break;
  306.             case 'C_HIDE' :
  307.                 $gameSystem.chronus().hideCalendar();
  308.                 break;
  309.             case 'C_DISABLE_TINT':
  310.                 $gameSystem.chronus().disableTint();
  311.                 break;
  312.             case 'C_ENABLE_TINT':
  313.                 $gameSystem.chronus().enableTint();
  314.                 break;
  315.             case 'C_DISABLE_WEATHER':
  316.                 $gameSystem.chronus().disableWeather();
  317.                 break;
  318.             case 'C_ENABLE_WEATHER':
  319.                 $gameSystem.chronus().enableWeather();
  320.                 break;
  321.             case 'C_SET_SNOW_LAND':
  322.                 $gameSystem.chronus().setSnowLand();
  323.                 break;
  324.             case 'C_RESET_SNOW_LAND':
  325.                 $gameSystem.chronus().resetSnowLand();
  326.                 break;
  327.             case 'C_SET_SPEED':
  328.                 $gameSystem.chronus().setTimeAutoAdd(getArgNumber(args[0], 0, 99));
  329.                 break;
  330.             case 'C_SHOW_CLOCK':
  331.                 $gameSystem.chronus().showClock();
  332.                 break;
  333.             case 'C_HIDE_CLOCK':
  334.                 $gameSystem.chronus().hideClock();
  335.                 break;
  336.             case 'C_SET_TIME_REAL':
  337.                 $gameSystem.chronus().setTimeReal();
  338.                 break;
  339.             case 'C_SET_TIME_VIRTUAL':
  340.                 $gameSystem.chronus().setTimeVirtual();
  341.                 break;
  342.         }
  343.     };

  344.     var _Game_Interpreter_command236 = Game_Interpreter.prototype.command236;
  345.     Game_Interpreter.prototype.command236 = function() {
  346.         var result = _Game_Interpreter_command236.call(this);
  347.         if (!$gameParty.inBattle()) {
  348.             $gameSystem.chronus().setWeatherType(Game_Chronus.weatherTypes.indexOf(this._params[0]));
  349.             $gameSystem.chronus().setWeatherPower(this._params[1]);
  350.             $gameSystem.chronus().refreshTint(true);
  351.         }
  352.         return result;
  353.     };

  354.     //=============================================================================
  355.     // Game_System
  356.     //  ゲーム内時間を扱うクラス「Game_Chronus」を追加定義します。
  357.     //=============================================================================
  358.     var _Game_System_initialize = Game_System.prototype.initialize;
  359.     Game_System.prototype.initialize = function() {
  360.         _Game_System_initialize.call(this);
  361.         this._chronus = new Game_Chronus();
  362.     };

  363.     Game_System.prototype.chronus = function() {
  364.         return this._chronus;
  365.     };

  366.     Game_System.prototype.onBattleEnd = function() {
  367.         this.chronus().onBattleEnd();
  368.     };

  369.     var _Game_System_onLoad = Game_System.prototype.onLoad;
  370.     Game_System.prototype.onLoad = function() {
  371.         if (_Game_System_onLoad) _Game_System_onLoad.apply(this, arguments);
  372.         if (!this.chronus()) this._chronus = new Game_Chronus();
  373.         this._chronus.onLoad();
  374.     };

  375.     //=============================================================================
  376.     // Game_Map
  377.     //  マップ及びタイルセットから、色調変化無効フラグを取得します。
  378.     //=============================================================================
  379.     Game_Map.prototype.isDisableTint = function() {
  380.         return this.isChronicleMetaInfo('Tint');
  381.     };

  382.     Game_Map.prototype.isDisableWeather = function() {
  383.         return this.isChronicleMetaInfo('Weather');
  384.     };

  385.     Game_Map.prototype.isChronicleMetaInfo = function(tagName) {
  386.         if (Utils.isOptionValid('etest') || Utils.isOptionValid('btest')) return false;
  387.         var value = $dataMap.meta['chronus' + tagName];
  388.         if (value != null) return value === 'OFF';
  389.         value = $dataMap.meta['C_' + tagName];
  390.         if (value != null) return value === 'OFF';
  391.         value = $dataTilesets[$dataMap.tilesetId].meta['chronus' + tagName];
  392.         if (value != null) return value === 'OFF';
  393.         value = $dataTilesets[$dataMap.tilesetId].meta['C_' + tagName];
  394.         if (value != null) return value === 'OFF';
  395.         return false;
  396.     };

  397.     //=============================================================================
  398.     // Game_Player
  399.     //  場所移動時の時間経過を追加定義します。
  400.     //=============================================================================
  401.     var _Game_Player_performTransfer = Game_Player.prototype.performTransfer;
  402.     Game_Player.prototype.performTransfer = function() {
  403.         _Game_Player_performTransfer.call(this);
  404.         $gameSystem.chronus().transfer();
  405.     };

  406.     //=============================================================================
  407.     // Scene_Map
  408.     //  Game_Chronusの更新を追加定義します。
  409.     //=============================================================================
  410.     var _Scene_Map_onMapLoaded = Scene_Map.prototype.onMapLoaded;
  411.     Scene_Map.prototype.onMapLoaded = function() {
  412.         $gameSystem.chronus().refreshTint(true);
  413.         $gameSystem.chronus().refreshWeather(true);
  414.         _Scene_Map_onMapLoaded.apply(this, arguments);
  415.     };

  416.     var _Scene_Map_updateMain = Scene_Map.prototype.updateMain;
  417.     Scene_Map.prototype.updateMain = function() {
  418.         _Scene_Map_updateMain.apply(this, arguments);
  419.         $gameSystem.chronus().update();
  420.     };

  421.     var _Scene_Map_createAllWindows = Scene_Map.prototype.createAllWindows;
  422.     Scene_Map.prototype.createAllWindows = function() {
  423.         this.createChronusWindow();
  424.         _Scene_Map_createAllWindows.apply(this, arguments);
  425.     };

  426.     Scene_Map.prototype.createChronusWindow = function() {
  427.         this._chronusWindow = new Window_Chronus();
  428.         this.addWindow(this._chronusWindow);
  429.     };

  430.     //=============================================================================
  431.     // BattleManager
  432.     //  戦闘終了時のゲーム内時間経過処理を追加定義します。
  433.     //=============================================================================
  434.     var _BattleManager_endBattle = BattleManager.endBattle;
  435.     BattleManager.endBattle = function(result) {
  436.         $gameSystem.onBattleEnd();
  437.         _BattleManager_endBattle.call(this, result);
  438.     };

  439.     //=============================================================================
  440.     // Window_Chronus
  441.     //  ゲーム内時間情報を描画するウィンドウです。
  442.     //=============================================================================
  443.     function Window_Chronus() {
  444.         this.initialize.apply(this, arguments);
  445.     }

  446.     Window_Chronus.prototype = Object.create(Window_Base.prototype);
  447.     Window_Chronus.prototype.constructor = Window_Chronus;

  448.     var _Window_Chronus_initialize = Window_Chronus.prototype.initialize;
  449.     Window_Chronus.prototype.initialize = function() {
  450.         var bitmap = new Bitmap();
  451.         var pad = 8;
  452.         var width = Math.max(bitmap.measureTextWidth(this.chronus().getDateFormat(1)),
  453.             bitmap.measureTextWidth(this.chronus().getDateFormat(2)));
  454.         _Window_Chronus_initialize.call(this, 0, 0, width + pad * 2, 28 * 2 + pad * 2);
  455.         this.padding = pad;
  456.         this.contents = new Bitmap(this.width - this.padding * 2, this.height - this.padding * 2);
  457.         this.x = getParamNumber('カレンダー表示X座標');
  458.         this.y = getParamNumber('カレンダー表示Y座標');
  459.         this.refresh();
  460.     };

  461.     Window_Chronus.prototype.refresh = function() {
  462.         this.contents.clear();
  463.         this.contents.drawText(this.chronus().getDateFormat(1),
  464.             0, 0, this.contents.width, this.contents.fontSize, 'left');
  465.         this.contents.drawText(this.chronus().getDateFormat(2),
  466.             0, this.contents.fontSize, this.contents.width, this.contents.fontSize, 'left');
  467.     };

  468.     Window_Chronus.prototype.update = function() {
  469.         if (this.chronus().isShowingCalendar()) {
  470.             this.show();
  471.             if (this.chronus().isNeedRefresh()) this.refresh();
  472.         } else {
  473.             this.hide();
  474.         }
  475.     };

  476.     Window_Chronus.prototype.chronus = function() {
  477.         return $gameSystem.chronus();
  478.     };

  479.     //=============================================================================
  480.     // Sprite_Abstract
  481.     //  時計スプライトを使用しない場合に使用される抽象スプライトクラスです。
  482.     //=============================================================================
  483.     function Sprite_Abstract() {
  484.         this.initialize.apply(this, arguments);
  485.     }

  486.     Sprite_Abstract.prototype.initialize = function() {
  487.         this.x = 0;
  488.         this.y = 0;
  489.         this.width = 0;
  490.         this.height = 0;
  491.     };

  492.     Sprite_Abstract.prototype.update = function() {
  493.     };

  494.     //=============================================================================
  495.     // Sprite_Chronicle_Clock
  496.     //  アナログ時計表示スプライトクラスです。
  497.     //=============================================================================
  498.     function Sprite_Chronicle_Clock() {
  499.         this.initialize.apply(this, arguments);
  500.     }

  501.     Sprite_Chronicle_Clock.prototype = Object.create(Sprite.prototype);
  502.     Sprite_Chronicle_Clock.prototype.constructor = Sprite_Chronicle_Clock;

  503.     var _Sprite_Chronicle_Clock_initialize = Sprite_Chronicle_Clock.prototype.initialize;
  504.     Sprite_Chronicle_Clock.prototype.initialize = function() {
  505.         _Sprite_Chronicle_Clock_initialize.apply(this, arguments);
  506.         this.x = getParamNumber('時計X座標');
  507.         this.y = getParamNumber('時計Y座標');
  508.         this.anchor.x = 0.5;
  509.         this.anchor.y = 0.5;
  510.         this.bitmap = ImageManager.loadPicture(getParamString('文字盤画像ファイル'));
  511.         this.createHourHandSprite();
  512.         this.createMinuteHandSprite();
  513.     };

  514.     Sprite_Chronicle_Clock.prototype.createHourHandSprite = function() {
  515.         var handName = getParamString('短針画像ファイル'), handSprite = new Sprite();
  516.         handSprite.anchor.x = 0.5;
  517.         handSprite.anchor.y = 0.5;
  518.         handSprite.bitmap = handName ? ImageManager.loadPicture(handName) : ImageManager.loadEmptyBitmap();
  519.         handSprite.visible = !!handName;
  520.         this.hourHandSprite = handSprite;
  521.         this.addChild(this.hourHandSprite);
  522.     };

  523.     Sprite_Chronicle_Clock.prototype.createMinuteHandSprite = function() {
  524.         var handName = getParamString('長針画像ファイル'), handSprite = new Sprite();
  525.         handSprite.anchor.x = 0.5;
  526.         handSprite.anchor.y = 0.5;
  527.         handSprite.bitmap = handName ? ImageManager.loadPicture(handName) : ImageManager.loadEmptyBitmap();
  528.         handSprite.visible = !!handName;
  529.         this.minuteHandSprite = handSprite;
  530.         this.addChild(this.minuteHandSprite);
  531.     };

  532.     Sprite_Chronicle_Clock.prototype.update = function() {
  533.         this.visible = this.chronus().isShowingClock();
  534.         if (this.visible && !this.chronus().isTimeStop()) {
  535.             this.updateHourHand();
  536.             this.updateMinuteHand();
  537.         }
  538.     };

  539.     Sprite_Chronicle_Clock.prototype.updateHourHand = function() {
  540.         if (!this.hourHandSprite.visible) return;
  541.         this.hourHandSprite.rotation = this.chronus().getRotationHourHand();
  542.     };

  543.     Sprite_Chronicle_Clock.prototype.updateMinuteHand = function() {
  544.         if (!this.minuteHandSprite.visible) return;
  545.         this.minuteHandSprite.rotation = this.chronus().getRotationMinuteHand();
  546.     };

  547.     Sprite_Chronicle_Clock.prototype.chronus = function() {
  548.         return $gameSystem.chronus();
  549.     };

  550.     //=============================================================================
  551.     // Spriteset_Map
  552.     //  アナログ時計の画像を追加定義します。
  553.     //=============================================================================
  554.     var _Spriteset_Map_createUpperLayer = Spriteset_Map.prototype.createUpperLayer;
  555.     Spriteset_Map.prototype.createUpperLayer = function() {
  556.         _Spriteset_Map_createUpperLayer.apply(this, arguments);
  557.         this.createClockSprite();
  558.     };

  559.     Spriteset_Map.prototype.createClockSprite = function() {
  560.         this._clockSprite = isParamExist('文字盤画像ファイル') ? new Sprite_Chronicle_Clock() : new Sprite_Abstract();
  561.         this.addChild(this._clockSprite);
  562.     };

  563.     //=============================================================================
  564.     // Game_Chronus
  565.     //  時の流れを扱うクラスです。このクラスはGame_Systemクラスで生成されます。
  566.     //  セーブデータの保存対象のためグローバル領域に定義します。
  567.     //=============================================================================
  568.     Game_Chronus.prototype             = Object.create(Game_Chronus.prototype);
  569.     Game_Chronus.prototype.constructor = Game_Chronus;
  570.     Game_Chronus.weatherTypes          = ['none', 'rain', 'storm', 'snow'];

  571.     Game_Chronus.prototype.initialize = function () {
  572.         this._timeMeter       = 0;            // 一日の中での時間経過(分単位)60 * 24
  573.         this._dayMeter        = 0;            // ゲーム開始からの累計日数
  574.         this._stop            = true;         // 停止フラグ(全ての加算に対して有効。ただし手動による加算は例外)
  575.         this._disableTint     = false;        // 色調変更禁止フラグ
  576.         this._calendarVisible = false;        // カレンダー表示フラグ
  577.         this._disableWeather  = false;        // 天候制御禁止フラグ
  578.         this._weatherType     = 0;            // 天候タイプ(0:なし 1:雨 2:嵐 :3雪)
  579.         this._weatherPower    = 0;            // 天候の強さ
  580.         this._weatherCounter  = 0;            // 同一天候の維持時間
  581.         this._weatherSnowLand = false;        // 降雪地帯フラグ
  582.         this._clockVisible    = false;        // アナログ時計表示フラグ
  583.         this._realTime        = false;        // 実時間フラグ
  584.         this._frameCount      = 0;
  585.         this._demandRefresh   = false;
  586.         this._prevHour        = -1;
  587.         this._nowDate         = null;
  588.         this._timeAutoAdd     = getParamNumber('自然時間加算', 0, 99);
  589.         this._timeTransferAdd = getParamNumber('場所移動時間加算', 0);
  590.         this._timeBattleAdd   = getParamNumber('戦闘時間加算(固定)', 0);
  591.         this._timeTurnAdd     = getParamNumber('戦闘時間加算(ターン)', 0);
  592.         this._weekNames       = getParamArrayString('曜日配列');
  593.         this._daysOfMonth     = getParamArrayNumber('月ごとの日数配列');
  594.         this.onLoad();
  595.     };

  596.     Game_Chronus.prototype.onLoad = function () {
  597.         this._nowDate = new Date();
  598.         if (!this._frameCount) this._frameCount = 0;
  599.     };

  600.     Game_Chronus.prototype.update = function () {
  601.         this.updateEffect();
  602.         if (this.isTimeStop()) return;
  603.         this._frameCount++;
  604.         if (this._frameCount >= 60) {
  605.             if (this.isRealTime()) this._nowDate.setTime(Date.now());
  606.             this.addTime();
  607.         }
  608.     };

  609.     Game_Chronus.prototype.isRealTime = function () {
  610.         return !!this._realTime;
  611.     };

  612.     Game_Chronus.prototype.isTimeStop = function() {
  613.         return this.isStop() || $gameMap.isEventRunning();
  614.     };

  615.     Game_Chronus.prototype.updateEffect = function () {
  616.         var hour = this.getHour();
  617.         if (this._prevHour !== hour) {
  618.             this.controlWeather(false);
  619.             this.refreshTint(false);
  620.             this._prevHour = this.getHour();
  621.         }
  622.     };

  623.     Game_Chronus.prototype.refreshTint = function (swift) {
  624.         this.isEnableTint() ? this.setTint(this.getTimeZone(), swift) : $gameScreen.clearTone();
  625.     };

  626.     Game_Chronus.prototype.setTint = function (timezone, swift) {
  627.         var tone = null;
  628.         switch (timezone) {
  629.             case 0:
  630.                 tone = [-102, -102, -68, 102];
  631.                 break;
  632.             case 1:
  633.                 tone = [-68, -68, 0, 0];
  634.                 break;
  635.             case 2:
  636.                 tone = [0, 0, 0, 0];
  637.                 break;
  638.             case 3:
  639.                 tone = [34, 34, 34, 0];
  640.                 break;
  641.             case 4:
  642.                 tone = [68, -34, -34, 0];
  643.                 break;
  644.             case 5:
  645.                 tone = [-68, -68, 0, 68];
  646.                 break;
  647.         }
  648.         if (this.getWeatherTypeId() !== 0) {
  649.             tone[0] > 0 ? tone[0] /= 7 : tone[0] -= 14;
  650.             tone[1] > 0 ? tone[1] /= 7 : tone[1] -= 14;
  651.             tone[2] > 0 ? tone[2] /= 7 : tone[1] -= 14;
  652.             tone[3] === 0 ? tone[3] = 68 : tone[3] += 14;
  653.         }
  654.         $gameScreen.startTint(tone, swift ? 0 : this.getEffectDuration());
  655.     };

  656.     Game_Chronus.prototype.setWeatherType = function(value) {
  657.         this._weatherType = value.clamp(0, Game_Chronus.weatherTypes.length - 1);
  658.     };

  659.     Game_Chronus.prototype.setWeatherPower = function(value) {
  660.         this._weatherPower = value.clamp(0, 10);
  661.     };

  662.     Game_Chronus.prototype.setTimeAutoAdd = function(value) {
  663.         this._timeAutoAdd = value.clamp(0, 99);
  664.     };

  665.     Game_Chronus.prototype.controlWeather = function (force) {
  666.         if (!force && Math.random() * 10 > this._weatherCounter - 7) {
  667.             this._weatherCounter++;
  668.         } else {
  669.             this._weatherCounter = 0;
  670.             if (Math.random() * 10 > 7) {
  671.                 this.setWeatherType(this.isSnowLand() ? 3 : Math.random() * 10 > 6 ? 2 : 1);
  672.                 this.setWeatherPower(Math.floor(Math.random() * 10));
  673.             } else {
  674.                 this.setWeatherType(0);
  675.                 this.setWeatherPower(0);
  676.             }
  677.         }
  678.         this.refreshWeather(false);
  679.     };

  680.     Game_Chronus.prototype.refreshWeather = function (swift) {
  681.         this.isEnableWeather() ? this.setScreenWeather(swift) : $gameScreen.changeWeather(0, 0, 0);
  682.     };

  683.     Game_Chronus.prototype.setScreenWeather = function (swift) {
  684.         $gameScreen.changeWeather(this.getWeatherType(), this._weatherPower, swift ? 0 : this.getEffectDuration());
  685.     };

  686.     Game_Chronus.prototype.getEffectDuration = function () {
  687.         return this.isRealTime() ? 600 : Math.floor(60 * 5 / (this._timeAutoAdd / 10));
  688.     };

  689.     Game_Chronus.prototype.disableTint = function () {
  690.         this._disableTint = true;
  691.         this.refreshTint(true);
  692.     };

  693.     Game_Chronus.prototype.enableTint = function () {
  694.         this._disableTint = false;
  695.         this.refreshTint(true);
  696.     };

  697.     Game_Chronus.prototype.isEnableTint = function () {
  698.         return !this._disableTint && !$gameMap.isDisableTint();
  699.     };

  700.     Game_Chronus.prototype.disableWeather = function () {
  701.         this._disableWeather = true;
  702.         this.refreshWeather(true);
  703.     };

  704.     Game_Chronus.prototype.enableWeather = function () {
  705.         this._disableWeather = false;
  706.         this.refreshWeather(true);
  707.     };

  708.     Game_Chronus.prototype.isEnableWeather = function () {
  709.         return !this._disableWeather && !$gameMap.isDisableWeather();
  710.     };

  711.     Game_Chronus.prototype.setSnowLand = function () {
  712.         this._weatherSnowLand = true;
  713.         this.refreshWeather(true);
  714.     };

  715.     Game_Chronus.prototype.resetSnowLand = function () {
  716.         this._weatherSnowLand = false;
  717.         this.refreshWeather(true);
  718.     };

  719.     Game_Chronus.prototype.isSnowLand = function () {
  720.         return this._weatherSnowLand;
  721.     };

  722.     Game_Chronus.prototype.setTimeReal = function () {
  723.         this._realTime = true;
  724.     };

  725.     Game_Chronus.prototype.setTimeVirtual = function () {
  726.         this._realTime = false;
  727.     };

  728.     Game_Chronus.prototype.onBattleEnd = function () {
  729.         if (this.isStop()) return;
  730.         this.addTime(this._timeBattleAdd + this._timeTurnAdd * $gameTroop.turnCount());
  731.     };

  732.     Game_Chronus.prototype.transfer = function () {
  733.         if (this.isStop()) return;
  734.         this.addTime(this._timeTransferAdd);
  735.     };

  736.     Game_Chronus.prototype.stop = function () {
  737.         this._stop = true;
  738.     };

  739.     Game_Chronus.prototype.start = function () {
  740.         this._stop = false;
  741.     };

  742.     Game_Chronus.prototype.isStop = function () {
  743.         return this._stop;
  744.     };

  745.     Game_Chronus.prototype.showCalendar = function () {
  746.         this._calendarVisible = true;
  747.     };

  748.     Game_Chronus.prototype.hideCalendar = function () {
  749.         this._calendarVisible = false;
  750.     };

  751.     Game_Chronus.prototype.isShowingCalendar = function () {
  752.         return this._calendarVisible;
  753.     };

  754.     Game_Chronus.prototype.isSnowLand = function () {
  755.         return this._weatherSnowLand;
  756.     };

  757.     Game_Chronus.prototype.showClock = function () {
  758.         this._clockVisible = true;
  759.     };

  760.     Game_Chronus.prototype.hideClock = function () {
  761.         this._clockVisible = false;
  762.     };

  763.     Game_Chronus.prototype.isShowingClock = function () {
  764.         return this._clockVisible;
  765.     };

  766.     Game_Chronus.prototype.addTime = function (value) {
  767.         if (arguments.length === 0) value = this._timeAutoAdd;
  768.         this._timeMeter += value;
  769.         while (this._timeMeter >= 60 * 24) {
  770.             this.addDay();
  771.             this._timeMeter -= 60 * 24;
  772.         }
  773.         this.demandRefresh(false);
  774.     };

  775.     Game_Chronus.prototype.setTime = function (hour, minute) {
  776.         var time = hour * 60 + minute;
  777.         if (this._timeMeter > time) this.addDay();
  778.         this._timeMeter = time;
  779.         this.demandRefresh(true);
  780.     };

  781.     Game_Chronus.prototype.addDay = function (value) {
  782.         if (arguments.length === 0) value = 1;
  783.         this._dayMeter += value;
  784.         this.demandRefresh(false);
  785.     };

  786.     Game_Chronus.prototype.setDay = function (year, month, day) {
  787.         var newDay = (year - 1) * this.getDaysOfYear();
  788.         for (var i = 0; i < month - 1; i++) {
  789.             newDay += this._daysOfMonth[i];
  790.         }
  791.         newDay += day - 1;
  792.         this._dayMeter = newDay;
  793.         this.demandRefresh(true);
  794.     };

  795.     Game_Chronus.prototype.demandRefresh = function (effectRefreshFlg) {
  796.         this._demandRefresh = true;
  797.         this._frameCount = 0;
  798.         this.setGameVariable();
  799.         if (effectRefreshFlg) {
  800.             this.refreshTint(true);
  801.             this.controlWeather(true);
  802.         }
  803.     };

  804.     Game_Chronus.prototype.isNeedRefresh = function() {
  805.         var needRefresh = this._demandRefresh;
  806.         this._demandRefresh = false;
  807.         return needRefresh;
  808.     };

  809.     Game_Chronus.prototype.getDaysOfWeek = function () {
  810.         return this._weekNames.length;
  811.     };

  812.     Game_Chronus.prototype.getDaysOfMonth = function (month) {
  813.         return this._daysOfMonth[month - 1];
  814.     };

  815.     Game_Chronus.prototype.getDaysOfYear = function () {
  816.         var result = 0;
  817.         this._daysOfMonth.forEach(function(days) {result += days});
  818.         return result;
  819.     };

  820.     Game_Chronus.prototype.setGameVariable = function () {
  821.         this.setGameVariableSub('年のゲーム変数', this.getYear());
  822.         this.setGameVariableSub('月のゲーム変数', this.getMonth());
  823.         this.setGameVariableSub('日のゲーム変数', this.getDay());
  824.         this.setGameVariableSub('曜日IDのゲーム変数', this.getWeekIndex());
  825.         this.setGameVariableSub('曜日名のゲーム変数', this.getWeekName());
  826.         this.setGameVariableSub('時のゲーム変数', this.getHour());
  827.         this.setGameVariableSub('分のゲーム変数', this.getMinute());
  828.         this.setGameVariableSub('時間帯IDのゲーム変数', this.getTimeZone());
  829.         this.setGameVariableSub('天候IDのゲーム変数', this.getWeatherTypeId());
  830.     };

  831.     Game_Chronus.prototype.setGameVariableSub = function (paramName, value) {
  832.         var index = getParamNumber(paramName, 0, 5000);
  833.         if (index !== 0) $gameVariables.setValue(index, value);
  834.     };

  835.     Game_Chronus.prototype.getMonthOfYear = function () {
  836.         return this._daysOfMonth.length;
  837.     };

  838.     Game_Chronus.prototype.getWeekName = function () {
  839.         return this._weekNames[this.getWeekIndex()];
  840.     };

  841.     Game_Chronus.prototype.getWeekIndex = function () {
  842.         return this.isRealTime() ? this._nowDate.getDay() : this._dayMeter % this.getDaysOfWeek();
  843.     };

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

  847.     Game_Chronus.prototype.getMonth = function () {
  848.         if (this.isRealTime()) return this._nowDate.getMonth() + 1;
  849.         var days = this._dayMeter % this.getDaysOfYear();
  850.         for (var i = 0; i < this._daysOfMonth.length; i++) {
  851.             days -= this._daysOfMonth[i];
  852.             if (days < 0) return i + 1;
  853.         }
  854.         return null;
  855.     };

  856.     Game_Chronus.prototype.getDay = function () {
  857.         if (this.isRealTime()) return this._nowDate.getDate();
  858.         var days = this._dayMeter % this.getDaysOfYear();
  859.         for (var i = 0; i < this._daysOfMonth.length; i++) {
  860.             if (days < this._daysOfMonth[i]) return days + 1;
  861.             days -= this._daysOfMonth[i];
  862.         }
  863.         return null;
  864.     };

  865.     Game_Chronus.prototype.getHour = function () {
  866.         return this.isRealTime() ? this._nowDate.getHours() : Math.floor(this._timeMeter / 60);
  867.     };

  868.     Game_Chronus.prototype.getMinute = function () {
  869.         return this.isRealTime() ? this._nowDate.getMinutes() : this._timeMeter % 60;
  870.     };

  871.     Game_Chronus.prototype.getDateFormat = function(index) {
  872.         var format = getParamString('日時フォーマット' + String(index));
  873.         format = format.replace(/DY/gi, function() {
  874.             return this.getWeekName();
  875.         }.bind(this));
  876.         format = format.replace(/(Y+)/gi, function() {
  877.             return this.getValuePadding(this.getYear(), arguments[1].length);
  878.         }.bind(this));
  879.         format = format.replace(/MM/gi, function() {
  880.             return this.getValuePadding(this.getMonth(), String(this.getMonthOfYear()).length);
  881.         }.bind(this));
  882.         format = format.replace(/DD/gi, function() {
  883.             return this.getValuePadding(this.getDay(),
  884.                 String(this.getDaysOfMonth(this.getMonth())).length);
  885.         }.bind(this));
  886.         format = format.replace(/HH24/gi, function() {
  887.             return this.getValuePadding(this.getHour(), 2);
  888.         }.bind(this));
  889.         format = format.replace(/HH/gi, function() {
  890.             return this.getValuePadding(this.getHour() % 12, 2);
  891.         }.bind(this));
  892.         format = format.replace(/AM/gi, function() {
  893.             return Math.floor(this.getHour() / 12) === 0 ?
  894.                 $gameSystem.isJapanese() ? '午前' : 'Morning  ' :
  895.                 $gameSystem.isJapanese() ? '午後' : 'Afternoon';
  896.         }.bind(this));
  897.         format = format.replace(/MI/gi, function() {
  898.             return this.getValuePadding(this.getMinute(), 2);
  899.         }.bind(this));
  900.         return format;
  901.     };

  902.     Game_Chronus.prototype.getTimeZone = function () {
  903.         return this.isHourInRange(0, 4)   ? 0 :
  904.                this.isHourInRange(5, 6)   ? 1 :
  905.                this.isHourInRange(7, 11)  ? 2 :
  906.                this.isHourInRange(12, 16) ? 3 :
  907.                this.isHourInRange(17, 18) ? 4 :
  908.                this.isHourInRange(19, 21) ? 5 :
  909.                this.isHourInRange(22, 24) ? 0 : null;
  910.     };

  911.     Game_Chronus.prototype.getWeatherTypeId = function () {
  912.         return this._weatherType;
  913.     };

  914.     Game_Chronus.prototype.getWeatherType = function () {
  915.         return Game_Chronus.weatherTypes[this.getWeatherTypeId()];
  916.     };

  917.     Game_Chronus.prototype.getValuePadding = function(value, digit, padChar) {
  918.         if (arguments.length === 2) padChar = '0';
  919.         var result = "";
  920.         for (var i = 0; i < digit; i++) result += padChar;
  921.         result += value;
  922.         return result.substr(-digit);
  923.     };

  924.     Game_Chronus.prototype.isHourInRange = function(min, max) {
  925.         var hour = this.getHour();
  926.         return hour >= min && hour <= max;
  927.     };

  928.     Game_Chronus.prototype.getAnalogueHour = function() {
  929.         return this.getHour() + (this.getAnalogueMinute() / 60);
  930.     };

  931.     Game_Chronus.prototype.getAnalogueMinute = function() {
  932.         return this.getMinute() + (this.isRealTime() ? 0 : this._frameCount / 60 * this._timeAutoAdd);
  933.     };

  934.     Game_Chronus.prototype.getRotationHourHand = function() {
  935.         return (this.getAnalogueHour() % 12) * (360 / 12) * Math.PI / 180;
  936.     };

  937.     Game_Chronus.prototype.getRotationMinuteHand = function() {
  938.         return this.getAnalogueMinute() * (360 / 60) * Math.PI / 180;
  939.     };
  940. })();
复制代码

点评

大佬范本挂了,能补个档吗  发表于 2020-5-20 18:55
你下载下来了吗,这边系在速度太慢了,分享到云盘可以吗,谢谢!  发表于 2016-3-1 19:40
回复

使用道具 举报

梦石
0
星屑
765
在线时间
90 小时
注册时间
2018-10-29
回帖
86
发表于 2020-5-20 11:08:22 | 显示全部楼层
tseyik 发表于 2016-2-29 18:55
https://github.com/triacontane/RPGMakerMV
Mit
範本

大佬范本挂了,能补个档吗
回复

使用道具 举报

梦石
0
星屑
1507
在线时间
115 小时
注册时间
2020-5-10
回帖
78
发表于 2020-5-20 11:25:24 | 显示全部楼层
无名小生 发表于 2020-5-20 11:08
大佬范本挂了,能补个档吗

这贴也太老了吧

你可以去看看这个
https://rpg.blue/thread-409713-1-1.html
里面什么插件都有,非常赞
你要的时间系统里面可以找到
"明るい夜"のために
回复

使用道具 举报

梦石
0
星屑
765
在线时间
90 小时
注册时间
2018-10-29
回帖
86
发表于 2020-5-21 17:08:57 | 显示全部楼层
shmily0725 发表于 2020-5-20 11:25
这贴也太老了吧

你可以去看看这个

谢谢,不过和Drill大佬问过了,MOG的时间系统占用了原本的画面色调功能导致我很多东西都做不了,所以放弃了
回复

使用道具 举报

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

本版积分规则

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

在本版发帖返回顶部