155 lines
7.1 KiB
Java
155 lines
7.1 KiB
Java
package ProjectStormtrooper;
|
|
|
|
import java.awt.*;
|
|
|
|
public class DrawingStormtrooper extends DrawingPlane {
|
|
public DrawingStormtrooper(int speed, double weight, Color bodyColor,
|
|
Color additionalColor, boolean rockets, boolean bombs,
|
|
int width, int height) {
|
|
super(speed, weight, bodyColor, width, height, 140, 90);
|
|
if (EntityPlane != null) {
|
|
EntityPlane = new EntityStormtrooper(speed, weight, bodyColor, additionalColor, rockets, bombs);
|
|
}
|
|
}
|
|
|
|
public DrawingStormtrooper(EntityStormtrooper entityStormtrooper, IDrawingEngines drawingEngines, int width, int height) {
|
|
super(entityStormtrooper, drawingEngines, width, height, 140, 90);
|
|
}
|
|
|
|
public void DrawTransport(Graphics g) {
|
|
if (EntityPlane == null) {
|
|
return;
|
|
}
|
|
if (!(EntityPlane instanceof EntityStormtrooper entityStormtrooper)) {
|
|
return;
|
|
}
|
|
Graphics2D g2d = (Graphics2D) g;
|
|
|
|
int bodyHeight = _planeHeight / 9;
|
|
|
|
Color blackColor = Color.BLACK;
|
|
Color redColor = Color.RED;
|
|
Color additionalColor = entityStormtrooper.AdditionalColor;
|
|
|
|
// Рисуем бомбы
|
|
if (entityStormtrooper.Bombs) {
|
|
Polygon bombTailPolygon = new Polygon();
|
|
bombTailPolygon.addPoint(_startPosX + _planeWidth / 2 - _planeWidth / 8 + bodyHeight * 3 - 5,
|
|
_startPosY + _planeHeight / 2 - bodyHeight / 2 - _planeHeight / 3 + bodyHeight / 2);
|
|
bombTailPolygon.addPoint(_startPosX + _planeWidth / 2 - _planeWidth / 8 + bodyHeight * 3 + 5,
|
|
_startPosY + _planeHeight / 2 - bodyHeight / 2 - _planeHeight / 3 + bodyHeight / 2 - 5);
|
|
bombTailPolygon.addPoint(_startPosX + _planeWidth / 2 - _planeWidth / 8 + bodyHeight * 3 + 5,
|
|
_startPosY + _planeHeight / 2 - bodyHeight / 2 - _planeHeight / 3 + bodyHeight / 2 + 5);
|
|
bombTailPolygon.addPoint(_startPosX + _planeWidth / 2 - _planeWidth / 8 + bodyHeight * 3 - 5,
|
|
_startPosY + _planeHeight / 2 - bodyHeight / 2 - _planeHeight / 3 + bodyHeight / 2);
|
|
|
|
g2d.setColor(additionalColor);
|
|
g2d.fillPolygon(bombTailPolygon);
|
|
g2d.setColor(blackColor);
|
|
g2d.drawPolygon(bombTailPolygon);
|
|
|
|
bombTailPolygon.translate(0, (int) (_planeHeight - 2 * (_planeHeight / 2 - bodyHeight / 2 - _planeHeight / 3 + bodyHeight / 2 - 5) - bombTailPolygon.getBounds2D().getHeight()));
|
|
|
|
g2d.setColor(additionalColor);
|
|
g2d.fillPolygon(bombTailPolygon);
|
|
g2d.setColor(blackColor);
|
|
g2d.drawPolygon(bombTailPolygon);
|
|
|
|
g2d.setColor(additionalColor);
|
|
g2d.fillOval(
|
|
_startPosX + _planeWidth / 2 - _planeWidth / 8,
|
|
_startPosY + _planeHeight / 2 - bodyHeight / 2 - _planeHeight / 3,
|
|
bodyHeight * 3,
|
|
bodyHeight);
|
|
|
|
g2d.fillOval(
|
|
_startPosX + _planeWidth / 2 - _planeWidth / 8,
|
|
_startPosY + _planeHeight / 2 - bodyHeight / 2 + _planeHeight / 3,
|
|
bodyHeight * 3,
|
|
bodyHeight);
|
|
|
|
g2d.setColor(blackColor);
|
|
g2d.drawOval(
|
|
_startPosX + _planeWidth / 2 - _planeWidth / 8,
|
|
_startPosY + _planeHeight / 2 - bodyHeight / 2 - _planeHeight / 3,
|
|
bodyHeight * 3,
|
|
bodyHeight);
|
|
g2d.drawOval(
|
|
_startPosX + _planeWidth / 2 - _planeWidth / 8,
|
|
_startPosY + _planeHeight / 2 - bodyHeight / 2 + _planeHeight / 3,
|
|
bodyHeight * 3,
|
|
bodyHeight);
|
|
}
|
|
|
|
// Рисуем ракеты
|
|
if (entityStormtrooper.Rockets) {
|
|
int rocketWidth = bodyHeight * 4;
|
|
int rocketHeight = bodyHeight / 2;
|
|
|
|
Polygon rocketCockPitPolygon = new Polygon();
|
|
rocketCockPitPolygon.addPoint(_startPosX + _planeWidth / 2 - _planeWidth / 5 - rocketHeight,
|
|
_startPosY + _planeHeight / 2 - bodyHeight - bodyHeight / 2 + rocketHeight / 2);
|
|
rocketCockPitPolygon.addPoint(_startPosX + _planeWidth / 2 - _planeWidth / 5,
|
|
_startPosY + _planeHeight / 2 - bodyHeight - bodyHeight / 2);
|
|
rocketCockPitPolygon.addPoint(_startPosX + _planeWidth / 2 - _planeWidth / 5,
|
|
_startPosY + _planeHeight / 2 - bodyHeight - bodyHeight / 2 + rocketHeight);
|
|
|
|
Polygon rocketTailPolygon = new Polygon();
|
|
rocketTailPolygon.addPoint(_startPosX + _planeWidth / 2 - _planeWidth / 5 - rocketHeight + rocketWidth - 10,
|
|
_startPosY + _planeHeight / 2 - bodyHeight - bodyHeight / 2 + rocketHeight / 2);
|
|
rocketTailPolygon.addPoint(_startPosX + _planeWidth / 2 - _planeWidth / 5 + rocketWidth,
|
|
_startPosY + _planeHeight / 2 - bodyHeight * 2 + rocketHeight / 2);
|
|
rocketTailPolygon.addPoint(_startPosX + _planeWidth / 2 - _planeWidth / 5 + rocketWidth,
|
|
_startPosY + _planeHeight / 2 - bodyHeight - bodyHeight / 2 + rocketHeight + bodyHeight / 2 - rocketHeight / 2);
|
|
|
|
g2d.setColor(redColor);
|
|
g2d.fillPolygon(rocketCockPitPolygon);
|
|
g2d.setColor(blackColor);
|
|
g2d.drawPolygon(rocketCockPitPolygon);
|
|
|
|
g2d.setColor(blackColor);
|
|
g2d.fillPolygon(rocketTailPolygon);
|
|
|
|
rocketCockPitPolygon.translate(0, (int) (_planeHeight - 2 * (_planeHeight / 2 - bodyHeight - bodyHeight / 2) - rocketCockPitPolygon.getBounds2D().getHeight()));
|
|
rocketTailPolygon.translate(0, (int) (_planeHeight - 2 * (_planeHeight / 2 - bodyHeight * 2 + rocketHeight / 2) - rocketTailPolygon.getBounds2D().getHeight()));
|
|
|
|
g2d.setColor(redColor);
|
|
g2d.fillPolygon(rocketCockPitPolygon);
|
|
g2d.setColor(blackColor);
|
|
g2d.drawPolygon(rocketCockPitPolygon);
|
|
|
|
g2d.setColor(blackColor);
|
|
g2d.fillPolygon(rocketTailPolygon);
|
|
|
|
g2d.setColor(additionalColor);
|
|
g2d.fillRect(
|
|
_startPosX + _planeWidth / 2 - _planeWidth / 5,
|
|
_startPosY + _planeHeight / 2 - bodyHeight - bodyHeight / 2,
|
|
rocketWidth,
|
|
rocketHeight);
|
|
|
|
|
|
g2d.fillRect(
|
|
_startPosX + _planeWidth / 2 - _planeWidth / 5,
|
|
_startPosY + _planeHeight / 2 + bodyHeight / 2 + bodyHeight / 2,
|
|
rocketWidth,
|
|
rocketHeight);
|
|
|
|
g2d.setColor(blackColor);
|
|
g2d.drawRect(
|
|
_startPosX + _planeWidth / 2 - _planeWidth / 5,
|
|
_startPosY + _planeHeight / 2 - bodyHeight - bodyHeight / 2,
|
|
rocketWidth,
|
|
rocketHeight);
|
|
|
|
g2d.drawRect(
|
|
_startPosX + _planeWidth / 2 - _planeWidth / 5,
|
|
_startPosY + _planeHeight / 2 + bodyHeight / 2 + bodyHeight / 2,
|
|
rocketWidth,
|
|
rocketHeight);
|
|
}
|
|
|
|
super.DrawTransport(g);
|
|
}
|
|
}
|