查看: 4021|回复: 4

[已经解决] 关于时间脚本 求助

[复制链接]
梦石
0
星屑
6963
在线时间
1557 小时
注册时间
2011-6-14
回帖
425
发表于 2016-3-11 12:00:24 | 显示全部楼层 |阅读模式

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

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

×
这个的脚本本来是12个小时变动一次时辰 我设置了6个时长想让他4个小时变动一次
于是我改了这个
return Math.floor(this.getHour() / 12 ) === 0 ?
为
return Math.floor(this.getHour() / 4 ) === 0 ?
但是他只是变成第一次为4小时跳动第二次为20小时 求教改哪里才是正确的





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

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

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

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

  198.     //=============================================================================
  199.     // PluginManager
  200.     //  多言語とnullに対応したパラメータの取得を行います。
  201.     //  このコードは自動生成され、全てのプラグインで同じものが使用されます。
  202.     //=============================================================================
  203.     var getParamString = function(paramNames) {
  204.         var value = getParamOther(paramNames);
  205.         return value == null ? '' : value;
  206.     };

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

  386.     Game_Map.prototype.isChronicleMetaInfo = function(tagName) {
  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.         var fileName = ImageManager.loadPicture(getParamString('文字盤画像ファイル'));
  561.         this._clockSprite = fileName ? new Sprite_Chronicle_Clock() : new Sprite_Abstract();
  562.         this.addChild(this._clockSprite);
  563.     };

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

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

  597.     Game_Chronus.prototype.onLoad = function () {
  598.         if (!this._nowDate) this._nowDate = new Date();
  599.         if (!this._frameCount) this._frameCount = 0;
  600.         this._timeAutoAdd     = getParamNumber('自然時間加算', 0, 99);
  601.         this._timeTransferAdd = getParamNumber('場所移動時間加算', 0);
  602.         this._timeBattleAdd   = getParamNumber('戦闘時間加算(固定)', 0);
  603.         this._timeTurnAdd     = getParamNumber('戦闘時間加算(ターン)', 0);
  604.         this._weekNames       = getParamArrayString('曜日配列');
  605.         this._daysOfMonth     = getParamArrayNumber('月ごとの日数配列');
  606.     };

  607.     Game_Chronus.prototype.update = function () {
  608.         this.updateEffect();
  609.         if (this.isTimeStop()) return;
  610.         this._frameCount++;
  611.         if (this._frameCount >= 60) {
  612.             if (this.isRealTime()) this._nowDate.setTime(Date.now());
  613.             this.addTime();
  614.         }
  615.     };

  616.     Game_Chronus.prototype.isRealTime = function () {
  617.         return !!this._realTime;
  618.     };

  619.     Game_Chronus.prototype.isTimeStop = function() {
  620.         return this.isStop() || $gameMap.isEventRunning();
  621.     };

  622.     Game_Chronus.prototype.updateEffect = function () {
  623.         var hour = this.getHour();
  624.         if (this._prevHour !== hour) {
  625.             this.controlWeather(false);
  626.             this.refreshTint(false);
  627.             this._prevHour = this.getHour();
  628.         }
  629.     };

  630.     Game_Chronus.prototype.refreshTint = function (swift) {
  631.         this.isEnableTint() ? this.setTint(this.getTimeZone(), swift) : $gameScreen.clearTone();
  632.     };

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

  663.     Game_Chronus.prototype.setWeatherType = function(value) {
  664.         this._weatherType = value.clamp(0, Game_Chronus.weatherTypes.length - 1);
  665.     };

  666.     Game_Chronus.prototype.setWeatherPower = function(value) {
  667.         this._weatherPower = value.clamp(0, 10);
  668.     };

  669.     Game_Chronus.prototype.setTimeAutoAdd = function(value) {
  670.         this._timeAutoAdd = value.clamp(0, 99);
  671.     };

  672.     Game_Chronus.prototype.controlWeather = function (force) {
  673.         if (!force && Math.random() * 10 > this._weatherCounter - 7) {
  674.             this._weatherCounter++;
  675.         } else {
  676.             this._weatherCounter = 0;
  677.             if (Math.random() * 10 > 7) {
  678.                 this.setWeatherType(this.isSnowLand() ? 3 : Math.random() * 10 > 6 ? 2 : 1);
  679.                 this.setWeatherPower(Math.floor(Math.random() * 10));
  680.             } else {
  681.                 this.setWeatherType(0);
  682.                 this.setWeatherPower(0);
  683.             }
  684.         }
  685.         this.refreshWeather(false);
  686.     };

  687.     Game_Chronus.prototype.refreshWeather = function (swift) {
  688.         this.isEnableWeather() ? this.setScreenWeather(swift) : $gameScreen.changeWeather(0, 0, 0);
  689.     };

  690.     Game_Chronus.prototype.setScreenWeather = function (swift) {
  691.         $gameScreen.changeWeather(this.getWeatherType(), this._weatherPower, swift ? 0 : this.getEffectDuration());
  692.     };

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

  696.     Game_Chronus.prototype.disableTint = function () {
  697.         this._disableTint = true;
  698.         this.refreshTint(true);
  699.     };

  700.     Game_Chronus.prototype.enableTint = function () {
  701.         this._disableTint = false;
  702.         this.refreshTint(true);
  703.     };

  704.     Game_Chronus.prototype.isEnableTint = function () {
  705.         return !this._disableTint && !$gameMap.isDisableTint();
  706.     };

  707.     Game_Chronus.prototype.disableWeather = function () {
  708.         this._disableWeather = true;
  709.         this.refreshWeather(true);
  710.     };

  711.     Game_Chronus.prototype.enableWeather = function () {
  712.         this._disableWeather = false;
  713.         this.refreshWeather(true);
  714.     };

  715.     Game_Chronus.prototype.isEnableWeather = function () {
  716.         return !this._disableWeather && !$gameMap.isDisableWeather();
  717.     };

  718.     Game_Chronus.prototype.setSnowLand = function () {
  719.         this._weatherSnowLand = true;
  720.         this.refreshWeather(true);
  721.     };

  722.     Game_Chronus.prototype.resetSnowLand = function () {
  723.         this._weatherSnowLand = false;
  724.         this.refreshWeather(true);
  725.     };

  726.     Game_Chronus.prototype.isSnowLand = function () {
  727.         return this._weatherSnowLand;
  728.     };

  729.     Game_Chronus.prototype.setTimeReal = function () {
  730.         this._realTime = true;
  731.     };

  732.     Game_Chronus.prototype.setTimeVirtual = function () {
  733.         this._realTime = false;
  734.     };

  735.     Game_Chronus.prototype.onBattleEnd = function () {
  736.         if (this.isStop()) return;
  737.         this.addTime(this._timeBattleAdd + this._timeTurnAdd * $gameTroop.turnCount());
  738.     };

  739.     Game_Chronus.prototype.transfer = function () {
  740.         if (this.isStop()) return;
  741.         this.addTime(this._timeTransferAdd);
  742.     };

  743.     Game_Chronus.prototype.stop = function () {
  744.         this._stop = true;
  745.     };

  746.     Game_Chronus.prototype.start = function () {
  747.         this._stop = false;
  748.     };

  749.     Game_Chronus.prototype.isStop = function () {
  750.         return this._stop;
  751.     };

  752.     Game_Chronus.prototype.showCalendar = function () {
  753.         this._calendarVisible = true;
  754.     };

  755.     Game_Chronus.prototype.hideCalendar = function () {
  756.         this._calendarVisible = false;
  757.     };

  758.     Game_Chronus.prototype.isShowingCalendar = function () {
  759.         return this._calendarVisible;
  760.     };

  761.     Game_Chronus.prototype.isSnowLand = function () {
  762.         return this._weatherSnowLand;
  763.     };

  764.     Game_Chronus.prototype.showClock = function () {
  765.         this._clockVisible = true;
  766.     };

  767.     Game_Chronus.prototype.hideClock = function () {
  768.         this._clockVisible = false;
  769.     };

  770.     Game_Chronus.prototype.isShowingClock = function () {
  771.         return this._clockVisible;
  772.     };

  773.     Game_Chronus.prototype.addTime = function (value) {
  774.         if (arguments.length === 0) value = this._timeAutoAdd;
  775.         this._timeMeter += value;
  776.         while (this._timeMeter >= 60 * 24) {
  777.             this.addDay();
  778.             this._timeMeter -= 60 * 24;
  779.         }
  780.         this.demandRefresh(false);
  781.     };

  782.     Game_Chronus.prototype.setTime = function (hour, minute) {
  783.         var time = hour * 60 + minute;
  784.         if (this._timeMeter > time) this.addDay();
  785.         this._timeMeter = time;
  786.         this.demandRefresh(true);
  787.     };

  788.     Game_Chronus.prototype.addDay = function (value) {
  789.         if (arguments.length === 0) value = 1;
  790.         this._dayMeter += value;
  791.         this.demandRefresh(false);
  792.     };

  793.     Game_Chronus.prototype.setDay = function (year, month, day) {
  794.         var newDay = (year - 1) * this.getDaysOfYear();
  795.         for (var i = 0; i < month - 1; i++) {
  796.             newDay += this._daysOfMonth[i];
  797.         }
  798.         newDay += day - 1;
  799.         this._dayMeter = newDay;
  800.         this.demandRefresh(true);
  801.     };

  802.     Game_Chronus.prototype.demandRefresh = function (effectRefreshFlg) {
  803.         this._demandRefresh = true;
  804.         this._frameCount = 0;
  805.         this.setGameVariable();
  806.         if (effectRefreshFlg) {
  807.             this.refreshTint(true);
  808.             this.controlWeather(true);
  809.         }
  810.     };

  811.     Game_Chronus.prototype.isNeedRefresh = function() {
  812.         var needRefresh = this._demandRefresh;
  813.         this._demandRefresh = false;
  814.         return needRefresh;
  815.     };

  816.     Game_Chronus.prototype.getDaysOfWeek = function () {
  817.         return this._weekNames.length;
  818.     };

  819.     Game_Chronus.prototype.getDaysOfMonth = function (month) {
  820.         return this._daysOfMonth[month - 1];
  821.     };

  822.     Game_Chronus.prototype.getDaysOfYear = function () {
  823.         var result = 0;
  824.         this._daysOfMonth.forEach(function(days) {result += days});
  825.         return result;
  826.     };

  827.     Game_Chronus.prototype.setGameVariable = function () {
  828.         this.setGameVariableSub('年のゲーム変数', this.getYear());
  829.         this.setGameVariableSub('月のゲーム変数', this.getMonth());
  830.         this.setGameVariableSub('日のゲーム変数', this.getDay());
  831.         this.setGameVariableSub('曜日IDのゲーム変数', this.getWeekIndex());
  832.         this.setGameVariableSub('曜日名のゲーム変数', this.getWeekName());
  833.         this.setGameVariableSub('時のゲーム変数', this.getHour());
  834.         this.setGameVariableSub('分のゲーム変数', this.getMinute());
  835.         this.setGameVariableSub('時間帯IDのゲーム変数', this.getTimeZone());
  836.         this.setGameVariableSub('天候IDのゲーム変数', this.getWeatherTypeId());
  837.     };

  838.     Game_Chronus.prototype.setGameVariableSub = function (paramName, value) {
  839.         var index = getParamNumber(paramName, 0, 5000);
  840.         if (index !== 0) $gameVariables.setValue(index, value);
  841.     };

  842.     Game_Chronus.prototype.getMonthOfYear = function () {
  843.         return this._daysOfMonth.length;
  844.     };

  845.     Game_Chronus.prototype.getWeekName = function () {
  846.         return this._weekNames[this.getWeekIndex()];
  847.     };

  848.     Game_Chronus.prototype.getWeekIndex = function () {
  849.         return this.isRealTime() ? this._nowDate.getDay() : this._dayMeter % this.getDaysOfWeek();
  850.     };

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

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

  863.     Game_Chronus.prototype.getDay = function () {
  864.         if (this.isRealTime()) return this._nowDate.getDate();
  865.         var days = this._dayMeter % this.getDaysOfYear();
  866.         for (var i = 0; i < this._daysOfMonth.length; i++) {
  867.             if (days < this._daysOfMonth[i]) return days + 1;
  868.             days -= this._daysOfMonth[i];
  869.         }
  870.         return null;
  871.     };

  872.     Game_Chronus.prototype.getHour = function () {
  873.         return this.isRealTime() ? this._nowDate.getHours() : Math.floor(this._timeMeter / 60);
  874.     };

  875.     Game_Chronus.prototype.getMinute = function () {
  876.         return this.isRealTime() ? this._nowDate.getMinutes() : this._timeMeter % 60;
  877.     };

  878.     Game_Chronus.prototype.getDateFormat = function(index) {
  879.         var format = getParamString('日時フォーマット' + String(index));
  880.         format = format.replace(/DY/gi, function() {
  881.             return this.getWeekName();
  882.         }.bind(this));
  883.         format = format.replace(/(Y+)/gi, function() {
  884.             return this.getValuePadding(this.getYear(), arguments[1].length);
  885.         }.bind(this));
  886.         format = format.replace(/MM/gi, function() {
  887.             return this.getValuePadding(this.getMonth(), String(this.getMonthOfYear()).length);
  888.         }.bind(this));
  889.         format = format.replace(/DD/gi, function() {
  890.             return this.getValuePadding(this.getDay(),
  891.                 String(this.getDaysOfMonth(this.getMonth())).length);
  892.         }.bind(this));
  893.         format = format.replace(/HH24/gi, function() {
  894.             return this.getValuePadding(this.getHour(), 2);
  895.         }.bind(this));
  896.         format = format.replace(/HH/gi, function() {
  897.             return this.getValuePadding(this.getHour() % 12, 2);
  898.         }.bind(this));
  899.         format = format.replace(/AM/gi, function() {
  900.             return Math.floor(this.getHour() / 12 ) === 0 ?
  901.                 $gameSystem.isJapanese() ? '午前' : '深夜  ' :
  902.                 $gameSystem.isJapanese() ? '午後' : '早晨  ' ;
  903.                 $gameSystem.isJapanese() ? '午後' : '深夜  ' ;
  904.                 $gameSystem.isJapanese() ? '午後' : '早晨  ' ;
  905.                 $gameSystem.isJapanese() ? '午後' : '深夜  ' ;
  906.                 $gameSystem.isJapanese() ? '午後' : '早晨  ' ;
  907.         }.bind(this));
  908.         format = format.replace(/MI/gi, function() {
  909.             return this.getValuePadding(this.getMinute(), 2);
  910.         }.bind(this));
  911.         return format;
  912.     };

  913.     Game_Chronus.prototype.getTimeZone = function () {
  914.         return this.isHourInRange(0, 4)   ? 0 :
  915.                this.isHourInRange(5, 6)   ? 1 :
  916.                this.isHourInRange(7, 11)  ? 2 :
  917.                this.isHourInRange(12, 16) ? 3 :
  918.                this.isHourInRange(17, 18) ? 4 :
  919.                this.isHourInRange(19, 21) ? 5 :
  920.                this.isHourInRange(22, 24) ? 0 : null;
  921.     };

  922.     Game_Chronus.prototype.getWeatherTypeId = function () {
  923.         return this._weatherType;
  924.     };

  925.     Game_Chronus.prototype.getWeatherType = function () {
  926.         return Game_Chronus.weatherTypes[this.getWeatherTypeId()];
  927.     };

  928.     Game_Chronus.prototype.getValuePadding = function(value, digit, padChar) {
  929.         if (arguments.length === 2) padChar = '0';
  930.         var result = "";
  931.         for (var i = 0; i < digit; i++) result += padChar;
  932.         result += value;
  933.         return result.substr(-digit);
  934.     };

  935.     Game_Chronus.prototype.isHourInRange = function(min, max) {
  936.         var hour = this.getHour();
  937.         return hour >= min && hour <= max;
  938.     };

  939.     Game_Chronus.prototype.getAnalogueHour = function() {
  940.         return this.getHour() + (this.getAnalogueMinute() / 60);
  941.     };

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

  945.     Game_Chronus.prototype.getRotationHourHand = function() {
  946.         return (this.getAnalogueHour() % 12) * (360 / 12) * Math.PI / 180;
  947.     };

  948.     Game_Chronus.prototype.getRotationMinuteHand = function() {
  949.         return this.getAnalogueMinute() * (360 / 60) * Math.PI / 180;
  950.     };
  951. })();
