level 5
//=============================================================================
// D8test.js
//=============================================================================
/*:
* @plugindesc 通用性很渣的八向行走,因为仅考虑本游戏制作需要
* @author Hexly
*
* @help 使用该脚本的行走图素材文件名前面添加一个标志:$
*没错,我覆盖了BigCharacter的素材文件标志,因为不需要用到BigCharacter
*/(function(){
var direction;
var Lastdirection = 2;
Sprite_Character.prototype.patternWidth = function() {
if (this._tileId > 0) {
return $gameMap.tileWidth();
} else if (this._isBigCharacter) {
return this.bitmap.width / 6;
} else {
return this.bitmap.width / 12;
}
};
//注意BigCharacter已经被用来制作D8了
Sprite_Character.prototype.patternHeight = function() {
if (this._tileId > 0) {
return $gameMap.tileHeight();
// } else if (this._isBigCharacter) {
// return this.bitmap.height / 8;
} else {
return this.bitmap.height / 8;
}
}; Game_Player.prototype.moveByInput = function() {
if (!this.isMoving() && this.canMove()) {
direction = Input.dir8;
if (direction > 0) {
$gameTemp.clearDestination();
} else if ($gameTemp.isDestinationValid()){
var x = $gameTemp.destinationX();
var y = $gameTemp.destinationY();
direction = this.findDirectionTo(x, y);
}
if (direction > 0) {
Lastdirection = direction;
if (direction % 2 == 0){
this.executeMove(direction);
return;
}
if (direction < 5){
this.moveDiagonally(direction + 3 , 2);
} else {
this.moveDiagonally(direction - 3 , 8);
}
}
}
}; Game_Player.prototype.moveDiagonally = function(horz, vert) {
if (!this.canPass(this._x, this._y, horz) && !this.canPass(this._x, this._y, vert)){
this.setMovementSuccess(false);
return;
}
if (this.canPass(this._x, this._y, horz) && !this.canPass(this._x, this._y, vert)){
this.moveStraight(horz);
return;
}
if (this.canPass(this._x, this._y, vert) && !this.canPass(this._x, this._y, horz)){
this.moveStraight(vert);
return;
}
if (!this.canPassDiagonally(this._x, this._y, horz, vert)) {
this.setDirection(vert); this.moveStraight(vert);
}
this._followers.updateMove(); //未经调试,如队友跟随有问题,先调试这里。
Game_Character.prototype.moveDiagonally.call(this, horz, vert);
};
//Sprite_Character.prototype.characterPatternX = function() {
//return this._character.pattern();
//};
Sprite_Character.prototype.characterPatternY = function() {
//if (Lastdirection == 0) Lastdirection = 2;
if(direction != 0)
{
if(direction % 2 != 0)
{
/*if(this._isBigCharacter)
{
this._character.CharacterIndex = 5;
}
else
{
this._character.CharacterIndex = 1;
}*/
if(direction > 5)
{
return((direction + 5)/2);
}
else
{
return((direction + 7)/2);
}
}
return ((this._character.direction() - 2) / 2);
}
else
{
if(Lastdirection % 2 != 0)
{
if(Lastdirection > 5)
{
return((Lastdirection + 5)/2);
}
else
{
return((Lastdirection + 7)/2);
}
}
else
{
return ((Lastdirection - 2) / 2); //两段应可合并,考虑到如果找到了direction()方法的代码找到了,则可做最简单的代码,因此保留
}
} };
})()
2018年02月25日 03点02分