Продвинутый объект
This commit is contained in:
parent
955879bbfb
commit
1ecf2e3960
71
Warship/Warship/DrawingAdvancedWarship.cs
Normal file
71
Warship/Warship/DrawingAdvancedWarship.cs
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Warship
|
||||||
|
{
|
||||||
|
internal class DrawingAdvancedWarship : DrawingWarship
|
||||||
|
{
|
||||||
|
public DrawingAdvancedWarship(int speed, float weight, Color bodyColor, Color dopColor, bool Helipad, bool Antenna, bool Missile) : base(speed, weight, bodyColor, 120, 50)
|
||||||
|
{
|
||||||
|
Warship = new EntityAdvancedWarship(speed, weight, bodyColor, dopColor, Helipad, Antenna, Missile);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void DrawTransport(Graphics g)
|
||||||
|
{
|
||||||
|
if (Warship is not EntityAdvancedWarship advancedWarship)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Pen pen = new(Color.Black);
|
||||||
|
Brush dopBrush = new SolidBrush(advancedWarship.DopColor);
|
||||||
|
|
||||||
|
if (advancedWarship.Missile)
|
||||||
|
{
|
||||||
|
g.FillPolygon(dopBrush, new Point[]
|
||||||
|
{
|
||||||
|
new Point(_startPosX+25,_startPosY+5-5),new Point(_startPosX+65,_startPosY+5-5),
|
||||||
|
new Point(_startPosX+75,_startPosY+10-5),new Point(_startPosX+25,_startPosY+10-5),
|
||||||
|
new Point(_startPosX+25,_startPosY+5-5)
|
||||||
|
}
|
||||||
|
);
|
||||||
|
g.DrawLine(pen, new Point(_startPosX + 25, _startPosY + 5 - 5), new Point(_startPosX + 65, _startPosY + 5 - 5));
|
||||||
|
g.DrawLine(pen, new Point(_startPosX + 65, _startPosY + 5 - 5), new Point(_startPosX + 75, _startPosY + 10 - 5));
|
||||||
|
g.DrawLine(pen, new Point(_startPosX + 75, _startPosY + 10 - 5), new Point(_startPosX + 25, _startPosY + 10 - 5));
|
||||||
|
g.DrawLine(pen, new Point(_startPosX + 25, _startPosY + 10 - 5), new Point(_startPosX + 25, _startPosY + 5 - 5));
|
||||||
|
|
||||||
|
g.FillPolygon(dopBrush, new Point[]
|
||||||
|
{
|
||||||
|
new Point(_startPosX+25,_startPosY+50-5),new Point(_startPosX+75,_startPosY+50-5),
|
||||||
|
new Point(_startPosX+65,_startPosY+55-5),new Point(_startPosX+25,_startPosY+55-5),
|
||||||
|
new Point(_startPosX+25,_startPosY+50-5)
|
||||||
|
}
|
||||||
|
);
|
||||||
|
g.DrawLine(pen, new Point(_startPosX + 25, _startPosY + 50 - 5), new Point(_startPosX + 75, _startPosY + 50 - 5));
|
||||||
|
g.DrawLine(pen, new Point(_startPosX + 75, _startPosY + 50 - 5), new Point(_startPosX + 65, _startPosY + 55 - 5));
|
||||||
|
g.DrawLine(pen, new Point(_startPosX + 65, _startPosY + 55 - 5), new Point(_startPosX + 25, _startPosY + 55 - 5));
|
||||||
|
g.DrawLine(pen, new Point(_startPosX + 25, _startPosY + 55 - 5), new Point(_startPosX + 25, _startPosY + 50 - 5));
|
||||||
|
}
|
||||||
|
_startPosY += 5;
|
||||||
|
base.DrawTransport(g);
|
||||||
|
_startPosY -= 5;
|
||||||
|
|
||||||
|
if (advancedWarship.Helipad)
|
||||||
|
{
|
||||||
|
g.FillEllipse(dopBrush, _startPosX + 85, _startPosY + 20 - 5, 20, 20);
|
||||||
|
g.DrawEllipse(pen, _startPosX + 85, _startPosY + 20 - 5, 20, 20);
|
||||||
|
g.DrawLine(pen, _startPosX + 90, _startPosY + 25 - 5, _startPosX + 90, _startPosY + 35 - 5);
|
||||||
|
g.DrawLine(pen, _startPosX + 90 + 10, _startPosY + 25 - 5, _startPosX + 90 + 10, _startPosY + 35 - 5);
|
||||||
|
g.DrawLine(pen, _startPosX + 90, _startPosY + 30 - 5, _startPosX + 100, _startPosY + 30 - 5);
|
||||||
|
}
|
||||||
|
if (advancedWarship.Antenna)
|
||||||
|
{
|
||||||
|
g.DrawLine(pen, _startPosX + 15, _startPosY + 20 - 5, _startPosX + 15, _startPosY + 40 - 5);
|
||||||
|
g.DrawLine(pen, _startPosX + 10, _startPosY + 30 - 5, _startPosX + 20, _startPosY + 30 - 5);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
24
Warship/Warship/EntityAdvancedWarship.cs
Normal file
24
Warship/Warship/EntityAdvancedWarship.cs
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Warship
|
||||||
|
{
|
||||||
|
internal class EntityAdvancedWarship : EntityWarship
|
||||||
|
{
|
||||||
|
public Color DopColor { get; private set; }
|
||||||
|
public bool Helipad { get; private set; }
|
||||||
|
public bool Antenna { get; private set; }
|
||||||
|
public bool Missile { get; private set; }
|
||||||
|
public EntityAdvancedWarship(int speed, float weight, Color bodyColor, Color dopColor, bool helipad, bool antenna, bool missile) : base(speed, weight, bodyColor)
|
||||||
|
{
|
||||||
|
DopColor = dopColor;
|
||||||
|
Helipad = helipad;
|
||||||
|
Antenna = antenna;
|
||||||
|
Missile = missile;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
13
Warship/Warship/FormWarship.Designer.cs
generated
13
Warship/Warship/FormWarship.Designer.cs
generated
@ -38,6 +38,7 @@
|
|||||||
this.buttonLeft = new System.Windows.Forms.Button();
|
this.buttonLeft = new System.Windows.Forms.Button();
|
||||||
this.buttonUp = new System.Windows.Forms.Button();
|
this.buttonUp = new System.Windows.Forms.Button();
|
||||||
this.buttonDown = new System.Windows.Forms.Button();
|
this.buttonDown = new System.Windows.Forms.Button();
|
||||||
|
this.buttonCreateModif = new System.Windows.Forms.Button();
|
||||||
((System.ComponentModel.ISupportInitialize)(this.pictureBoxWarship)).BeginInit();
|
((System.ComponentModel.ISupportInitialize)(this.pictureBoxWarship)).BeginInit();
|
||||||
this.statusStrip1.SuspendLayout();
|
this.statusStrip1.SuspendLayout();
|
||||||
this.SuspendLayout();
|
this.SuspendLayout();
|
||||||
@ -135,11 +136,22 @@
|
|||||||
this.buttonDown.UseVisualStyleBackColor = true;
|
this.buttonDown.UseVisualStyleBackColor = true;
|
||||||
this.buttonDown.Click += new System.EventHandler(this.ButtonMove_Click);
|
this.buttonDown.Click += new System.EventHandler(this.ButtonMove_Click);
|
||||||
//
|
//
|
||||||
|
// buttonCreateModif
|
||||||
|
//
|
||||||
|
this.buttonCreateModif.Location = new System.Drawing.Point(120, 381);
|
||||||
|
this.buttonCreateModif.Name = "buttonCreateModif";
|
||||||
|
this.buttonCreateModif.Size = new System.Drawing.Size(100, 23);
|
||||||
|
this.buttonCreateModif.TabIndex = 7;
|
||||||
|
this.buttonCreateModif.Text = "Модификация";
|
||||||
|
this.buttonCreateModif.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonCreateModif.Click += new System.EventHandler(this.ButtonCreateModif_Click);
|
||||||
|
//
|
||||||
// FormWarship
|
// FormWarship
|
||||||
//
|
//
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
this.ClientSize = new System.Drawing.Size(800, 450);
|
this.ClientSize = new System.Drawing.Size(800, 450);
|
||||||
|
this.Controls.Add(this.buttonCreateModif);
|
||||||
this.Controls.Add(this.buttonDown);
|
this.Controls.Add(this.buttonDown);
|
||||||
this.Controls.Add(this.buttonUp);
|
this.Controls.Add(this.buttonUp);
|
||||||
this.Controls.Add(this.buttonLeft);
|
this.Controls.Add(this.buttonLeft);
|
||||||
@ -169,5 +181,6 @@
|
|||||||
private Button buttonLeft;
|
private Button buttonLeft;
|
||||||
private Button buttonUp;
|
private Button buttonUp;
|
||||||
private Button buttonDown;
|
private Button buttonDown;
|
||||||
|
private Button buttonCreateModif;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -55,5 +55,24 @@ namespace Warship
|
|||||||
_warship?.ChangeBorders(pictureBoxWarship.Width, pictureBoxWarship.Height);
|
_warship?.ChangeBorders(pictureBoxWarship.Width, pictureBoxWarship.Height);
|
||||||
Draw();
|
Draw();
|
||||||
}
|
}
|
||||||
|
private void ButtonCreateModif_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
Random rnd = new();
|
||||||
|
Color color1 = Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256));
|
||||||
|
ColorDialog dialog1 = new();
|
||||||
|
if (dialog1.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
color1 = dialog1.Color;
|
||||||
|
}
|
||||||
|
Color color2 = Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256));
|
||||||
|
ColorDialog dialog2 = new();
|
||||||
|
if (dialog2.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
color2 = dialog2.Color;
|
||||||
|
}
|
||||||
|
_warship = new DrawingAdvancedWarship(rnd.Next(10, 60), rnd.Next(20000, 25000), color1, color2, Convert.ToBoolean(rnd.Next(0, 2)), Convert.ToBoolean(rnd.Next(0, 2)), Convert.ToBoolean(rnd.Next(0, 2)));
|
||||||
|
SetData();
|
||||||
|
Draw();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user