package graphics;
import vehicles.RobberyCar;
import javax.swing.Icon;
import javax.swing.ImageIcon;
import java.awt.*;
import route.Route;
import _main.Game;
import cross.Cross;
import cross.Lamp;
import cross.StopCross;
import java.awt.*;
import java.util.ArrayList;
public class GraphicsStopCross extends AbstractGraphicsObject {
int xp;
int yp;
Image image;
int rotation;
Draw draw;
StopCross cr;
Icon table1;
/**
* GraphicsStopCross konstruktora, beolvassuk a felhasznalt kepeket a megfelelo attributumokba
* a kesobbi felhasznalas celjabol
*/
public GraphicsStopCross(){
table1 = new ImageIcon("images/stop.gif","stoptabla"); //egy ilyen imageIcont kell letrehozni
}
/**
* Pozicio beallitasa
* @param xpos: x koordinata
* @param ypos: y koordinata
*/
public void setPosition(int xpos,int ypos){
xp = xpos;
yp = ypos;
}
/**
* Lekerjuk a poziciot
* @return Point: koordinata
*/
public Point getPosition(){
return new Point(xp,yp);
}
/**
* Beallitjuk az adott Draw-t
* @param d Draw
*/
public void setDraw(Draw d){
draw = d;
}
/**
* Beallitjuk a Cross-t
* @param c Cross
*/
public void setCross(StopCross c){
cr = c;
}
public Icon getTable(){return table1;}
/**
* Lekerjuk a tabla koordinatajat
* @return Point koordinata
*/
public Point getTablePosition()
{
// MainGraphics-hoz hozzaferes
MainGraphics gr = Game.getInstance().getMap().getGraphics();
// stoptabla helye megnezzuk az elso bemeno utat:
Route r = cr.getInRoutes().get(1);
//megnezzuk a ket csomopontjat a kijelolt utnak
Cross cr1 = r.getStartCross();
Point cr1p = gr.getGraphicsFromObject(cr1).getPosition();
Cross cr2 = r.getEndCross();
Point cr2p = gr.getGraphicsFromObject(cr2).getPosition();
// a tavolsag tizedenel helyezzuk el a tablat
Point pos = new Point(cr2p.x+(cr1p.x-cr2p.x)/10,cr2p.y+(cr1p.y-cr2p.y)/10);
return pos;
}
/**
* Megjeleniteshez hasznalt valtozok ertekeinek kiszamolasa
*/
public void calcGraphics(){
MainGraphics gr = Game.getInstance().getMap().getGraphics();
draw.drawing(this,gr.getGraphic());
}
}