Фикс формы, логика стратегии MoveToCenter
This commit is contained in:
parent
5890fcbba7
commit
68ac0088fd
@ -42,23 +42,20 @@ namespace AirBomber
|
||||
Brush bombsColor = new SolidBrush(airBomber.BombsColor);
|
||||
base.DrawPlane(g);
|
||||
// обвесы
|
||||
if (airBomber.Bombs)
|
||||
{
|
||||
|
||||
g.FillEllipse(bombsColor, _startPosX + 90, _startPosY + 20, 15, 29);
|
||||
g.DrawEllipse(pen, _startPosX + 90, _startPosY + 20, 15, 29);
|
||||
g.FillEllipse(bombsColor, _startPosX + 90, _startPosY + 70, 15, 29);
|
||||
g.DrawEllipse(pen, _startPosX + 90, _startPosY + 70, 15, 29);
|
||||
g.FillEllipse(bombsColor, _startPosX + 140, _startPosY + 50, 15, 15);
|
||||
g.DrawEllipse(pen, _startPosX + 140, _startPosY + 50, 15, 15);
|
||||
}
|
||||
|
||||
// fueltanks
|
||||
if (airBomber.FuelTanks)
|
||||
{
|
||||
g.FillRectangle(additionalBrush, _startPosX + 63, _startPosY + 34, 20, 15);
|
||||
g.DrawRectangle(pen, _startPosX + 63, _startPosY + 34, 20, 15);
|
||||
g.FillRectangle(additionalBrush, _startPosX + 63, _startPosY + 70, 20, 15);
|
||||
g.DrawRectangle(pen, _startPosX + 63, _startPosY + 70, 20, 15);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -112,11 +112,17 @@ namespace AirBomber
|
||||
break;
|
||||
// вправо
|
||||
case DirectionType.Right:
|
||||
// TODO: Продумать логику
|
||||
if (_startPosX + EntityAirPlane.Step + _airPlaneWidth < _pictureWidth)
|
||||
{
|
||||
_startPosX += (int)EntityAirPlane.Step;
|
||||
}
|
||||
break;
|
||||
//вниз
|
||||
case DirectionType.Down:
|
||||
// TODO: Продумать логику
|
||||
if (_startPosY + EntityAirPlane.Step + _airPlaneHeight < _pictureHeight)
|
||||
{
|
||||
_startPosY += (int)EntityAirPlane.Step;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -249,9 +255,9 @@ namespace AirBomber
|
||||
//вверх
|
||||
DirectionType.Up => _startPosY - EntityAirPlane.Step > 0,
|
||||
// вправо
|
||||
DirectionType.Right => false,// TODO: Продумать логику
|
||||
DirectionType.Right => _startPosX + EntityAirPlane.Step < _pictureWidth,
|
||||
//вниз
|
||||
DirectionType.Down => false,// TODO: Продумать логику
|
||||
DirectionType.Down => _startPosY + EntityAirPlane.Step < _pictureHeight,
|
||||
_ => false,
|
||||
};
|
||||
}
|
||||
|
16
AirBomber/AirBomber/FormAirBomber.Designer.cs
generated
16
AirBomber/AirBomber/FormAirBomber.Designer.cs
generated
@ -36,6 +36,7 @@
|
||||
pictureBoxAirBomber = new PictureBox();
|
||||
comboBoxStrategy = new ComboBox();
|
||||
buttonCreateAirPlane = new Button();
|
||||
buttonStep = new Button();
|
||||
((System.ComponentModel.ISupportInitialize)pictureBoxAirBomber).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
@ -110,6 +111,7 @@
|
||||
//
|
||||
// comboBoxStrategy
|
||||
//
|
||||
comboBoxStrategy.Anchor = AnchorStyles.Top | AnchorStyles.Right;
|
||||
comboBoxStrategy.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||
comboBoxStrategy.FormattingEnabled = true;
|
||||
comboBoxStrategy.Items.AddRange(new object[] { "MoveToCenter", "MoveToRightEdge" });
|
||||
@ -120,6 +122,7 @@
|
||||
//
|
||||
// buttonCreateAirPlane
|
||||
//
|
||||
buttonCreateAirPlane.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
|
||||
buttonCreateAirPlane.Location = new Point(249, 447);
|
||||
buttonCreateAirPlane.Name = "buttonCreateAirPlane";
|
||||
buttonCreateAirPlane.Size = new Size(191, 65);
|
||||
@ -128,11 +131,23 @@
|
||||
buttonCreateAirPlane.UseVisualStyleBackColor = true;
|
||||
buttonCreateAirPlane.Click += buttonCreateAirPlane_Click;
|
||||
//
|
||||
// buttonStep
|
||||
//
|
||||
buttonStep.Anchor = AnchorStyles.Top | AnchorStyles.Right;
|
||||
buttonStep.Location = new Point(862, 77);
|
||||
buttonStep.Name = "buttonStep";
|
||||
buttonStep.Size = new Size(112, 49);
|
||||
buttonStep.TabIndex = 8;
|
||||
buttonStep.Text = "Шаг";
|
||||
buttonStep.UseVisualStyleBackColor = true;
|
||||
buttonStep.Click += buttonStep_Click;
|
||||
//
|
||||
// FormAirBomber
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(10F, 25F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(986, 540);
|
||||
Controls.Add(buttonStep);
|
||||
Controls.Add(buttonCreateAirPlane);
|
||||
Controls.Add(comboBoxStrategy);
|
||||
Controls.Add(buttonUp);
|
||||
@ -157,5 +172,6 @@
|
||||
private PictureBox pictureBoxAirBomber;
|
||||
private ComboBox comboBoxStrategy;
|
||||
private Button buttonCreateAirPlane;
|
||||
private Button buttonStep;
|
||||
}
|
||||
}
|
@ -69,7 +69,42 @@
|
||||
}
|
||||
Draw();
|
||||
}
|
||||
|
||||
private void buttonStep_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (_drawningAirPlane == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (comboBoxStrategy.Enabled)
|
||||
{
|
||||
_abstractStrategy = comboBoxStrategy.SelectedIndex
|
||||
switch
|
||||
{
|
||||
0 => new MoveToCenter(),
|
||||
//1 => new MoveToBorder(),
|
||||
_ => null,
|
||||
};
|
||||
if (_abstractStrategy == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_abstractStrategy.SetData(new
|
||||
DrawningObjectAirPlane(_drawningAirPlane), pictureBoxAirBomber.Width,
|
||||
pictureBoxAirBomber.Height);
|
||||
comboBoxStrategy.Enabled = false;
|
||||
}
|
||||
if (_abstractStrategy == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_abstractStrategy.MakeStep();
|
||||
Draw();
|
||||
if (_abstractStrategy.GetStatus() == Status.Finish)
|
||||
{
|
||||
comboBoxStrategy.Enabled = true;
|
||||
_abstractStrategy = null;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user