From 25aa2271a1dd2af7068b44fedcb208d593d9d5d8 Mon Sep 17 00:00:00 2001 From: musilto9 Date: Wed, 4 Mar 2020 14:19:17 +0100 Subject: [PATCH] added walk-in doors --- src/main/java/Map.java | 16 ++++++++++++---- src/main/java/Person.java | 17 +++++++++++++++-- 2 files changed, 27 insertions(+), 6 deletions(-) diff --git a/src/main/java/Map.java b/src/main/java/Map.java index fa50cac..699fdf3 100644 --- a/src/main/java/Map.java +++ b/src/main/java/Map.java @@ -121,22 +121,30 @@ public class Map { switch (cell.getDirectionOut()) { case 1: person.set(cell.getX(), cell.getY() - 1); - person.setDirectionMoveLast(0); + person.setIsMoving(true); + person.setDirectionMoveLast(WindowOfFreeMove.KEY_UP); + person.setSize(WindowOfFreeMove.CELL_SIZE); person.setDirectionSight(2); break; case 2: person.set(cell.getX() + 1, cell.getY()); - person.setDirectionMoveLast(0); + person.setIsMoving(true); + person.setDirectionMoveLast(WindowOfFreeMove.KEY_RIGHT); + person.setSize(WindowOfFreeMove.CELL_SIZE); person.setDirectionSight(3); break; case 3: person.set(cell.getX(), cell.getY() + 1); - person.setDirectionMoveLast(0); + person.setIsMoving(true); + person.setDirectionMoveLast(WindowOfFreeMove.KEY_DOWN); + person.setSize(WindowOfFreeMove.CELL_SIZE); person.setDirectionSight(0); break; case 4: person.set(cell.getX() - 1, cell.getY()); - person.setDirectionMoveLast(0); + person.setIsMoving(true); + person.setDirectionMoveLast(WindowOfFreeMove.KEY_LEFT); + person.setSize(WindowOfFreeMove.CELL_SIZE); person.setDirectionSight(1); break; default: diff --git a/src/main/java/Person.java b/src/main/java/Person.java index 2d3aee9..11fd96d 100644 --- a/src/main/java/Person.java +++ b/src/main/java/Person.java @@ -79,7 +79,10 @@ public class Person extends Cell { directionMoveLast = 0; } if (WindowOfFreeMove.getMap().isCellMoveTo(x, y)) { - WindowOfFreeMove.getMap().findEventByXY(x, y).moveToMap(); + set(x, y); + if (!isMoving) { + WindowOfFreeMove.getMap().findEventByXY(x, y).moveToMap(); + } } else { if (!WindowOfFreeMove.getMap().isBusyCell(x, y)) { set(x, y); @@ -91,6 +94,8 @@ public class Person extends Cell { public void stopPerson(){ directionMove = 0; directionMoveLast = 0; + size = 0; + isMoving = false; } public boolean isInPerson(int x, int y) { @@ -131,7 +136,7 @@ public class Person extends Cell { } } - private void animateMove(Graphics2D g, int direction){ + public void animateMove(Graphics2D g, int direction){ int Xsize = 0; int Ysize = 0; switch (direction) { @@ -166,4 +171,12 @@ public class Person extends Cell { public boolean getIsMoving() { return isMoving; } + + public void setIsMoving(boolean isMoving) { + this.isMoving = isMoving; + } + + public void setSize(int size) { + this.size = size; + } }