/*:
* Acceleration.js
* @plugindesc 均匀加减速插件
* @author 魏玉龙
* @since 2018.09.15
* @version 1.0
*
* @param speed
* @desc 加速度
* @default 0.01
*
* @param stamina
* @desc 角色冲刺持续帧数,为0时可无限时冲刺。
* @default 600
*
*/
(function () {
var parameters = PluginManager.parameters('Acceleration');
var speed = Number(parameters['speed'] || 0.01);
var stamina = Number(parameters['stamina'] || 600);
var Game_CharacterBase_prototype_initMembers = Game_CharacterBase.prototype.initMembers;
Game_CharacterBase.prototype.initMembers = function () {
Game_CharacterBase_prototype_initMembers.call(this);
this._dashSpeed = 0;
this._stamina = stamina;
}
Game_CharacterBase.prototype.realMoveSpeed = function () {
return this._moveSpeed + this._dashSpeed;
}
var Game_CharacterBase_prototype_updateStop = Game_CharacterBase.prototype.updateStop;
Game_CharacterBase.prototype.updateStop = function () {
Game_CharacterBase_prototype_updateStop.call(this);
if (this._dashSpeed != 0) {
this._dashSpeed = 0;
}
if (this._stamina < stamina) {
this._stamina++;
}
}
var Game_CharacterBase_prototype_updateMove = Game_CharacterBase.prototype.updateMove;
Game_CharacterBase.prototype.updateMove = function () {
Game_CharacterBase_prototype_updateMove.call(this);
this.updateDashSpeed();
}
Game_CharacterBase.prototype.updateDashSpeed = function () {
if (this.isDashing()) {
if (this._stamina > 0 || stamina == 0) {
this._dashSpeed = Math.min(this._dashSpeed + speed, 1);
this._stamina > 0 && this._stamina--;
} else {
if (this._stamina == 0 && this._dashSpeed == 1) {
this.requestBalloon(7);
}
this._dashSpeed = Math.max(this._dashSpeed - speed, -1);
}
} else {
if (this._dashSpeed > 0) {
this._dashSpeed = Math.max(this._dashSpeed - speed, 0);
} else {
this._dashSpeed = Math.min(this._dashSpeed + speed, 0);
}
if (this._stamina < stamina) {
this._stamina++;
}
}
}
})();