Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*:
- //==============================================================================
- // ■ Emoji Engine MV - Origin "EmojiBase"
- // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- // * @plugindesc Base for EMM. It's store params and permit to extract plugin
- parrameters easily and faster then the default manner.
- // * id: EEMV::Base
- // * @author Nio Kasgami.
- // * @Data : 2015/10/05
- // * @Version : 1.0.0
- // * @Require : NA
- //==============================================================================
- //==============================================================================
- // ■ History
- // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- // * 2015/10/29 - Begin and finish the plugin.
- //==============================================================================
- //==============================================================================
- // ■ Introduction
- // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- // * it's serve for store params
- //==============================================================================
- //==============================================================================
- // ■ Plugin Parameter
- // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- // this section handle the plugin parameter. Please do not edit unless you
- // want to add extra plugin command.
- //------------------------------------------------------------------------------
- * it's a base so this not handle any param commands
- //==============================================================================
- //==============================================================================
- // ■ Help File
- // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- // This section serve for input the help file in the engine don't touch this
- // unless you want to input more information
- //------------------------------------------------------------------------------
- * @help
- * This plugin base serve for handles datas so it's not provide plugin command
- * though it's serve for store my other plugin commands via the alias of
- * the method "get_pluginname" and "get_params".
- *
- * be sure please to input this above all my EEMV plugin for avoid any issues.
- *
- * ====================================================================
- * ■ Internal Method call
- * ====================================================================
- * /var/ = this.set_PluginName(plugin); : set the plugin name.
- * /var/ = this.set_PluginID(plugin); : set the plugin ID.
- * /var/ = this.setString(pluginVar,ParamName); : set the param as a string.
- * /var/ = this.setBoolean(pluginVar,ParamName); : set the param as a boolean.
- * /var/ = this.setNumber(PluginVar,ParamName,type,max_number); : set the
- * params as number and permit to proceed maths conversion.
- * /var/ = this.setArray(PluginVar,ParamName); : transform a list of number in
- * array.
- */
- //==============================================================================
- // ■ Emoji_Engine
- //------------------------------------------------------------------------------
- // the class who handle all the base of my plugins. Can be access via $emoji.
- //==============================================================================
- //==============================================================================
- // ■ Emoji_Engine {Core}
- //------------------------------------------------------------------------------
- // this section serve for handle the param getting and initialize it.
- //==============================================================================
- var EmojiAlias = EmojiAlias || {};
- function Emoji_Engine() {this.initialize.apply(this,arguments);}
- Emoji_Engine.prototype.constructor = Emoji_Engine;
- //----------------------------------------------------------------------------
- // ○ new function: initialize
- //----------------------------------------------------------------------------
- // * This method serve for initialize. It's not necessary to touch this method.
- //
- Emoji_Engine.prototype.initialize = function() {
- this.get_pluginname();
- this.get_params();
- };
- //----------------------------------------------------------------------------
- // ○ new function: Get_pluginName
- //----------------------------------------------------------------------------
- // * This the function who serve for hold all your plugin name.
- // * Do a alias for your plugin name or you gonna overwrite the previous.
- // * and you don't want this because overwrite = breaking.
- //
- Emoji_Engine.prototype.get_pluginname = function() {
- this.emojibase = this.set_PluginID("EEMV::Base");
- };
- //----------------------------------------------------------------------------
- // ○ new function: get_params
- //----------------------------------------------------------------------------
- // * This the function where you hold all your plugin parameter.
- // * Do a alias for store your param or you gonna overwrite the previous.
- // * and you don't want this because overwrite = breaking.
- //
- Emoji_Engine.prototype.get_params = function() {};
- //===============================================================================
- // => END : Emoji_Engine {Core}
- //===============================================================================
- //==============================================================================
- // ■ Emoji_Engine {PluginName}
- //------------------------------------------------------------------------------
- // this section serve for get everything's related to Plugin Name. It's
- // contain method for permit to extract the name.
- //==============================================================================
- //----------------------------------------------------------------------------
- // ○ new function: set_PluginName
- //----------------------------------------------------------------------------
- // * Special command who permit to get your plugin name more easily without having
- // * repeat the code "PluginManager.parameters('yourpluginname')".
- // * you can use "this.set_PluginName('plugin name');"
- // * or $Emoji.get_PluginName('plugin'); for get your param_name if you
- // * do your params outside of the Core functions.
- //
- Emoji_Engine.prototype.set_PluginName = function(plugin){
- return PluginManager.parameters(plugin);
- };
- //----------------------------------------------------------------------------
- // ○ new function: set_PluginID
- //----------------------------------------------------------------------------
- // * Originally Lavra Method for permit to remove the dependancie of the
- // * original PluginManager who was Heavy name focussed. I just decide to
- // * transfert is method into a function so it's avoid to have to repeat the
- // * whole code in in your plugin. Can be acesses like the other function.
- // * the id: have to be in the description method. Please check Lavra
- // * original method here :
- // * (http://forums.rpgmakerweb.com/index.php?/topic/47591-how-to-get-plugin-parameters-without-knowing-your-filename/)
- //
- Emoji_Engine.prototype.set_PluginID = function(plugin) {
- return $plugins.filter(function(p){return p.description.contains("id: " + plugin )})[0].parameters;
- };
- //===============================================================================
- // => END : Emoji_engine {PluginName}
- //===============================================================================
- //==============================================================================
- // ■ Emoji_Engine {Param}
- //------------------------------------------------------------------------------
- // this section serve for get everything's related to Plugin params. It's
- // contain methods for permit to extract the params and to use them.
- //==============================================================================
- //----------------------------------------------------------------------------
- // ○ new function: setString
- //----------------------------------------------------------------------------
- // * Convert the params in a string. Even if it's still a string in a ways,
- // * it's better to implement string for being sure the system will read this
- // * only as a string and nothing else!
- //
- Emoji_Engine.prototype.setString = function(Plugin_var,ParamName) {
- return String(Plugin_var[ParamName]);
- };
- //----------------------------------------------------------------------------
- // ○ new function: setBoolean
- //----------------------------------------------------------------------------
- // * By default the Boolean can't recognize string's correctly. Pure example,
- // * if you input Boolean(param); it's will not work. Why? Because boolean()
- // * auto recognize a string as true. it's not eval the string content.
- // * and sadly Plugin parameters are strings. So this method will
- // * consider your param as a boolean and return a true or a false.
- //
- Emoji_Engine.prototype.setBoolean = function(PluginVar,ParamName) {
- var n = PluginVar[ParamName];
- var s = undefined;
- if(n === 'true' || n === 'false'){
- if(n === 'true'){
- s = true;
- } else {
- s = false;
- }
- } else {
- throw new Error(ParamName + ' is a boolean please set it to true or false.');
- }
- return s;
- };
- //----------------------------------------------------------------------------
- // ○ new function: setNumber
- //----------------------------------------------------------------------------
- // * It's create the plugin command into number but also permit to add maths
- // * conversion.
- // * They have multiple options who permit to quick convert your number in
- // * math process. Process who are :
- // * 'default' or "" : transform the param string in a regular number.
- // * 'floor' : round your number to the lowest round. E.g : 3.9 -> 3
- // * 'ceil' : round your number to the highest round. E.g : 3.9 -> 4
- // * 'round' : round your number to the nearest values. E.g : 5.35 -> 5
- // * 'topercent' : convert your number in a Percentage value.
- // * 'todecimal' : convert your percent in a decimal value.
- // * 'topi' : convert your number in a PI value.
- // * 'abs' : return the absolute value of your number
- // *
- // * You can use this method by doing this.setNumber or $emoji.setNumber.
- // * the function works like this :
- // * this.setNumber(Plugin_var,ParamName,type,max_number);
- // * The definition of these arguments are :
- // * Plugin_var : The variable you stored your plugin name.
- // * ParamName : The Name of your Param command.
- // * Type : Set the Number process you want to do (set to 'default' for reg number).
- // * max_number : set the limit of your number (use only for topercent and todecimal).
- // * (PS : you can setup a varaible for max_number. E.g : this.maxHP)
- //
- Emoji_Engine.prototype.setNumber = function(Plugin_var,ParamName,type,max_number) {
- var number = Number(Plugin_var[ParamName]);
- var final_result = null;
- switch (type.toLowerCase()){
- // get the regular number.
- default :
- final_result = number;
- break;
- // get the low round
- case 'floor' :
- final_result = Math.floor(number);
- break;
- // get the uppest round.
- case 'ceil' :
- final_result = Math.ceil(number);
- break;
- case 'round' :
- // round to the nearest value.
- final_result = Math.round(number);
- break;
- case 'topercent' :
- // convert number to percent.
- final_result = (number / max_number) * 100;
- break;
- // convert the percent in float number.
- case 'todecimal' :
- final_result = (number / 100) * max_number;
- break;
- // convert your number into a PI math value.
- case 'topi' :
- final_result = Math.PI(number);
- break;
- // return the absolute values of the number.
- case 'abs' :
- final_result = Math.abs(number);
- }
- return final_result;
- };
- //----------------------------------------------------------------------------
- // ○ new function: setArray
- //----------------------------------------------------------------------------
- // * Convert a list of number in a Array. It's transform the string into a
- // * number for after convert the chain into a Array.
- // * it's look like this in the pluginManager :
- // * Paramcommand = 1,2,3,4
- // * in the system it's will return this [1,2,3,4];
- // * so after you can access the array easily by doing this.varname[0];
- //
- Emoji_Engine.prototype.setArray = function (Plugin_var,ParamName) {
- return Plugin_var[ParamName].split(',').map( function (i) { return Number(i || 0); } );
- };
- //----------------------------------------------------------------------------
- // ○ new function: loadJSON
- //----------------------------------------------------------------------------
- // * Load JSON files when asked.
- // * Though when input in get_misc, it's will load the JSON file on startup.
- // * you can get the file via this.loadJSON(pathofile,jsonfile);
- // * pathofile = the JSON folder.
- // * jsonfile = the JSON file.
- //
- Emoji_Engine.prototype.loadJSON = function(pathofile,jsonfile) {};
- //----------------------------------------------------------------------------
- // ○ new function: getLinear
- //----------------------------------------------------------------------------
- // * Permit to create a dynamic lineart movement of a sprite easily.
- // * You have although need to create a if method for stop the sprite to update.
- // * if(t < 0 || b < c){}
- // * please be sure to input true variable and not the c,t,d because this not var
- // * t = Current time (frame)
- // * b = Start value
- // * c = Target value
- // * d = Duration total (frames)
- // * Returns: Value modified by t
- //
- Emoji_Engine.prototype.getLinear = function(t,b,c,d) {
- return c*t/d + b;
- };
- //===============================================================================
- // => END : Emoji_engine {PluginName}
- //===============================================================================
- //===============================================================================
- // => END : Emoji_Engine
- //===============================================================================
- //==============================================================================
- // ■ DataManager
- //------------------------------------------------------------------------------
- // The static class that manages the database and game objects.
- //==============================================================================
- //----------------------------------------------------------------------------
- // ★ new global variables : $emoji
- //----------------------------------------------------------------------------
- var $emoji = null;
- //----------------------------------------------------------------------------
- // ● alias function: createGameObjects
- //----------------------------------------------------------------------------
- var emoji_basealias = DataManager.createGameObjects;
- DataManager.createGameObjects = function() {
- emoji_basealias.call(this);
- $emoji = new Emoji_Engine();
- };
- //----------------------------------------------------------------------------
- // ● overwrite function: loadDataFileSync
- //----------------------------------------------------------------------------
- DataManager.loadDataFileSync = function(name, src) {
- var xhr = new XMLHttpRequest();
- var url = 'data/' + src;
- xhr.open('GET', url, true);
- xhr.overrideMimeType('application/json');
- xhr.onload = function() {
- if (xhr.status < 400) {
- window[name] = JSON.parse(xhr.responseText);
- DataManager.onLoad(window[name]);
- }
- };
- xhr.onerror = function() {
- DataManager._errorUrl = DataManager._errorUrl || url;
- };
- window[name] = null;
- xhr.send();
- };
- //===============================================================================
- // => END : DataManager
- //===============================================================================
- //==============================================================================
- // ■ ExSprite
- //------------------------------------------------------------------------------
- // Extended version of Sprite for add more "Ace-like" options.
- // Call it by using this.varname = new Sprite();
- //==============================================================================
- //----------------------------------------------------------------------------
- // ○ new function: mirror
- //----------------------------------------------------------------------------
- // * This function serve for flip the picture from horizontal and vertical.
- // * Just use sprite.mirror(true or false,true or false); and it's will flip
- // * the picture. Though be sure to fix the anchor if it's really needed.
- // * The first argument will flip the picture horizontaly.
- // * The second argument will flip the picture vertically
- Sprite.prototype.mirror = function(hori,verti) {
- if(hori) {
- this.scale.x = -1;
- }else{
- this.scale.x = 1;
- }
- if(verti){
- this.scale.y = -1;
- }else{
- this.scale.y = 1;
- }
- };
- //----------------------------------------------------------------------------
- // ○ new function: setOrigin
- //----------------------------------------------------------------------------
- // * This function serve for set anchor in a more lazy ways or Ace way.
- // * Totally just a extra code for convenience.
- // * call it like this sprite.setOrigin(ox,oy);
- //
- Sprite.prototype.setOrigin = function(ox,oy) {
- this.anchor.x = ox;
- this.anchor.y = oy;
- };
- //----------------------------------------------------------------------------
- // ○ new function: linear
- //----------------------------------------------------------------------------
- // * This function serve for help easy linear sprite movement based on
- // * the time. this method need to be called like this in a update method
- // * this.sprite = this.sprite.linear(t,b,c,d);
- // * t = Current time (frame)
- // * b = Start value
- // * c = Target value
- // * d = Duration total (frames)
- // * Returns: Value modified by t
- //
- Sprite.prototype.linear = function(t, b, c, d) {
- return c * t / d + b;
- };
- //----------------------------------------------------------------------------
- // ○ new function: radius
- //----------------------------------------------------------------------------
- // * this method permit easier circle sprite movement. it's take the sprite x
- // * coordinate as the center.
- // * Also work with time value
- // * t = current time (frame)
- // * b = start angle
- // * c = target angle
- // * d = duration total (frames)
- // * Returns: Value modified by t
- //
- Sprite.prototype.radius = function(t, b, c, d) {
- var circle = Maths.PI * 2 / 180;
- var center = this.x;
- var maths = "";
- };
- //===============================================================================
- // => END : ExSprite
- //===============================================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement