查看: 3345|回复: 1

[已经解决] rpg maker MV 制作一个循环游戏

[复制链接]
梦石
0
星屑
60
在线时间
45 小时
注册时间
2008-8-4
回帖
9
发表于 2016-8-31 00:36:14 | 显示全部楼层 |阅读模式

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

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

×
  就是game over以后 我可以给变量计数 下一次游戏的时候根据变量来触发不一样的开场 请问具体需要做什么定义呢?
梦石
0
星屑
311
在线时间
204 小时
注册时间
2007-2-4
回帖
1772
发表于 2016-8-31 11:34:27 | 显示全部楼层
本帖最后由 玄天 于 2016-8-31 11:38 编辑

你这个效果用全局变量类型的插件就行了。

比如这个插件的功能大概就是指定某些变量为全局保存,即不管你游戏进度如何,这个变量都会保持在最后更新的状态。这样你只要在需要分歧的地方加个条件分歧就行了,很简单。
  1. //=============================================================================
  2. // MrTS_GlobalSavesData.js
  3. //=============================================================================

  4. /*:
  5. * @plugindesc Allows player to set and change variables that affect all saves.
  6. * @author Mr. Trivel
  7. *
  8. * @help
  9. * --------------------------------------------------------------------------------
  10. * Terms of Use
  11. * --------------------------------------------------------------------------------
  12. * Don't remove the header or claim that you wrote this plugin.
  13. * Credit Mr. Trivel if using this plugin in your project.
  14. * Free for commercial non-commercial projects.
  15. * --------------------------------------------------------------------------------
  16. * Version 1.0
  17. * --------------------------------------------------------------------------------
  18. *
  19. * --------------------------------------------------------------------------------
  20. * Plugin Commands
  21. * --------------------------------------------------------------------------------
  22. * GlobalVar Set [NAME] [VALUE] - Sets variable to [VALUE]
  23. * GlobalVar Add [NAME] [VALUE] - Adds [VALUE] to variable
  24. * GlobalVar Sub [NAME] [VALUE] - Subtracts [VALUE] from value
  25. *
  26. * [NAME] - Variable name, case sensitive
  27. * [VALUE] - Value of variable a number or true/false
  28. *
  29. * Examples:
  30. * GlobalVar Set Glasses true
  31. *
  32. * GlobalVar Set GameCompleted 1
  33. * GlobalVar Add GameCompleted 1
  34. * GlobalVar Sub GameCompleted 2
  35. * --------------------------------------------------------------------------------
  36. *
  37. * --------------------------------------------------------------------------------
  38. * Script Calls - for use in switches, variables, branches and script calls
  39. * --------------------------------------------------------------------------------
  40. * DataManager.getGlobalVar(NAME) - returns global variable of NAME
  41. *
  42. * Example:
  43. * DataManager.getGlobalVar(Glasses)
  44. * --------------------------------------------------------------------------------
  45. *
  46. * --------------------------------------------------------------------------------
  47. * Version History
  48. * --------------------------------------------------------------------------------
  49. * 1.0 - Release
  50. */

  51. (function() {

  52.         //--------------------------------------------------------------------------
  53.         // Game_Interpreter
  54.         //
  55.        
  56.         var _Game_Interpreter_pluginCommand = Game_Interpreter.prototype.pluginCommand;
  57.         Game_Interpreter.prototype.pluginCommand = function(command, args) {
  58.                 _Game_Interpreter_pluginCommand.call(this, command, args);
  59.                 if (command.toLowerCase() === "globalvar") {
  60.                         switch (args[0].toUpperCase())
  61.                         {
  62.                                 case 'SET':
  63.                                 {
  64.                                         DataManager.setGlobalVar(args[1], eval(args[2]))
  65.                                 } break;
  66.                                 case 'ADD':
  67.                                 {
  68.                                         DataManager.addGlobalVar(args[1], Number(args[2]))
  69.                                 } break;
  70.                                 case 'SUB':
  71.                                 {
  72.                                         DataManager.setGlobalVar(args[1], Number(args[2]))
  73.                                 } break;
  74.                                
  75.                         }
  76.                 }
  77.         };

  78.         //--------------------------------------------------------------------------
  79.         // StorageManager
  80.         //

  81.         var _StorageManager_localFilePath = StorageManager.localFilePath;
  82.         StorageManager.localFilePath = function(key) {
  83.             if (key === 'globalsavedata') return this.localFileDirectoryPath() + 'globalSaveData.rpgsave';
  84.             else return _StorageManager_localFilePath.call(this, key);
  85.         };

  86.         var _StorageManager_webStorageKey = StorageManager.webStorageKey;
  87.         StorageManager.webStorageKey = function(key) {
  88.                 if (key === 'globalsavedata') return 'RPG GlobalSaveData';
  89.                 else return _StorageManager_webStorageKey.call(this, key);
  90.         };

  91.         //--------------------------------------------------------------------------
  92.         // DataManager
  93.         //

  94.         var _DataManager_loadGameWithoutRescue = DataManager.loadGameWithoutRescue;
  95.         DataManager.loadGameWithoutRescue = function(savefileId) {
  96.                 var success = _DataManager_loadGameWithoutRescue.call(this, savefileId);
  97.             if (success) this._globalSaveData = this.loadGlobalSaveData();
  98.             return success;
  99.         };

  100.         var _DataManager_setupNewgame = DataManager.setupNewGame;
  101.         DataManager.setupNewGame = function() {
  102.                 _DataManager_setupNewgame.call(this);
  103.                 this._globalSaveData = this.loadGlobalSaveData();
  104.         };

  105.         DataManager.setGlobalVar = function(name, value) {
  106.                 this._globalSaveData[name] = value;
  107.         };

  108.         DataManager.addGlobalVar = function(name, value) {
  109.                 if (!this._globalSaveData[name]) this._globalSaveData[name] = 0;
  110.                 this._globalSaveData[name] += value;
  111.         };

  112.         DataManager.subGlobalVar = function(name, value) {
  113.                 this.addGlobalVar(name, -value);
  114.         };

  115.         DataManager.getGlobalVar = function(name) {
  116.                 if (!this._globalSaveData[name]) this._globalSaveData[name] = 0;
  117.                 return this._globalSaveData[name];
  118.         };

  119.         DataManager.loadGlobalSaveData = function() {
  120.                 var data = StorageManager.load('globalsavedata');
  121.                 if (data)
  122.                 {
  123.                         return JsonEx.parse(data);
  124.                 }
  125.                 else return {};
  126.         };

  127.         var _DataManager_saveGameWithoutRescue = DataManager.saveGameWithoutRescue;
  128.         DataManager.saveGameWithoutRescue = function(savefileId) {
  129.                 var saved = _DataManager_saveGameWithoutRescue.call(this, savefileId);
  130.                 if (saved) {
  131.                         this.saveGlobalSaveData(this._globalSaveData);
  132.                 }
  133.                 return saved;
  134.         };

  135.         DataManager.saveGlobalSaveData = function(data) {
  136.                 StorageManager.save('globalsavedata', JSON.stringify(data));
  137.         };
  138. })();       
复制代码


如果觉得这个不够好还可以搜搜其他的,还有不少其他运作方式的全局变量插件。

评分

参与人数 1梦石 +1 收起 理由
余烬之中 + 1 认可答案

查看全部评分

新しい誕生祝いだッ!
回复

使用道具 举报

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

本版积分规则

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

在本版发帖返回顶部