From 4e7db63b49d88662bfdeba25e6db9929f53d4a8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D0=B5=D1=80=D0=B3=D0=B5=D0=B9=20=D0=9F=D0=BE=D0=BB?= =?UTF-8?q?=D0=B5=D0=B2=D0=BE=D0=B9?= Date: Sat, 8 Oct 2022 15:13:24 +0400 Subject: [PATCH] Added class DrawingAdvancedArtillery --- DrawingAdvancedArtillery.java | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 DrawingAdvancedArtillery.java diff --git a/DrawingAdvancedArtillery.java b/DrawingAdvancedArtillery.java new file mode 100644 index 0000000..d7d8c79 --- /dev/null +++ b/DrawingAdvancedArtillery.java @@ -0,0 +1,28 @@ +import java.awt.*; + +public class DrawingAdvancedArtillery extends DrawingArtillery { + public DrawingAdvancedArtillery(int speed, float weight, Color bodyColor, int rollersCount, Color dopColor, boolean weapon, boolean salvoBattery) { + super(speed, weight, bodyColor, rollersCount, 80, 50); + artillery = new EntityAdvancedArtillery(speed, weight, bodyColor, dopColor, weapon, salvoBattery); + } + + @Override + public void drawTransport(Graphics2D g) { + if (!(artillery instanceof EntityAdvancedArtillery advancedArtillery)) { + return; + } + + g.setColor(advancedArtillery.getDopColor()); + if (advancedArtillery.getWeapon()) { + g.setStroke(new BasicStroke(8)); + g.drawLine((int) _startPosX + _artilleryWidth / 2, (int) _startPosY + _artilleryHeight / 10, (int) _startPosX + _artilleryWidth, (int) _startPosY); + } + g.setStroke(new BasicStroke(6)); + if (advancedArtillery.getSalvoBattery()) { + g.drawLine((int) _startPosX + _artilleryWidth / 4, (int) _startPosY + _artilleryHeight / 4, (int) _startPosX + _artilleryWidth / 4 + _artilleryHeight / 4, (int) _startPosY - 5); + g.drawLine((int) _startPosX + _artilleryWidth / 4 - _artilleryHeight / 4, (int) _startPosY + _artilleryHeight / 4, (int) _startPosX + _artilleryWidth / 4, (int) _startPosY - 5); + g.drawLine((int) _startPosX + _artilleryWidth / 4 - _artilleryHeight / 2, (int) _startPosY + _artilleryHeight / 4, (int) _startPosX + _artilleryWidth / 4 - _artilleryHeight / 4, (int) _startPosY - 5); + } + super.drawTransport(g); + } +}