added endEvent method
This commit is contained in:
parent
23c12ab711
commit
1c292ce0fd
@ -56,5 +56,10 @@ public class Dialog {
|
||||
timer.start();
|
||||
}
|
||||
|
||||
public void hideText() {
|
||||
dialogBar.setVisible(false);
|
||||
dialogBar.repaint();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -19,11 +19,19 @@ public class InteractionCell extends Cell {
|
||||
}
|
||||
|
||||
public void startEvent() {
|
||||
WindowOfFreeMove.setCanPersonMove(false);
|
||||
if (message != null)
|
||||
System.out.println(message);
|
||||
if (dialog != null)
|
||||
if (dialog != null) {
|
||||
dialog.showText();
|
||||
}
|
||||
}
|
||||
|
||||
public void endEvent() {
|
||||
if (dialog != null)
|
||||
dialog.hideText();
|
||||
WindowOfFreeMove.setCanPersonMove(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paint(Graphics2D g) {
|
||||
|
||||
@ -8,6 +8,7 @@ public class Person extends Cell {
|
||||
private int directionSight;
|
||||
private int directionMoveLast;
|
||||
private boolean isMoving;
|
||||
private boolean isInEvent;
|
||||
private int size;
|
||||
|
||||
public void setDirectionMoveLast(int directionMoveLast) {
|
||||
@ -24,6 +25,7 @@ public class Person extends Cell {
|
||||
this.map = map;
|
||||
this.directionSight = 3;
|
||||
this.isMoving = false;
|
||||
this.isInEvent = false;
|
||||
this.size = WindowOfFreeMove.CELL_SIZE;
|
||||
}
|
||||
|
||||
@ -75,9 +77,14 @@ public class Person extends Cell {
|
||||
y = 0;
|
||||
break;
|
||||
case WindowOfFreeMove.KEY_EVENT:
|
||||
if (isEventInFront(x,y,directionSight)) {
|
||||
if (isEventInFront(x,y,directionSight) && !isInEvent) {
|
||||
isInEvent = true;
|
||||
map.findInteractionByXY(x, y, directionSight).startEvent();
|
||||
}
|
||||
else if (isEventInFront(x,y,directionSight) && isInEvent) {
|
||||
map.findInteractionByXY(x, y, directionSight).endEvent();
|
||||
isInEvent = false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (directionMove != 69) {
|
||||
|
||||
@ -85,7 +85,7 @@ public class WindowOfFreeMove extends JFrame {
|
||||
addKeyListener(new KeyAdapter() {
|
||||
@Override
|
||||
public void keyTyped(KeyEvent e) {
|
||||
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