//=============================================================================
// VariableProgressBar.js
//=============================================================================
/*:
* @plugindesc 显示变量的进度条。
* @author LiXiaYu & 墨汁
*
* @param windowPositionX
* @desc Bar窗口的位置X
* @default 20
*
* @param windowPositionY
* @desc Bar窗口的位置Y
* @default 20
*
* @param windowPositionX
* @desc Bar窗口的位置X
* @default 20
*
* @param windowWidth
* @desc Bar窗口的宽度
* @default 500
*
* @param windowHeight
* @desc Bar窗口的高度
* @default 500
*
* @param windowOpacity
* @desc Bar窗口的不透明度
* @default 50
*
*
* @help
* Version: 0.0.3
*
*
* Plugin Command:
* VariableProgressBar clear # 删除所有进度条
* VariableProgressBar add 5 200 # 添加变量5其上限为200的进度条
* VariableProgressBar delete 5 # 删除一个变量5的进度条
* VariableProgressBar set 5 80 # 设置所有变量5的上限为80
* VariableProgressBar open # 打开窗口
* VariableProgressBar close # 关闭窗口
*
* Log:
* 2016/4/19-0.0.3
* 现在可以打开和关闭窗口啦
* 2016/4/19-0.0.2
* 改变了命令的格式,每个变量显示对应一个上限
* 2016/4/16-0.0.1
* 基本功能
*/
var VariableProgressBar = window.VariableProgressBar || {} ;
VariableProgressBar.parameters = PluginManager.parameters('VariableProgressBar');
VariableProgressBar.id=[];
VariableProgressBar.top=[];
//VariableProgressBar.price = parseInt(VariableProgressBar.parameters['price'] || '1000');
//用于读取命令
VariableProgressBar._Game_Interpreter_pluginCommand =Game_Interpreter.prototype.pluginCommand;
Game_Interpreter.prototype.pluginCommand = function(command, args) {
VariableProgressBar._Game_Interpreter_pluginCommand.call(this, command, args);
if (command === 'VariableProgressBar') {
switch (args[0]) {
case 'clear'://命令claer 清除所有的id和top
VariableProgressBar.id.splice(0,VariableProgressBar.id.length);
VariableProgressBar.top.splice(0,VariableProgressBar.top.length);
break;
case 'add'://命令add 现在只能接两个参数了
VariableProgressBar.id.push(Number(args[1]));
VariableProgressBar.top.push(Number(args[2]));
break;
case 'delete'://命令delete 按照id删掉一个
for(var i=0;i<VariableProgressBar.id.length;i++){
if(VariableProgressBar.id[i]==Number(args[1])){
VariableProgressBar.id.splice(i,1);
VariableProgressBar.top.splice(i,1);
break;
}
}
break;
case 'set'://命令set 按照id设置top,所有的
for(var i=0;i<VariableProgressBar.id.length;i++){
if(VariableProgressBar.id[i]==Number(args[1])){
VariableProgressBar.top[i]=Number(args[2]);
}
}
break;
case 'close'://关闭窗口
VariableProgressBar.sc.removeChild(VariableProgressBar.mw);
break;
case 'open'://打开窗口
VariableProgressBar.sc.addChild(VariableProgressBar.mw);
break;
}
}
};
VariableProgressBar.sc=null;
VariableProgressBar.mw=null;
VariableProgressBar._Scene_Map_createAllWindows = Scene_Map.prototype.createAllWindows;
Scene_Map.prototype.createAllWindows = function (){
VariableProgressBar._Scene_Map_createAllWindows.call(this);
VariableProgressBar.mw=new VariableProgressBar.Window_Bar();
this.addChild(VariableProgressBar.mw);
VariableProgressBar.sc=this;
VariableProgressBar.sc.removeChild(VariableProgressBar.mw);
};
VariableProgressBar.Window_Bar=function(){
this.initialize.apply(this, arguments);
}
VariableProgressBar.Window_Bar.prototype = Object.create(Window_Base.prototype);
VariableProgressBar.Window_Bar.prototype.constructor = VariableProgressBar.Window_Bar;
//初始化
VariableProgressBar.Window_Bar.prototype.initialize = function (){
var width = this.windowWidth();
var height = this.windowHeight();
var x=this.windowPosition().x;
var y=this.windowPosition().y;
Window_Base.prototype.initialize.call(this, x, y, width, height);
this.opacity = this.windowOpacity();
};
//窗口位置
VariableProgressBar.Window_Bar.prototype.windowPosition = function (){
return {x:parseInt(VariableProgressBar.parameters['windowPositionX'] || '264'),y:parseInt(VariableProgressBar.parameters['windowPositionY'] || '192')};
};
//窗口宽
VariableProgressBar.Window_Bar.prototype.windowWidth = function (){
return parseInt(VariableProgressBar.parameters['windowWidth'] || '384');
};
//窗口高
VariableProgressBar.Window_Bar.prototype.windowHeight = function (){
return parseInt(VariableProgressBar.parameters['windowHeight'] || '112');
};
//窗口不透明度
VariableProgressBar.Window_Bar.prototype.windowOpacity = function (){
return parseInt(VariableProgressBar.parameters['windowOpacity'] || '192');
};
//更新方法,每次刷新窗口都要执行
VariableProgressBar.Window_Bar.prototype.update = function (){
this.contents.clear();
for(i=0;i<VariableProgressBar.id.length;i++)
{
this.show(VariableProgressBar.id[i],i);
}
};
VariableProgressBar.Window_Bar.prototype.show=function(id,i) {
var v1 = $gameVariables.value(id); //读取一个数据这里读取的是内部变量56号的值
var v2 = VariableProgressBar.top[i]; //设置这个数据的上限
var z =31.5 //计算声望条的绘制比例
var width = 150; //设置一个宽度(后面会用到)
var x = 40; //设置x坐标(后面会用到)
var y = 128; //设置y坐标(后面会用到)
this.contents.fontSize = 22;
if (id == 4){
this.drawText("怪物生命:"+$gameVariables.value(1), 0 , 0 , width, 'left','#ff0000');
this.drawText("怪物攻击:"+$gameVariables.value(2), 0 , 48 , width, 'left','#006666');
this.drawText("怪物防御:"+$gameVariables.value(3), 192 , 0 , width, 'left','#ff0000');
if ($gameVariables.value(27) == -1) {
this.drawText("怪物太强!打不过!", 192 , 48 , width, 'left','#ff0000');
} else {
this.drawText("战斗损伤:"+$gameVariables.value(27), 192 , 48 , width, 'left','#ff0000');
}
}
}