добавил Enum и Класс рисования усложнённой части
This commit is contained in:
parent
ad362f0fab
commit
56f57afc19
@ -36,8 +36,9 @@ public class ControllerMissileCruiser
|
|||||||
random.nextInt(100, 300), random.nextInt(1000, 3000),
|
random.nextInt(100, 300), random.nextInt(1000, 3000),
|
||||||
Color.rgb(random.nextInt(0, 256), random.nextInt(0, 256), random.nextInt(0, 256)),
|
Color.rgb(random.nextInt(0, 256), random.nextInt(0, 256), random.nextInt(0, 256)),
|
||||||
Color.rgb(random.nextInt(0, 256), random.nextInt(0, 256), random.nextInt(0, 256)),
|
Color.rgb(random.nextInt(0, 256), random.nextInt(0, 256), random.nextInt(0, 256)),
|
||||||
random.nextBoolean(), random.nextBoolean(), random.nextBoolean()
|
random.nextBoolean(), random.nextBoolean()
|
||||||
);
|
);
|
||||||
|
drawingMissileCruiser.getDrawingVLS().setVlsBlockCount(random.nextInt(0, 7));
|
||||||
|
|
||||||
drawingMissileCruiser.SetPictureSize((int) mainCanvas.getWidth(), (int) mainCanvas.getHeight());
|
drawingMissileCruiser.SetPictureSize((int) mainCanvas.getWidth(), (int) mainCanvas.getHeight());
|
||||||
drawingMissileCruiser.SetPosition(random.nextInt(10, 100), random.nextInt(10, 100));
|
drawingMissileCruiser.SetPosition(random.nextInt(10, 100), random.nextInt(10, 100));
|
||||||
|
@ -14,6 +14,12 @@ public class DrawingMissileCruiser {
|
|||||||
return entityMissileCruiser;
|
return entityMissileCruiser;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private DrawingVLS drawingVLS;
|
||||||
|
|
||||||
|
public DrawingVLS getDrawingVLS() {
|
||||||
|
return drawingVLS;
|
||||||
|
}
|
||||||
|
|
||||||
/// Ширина окна
|
/// Ширина окна
|
||||||
private int pictureWidth;
|
private int pictureWidth;
|
||||||
|
|
||||||
@ -39,13 +45,13 @@ public class DrawingMissileCruiser {
|
|||||||
/// @param weight Вес крейсера
|
/// @param weight Вес крейсера
|
||||||
/// @param primaryColor Основной цвет
|
/// @param primaryColor Основной цвет
|
||||||
/// @param secondaryColor Дополнительный цвет
|
/// @param secondaryColor Дополнительный цвет
|
||||||
/// @param vls_sides Признак наличия боковых установок вертикального пуска
|
/// @param vls Признак наличия установок вертикального пуска
|
||||||
/// @param vls_center Признак наличия центральных установок вертикального пуска
|
|
||||||
/// @param helipad Признак наличия вертолётной площадки
|
/// @param helipad Признак наличия вертолётной площадки
|
||||||
public void Init(int speed, int weight, Color primaryColor, Color secondaryColor, boolean vls_sides, boolean vls_center, boolean helipad)
|
public void Init(int speed, int weight, Color primaryColor, Color secondaryColor, boolean vls, boolean helipad)
|
||||||
{
|
{
|
||||||
entityMissileCruiser = new EntityMissileCruiser();
|
entityMissileCruiser = new EntityMissileCruiser();
|
||||||
entityMissileCruiser.Init(speed, weight, primaryColor, secondaryColor, vls_sides, vls_center, helipad);
|
drawingVLS = new DrawingVLS();
|
||||||
|
entityMissileCruiser.Init(speed, weight, primaryColor, secondaryColor, vls, helipad);
|
||||||
pictureWidth = 0;
|
pictureWidth = 0;
|
||||||
pictureHeight = 0;
|
pictureHeight = 0;
|
||||||
posX = 0;
|
posX = 0;
|
||||||
@ -170,18 +176,9 @@ public class DrawingMissileCruiser {
|
|||||||
gc.setFill(entityMissileCruiser.getPrimaryColor());
|
gc.setFill(entityMissileCruiser.getPrimaryColor());
|
||||||
gc.fillPolygon(contourPolygonX, contourPolygonY, contourPolygonX.length);
|
gc.fillPolygon(contourPolygonX, contourPolygonY, contourPolygonX.length);
|
||||||
|
|
||||||
if (entityMissileCruiser.getVLS_Sides())
|
if (entityMissileCruiser.getVLS())
|
||||||
{
|
{
|
||||||
gc.setFill(entityMissileCruiser.getSecondaryColor());
|
drawingVLS.drawVLS(gc, posX, posY, entityMissileCruiser.getSecondaryColor());
|
||||||
gc.fillRect(posX + 44, posY + 5, 24, 6);
|
|
||||||
gc.fillRect(posX + 44, posY + 23, 24, 6);
|
|
||||||
gc.drawImage(vlsSideImg, posX, posY, entityWidth, entityHeight);
|
|
||||||
}
|
|
||||||
if (entityMissileCruiser.getVLS_Center())
|
|
||||||
{
|
|
||||||
gc.setFill(entityMissileCruiser.getSecondaryColor());
|
|
||||||
gc.fillRect(posX + 44, posY + 14, 24, 6);
|
|
||||||
gc.drawImage(vlsCenterImg, posX, posY, entityWidth, entityHeight);
|
|
||||||
}
|
}
|
||||||
if (entityMissileCruiser.getHelipad())
|
if (entityMissileCruiser.getHelipad())
|
||||||
{
|
{
|
||||||
|
54
src/main/java/kvr/missilecruiser_hard/DrawingVLS.java
Normal file
54
src/main/java/kvr/missilecruiser_hard/DrawingVLS.java
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
package kvr.missilecruiser_hard;
|
||||||
|
|
||||||
|
import javafx.scene.canvas.GraphicsContext;
|
||||||
|
import javafx.scene.image.Image;
|
||||||
|
import javafx.scene.paint.Color;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
public class DrawingVLS {
|
||||||
|
private VlsBlockCount vlsBlockCount;
|
||||||
|
|
||||||
|
public VlsBlockCount getVlsBlockCount() {
|
||||||
|
return vlsBlockCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setVlsBlockCount(int vlsBlockCount) {
|
||||||
|
if (vlsBlockCount > 4) {
|
||||||
|
this.vlsBlockCount = VlsBlockCount.six;
|
||||||
|
} else if (vlsBlockCount > 2) {
|
||||||
|
this.vlsBlockCount = VlsBlockCount.four;
|
||||||
|
} else {
|
||||||
|
this.vlsBlockCount = VlsBlockCount.two;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private final Image doubleVlsImage = new Image(
|
||||||
|
Objects.requireNonNull(getClass().getResource("images/doubleVLS.png")).toExternalForm()
|
||||||
|
);
|
||||||
|
public void drawVLS(GraphicsContext gc, double x, double y, Color secondaryColor) {
|
||||||
|
gc.setFill(secondaryColor);
|
||||||
|
|
||||||
|
switch (vlsBlockCount) {
|
||||||
|
case VlsBlockCount.six:
|
||||||
|
gc.fillRect(x + 43, y + 14, 12, 6);
|
||||||
|
gc.fillRect(x + 57, y + 14, 12, 6);
|
||||||
|
gc.drawImage(doubleVlsImage, x, y + 9);
|
||||||
|
case VlsBlockCount.four:
|
||||||
|
gc.fillRect(x + 43, y + 5, 12, 6);
|
||||||
|
gc.fillRect(x + 57, y + 5, 12, 6);
|
||||||
|
|
||||||
|
gc.fillRect(x + 43, y + 23, 12, 6);
|
||||||
|
gc.fillRect(x + 57, y + 23, 12, 6);
|
||||||
|
|
||||||
|
gc.drawImage(doubleVlsImage, x, y);
|
||||||
|
gc.drawImage(doubleVlsImage, x, y + 18);
|
||||||
|
break;
|
||||||
|
case VlsBlockCount.two:
|
||||||
|
gc.fillRect(x + 43, y + 14, 12, 6);
|
||||||
|
gc.fillRect(x + 57, y + 14, 12, 6);
|
||||||
|
gc.drawImage(doubleVlsImage, x, y + 9);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -32,18 +32,11 @@ public class EntityMissileCruiser {
|
|||||||
return secondaryColor;
|
return secondaryColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Боковые установки вертикального пуска
|
/// Установки вертикального пуска
|
||||||
private boolean vls_sides;
|
private boolean vls;
|
||||||
|
|
||||||
public boolean getVLS_Sides(){
|
public boolean getVLS(){
|
||||||
return vls_sides;
|
return vls;
|
||||||
}
|
|
||||||
|
|
||||||
/// Центральные установки вертикального пуска
|
|
||||||
private boolean vls_center;
|
|
||||||
|
|
||||||
public boolean getVLS_Center() {
|
|
||||||
return vls_center;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Вертолётная площадка
|
/// Вертолётная площадка
|
||||||
@ -60,22 +53,20 @@ public class EntityMissileCruiser {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Инициализация полей объекта-класса ракетного крейсера
|
* Инициализация полей объекта-класса ракетного крейсера
|
||||||
* @param Speed Скорость
|
* @param speed Скорость
|
||||||
* @param Weight Вес крейсера
|
* @param weight Вес крейсера
|
||||||
* @param PrimaryColor Основной цвет
|
* @param primaryColor Основной цвет
|
||||||
* @param SecondaryColor Дополнительный цвет
|
* @param secondaryColor Дополнительный цвет
|
||||||
* @param VLS_Sides Признак наличия боковых установок вертикального пуска
|
* @param vls Признак наличия установок вертикального пуска
|
||||||
* @param VLS_Center Признак наличия центральных установок вертикального пуска
|
* @param helipad Признак наличия вертолётной площадки
|
||||||
* @param Helipad Признак наличия вертолётной площадки
|
|
||||||
*/
|
*/
|
||||||
public void Init(int Speed, int Weight, Color PrimaryColor, Color SecondaryColor, boolean VLS_Sides, boolean VLS_Center, boolean Helipad)
|
public void Init(int speed, int weight, Color primaryColor, Color secondaryColor, boolean vls, boolean helipad)
|
||||||
{
|
{
|
||||||
speed = Speed;
|
this.speed = speed;
|
||||||
weight = Weight;
|
this.weight = weight;
|
||||||
primaryColor = PrimaryColor;
|
this.primaryColor = primaryColor;
|
||||||
secondaryColor = SecondaryColor;
|
this.secondaryColor = secondaryColor;
|
||||||
vls_sides = VLS_Sides;
|
this.vls = vls;
|
||||||
vls_center = VLS_Center;
|
this.helipad = helipad;
|
||||||
helipad = Helipad;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
7
src/main/java/kvr/missilecruiser_hard/VlsBlockCount.java
Normal file
7
src/main/java/kvr/missilecruiser_hard/VlsBlockCount.java
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
package kvr.missilecruiser_hard;
|
||||||
|
|
||||||
|
public enum VlsBlockCount {
|
||||||
|
two,
|
||||||
|
four,
|
||||||
|
six
|
||||||
|
}
|
BIN
src/main/resources/kvr/missilecruiser_hard/images/doubleVLS.png
Normal file
BIN
src/main/resources/kvr/missilecruiser_hard/images/doubleVLS.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 647 B |
Loading…
x
Reference in New Issue
Block a user