查看: 3290|回复: 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 编辑

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

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

/*:
* @plugindesc Allows player to set and change variables that affect all saves.
* @author Mr. Trivel
*
* @help
* --------------------------------------------------------------------------------
* Terms of Use
* --------------------------------------------------------------------------------
* Don't remove the header or claim that you wrote this plugin.
* Credit Mr. Trivel if using this plugin in your project.
* Free for commercial non-commercial projects.
* --------------------------------------------------------------------------------
* Version 1.0
* --------------------------------------------------------------------------------
*
* --------------------------------------------------------------------------------
* Plugin Commands
* --------------------------------------------------------------------------------
* GlobalVar Set [NAME] [VALUE] - Sets variable to [VALUE]
* GlobalVar Add [NAME] [VALUE] - Adds [VALUE] to variable
* GlobalVar Sub [NAME] [VALUE] - Subtracts [VALUE] from value
*
* [NAME] - Variable name, case sensitive
* [VALUE] - Value of variable a number or true/false
*
* Examples:
* GlobalVar Set Glasses true
*
* GlobalVar Set GameCompleted 1
* GlobalVar Add GameCompleted 1
* GlobalVar Sub GameCompleted 2
* --------------------------------------------------------------------------------
*
* --------------------------------------------------------------------------------
* Script Calls - for use in switches, variables, branches and script calls
* --------------------------------------------------------------------------------
* DataManager.getGlobalVar(NAME) - returns global variable of NAME
*
* Example:
* DataManager.getGlobalVar(Glasses)
* --------------------------------------------------------------------------------
*
* --------------------------------------------------------------------------------
* Version History
* --------------------------------------------------------------------------------
* 1.0 - Release
*/

(function() {

        //--------------------------------------------------------------------------
        // Game_Interpreter
        //
       
        var _Game_Interpreter_pluginCommand = Game_Interpreter.prototype.pluginCommand;
        Game_Interpreter.prototype.pluginCommand = function(command, args) {
                _Game_Interpreter_pluginCommand.call(this, command, args);
                if (command.toLowerCase() === "globalvar") {
                        switch (args[0].toUpperCase())
                        {
                                case 'SET':
                                {
                                        DataManager.setGlobalVar(args[1], eval(args[2]))
                                } break;
                                case 'ADD':
                                {
                                        DataManager.addGlobalVar(args[1], Number(args[2]))
                                } break;
                                case 'SUB':
                                {
                                        DataManager.setGlobalVar(args[1], Number(args[2]))
                                } break;
                               
                        }
                }
        };

        //--------------------------------------------------------------------------
        // StorageManager
        //

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

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

        //--------------------------------------------------------------------------
        // DataManager
        //

        var _DataManager_loadGameWithoutRescue = DataManager.loadGameWithoutRescue;
        DataManager.loadGameWithoutRescue = function(savefileId) {
                var success = _DataManager_loadGameWithoutRescue.call(this, savefileId);
            if (success) this._globalSaveData = this.loadGlobalSaveData();
            return success;
        };

        var _DataManager_setupNewgame = DataManager.setupNewGame;
        DataManager.setupNewGame = function() {
                _DataManager_setupNewgame.call(this);
                this._globalSaveData = this.loadGlobalSaveData();
        };

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

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

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

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

        DataManager.loadGlobalSaveData = function() {
                var data = StorageManager.load('globalsavedata');
                if (data)
                {
                        return JsonEx.parse(data);
                }
                else return {};
        };

        var _DataManager_saveGameWithoutRescue = DataManager.saveGameWithoutRescue;
        DataManager.saveGameWithoutRescue = function(savefileId) {
                var saved = _DataManager_saveGameWithoutRescue.call(this, savefileId);
                if (saved) {
                        this.saveGlobalSaveData(this._globalSaveData);
                }
                return saved;
        };

        DataManager.saveGlobalSaveData = function(data) {
                StorageManager.save('globalsavedata', JSON.stringify(data));
        };
})();       
[/pre]

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

评分

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

查看全部评分

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

使用道具 举报

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

本版积分规则

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

在本版发帖返回顶部