2024-06-12 19:21:59 +04:00
|
|
|
|
namespace ProjectCruiser.Entities;
|
2024-06-12 16:25:55 +04:00
|
|
|
|
|
|
|
|
|
public class EntityCruiser : EntityBase
|
|
|
|
|
{
|
|
|
|
|
public Color AdditionalColor { get; private set; } // доп. цвет
|
|
|
|
|
|
2024-06-15 09:53:32 +04:00
|
|
|
|
public void setAdditionalColor(Color clr)
|
|
|
|
|
{
|
|
|
|
|
AdditionalColor = clr;
|
|
|
|
|
}
|
|
|
|
|
|
2024-06-12 16:25:55 +04:00
|
|
|
|
// признаки (наличия)
|
|
|
|
|
public bool HelicopterPads { get; private set; } // вертолетная площадка
|
2024-06-13 10:57:01 +04:00
|
|
|
|
public bool Hangars { get; private set; } // ангар
|
2024-06-12 16:25:55 +04:00
|
|
|
|
|
|
|
|
|
public EntityCruiser(int speed, double weight, Color mainc,
|
2024-06-15 10:03:23 +04:00
|
|
|
|
Color additionalColor, bool pad, bool hangars)
|
2024-06-12 16:25:55 +04:00
|
|
|
|
: base(speed, weight, mainc)
|
|
|
|
|
{
|
|
|
|
|
AdditionalColor = additionalColor;
|
2024-06-15 10:03:23 +04:00
|
|
|
|
HelicopterPads = pad; // non-default now for editor Form3
|
2024-06-13 10:57:01 +04:00
|
|
|
|
Hangars = hangars;
|
2024-06-12 16:25:55 +04:00
|
|
|
|
}
|
2024-06-15 13:28:42 +04:00
|
|
|
|
|
|
|
|
|
// Получение массива строк со значениями свойств
|
|
|
|
|
// объекта : тип (название класса), скорость, вес, осн. цвет [*],
|
|
|
|
|
// доп. цвет, истинность наличия площадки и (,) ангаров.
|
|
|
|
|
public virtual string[] GetStringRepresentation()
|
|
|
|
|
{
|
|
|
|
|
return new[] { nameof(EntityCruiser), Speed.ToString(),
|
|
|
|
|
Weight.ToString(), MainColor.Name, AdditionalColor.Name,
|
|
|
|
|
HelicopterPads.ToString(), Hangars.ToString()};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// decoding string to object
|
|
|
|
|
public static EntityCruiser? CreateEntity(string[] parameters)
|
|
|
|
|
{
|
|
|
|
|
if (parameters.Length != 7 || parameters.Length == 0 ||
|
|
|
|
|
parameters[0] != "EntityCruiser") return null;
|
|
|
|
|
|
|
|
|
|
return new EntityCruiser(Convert.ToInt32(parameters[1]),
|
|
|
|
|
Convert.ToDouble(parameters[2]), Color.FromName(parameters[3]),
|
|
|
|
|
Color.FromName(parameters[4]), Convert.ToBoolean(parameters[5]),
|
|
|
|
|
Convert.ToBoolean(parameters[6]));
|
|
|
|
|
}
|
2024-06-12 16:25:55 +04:00
|
|
|
|
}
|