Skip to content

Commit

Permalink
fix: 向きをなるべく変えないように chase する
Browse files Browse the repository at this point in the history
  • Loading branch information
teramotodaiki committed Jan 13, 2019
1 parent 58cabdf commit cd52d9e
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/hackforplay/object/object.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1286,7 +1286,7 @@ export default class RPGObject extends enchant.Sprite implements N.INumbers {
*/
async mayWalkTo(movements: Vector2[], unit8 = false, prioritizeX = false) {
movements = movements.filter(vec => vec.x !== 0 || vec.y !== 0);
movements.sort((a, b) => (prioritizeX ? a.x - b.x : a.y - b.y));
movements.sort((a, b) => (prioritizeX ? b.x - a.x : b.y - a.y)); // 優先されている方の差が大きい順
for (const forward of movements) {
const unit = unit8 ? forward.unit8() : forward.unit();
if (!Vector2.equal(this.forward, unit) || this.canWalk(unit)) {
Expand Down

0 comments on commit cd52d9e

Please sign in to comment.