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