72 lines
2.5 KiB
Java
72 lines
2.5 KiB
Java
package Drawnings;
|
|
|
|
import Entities.EntityElectroTrans;
|
|
|
|
import java.awt.*;
|
|
|
|
public class DrawningElectroTrans extends DrawningTrans {
|
|
private EntityElectroTrans entityElectroTrans;
|
|
|
|
public DrawningElectroTrans(int speed, float weight, Color bodyColor, int wheelsType, Color additionalColor, boolean horns, boolean battery) {
|
|
super(speed, weight, bodyColor, wheelsType, 110, 60);
|
|
entityElectroTrans = new EntityElectroTrans(speed, weight, bodyColor, additionalColor, horns, battery);
|
|
}
|
|
|
|
public void drawTrans(Graphics g) {
|
|
if (entityElectroTrans == null || _startPosX == null || _startPosY == null) {
|
|
return;
|
|
}
|
|
super.drawTrans(g);
|
|
Graphics2D g2d = (Graphics2D) g;
|
|
|
|
Point[] electroTransHorns;
|
|
if (entityElectroTrans.getHorns()) {
|
|
electroTransHorns = new Point[]{
|
|
new Point(_startPosX + 40, _startPosY + 10),
|
|
new Point(_startPosX + 20, _startPosY),
|
|
new Point(_startPosX + 60, _startPosY),
|
|
|
|
};
|
|
} else {
|
|
electroTransHorns = new Point[]{
|
|
new Point(_startPosX + 40, _startPosY + 7),
|
|
new Point(_startPosX + 20, _startPosY + 7),
|
|
new Point(_startPosX + 60, _startPosY + 7),
|
|
|
|
};
|
|
}
|
|
|
|
Polygon electroTransHornsPolygon = new Polygon();
|
|
for (Point point : electroTransHorns)
|
|
electroTransHornsPolygon.addPoint(point.x, point.y);
|
|
|
|
g2d.setColor(entityElectroTrans.getAdditionalColor());
|
|
g2d.drawPolygon(electroTransHornsPolygon);
|
|
|
|
|
|
if (entityElectroTrans.getBattery()) {
|
|
Point[] electroTransBattery = new Point[]{
|
|
new Point(_startPosX + 25, _startPosY + 32),
|
|
new Point(_startPosX + 25, _startPosY + 36),
|
|
new Point(_startPosX + 22, _startPosY + 36),
|
|
new Point(_startPosX + 22, _startPosY + 40),
|
|
new Point(_startPosX + 25, _startPosY + 40),
|
|
new Point(_startPosX + 25, _startPosY + 46),
|
|
new Point(_startPosX + 58, _startPosY + 46),
|
|
new Point(_startPosX + 58, _startPosY + 32),
|
|
|
|
};
|
|
Polygon electroTransBatteryPolygon = new Polygon();
|
|
for (Point point : electroTransBattery)
|
|
electroTransBatteryPolygon.addPoint(point.x, point.y);
|
|
|
|
g2d.setColor(entityElectroTrans.getAdditionalColor());
|
|
g2d.fillPolygon(electroTransBatteryPolygon);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|