2023-09-13 14:19:11 +04:00
|
|
|
package ProjectStormtrooper;
|
|
|
|
|
|
|
|
import java.awt.*;
|
|
|
|
|
|
|
|
public class DrawingEngines {
|
|
|
|
private EnumEnginesCount _enumEnginesCount;
|
|
|
|
|
2023-09-26 13:41:56 +04:00
|
|
|
public void SetEnumEnginesCount(int enginesCount) {
|
2023-09-13 14:19:11 +04:00
|
|
|
for (EnumEnginesCount val : EnumEnginesCount.values()) {
|
|
|
|
if (val.count == enginesCount) {
|
|
|
|
this._enumEnginesCount = val;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2023-09-26 13:41:56 +04:00
|
|
|
this._enumEnginesCount = EnumEnginesCount.Two;
|
2023-09-13 14:19:11 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
private void DrawEngine(Graphics2D g2d, Color color, int x, int y, int w, int h) {
|
|
|
|
g2d.setColor(Color.WHITE);
|
|
|
|
g2d.fillRect(x, y, w, h);
|
|
|
|
g2d.setColor(Color.BLACK);
|
|
|
|
g2d.drawRect(x, y, w, h);
|
|
|
|
g2d.setColor(color);
|
|
|
|
g2d.fillRect(x, y, 6, h);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void DrawEngines(Graphics g, Color color, int startPosX, int startPosY, int drawingWidth, int drawingHeight) {
|
|
|
|
if (_enumEnginesCount == null) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
Graphics2D g2d = (Graphics2D) g;
|
|
|
|
|
|
|
|
int engineWidth = 20;
|
|
|
|
int engineHeight = 6;
|
|
|
|
|
|
|
|
if (_enumEnginesCount.count >= EnumEnginesCount.Two.count) {
|
|
|
|
DrawEngine(
|
|
|
|
g2d, color,
|
|
|
|
startPosX + drawingWidth - drawingWidth / 5,
|
|
|
|
startPosY + drawingHeight / 2 - drawingHeight / 6,
|
|
|
|
engineWidth,
|
|
|
|
engineHeight
|
|
|
|
);
|
|
|
|
DrawEngine(
|
|
|
|
g2d, color,
|
|
|
|
startPosX + drawingWidth - drawingWidth / 5,
|
|
|
|
startPosY + drawingHeight / 2 + drawingHeight / 6 - engineHeight,
|
|
|
|
engineWidth,
|
|
|
|
engineHeight
|
|
|
|
);
|
|
|
|
}
|
|
|
|
if (_enumEnginesCount.count >= EnumEnginesCount.Four.count) {
|
|
|
|
DrawEngine(
|
|
|
|
g2d, color,
|
|
|
|
startPosX + drawingWidth - drawingWidth / 5 + 5,
|
|
|
|
startPosY + drawingHeight / 2 - drawingHeight / 6 - 10,
|
|
|
|
engineWidth - 5,
|
|
|
|
engineHeight
|
|
|
|
);
|
|
|
|
DrawEngine(
|
|
|
|
g2d, color,
|
|
|
|
startPosX + drawingWidth - drawingWidth / 5 + 5,
|
|
|
|
startPosY + drawingHeight / 2 + drawingHeight / 6 - engineHeight + 10,
|
|
|
|
engineWidth - 5,
|
|
|
|
engineHeight
|
|
|
|
);
|
|
|
|
}
|
|
|
|
if (_enumEnginesCount.count >= EnumEnginesCount.Six.count) {
|
|
|
|
DrawEngine(
|
|
|
|
g2d, color,
|
|
|
|
startPosX + drawingWidth / 2 - 10,
|
|
|
|
startPosY + drawingHeight / 2 - drawingHeight / 6 - 10,
|
|
|
|
engineWidth,
|
|
|
|
engineHeight
|
|
|
|
);
|
|
|
|
DrawEngine(
|
|
|
|
g2d, color,
|
|
|
|
startPosX + drawingWidth / 2 - 10,
|
|
|
|
startPosY + drawingHeight / 2 + drawingHeight / 6 + 3,
|
|
|
|
engineWidth,
|
|
|
|
engineHeight
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|