2024-03-05 09:00:55 +04:00
|
|
|
|
namespace ProjectStormtrooper.Entities;
|
2024-02-18 18:45:41 +04:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Класс-сущность "Штурмовик"
|
|
|
|
|
/// </summary>
|
2024-03-05 09:00:55 +04:00
|
|
|
|
public class EntityStormtrooper: EntityStormtrooperBase
|
2024-02-18 18:45:41 +04:00
|
|
|
|
{
|
2024-03-05 09:00:55 +04:00
|
|
|
|
|
2024-02-18 18:45:41 +04:00
|
|
|
|
public Color AdditionalColor { get; private set; }
|
2024-04-26 15:53:05 +04:00
|
|
|
|
public void SetAdditionalColor(Color additionalColor)
|
|
|
|
|
{
|
|
|
|
|
AdditionalColor = additionalColor;
|
|
|
|
|
}
|
2024-02-18 18:45:41 +04:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Признак (опция) наличия ракет
|
|
|
|
|
/// </summary>
|
|
|
|
|
public bool Rockets { get; private set; }
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Признак (опция) наличия бомб
|
|
|
|
|
/// </summary>
|
|
|
|
|
public bool Bombs { get; private set; }
|
|
|
|
|
|
2024-03-05 09:00:55 +04:00
|
|
|
|
|
2024-02-18 18:45:41 +04:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Инициализация полей объекта-класса штурмовик
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="speed">Скорость</param>
|
|
|
|
|
/// <param name="weight">Вес </param>
|
|
|
|
|
/// <param name="bodyColor">Основной цвет</param>
|
|
|
|
|
/// <param name="additionalColor">Дополнительный цвет</param>
|
|
|
|
|
/// <param name="rockets">Признак наличия ракет</param>
|
|
|
|
|
/// <param name="bombs">Признак наличия бомб</param>
|
|
|
|
|
|
2024-03-05 09:00:55 +04:00
|
|
|
|
public EntityStormtrooper(int speed, double weight, Color bodyColor, Color additionalColor, bool rockets, bool bombs):base(speed, weight, bodyColor)
|
2024-02-18 18:45:41 +04:00
|
|
|
|
{
|
2024-03-05 09:00:55 +04:00
|
|
|
|
|
2024-02-18 18:45:41 +04:00
|
|
|
|
AdditionalColor = additionalColor;
|
|
|
|
|
Rockets = rockets;
|
|
|
|
|
Bombs = bombs;
|
|
|
|
|
|
|
|
|
|
}
|
2024-04-30 11:26:54 +04:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Получение строк со значениями свойств объекта класса-сущности
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public override string[] GetStringRepresentation()
|
|
|
|
|
{
|
|
|
|
|
return new[] { nameof(EntityStormtrooper), Speed.ToString(), Weight.ToString(), BodyColor.Name, AdditionalColor.Name, Bombs.ToString(), Rockets.ToString() };
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Создание объекта из массива строк
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="strs"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public static EntityStormtrooper? CreateEntityStormtrooper(string[] strs)
|
|
|
|
|
{
|
|
|
|
|
if (strs.Length != 7 || strs[0] != nameof(EntityStormtrooper))
|
|
|
|
|
{
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
return new EntityStormtrooper(Convert.ToInt32(strs[1]), Convert.ToDouble(strs[2]), Color.FromName(strs[3]), Color.FromName(strs[4]), Convert.ToBoolean(strs[5]), Convert.ToBoolean(strs[6]));
|
|
|
|
|
}
|
2024-02-18 18:45:41 +04:00
|
|
|
|
}
|
|
|
|
|
|