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