2023-12-17 17:18:04 +04:00
|
|
|
package ProjectStormtrooper;
|
|
|
|
|
|
|
|
import java.awt.*;
|
2023-12-17 21:19:45 +04:00
|
|
|
import java.util.Objects;
|
2023-12-17 17:18:04 +04:00
|
|
|
|
|
|
|
public class ExtensionDrawingPlane {
|
|
|
|
public static DrawingPlane CreateDrawingPlane(String info, String separatorForObject, int width, int height) {
|
|
|
|
String[] strs = info.split(separatorForObject);
|
2023-12-17 21:19:45 +04:00
|
|
|
if (strs.length == 7) {
|
|
|
|
DrawingPlane drawingPlane = new DrawingPlane(
|
2023-12-17 17:18:04 +04:00
|
|
|
Integer.parseInt(strs[0]),
|
2023-12-17 19:26:43 +04:00
|
|
|
Double.parseDouble(strs[1]),
|
2023-12-17 19:20:21 +04:00
|
|
|
new Color(
|
|
|
|
Integer.parseInt(strs[2]),
|
|
|
|
Integer.parseInt(strs[3]),
|
|
|
|
Integer.parseInt(strs[4])
|
|
|
|
),
|
2023-12-17 17:18:04 +04:00
|
|
|
width, height
|
|
|
|
);
|
2023-12-17 23:06:17 +04:00
|
|
|
if (Objects.equals(strs[5], "DrawingEnginesSimple")) {
|
2023-12-17 21:19:45 +04:00
|
|
|
drawingPlane._drawingEngines = new DrawingEnginesSimple();
|
2023-12-17 23:06:17 +04:00
|
|
|
} else if (Objects.equals(strs[5], "DrawingEnginesPyramid")) {
|
2023-12-17 21:19:45 +04:00
|
|
|
drawingPlane._drawingEngines = new DrawingEnginesPyramid();
|
2023-12-17 23:06:17 +04:00
|
|
|
} else if (Objects.equals(strs[5], "DrawingEnginesEllipse")) {
|
2023-12-17 21:19:45 +04:00
|
|
|
drawingPlane._drawingEngines = new DrawingEnginesEllipse();
|
|
|
|
}
|
|
|
|
drawingPlane.SetEnginesCount(Integer.parseInt(strs[6]));
|
|
|
|
return drawingPlane;
|
2023-12-17 17:18:04 +04:00
|
|
|
}
|
2023-12-17 21:19:45 +04:00
|
|
|
if (strs.length == 12) {
|
|
|
|
DrawingPlane drawingPlane = new DrawingStormtrooper(
|
2023-12-17 17:18:04 +04:00
|
|
|
Integer.parseInt(strs[0]),
|
2023-12-17 19:26:43 +04:00
|
|
|
Double.parseDouble(strs[1]),
|
2023-12-17 19:20:21 +04:00
|
|
|
new Color(
|
|
|
|
Integer.parseInt(strs[2]),
|
|
|
|
Integer.parseInt(strs[3]),
|
|
|
|
Integer.parseInt(strs[4])
|
|
|
|
),
|
|
|
|
new Color(
|
2023-12-17 21:19:45 +04:00
|
|
|
Integer.parseInt(strs[7]),
|
|
|
|
Integer.parseInt(strs[8]),
|
|
|
|
Integer.parseInt(strs[9])
|
2023-12-17 19:20:21 +04:00
|
|
|
),
|
2023-12-17 21:19:45 +04:00
|
|
|
Boolean.parseBoolean(strs[10]),
|
|
|
|
Boolean.parseBoolean(strs[11]),
|
2023-12-17 17:18:04 +04:00
|
|
|
width, height
|
|
|
|
);
|
2023-12-17 21:19:45 +04:00
|
|
|
if (Objects.equals(strs[5], "DrawingEnginesSimple")) {
|
|
|
|
drawingPlane._drawingEngines = new DrawingEnginesSimple();
|
|
|
|
} else if (Objects.equals(strs[5], "DrawingEnginesPyramid")) {
|
|
|
|
drawingPlane._drawingEngines = new DrawingEnginesPyramid();
|
|
|
|
} else if (Objects.equals(strs[5], "DrawingEnginesEllipse")) {
|
|
|
|
drawingPlane._drawingEngines = new DrawingEnginesEllipse();
|
|
|
|
}
|
|
|
|
drawingPlane.SetEnginesCount(Integer.parseInt(strs[6]));
|
|
|
|
return drawingPlane;
|
2023-12-17 17:18:04 +04:00
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
2023-12-17 19:20:21 +04:00
|
|
|
|
|
|
|
public static String GetDataForSave(DrawingPlane drawingPlane, String separatorForObject) {
|
2023-12-17 17:32:29 +04:00
|
|
|
var plane = drawingPlane.EntityPlane;
|
2023-12-17 19:20:21 +04:00
|
|
|
if (plane == null) {
|
2023-12-17 17:32:29 +04:00
|
|
|
return "";
|
|
|
|
}
|
2023-12-17 21:19:45 +04:00
|
|
|
String str = plane.Speed +
|
|
|
|
separatorForObject +
|
|
|
|
plane.Weight +
|
|
|
|
separatorForObject +
|
|
|
|
plane.BodyColor.getRed() + separatorForObject +
|
|
|
|
plane.BodyColor.getGreen() + separatorForObject +
|
|
|
|
plane.BodyColor.getBlue() + separatorForObject +
|
2023-12-17 23:06:17 +04:00
|
|
|
(drawingPlane._drawingEngines.GetEnumEnginesCount() == null ? "null" : drawingPlane._drawingEngines.getClass()) + separatorForObject +
|
|
|
|
(drawingPlane._drawingEngines.GetEnumEnginesCount() == null ? "0" : drawingPlane._drawingEngines.GetEnumEnginesCount().count);
|
2023-12-17 19:20:21 +04:00
|
|
|
if (!(plane instanceof EntityStormtrooper stormtrooper)) {
|
2023-12-17 17:32:29 +04:00
|
|
|
return str;
|
|
|
|
}
|
2023-12-17 21:19:45 +04:00
|
|
|
return str +
|
|
|
|
separatorForObject +
|
|
|
|
stormtrooper.AdditionalColor.getRed() + separatorForObject +
|
|
|
|
stormtrooper.AdditionalColor.getGreen() + separatorForObject +
|
|
|
|
stormtrooper.AdditionalColor.getBlue() + separatorForObject +
|
|
|
|
stormtrooper.Bombs +
|
|
|
|
separatorForObject +
|
|
|
|
stormtrooper.Rockets;
|
2023-12-17 17:32:29 +04:00
|
|
|
}
|
2023-12-17 17:18:04 +04:00
|
|
|
}
|