ПИбд-23_Кондратьев_Никита_Lab1 #1
16
GasolineTanker/GasolineTanker/Direction.cs
Normal file
16
GasolineTanker/GasolineTanker/Direction.cs
Normal file
@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace GasolineTanker
|
||||
{
|
||||
public enum Direction
|
||||
{
|
||||
Up = 1,
|
||||
Down = 2,
|
||||
Left = 3,
|
||||
Right = 4
|
||||
}
|
||||
}
|
102
GasolineTanker/GasolineTanker/DrawningGasolineTanker.cs
Normal file
102
GasolineTanker/GasolineTanker/DrawningGasolineTanker.cs
Normal file
@ -0,0 +1,102 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace GasolineTanker
|
||||
{
|
||||
public class DrawningGasolineTanker
|
||||
{
|
||||
public EntityGasolineTanker? EntityGasolineTanker { get; private set; }
|
||||
public int _pictureWidth;
|
||||
public int _pictureHeight;
|
||||
private int _startPosX;
|
||||
private int _startPosY;
|
||||
//Ширина грузовика
|
||||
private readonly int _carWidth = 110;
|
||||
//Высота грузовика
|
||||
private readonly int _carHeight = 60;
|
||||
//Инициализация свойств
|
||||
public bool Init(int speed, double weight, Color bodyColor, Color additionalColor, bool bodyKit, bool wing, bool sportLine, int width, int height)
|
||||
{
|
||||
//TODO:Придумать проверки!
|
||||
_pictureWidth = width;
|
||||
_pictureHeight = height;
|
||||
EntityGasolineTanker = new EntityGasolineTanker();
|
||||
EntityGasolineTanker.Init(speed, weight, bodyColor, additionalColor, bodyKit, wing, sportLine);
|
||||
return true;
|
||||
}
|
||||
public void SetPosition(int x, int y)
|
||||
{
|
||||
//TODO:Изменение x, y
|
||||
_startPosX = x;
|
||||
_startPosY = y;
|
||||
}
|
||||
public void MoveTransport(Direction direction)
|
||||
{
|
||||
if (EntityGasolineTanker == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
switch (direction)
|
||||
|
||||
{
|
||||
case Direction.Left:
|
||||
if (_startPosX - EntityGasolineTanker.Step > 0)
|
||||
{
|
||||
_startPosX -= (int)EntityGasolineTanker.Step;
|
||||
}
|
||||
break;
|
||||
case Direction.Up:
|
||||
if (_startPosY - EntityGasolineTanker.Step > 0)
|
||||
{
|
||||
_startPosY -= (int)EntityGasolineTanker.Step;
|
||||
}
|
||||
break;
|
||||
case Direction.Right:
|
||||
//TODO:Логика движения
|
||||
if (_startPosX - EntityGasolineTanker.Step < 1000)
|
||||
{
|
||||
_startPosX += (int)EntityGasolineTanker.Step;
|
||||
}
|
||||
break;
|
||||
case Direction.Down:
|
||||
if (_startPosY - EntityGasolineTanker.Step < 1000)
|
||||
{
|
||||
_startPosY += (int)EntityGasolineTanker.Step;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
public void DrawTransport(Graphics g)
|
||||
{
|
||||
if (EntityGasolineTanker == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Pen pen = new(Color.Black);
|
||||
Brush additionalBrush = new SolidBrush(EntityGasolineTanker.AdditionalColor);
|
||||
//Дополнительные элементы
|
||||
if (EntityGasolineTanker.BodyKit)
|
||||
{
|
||||
//обвес
|
||||
}
|
||||
//границы автомобиля
|
||||
g.DrawEllipse(pen, _startPosX + 10, _startPosY + 5, 20, 20);
|
||||
g.DrawEllipse(pen, _startPosX + 10, _startPosY + 35, 20, 20);
|
||||
g.DrawEllipse(pen, _startPosX + 80, _startPosY + 5, 20, 20);
|
||||
g.DrawEllipse(pen, _startPosX + 80, _startPosY + 35, 20, 20);
|
||||
g.DrawRectangle(pen, _startPosX + 9, _startPosY + 15, 10, 30);
|
||||
g.DrawRectangle(pen, _startPosX + 90, _startPosY + 15, 10, 30);
|
||||
g.DrawRectangle(pen, _startPosX + 20, _startPosY + 4, 70, 52);
|
||||
//задние фары
|
||||
Brush brRed = new SolidBrush(Color.Red);
|
||||
g.FillEllipse(brRed, _startPosX + 10, _startPosY + 5, 20, 20);
|
||||
g.FillEllipse(brRed, _startPosX + 10, _startPosY + 35, 20, 20);
|
||||
//передние фары
|
||||
Brush brYellow = new SolidBrush(Color.Yellow);
|
||||
g.FillEllipse(brYellow, _startPosX + 80, _startPosY + 5, 20, 20);
|
||||
g.FillEllipse(brYellow, _startPosX + 80, _startPosY + 35, 20, 20);
|
||||
}
|
||||
}
|
||||
}
|
38
GasolineTanker/GasolineTanker/EntityGasolineTanker.cs
Normal file
38
GasolineTanker/GasolineTanker/EntityGasolineTanker.cs
Normal file
@ -0,0 +1,38 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Drawing;
|
||||
|
||||
namespace GasolineTanker
|
||||
{
|
||||
public class EntityGasolineTanker
|
||||
{
|
||||
public int Speed { get; private set; }
|
||||
public double Weight { get; private set; }
|
||||
// Основной цвет
|
||||
public Color BodyColor { get; private set; }
|
||||
//Дополнительный цвет
|
||||
public Color AdditionalColor { get; private set; }
|
||||
//Наличие обвеса
|
||||
public bool BodyKit { get; private set; }
|
||||
//Наличие антикрыла
|
||||
public bool Wing { get; private set; }
|
||||
//Наличие гоночной полосы
|
||||
public bool SportLine { get; private set; }
|
||||
//Шаг перемещения
|
||||
public double Step => (double)Speed * 100 / Weight;
|
||||
//Инициализация полей Грузовика
|
||||
public void Init(int speed, double weight, Color bodyColor, Color additionalColor, bool bodyKit, bool wing, bool sportLine)
|
||||
{
|
||||
Speed = speed;
|
||||
Weight = weight;
|
||||
BodyColor = bodyColor;
|
||||
AdditionalColor = additionalColor;
|
||||
BodyKit = bodyKit;
|
||||
Wing = wing;
|
||||
SportLine = sportLine;
|
||||
}
|
||||
}
|
||||
}
|
60
GasolineTanker/GasolineTanker/Form1.resx
Normal file
60
GasolineTanker/GasolineTanker/Form1.resx
Normal file
@ -0,0 +1,60 @@
|
||||
<root>
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
Loading…
x
Reference in New Issue
Block a user
Не учтены все условия, при которых объект может выйти за границы