Изменения

This commit is contained in:
evasina2312@gmail.com 2022-11-24 01:00:55 +04:00
parent 4276aa834e
commit 25b16cfdf9
4 changed files with 22 additions and 10 deletions

View File

@ -177,5 +177,10 @@ namespace ProjectMachine
{
return (_startPosX, _startPosX + _machineWidth, _startPosY, _startPosY + _machineHeight);
}
public virtual void SetBaseColor(Color color)
{
Machine = new EntityMachine(Machine.Speed, Machine.Weight, color);
}
}
}

View File

@ -17,10 +17,10 @@ namespace ProjectMachine
/// <param name="dopColor">Дополнительный цвет</param>
/// <param name="turret">Признак наличия башни с орудием</param>
/// <param name="gun">Признак наличия зенитного пулемета</param>
public DrawningTank(int speed, float weight, Color bodyColor, Color dopColor, bool bodyKit, bool turret, bool gun) :
public DrawningTank(int speed, float weight, Color bodyColor, Color dopColor, bool turret, bool gun) :
base(speed, weight, bodyColor, 90, 50)
{
Machine = new EntityTank(speed, weight, bodyColor, dopColor, bodyKit, turret, gun);
Machine = new EntityTank(speed, weight, bodyColor, dopColor, turret, gun);
}
public override void DrawTransport(Graphics g)
{
@ -50,5 +50,10 @@ namespace ProjectMachine
_startPosX -= 10;
_startPosY -= 5;
}
public void SetDopColor(Color color)
{
Machine = new EntityTank(Machine.Speed, Machine.Weight, Machine.BodyColor,
color, (Machine as EntityTank).Turret, (Machine as EntityTank).Gun);
}
}
}

View File

@ -34,14 +34,12 @@ namespace ProjectMachine
/// <param name="weight">Вес автомобиля</param>
/// <param name="bodyColor">Цвет кузова</param>
/// <param name="dopColor">Дополнительный цвет</param>
/// /// <param name="bodyKit">Признак наличия обвеса</param>
/// <param name="turret">Признак наличия башни с орудием</param>
/// <param name="gun">Признак наличия зенитного пулемета</param>
public EntityTank(int speed, float weight, Color bodyColor, Color dopColor, bool bodyKit, bool turret, bool gun) :
public EntityTank(int speed, float weight, Color bodyColor, Color dopColor, bool turret, bool gun) :
base(speed, weight, bodyColor)
{
DopColor = dopColor;
BodyKit = bodyKit;
Turret = turret;
Gun = gun;
}

View File

@ -34,8 +34,7 @@ namespace ProjectMachine
panelWhite.MouseDown += PanelColor_MouseDown;
panelYellow.MouseDown += PanelColor_MouseDown;
panelBlue.MouseDown += PanelColor_MouseDown;
// TODO buttonCancel.Click with lambda
buttonCancel.Click += (s, e) => Close();
}
/// <summary>
/// Отрисовать машину
@ -102,7 +101,7 @@ namespace ProjectMachine
break;
case "labelModifiedObject":
_tank = new DrawningTank((int)numericUpDownSpeed.Value, (int)numericUpDownWeight.Value, Color.White, Color.Black,
checkBoxBodyKit.Checked, checkBoxTurret.Checked, checkBoxGun.Checked);
checkBoxTurret.Checked, checkBoxGun.Checked);
break;
}
DrawTank();
@ -139,7 +138,7 @@ namespace ProjectMachine
/// <param name="e"></param>
private void LabelBaseColor_DragDrop(object sender, DragEventArgs e)
{
// TODO Call method from object _car and set color
}
/// <summary>
/// Принимаем дополнительный цвет
@ -148,7 +147,12 @@ namespace ProjectMachine
/// <param name="e"></param>
private void LabelDopColor_DragDrop(object sender, DragEventArgs e)
{
// TODO Call method from object _car if _car is DrawningSportCar and set dop color
if (_tank is DrawningTank)
{
var tank = _tank as DrawningTank;
tank.SetDopColor((Color)e.Data.GetData(typeof(Color)));
}
DrawTank();
}
/// <summary>
/// Добавление машины