Доделал
This commit is contained in:
parent
cb138fd554
commit
a0db4e8315
@ -35,11 +35,11 @@ namespace AntiAircraftGun
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Ширина прорисовки автомобиля
|
/// Ширина прорисовки автомобиля
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private readonly int _carWidth = 110;
|
private readonly int _zenitWidth = 110;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Высота прорисовки автомобиля
|
/// Высота прорисовки автомобиля
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private readonly int _carHeight = 60;
|
private readonly int _zenitHeight = 60;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Инициализация свойств
|
/// Инициализация свойств
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -54,7 +54,8 @@ namespace AntiAircraftGun
|
|||||||
public bool Init(int speed, double weight, Color bodyColor, Color
|
public bool Init(int speed, double weight, Color bodyColor, Color
|
||||||
additionalColor, Color dopColor, bool rocket, bool radar, int width, int height)
|
additionalColor, Color dopColor, bool rocket, bool radar, int width, int height)
|
||||||
{
|
{
|
||||||
// TODO: Продумать проверки
|
if (width <= _zenitWidth || height <= _zenitHeight) return false;
|
||||||
|
|
||||||
_pictureWidth = width;
|
_pictureWidth = width;
|
||||||
_pictureHeight = height;
|
_pictureHeight = height;
|
||||||
AntiAircraftGun = new EntityAntiAircraftGun();
|
AntiAircraftGun = new EntityAntiAircraftGun();
|
||||||
@ -68,9 +69,14 @@ namespace AntiAircraftGun
|
|||||||
/// <param name="y">Координата Y</param>
|
/// <param name="y">Координата Y</param>
|
||||||
public void SetPosition(int x, int y)
|
public void SetPosition(int x, int y)
|
||||||
{
|
{
|
||||||
// TODO: Изменение x, y
|
if (AntiAircraftGun == null) return;
|
||||||
_startPosX = x;
|
_startPosX = x;
|
||||||
_startPosY = y;
|
_startPosY = y;
|
||||||
|
if (x + _zenitWidth >= _pictureWidth || y + _zenitHeight>= _pictureHeight)
|
||||||
|
{
|
||||||
|
_startPosX = 1;
|
||||||
|
_startPosY = 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Изменение направления перемещения
|
/// Изменение направления перемещения
|
||||||
@ -82,14 +88,6 @@ namespace AntiAircraftGun
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
FormAntiAirCraftGun form1 = new FormAntiAirCraftGun();
|
|
||||||
Size windowSize = form1.Size;
|
|
||||||
int windowWidth = windowSize.Width;
|
|
||||||
int windowHeight = windowSize.Height;
|
|
||||||
|
|
||||||
// Теперь вы можете получить ширину и высоту отдельно, если это необходимо
|
|
||||||
|
|
||||||
switch (direction)
|
switch (direction)
|
||||||
{
|
{
|
||||||
//влево
|
//влево
|
||||||
@ -108,14 +106,14 @@ namespace AntiAircraftGun
|
|||||||
break;
|
break;
|
||||||
// вправо
|
// вправо
|
||||||
case DirectionType.Right:
|
case DirectionType.Right:
|
||||||
if (_startPosX + AntiAircraftGun.Step < windowWidth-150)
|
if (_startPosX + AntiAircraftGun.Step < _pictureWidth-110)
|
||||||
{
|
{
|
||||||
_startPosX += (int)AntiAircraftGun.Step;
|
_startPosX += (int)AntiAircraftGun.Step;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
//вниз
|
//вниз
|
||||||
case DirectionType.Down:
|
case DirectionType.Down:
|
||||||
if (_startPosY + AntiAircraftGun.Step < windowHeight-100)
|
if (_startPosY + AntiAircraftGun.Step < _pictureHeight-60)
|
||||||
{
|
{
|
||||||
_startPosY += (int)AntiAircraftGun.Step;
|
_startPosY += (int)AntiAircraftGun.Step;
|
||||||
}
|
}
|
||||||
@ -149,8 +147,6 @@ namespace AntiAircraftGun
|
|||||||
g.DrawEllipse(pen, trackRect);
|
g.DrawEllipse(pen, trackRect);
|
||||||
g.FillEllipse(Brushes.Black, trackRect);
|
g.FillEllipse(Brushes.Black, trackRect);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Brush dopBrush = new SolidBrush(AntiAircraftGun.DopColor);
|
Brush dopBrush = new SolidBrush(AntiAircraftGun.DopColor);
|
||||||
Pen dopPen = new Pen(AntiAircraftGun.DopColor);
|
Pen dopPen = new Pen(AntiAircraftGun.DopColor);
|
||||||
if (AntiAircraftGun.Rocket)
|
if (AntiAircraftGun.Rocket)
|
||||||
@ -169,12 +165,6 @@ namespace AntiAircraftGun
|
|||||||
g.DrawLine(dopPen, _startPosX + 98, _startPosY, _startPosX + 93, _startPosY + 10);
|
g.DrawLine(dopPen, _startPosX + 98, _startPosY, _startPosX + 93, _startPosY + 10);
|
||||||
g.FillEllipse(dopBrush, _startPosX + 88, _startPosY -10, 10, 10);
|
g.FillEllipse(dopBrush, _startPosX + 88, _startPosY -10, 10, 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -28,11 +28,17 @@ namespace AntiAircraftGun
|
|||||||
/// Шаг перемещения автомобиля
|
/// Шаг перемещения автомобиля
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public double Step => (double)Speed * 100 / Weight;
|
public double Step => (double)Speed * 100 / Weight;
|
||||||
|
/// <summary>
|
||||||
|
/// Цвет для доп. деталей
|
||||||
|
/// </summary>
|
||||||
public Color DopColor { get; private set; }
|
public Color DopColor { get; private set; }
|
||||||
|
/// <summary>
|
||||||
|
/// Ракета
|
||||||
|
/// </summary>
|
||||||
public bool Rocket { get; private set; }
|
public bool Rocket { get; private set; }
|
||||||
|
/// <summary>
|
||||||
|
/// Радар
|
||||||
|
/// </summary>
|
||||||
public bool Radar { get; private set; }
|
public bool Radar { get; private set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Инициализация полей объекта-класса спортивного автомобиля
|
/// Инициализация полей объекта-класса спортивного автомобиля
|
||||||
|
@ -2,34 +2,34 @@
|
|||||||
{
|
{
|
||||||
partial class FormAntiAirCraftGun
|
partial class FormAntiAirCraftGun
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Required designer variable.
|
/// Required designer variable.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private System.ComponentModel.IContainer components = null;
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Clean up any resources being used.
|
/// Clean up any resources being used.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||||
protected override void Dispose(bool disposing)
|
protected override void Dispose(bool disposing)
|
||||||
{
|
{
|
||||||
if (disposing && (components != null))
|
if (disposing && (components != null))
|
||||||
{
|
{
|
||||||
components.Dispose();
|
components.Dispose();
|
||||||
}
|
}
|
||||||
base.Dispose(disposing);
|
base.Dispose(disposing);
|
||||||
}
|
}
|
||||||
|
|
||||||
#region Windows Form Designer generated code
|
#region Windows Form Designer generated code
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Required method for Designer support - do not modify
|
/// Required method for Designer support - do not modify
|
||||||
/// the contents of this method with the code editor.
|
/// the contents of this method with the code editor.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private void InitializeComponent()
|
private void InitializeComponent()
|
||||||
{
|
{
|
||||||
this.pictureBoxAntiAircraftGun = new System.Windows.Forms.PictureBox();
|
this.pictureBoxAntiAircraftGun = new System.Windows.Forms.PictureBox();
|
||||||
this.Create = new System.Windows.Forms.Button();
|
this.buttonCreate = new System.Windows.Forms.Button();
|
||||||
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.buttonRight = new System.Windows.Forms.Button();
|
this.buttonRight = new System.Windows.Forms.Button();
|
||||||
@ -47,16 +47,16 @@
|
|||||||
this.pictureBoxAntiAircraftGun.TabIndex = 0;
|
this.pictureBoxAntiAircraftGun.TabIndex = 0;
|
||||||
this.pictureBoxAntiAircraftGun.TabStop = false;
|
this.pictureBoxAntiAircraftGun.TabStop = false;
|
||||||
//
|
//
|
||||||
// Create
|
// buttonCreate
|
||||||
//
|
//
|
||||||
this.Create.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
|
this.buttonCreate.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
|
||||||
this.Create.Location = new System.Drawing.Point(32, 577);
|
this.buttonCreate.Location = new System.Drawing.Point(32, 577);
|
||||||
this.Create.Name = "Create";
|
this.buttonCreate.Name = "buttonCreate";
|
||||||
this.Create.Size = new System.Drawing.Size(75, 23);
|
this.buttonCreate.Size = new System.Drawing.Size(75, 23);
|
||||||
this.Create.TabIndex = 1;
|
this.buttonCreate.TabIndex = 1;
|
||||||
this.Create.Text = "Создать";
|
this.buttonCreate.Text = "Создать";
|
||||||
this.Create.UseVisualStyleBackColor = true;
|
this.buttonCreate.UseVisualStyleBackColor = true;
|
||||||
this.Create.Click += new System.EventHandler(this.Create_Click_1);
|
this.buttonCreate.Click += new System.EventHandler(this.buttonCreate_Click);
|
||||||
//
|
//
|
||||||
// buttonLeft
|
// buttonLeft
|
||||||
//
|
//
|
||||||
@ -106,7 +106,7 @@
|
|||||||
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);
|
||||||
//
|
//
|
||||||
// Form1
|
// FormAntiAirCraftGun
|
||||||
//
|
//
|
||||||
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;
|
||||||
@ -115,23 +115,24 @@
|
|||||||
this.Controls.Add(this.buttonRight);
|
this.Controls.Add(this.buttonRight);
|
||||||
this.Controls.Add(this.buttonUp);
|
this.Controls.Add(this.buttonUp);
|
||||||
this.Controls.Add(this.buttonLeft);
|
this.Controls.Add(this.buttonLeft);
|
||||||
this.Controls.Add(this.Create);
|
this.Controls.Add(this.buttonCreate);
|
||||||
this.Controls.Add(this.pictureBoxAntiAircraftGun);
|
this.Controls.Add(this.pictureBoxAntiAircraftGun);
|
||||||
this.Name = "Form1";
|
this.Name = "FormAntiAirCraftGun";
|
||||||
this.Text = "Form1";
|
this.Text = "Form1";
|
||||||
((System.ComponentModel.ISupportInitialize)(this.pictureBoxAntiAircraftGun)).EndInit();
|
((System.ComponentModel.ISupportInitialize)(this.pictureBoxAntiAircraftGun)).EndInit();
|
||||||
this.ResumeLayout(false);
|
this.ResumeLayout(false);
|
||||||
this.PerformLayout();
|
this.PerformLayout();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
private PictureBox pictureBoxAntiAircraftGun;
|
private PictureBox pictureBoxAntiAircraftGun;
|
||||||
private Button Create;
|
private Button buttonCreate;
|
||||||
private Button buttonLeft;
|
private Button buttonLeft;
|
||||||
private Button buttonUp;
|
private Button buttonUp;
|
||||||
private Button buttonRight;
|
private Button buttonRight;
|
||||||
private Button buttonDown;
|
private Button buttonDown;
|
||||||
}
|
|
||||||
|
}
|
||||||
}
|
}
|
@ -37,11 +37,7 @@ namespace AntiAircraftGun
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Èçìåíåíèå ðàçìåðîâ ôîðìû
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="sender"></param>
|
|
||||||
/// <param name="e"></param>
|
|
||||||
|
|
||||||
private void pictureBoxZenit_Click(object sender, EventArgs e)
|
private void pictureBoxZenit_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
@ -62,11 +58,7 @@ namespace AntiAircraftGun
|
|||||||
pictureBoxAntiAircraftGun.Image = bmp;
|
pictureBoxAntiAircraftGun.Image = bmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Èçìåíåíèå ðàçìåðîâ ôîðìû
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="sender"></param>
|
|
||||||
/// <param name="e"></param>
|
|
||||||
private void ButtonMove_Click(object sender, EventArgs e)
|
private void ButtonMove_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (_drawing == null)
|
if (_drawing == null)
|
||||||
@ -91,8 +83,7 @@ namespace AntiAircraftGun
|
|||||||
}
|
}
|
||||||
Draw();
|
Draw();
|
||||||
}
|
}
|
||||||
|
private void buttonCreate_Click(object sender, EventArgs e)
|
||||||
private void Create_Click_1(object sender, EventArgs e)
|
|
||||||
{
|
{
|
||||||
Random random = new();
|
Random random = new();
|
||||||
_drawing = new DrawingAntiAirCraftGun();
|
_drawing = new DrawingAntiAirCraftGun();
|
||||||
@ -102,7 +93,7 @@ namespace AntiAircraftGun
|
|||||||
random.Next(0, 256)),
|
random.Next(0, 256)),
|
||||||
Color.FromArgb(random.Next(0, 256), random.Next(0, 256),//äîï. öâåò
|
Color.FromArgb(random.Next(0, 256), random.Next(0, 256),//äîï. öâåò
|
||||||
random.Next(0, 256)),
|
random.Next(0, 256)),
|
||||||
|
|
||||||
Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)), // Äîï. öâåò2
|
Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)), // Äîï. öâåò2
|
||||||
Convert.ToBoolean(random.Next(2)), // Rocket
|
Convert.ToBoolean(random.Next(2)), // Rocket
|
||||||
Convert.ToBoolean(random.Next(2)), // Radar
|
Convert.ToBoolean(random.Next(2)), // Radar
|
||||||
@ -111,8 +102,9 @@ namespace AntiAircraftGun
|
|||||||
_drawing.SetPosition(random.Next(10, 100),
|
_drawing.SetPosition(random.Next(10, 100),
|
||||||
random.Next(10, 100));
|
random.Next(10, 100));
|
||||||
|
|
||||||
|
|
||||||
Draw();
|
Draw();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,20 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace AntiAircraftGun
|
|
||||||
{
|
|
||||||
public class Vopros
|
|
||||||
{
|
|
||||||
private int _id;
|
|
||||||
|
|
||||||
public int change_id { set { _id = value; } }
|
|
||||||
|
|
||||||
public void Change(int id)
|
|
||||||
{
|
|
||||||
change_id = id;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user