40 lines
1.5 KiB
Java
40 lines
1.5 KiB
Java
package Trolleybus;
|
||
|
||
import java.awt.*;
|
||
|
||
public class DrawingTrolleybus extends DrawingBus{
|
||
// Конструктор
|
||
public DrawingTrolleybus(int speed, double weight, Color bodyColor, Color additionalColor, boolean horns, boolean batteries, int width, int height)
|
||
{
|
||
super(speed, weight, bodyColor, width, height, 150, 95);
|
||
if (EntityBus != null)
|
||
{
|
||
EntityBus = new EntityTrolleybus(speed, weight, bodyColor, additionalColor, horns, batteries);
|
||
}
|
||
}
|
||
// Прорисовка объекта
|
||
@Override
|
||
public void DrawTransport(Graphics g)
|
||
{
|
||
if (!(EntityBus instanceof EntityTrolleybus trolleybus))
|
||
{
|
||
return;
|
||
}
|
||
super.DrawTransport(g);
|
||
Graphics2D g2d = (Graphics2D)g;
|
||
//Опциональные "рога"
|
||
g2d.setColor(trolleybus.getAdditionalColor());
|
||
if (trolleybus.Horns)
|
||
{
|
||
g2d.drawLine(_startPosX + 70, _startPosY + 30, _startPosX + 40, _startPosY);
|
||
g2d.drawLine(_startPosX + 70, _startPosY + 30, _startPosX + 60, _startPosY);
|
||
}
|
||
//Опциональный отсек для батареи
|
||
if (trolleybus.Batteries)
|
||
{
|
||
int[] xOfBatteries = {_startPosX + 70, _startPosX + 70, _startPosX + 100, _startPosX + 110};
|
||
int[] yOfBatteries = {_startPosY + 30, _startPosY + 25, _startPosY + 25, _startPosY + 30};
|
||
g2d.fillPolygon(xOfBatteries, yOfBatteries, 4);
|
||
}
|
||
}
|
||
} |