56 lines
2.4 KiB
Java
56 lines
2.4 KiB
Java
package ProjectStormtrooper;
|
|
|
|
import java.awt.*;
|
|
|
|
public class ExtensionDrawingPlane {
|
|
public static DrawingPlane CreateDrawingPlane(String info, String separatorForObject, int width, int height) {
|
|
// todo Добавить сохранение значеиня допкласса
|
|
String[] strs = info.split(separatorForObject);
|
|
if (strs.length == 5) {
|
|
return new DrawingPlane(
|
|
Integer.parseInt(strs[0]),
|
|
Double.parseDouble(strs[1]),
|
|
new Color(
|
|
Integer.parseInt(strs[2]),
|
|
Integer.parseInt(strs[3]),
|
|
Integer.parseInt(strs[4])
|
|
),
|
|
width, height
|
|
);
|
|
}
|
|
if (strs.length == 10) {
|
|
return new DrawingStormtrooper(
|
|
Integer.parseInt(strs[0]),
|
|
Double.parseDouble(strs[1]),
|
|
new Color(
|
|
Integer.parseInt(strs[2]),
|
|
Integer.parseInt(strs[3]),
|
|
Integer.parseInt(strs[4])
|
|
),
|
|
new Color(
|
|
Integer.parseInt(strs[5]),
|
|
Integer.parseInt(strs[6]),
|
|
Integer.parseInt(strs[7])
|
|
),
|
|
Boolean.parseBoolean(strs[8]),
|
|
Boolean.parseBoolean(strs[9]),
|
|
width, height
|
|
);
|
|
}
|
|
return null;
|
|
}
|
|
|
|
public static String GetDataForSave(DrawingPlane drawingPlane, String separatorForObject) {
|
|
// todo Добавить загрузку значеиня допкласса
|
|
var plane = drawingPlane.EntityPlane;
|
|
if (plane == null) {
|
|
return "";
|
|
}
|
|
String str = plane.Speed + separatorForObject + plane.Weight + separatorForObject + plane.BodyColor.getRed() + separatorForObject + plane.BodyColor.getGreen() + separatorForObject + plane.BodyColor.getBlue();
|
|
if (!(plane instanceof EntityStormtrooper stormtrooper)) {
|
|
return str;
|
|
}
|
|
return str + separatorForObject + stormtrooper.AdditionalColor.getRed() + separatorForObject + stormtrooper.AdditionalColor.getGreen() + separatorForObject + stormtrooper.AdditionalColor.getBlue() + separatorForObject + stormtrooper.Bombs + separatorForObject + stormtrooper.Rockets;
|
|
}
|
|
}
|