game-of-prod/src/main/java/EventMoveToCell.java
2020-03-03 22:11:01 +01:00

50 lines
1.6 KiB
Java

import java.awt.*;
public class EventMoveToCell extends Cell {
private Map map;
private int id;
private int directionOut;
public int getId(){
return id;
}
public EventMoveToCell(int id, int directionOut, int x, int y) {
super(x, y, WindowOfFreeMove.CELL_SIZE, Color.green);
this.id = id;
this.directionOut = directionOut;
this.map = new Map(WindowOfFreeMove.CANVAS_HEIGHT, WindowOfFreeMove.CANVAS_WIDTH,false);
}
public EventMoveToCell(int id, int directionOut, int x, int y, String nameOfMap){
super(x,y,WindowOfFreeMove.CELL_SIZE, Color.green);
this.id = id;
this.directionOut = directionOut;
this.map = Map.findMapByName(nameOfMap);
}
public EventMoveToCell(int id, int directionOut, int x, int y, Map map){
super(x,y,WindowOfFreeMove.CELL_SIZE, Color.green);
this.id = id;
this.directionOut = directionOut;
this.map = map;
}
public int getDirectionOut() { return directionOut; }
public void moveToMap() {
WindowOfFreeMove.getMap().setIdExit(id);
WindowOfFreeMove.setMap(this.map);
WindowOfFreeMove.getMap().setIdExit(id);
WindowOfFreeMove.paintMapOnWindow();
WindowOfFreeMove.repaintCanvas();
}
@Override
public void paint(Graphics2D g) {
super.paint(g);
g.fillOval(getX() * WindowOfFreeMove.CELL_SIZE, getY() * WindowOfFreeMove.CELL_SIZE, WindowOfFreeMove.CELL_SIZE, WindowOfFreeMove.CELL_SIZE);
g.drawString(Integer.toString(getId()), getX()*WindowOfFreeMove.CELL_SIZE, getY()*WindowOfFreeMove.CELL_SIZE);
}
}