added walk-in doors

This commit is contained in:
musilto9 2020-03-04 14:19:17 +01:00
parent 44d3732275
commit 25aa2271a1
2 changed files with 27 additions and 6 deletions

View File

@ -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:

View File

@ -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;
}
}