This commit is contained in:
Макс Бондаренко 2022-11-11 18:57:16 +04:00
parent 99d1787cca
commit ce21b5e68f
4 changed files with 13 additions and 1 deletions

View File

@ -36,5 +36,9 @@ namespace WarmlyShip
{ {
_warmlyShip?.SetPosition(x, y, width, height); _warmlyShip?.SetPosition(x, y, width, height);
} }
public string GetInfo() => _warmlyShip?.GetDataForSave();
public static IDrawningObject Create(string data) => new DrawningObjectShip(data.CreateDrawningShip());
} }
} }

View File

@ -21,5 +21,11 @@ namespace WarmlyShip
Weight = weight <= 0 ? random.Next(1000, 2000) : weight; Weight = weight <= 0 ? random.Next(1000, 2000) : weight;
BodyColor = bodyColor; BodyColor = bodyColor;
} }
public static EntityWarmlyShip Creator(string data)
{
string[] strs = data.Split(':');
return new EntityWarmlyShip(Convert.ToInt32(strs[0]), Convert.ToInt32(strs[1]), Color.FromName(strs[2]));
}
} }
} }

View File

@ -11,7 +11,7 @@ namespace WarmlyShip
private static readonly char _separatorForObject = ':'; private static readonly char _separatorForObject = ':';
public static DrawingWarmlyShip CreateDrawningCar(this string info) public static DrawingWarmlyShip CreateDrawningShip(this string info)
{ {
string[] strs = info.Split(_separatorForObject); string[] strs = info.Split(_separatorForObject);
if (strs.Length == 3) if (strs.Length == 3)

View File

@ -13,5 +13,7 @@ namespace WarmlyShip
void MoveObject(Direction direction); void MoveObject(Direction direction);
void DrawningObject(Graphics g); void DrawningObject(Graphics g);
(float Left, float Right, float Top, float Bottom) GetCurrentPosition(); (float Left, float Right, float Top, float Bottom) GetCurrentPosition();
string GetInfo();
} }
} }