added event trigger
This commit is contained in:
parent
00ec0ea77e
commit
cdb5180f99
@ -37,7 +37,7 @@ public class Person extends Cell {
|
||||
}
|
||||
|
||||
public void setDirectionMove(int directionMove) {
|
||||
if ((directionMove >= WindowOfFreeMove.KEY_LEFT) && (directionMove <= WindowOfFreeMove.KEY_DOWN))
|
||||
if ((directionMove >= WindowOfFreeMove.KEY_LEFT) && (directionMove <= WindowOfFreeMove.KEY_EVENT))
|
||||
this.directionMove = directionMove;
|
||||
}
|
||||
|
||||
@ -74,7 +74,13 @@ public class Person extends Cell {
|
||||
if (y == WindowOfFreeMove.CANVAS_HEIGHT)
|
||||
y = 0;
|
||||
break;
|
||||
case WindowOfFreeMove.KEY_EVENT:
|
||||
if (isEventInFront(x,y,directionSight)) {
|
||||
System.out.println("showEvent");
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (directionMove != 69) {
|
||||
if (directionMove != 0 && !map.isBusyCell(x, y) && !map.isCellEvent(x, y)) {
|
||||
directionMoveLast = directionMove;
|
||||
isMoving = true;
|
||||
@ -94,11 +100,9 @@ public class Person extends Cell {
|
||||
set(x, y);
|
||||
}
|
||||
}
|
||||
directionMove = 0;
|
||||
|
||||
if (isEventInFront(x,y,directionSight)) {
|
||||
System.out.println("showEvent");
|
||||
}
|
||||
|
||||
directionMove = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -18,6 +18,7 @@ public class WindowOfFreeMove extends JFrame {
|
||||
static final int KEY_UP = 38;
|
||||
static final int KEY_RIGHT = 39;
|
||||
static final int KEY_DOWN = 40;
|
||||
static final int KEY_EVENT = 69;
|
||||
|
||||
private Canvas canvas;
|
||||
private static JPanel dialogBar;
|
||||
@ -74,7 +75,7 @@ public class WindowOfFreeMove extends JFrame {
|
||||
inputTimer = new Timer(10, new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent actionEvent) {
|
||||
if (!map.getPerson().getIsMoving() && canPersonMove) {
|
||||
if (!map.getPerson().getIsMoving() && canPersonMove && nextMove != KEY_EVENT) {
|
||||
map.getPerson().setDirectionMove(nextMove);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user