52 lines
1.7 KiB
C#
52 lines
1.7 KiB
C#
|
using System;
|
|||
|
using System.Collections.Generic;
|
|||
|
using ProjectLainer.Entities;
|
|||
|
|
|||
|
|
|||
|
namespace ProjectLainer.DrawningObjects
|
|||
|
{
|
|||
|
public static class ExtensionDrawningLainer
|
|||
|
{
|
|||
|
public static DrawingLainer? CreateDrawningLainer(this string info, char
|
|||
|
separatorForObject, int width, int height)
|
|||
|
{
|
|||
|
string[] strs = info.Split(separatorForObject);
|
|||
|
if (strs.Length == 3)
|
|||
|
{
|
|||
|
|
|||
|
return new DrawingLainer(Convert.ToInt32(strs[0]),
|
|||
|
Convert.ToInt32(strs[1]), Color.FromName(strs[2]), width, height);
|
|||
|
|
|||
|
}
|
|||
|
if (strs.Length == 7)
|
|||
|
{
|
|||
|
return new DrawningSuperLainer(Convert.ToInt32(strs[0]),
|
|||
|
Convert.ToInt32(strs[1]),
|
|||
|
Color.FromName(strs[2]),
|
|||
|
Color.FromName(strs[3]),
|
|||
|
Convert.ToBoolean(strs[4]),
|
|||
|
Convert.ToBoolean(strs[5]),
|
|||
|
width, height);
|
|||
|
}
|
|||
|
return null;
|
|||
|
}
|
|||
|
public static string GetDataForSave(this DrawingLainer drawningLainer, char separatorForObject)
|
|||
|
{
|
|||
|
var lainer = drawningLainer.EntityLainer;
|
|||
|
if (lainer == null)
|
|||
|
{
|
|||
|
return string.Empty;
|
|||
|
}
|
|||
|
|
|||
|
var str = $"{lainer.Speed}{separatorForObject}{lainer.Weight}{separatorForObject}{lainer.BodyColor.Name}";
|
|||
|
if (lainer is not EntitySuperLainer superLainer)
|
|||
|
{
|
|||
|
return str;
|
|||
|
}
|
|||
|
return $"{str}{separatorForObject}{superLainer.AdditionalColor.Name}{separatorForObject}{superLainer.Pools}{separatorForObject}{superLainer.Decks}{separatorForObject}";
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
|