57 lines
1.9 KiB
Java
57 lines
1.9 KiB
Java
package ruscz.game.gameOfProd.Cells;
|
|
|
|
import ruscz.game.gameOfProd.Map.Map;
|
|
import ruscz.game.gameOfProd.Windows.WindowOfFreeMove;
|
|
|
|
import java.awt.*;
|
|
|
|
public class EventMoveToCell extends Cell {
|
|
private final Map map;
|
|
private final WindowOfFreeMove window;
|
|
private final int id;
|
|
private final int directionOut;
|
|
private final boolean paint;
|
|
|
|
public int getId(){
|
|
return id;
|
|
}
|
|
|
|
public Map getMap() { return map; }
|
|
|
|
public EventMoveToCell(int id, int directionOut, int x, int y, Map map, WindowOfFreeMove window, boolean paint){
|
|
super(x,y, WindowOfFreeMove.CELL_SIZE, Color.green);
|
|
this.id = id;
|
|
this.directionOut = directionOut;
|
|
this.map = map;
|
|
this.window = window;
|
|
this.paint = paint;
|
|
}
|
|
|
|
public int getDirectionOut() { return directionOut; }
|
|
|
|
public void moveToMap() {
|
|
window.getMapManager().getActualMap().setIdExit(id);
|
|
window.setMapManager(this.map);
|
|
window.getMapManager().getActualMap().setIdExit(id);
|
|
window.paintMapOnWindow();
|
|
window.repaintCanvas();
|
|
if (!isActiveTriggerBehindMoveTo())
|
|
WindowOfFreeMove.setCanPersonMove(true);
|
|
}
|
|
|
|
private boolean isActiveTriggerBehindMoveTo() {
|
|
int x = window.getMapManager().getActualMap().getPerson().getX();
|
|
int y = window.getMapManager().getActualMap().getPerson().getY();
|
|
return map.isActiveTriggerCell(x, y);
|
|
}
|
|
|
|
@Override
|
|
public void paint(Graphics2D g) {
|
|
super.paint(g);
|
|
if (paint)
|
|
g.drawImage(window.getMapManager().getActualMap().getImageCell().getImagesOfTiles().get(window.getMapManager().getActualMap().getImageCell().getImageFromCellMap("MOVETO")), getX() * getSize(),
|
|
getY() * getSize(), getSize(), getSize(), null);
|
|
// g.drawString(Integer.toString(getId()), getX()* WindowOfFreeMove.CELL_SIZE, getY()* WindowOfFreeMove.CELL_SIZE);
|
|
}
|
|
}
|