复制代码

点评

我想让他X6  发表于 2016-3-11 14:06
這個1日是24小時或12小時x2(上午下午)  发表于 2016-3-11 13:52
梦石
0
星屑
50
在线时间
81 小时
注册时间
2016-1-6
回帖
145
发表于 2016-3-11 13:01:24 | 显示全部楼层
return Math.floor(this.getHour() / 12 ) === 0 ?这句是小时除以12,返回值小于1则取整为0,表示上午,返回值大于1则取整为1,表示下午,原文是这样的吧。
你如果要改成/4,则会出来4点之前返回0,4点到8点返回1,8点到12点返回2,一直到下一个0点之后,才会重新返回1,所以你的语句只有第一个4小时是发生变更的,后面没变,你得把后面的情况也写到代码里去,我看了下这个脚本要配合图片才会显示面板,我没法给你测试,只能给你指出下解决方法,你可以用switch语句,来对Math.floor(this.getHour() / 12 )进行判断,然后把时段名称放在数组里,或者单独放置也行,进行匹配就得到了你的效果。

点评

是不是没调用或者冲突了  发表于 2016-3-11 17:13
我试了下脚本没法显示左上角的框哦,调用插件指令的方法也不行  发表于 2016-3-11 17:09
不需要配合图标,他会自己在左上角显示一个框,显示图片只是另一个功能,另外大神能说详细点吗  发表于 2016-3-11 13:11
回复

