三级战斗指令菜单
仙剑1中三级战斗的菜单内容如下:使用、投掷、装备这三项。
效果
在RMMV中原始菜单中是没有这三级菜单的,因此需要重新进行添加进去。
代码
这里贴上完整的代码。。。
Pal_Scene_Battle.prototype.isAnyInputWindowActive = function() {
return (this._partyCommandWindow.active ||
this._actorCommandWindow.active ||
this._otherCommandWindow.active ||
this._itemCommandWindow.active ||
this._skillWindow.active ||
this._itemWindow.active ||
this._actorWindow.active ||
this._enemyWindow.active);
};
在isAnyInputWindowActive 方法的判断中继续添加新的变量判断,将物品指令菜单的激活变量加入进去。
Pal_Scene_Battle.prototype.changeInputWindow = function() {
if (BattleManager.isInputting()) {
if (BattleManager.actor()) {
if(this._otherCommandWindow.active||this._itemCommandWindow.active){
if(this._itemCommandWindow.active){
this.startItemCommandSelection();
}else{
this.startOtherCommandSelection();
}
}else{
this.startActorCommandSelection();
}
} else {
this.startPartyCommandSelection();
}
} else {
this.endCommandSelection();
}
};
changeInputWindow 方法的判断中将额外和物品指令窗口的放在一起啊确保窗口打开是按照正确的顺序进行,然后再单独判断物品指令窗口是否激活。
Pal_Scene_Battle.prototype.createAllWindows = function() {
this.createLogWindow();
this.createStatusWindow();
this.createPartyCommandWindow();
this.createActorCommandWindow();
this.createOtherCommandWindow();
this.createItemCommandWindow();
this.createHelpWindow();
this.createSkillWindow();
this.createItemWindow();
this.createActorWindow();
this.createEnemyWindow();
this.createMessageWindow();
this.createScrollTextWindow();
};
Pal_Scene_Battle.prototype.createItemCommandWindow = function() {
this._itemCommandWindow = new Window_ItemCommand();
this._itemCommandWindow.setHandler('use', this.commandAttack.bind(this));
this._itemCommandWindow.setHandler('throw', this.commandAttack.bind(this));
this._itemCommandWindow.setHandler('equip', this.commandAttack.bind(this));
this._itemCommandWindow.setHandler('cancel', this.selectItemCancelCommand.bind(this));
//this._otherCommandWindow.changeTransparent();
//this._actorCommandWindow.setHandler('escape', this.commandEscape.bind(this));
this.addWindow(this._itemCommandWindow);
};
createItemCommandWindow 方法创建了物品指令菜单,并在createAllWindows 方法中添加进去物品指令菜单的创建方法。
Pal_Scene_Battle.prototype.startItemCommandSelection = function() {
this._itemCommandWindow.setup(BattleManager.actor());
};
Pal_Scene_Battle.prototype.commandItem = function() {
this._itemCommandWindow.activate();
this.selectNextCommand2();
};
Pal_Scene_Battle.prototype.selectItemCancelCommand = function() {
this._itemCommandWindow.close();
this._otherCommandWindow.activate();
this.selectPreviousCommand2();
};
这三个方法和上一篇中的额外指令操作方法一致,这里不再赘述,只需要换个操作的窗口即可。
function Window_ItemCommand() {
this.initialize.apply(this, arguments);
}
Window_ItemCommand.prototype = Object.create(Window_Command.prototype);
Window_ItemCommand.prototype.constructor = Window_ItemCommand;
Window_ItemCommand.prototype.initialize = function() {
var y = Graphics.boxHeight - this.windowHeight();
Window_Command.prototype.initialize.call(this, 0, y);
this.move(70, 158, 128, 160);
this.BattleCommand= ImageManager.loadSystem('FightItem');
this.openness = 0;
this.deactivate();
this._actor = null;
};
Window_ItemCommand.prototype.windowWidth = function() {
return 128;
};
Window_ItemCommand.prototype.numVisibleRows = function() {
return 5;
};
//标准内边距
Window_ItemCommand.prototype.standardPadding = function() {
return 0;
};
//创建命令列表
Window_ItemCommand.prototype.makeCommandList = function() {
if (this._actor) {
this.addUseCommand();
this.addThrowCommands();
this.addJointAttackCommand();
}
};
//添加道具使用命令
Window_ItemCommand.prototype.addUseCommand = function() {
this.addCommand("使用", 'use', this._actor.canAttack());
};
//添加投掷命令
Window_ItemCommand.prototype.addThrowCommands = function() {
this.addCommand("投掷", 'throw', this._actor.canAttack());
};
//添加装备命令
Window_ItemCommand.prototype.addJointAttackCommand = function() {
this.addCommand(TextManager.equip, 'equip', this._actor.canAttack());
};
Window_ItemCommand.prototype.setup = function(actor) {
this._actor = actor;
this.clearCommandList();
this.makeCommandList();
this.refresh();
this.selectLast();
this.activate();
this.open();
};
Window_ItemCommand.prototype.update=function(){
Window_Base.prototype.update.call(this);
this.processCursorMove();
this.processHandling();
this._stayCount++;
this.refresh();
}
Window_ItemCommand.prototype.refresh=function(){
this.contents.clear();
if(this._actor){
this.drawBattleItemCommand();
}
}
Window_ItemCommand.prototype.drawSx=new Map([
[0,0],
[1,128],
[2,256]
]);
Window_ItemCommand.prototype.drawBattleItemCommand=function(){
var bitmap=this.BattleCommand;
var sy=0;
var sw=128;
var sh=160;
var dx=0;
var dy=0;
this.contents.blt(bitmap, this.drawSx.get(this._index), sy, sw, sh, dx, dy);
}
Window_ItemCommand.prototype.processOk = function() {
if (this._actor) {
if (ConfigManager.commandRemember) {
this._actor.setLastCommandSymbol(this.currentSymbol());
} else {
this._actor.setLastCommandSymbol('');
}
}
Window_Command.prototype.processOk.call(this);
};
Window_ItemCommand.prototype.selectLast = function() {
this.select(0);
if (this._actor && ConfigManager.commandRemember) {
var symbol = this._actor.lastCommandSymbol();
this.selectSymbol(symbol);
if (symbol === 'skill') {
var skill = this._actor.lastBattleSkill();
if (skill) {
this.selectExt(skill.stypeId);
}
}
}
};
这里由于复制使用了额外指令的代码,因此内容大同小异,但都可以看到行数那边数值与正常的有区别,那是进行对应的计算,但若修改后会发现绘制的图片被遮挡了,因此需要增大。
完成效果
这样具体的效果就完成了,这和原版仙剑可以说是一致的,当然现在还没有完成全部的UI效果,因此无法看到全部的完整的游戏效果出来。这里只要在创建窗口时将窗口背景透明,看着就更好了,现在暂时不做,不然不好进行其他的定位。
下篇预告
下一篇章进行的内容,会在战斗的状态菜单,法术菜单、物品菜单。装备菜单及状态菜单中选择一个进行开发制作,或是开始处理人物状态行走的相关开发,这也是一个大头的!!!