package main;

import ea.Ticker;
import main.entities.player.Player;
import main.maps.ImageMap;

public class DoorTile extends Tile implements Ticker {
	
	public static final int TOP = 0;
	public static final int BOTTOM = 1;
	public static final int LEFT = 2;
	public static final int RIGHT = 3;

	private int side;
	private DoorTile connected;
	private ImageMap map;

	public DoorTile(float x, float y, ImageMap map) {
		super(Tile.DOOR, x, y);
		this.map = map;

		Main.instance.tickerAnmelden(this, 50);
	}

	@Override
	public void tick() {
		if (Main.instance.getWorld() != null) {
			Player player = Main.instance.getWorld().getPlayer();
			float dist = player.dist(posX + 0.5f, posY + 0.5f);
			if (dist < 0.5f) {
				Main.instance.getWorld().changeMap(this);
			}
		}
	}

	public int getSide() {
		return side;
	}

	public void setSide(int side) {
		this.side = side;
	}
	
	public void setConnectedDoor(DoorTile door) {
		connected = door;
	}

	public ImageMap getMap() {
		return map;
	}
}