使用道具 举报

梦石
0
星屑
6963
在线时间
1557 小时
注册时间
2011-6-14
回帖
425
 楼主| 发表于 2016-3-11 17:13:03 | 显示全部楼层
seedj13 发表于 2016-3-11 13:01
return Math.floor(this.getHour() / 12 ) === 0 ?这句是小时除以12,返回值小于1则取整为0,表示上午,返 ...

FX]H`SS}A$FCLB)9FWST$L6.png NQNDYC]OX1F7J8%6%M_ZO5R.jpg
回复

使用道具 举报

梦石
0
星屑
50
在线时间
81 小时
注册时间
2016-1-6
回帖
145
发表于 2016-3-11 18:43:54 | 显示全部楼层
  1.         format = format.replace(/AM/gi, function() {
  2.                         switch(Math.floor(this.getHour() / 4 )){
  3.                                 case 0:
  4.                                         return '深夜';
  5.                                         break;
  6.                                 case 1:
  7.                                         return '凌晨';
  8.                                         break;
  9.                                 case 2:
  10.                                         return '上午';
  11.                                         break;
  12.                                 case 3:
  13.                                         return '下午';
  14.                                         break;
  15.                                 case 4:
  16.                                         return '傍晚';
  17.                                         break;
  18.                                 case 5:
  19.                                         return '晚上';
  20.                                         break;
  21.                                 }
  22.         }.bind(this));
  23. 替换一下
复制代码

点评

1008-1016行  发表于 2016-3-11 18:44

评分

参与人数 2星屑 +186 收起 理由
余烬之中 + 166 认可答案
347780682 + 20 认可答案

查看全部评分

回复

使用道具 举报

梦石
0
星屑
22879
在线时间
8598 小时
注册时间
2011-12-31
回帖
3270
发表于 2016-3-11 18:59:55 | 显示全部楼层
本帖最后由 tseyik 于 2016-3-11 19:01 编辑

除
応還栗修改這裏(1005-1012行)

        format = format.replace(/HH/gi, function() {
            return this.getValuePadding(this.getHour() % 12, 2);
        }.bind(this));
        format = format.replace(/AM/gi, function() {
            return Math.floor(this.getHour() / 12) === 0 ?
                $gameSystem.isJapanese() ? '午前' : 'Morning  ' :
                $gameSystem.isJapanese() ? '午後' : 'Afternoon';
        }.bind(this));



而
                $gameSystem.isJapanese() ? '午前' : 'Morning  ' :
                $gameSystem.isJapanese() ? '午後' : 'Afternoon';

也要改成4個

评分

参与人数 1星屑 +66 收起 理由
余烬之中 + 66 认可答案

查看全部评分

回复

使用道具 举报

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

本版积分规则

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

在本版发帖返回顶部