Compare commits
11 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
ce753bc8db | ||
|
f0cb0ab565 | ||
|
c7f9f0fc86 | ||
|
36f18be18a | ||
|
37aa57504d | ||
|
315f4dda55 | ||
|
ca8833f4e1 | ||
|
9a5a57c959 | ||
|
ad1b457f40 | ||
|
0ec2965ca6 | ||
|
7a3c0eb6dd |
25
Cruiser/Cruiser.sln
Normal file
25
Cruiser/Cruiser.sln
Normal file
@ -0,0 +1,25 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.3.32825.248
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Cruiser", "Cruiser\Cruiser.csproj", "{ED77B06B-3FF6-46B7-9C07-D85EADE42DBC}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{ED77B06B-3FF6-46B7-9C07-D85EADE42DBC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{ED77B06B-3FF6-46B7-9C07-D85EADE42DBC}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{ED77B06B-3FF6-46B7-9C07-D85EADE42DBC}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{ED77B06B-3FF6-46B7-9C07-D85EADE42DBC}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {34B5A2AC-C740-4C58-BE0E-D0978BC3AFB6}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
74
Cruiser/Cruiser/AbstractStrategy.cs
Normal file
74
Cruiser/Cruiser/AbstractStrategy.cs
Normal file
@ -0,0 +1,74 @@
|
||||
using Cruiser;
|
||||
using Cruiser.MovementStrategy;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Cruiser.MovementStrategy
|
||||
{
|
||||
public abstract class AbstractStrategy
|
||||
{
|
||||
private IMoveableObject? _moveableObject;
|
||||
private Status _state = Status.NotInit;
|
||||
protected int FieldWidth { get; private set; }
|
||||
protected int FieldHeight { get; private set; }
|
||||
public Status GetStatus() { return _state; }
|
||||
public void SetData(IMoveableObject moveableObject, int width, int
|
||||
height)
|
||||
{
|
||||
if (moveableObject == null)
|
||||
{
|
||||
_state = Status.NotInit;
|
||||
return;
|
||||
}
|
||||
_state = Status.InProgress;
|
||||
_moveableObject = moveableObject;
|
||||
FieldWidth = width;
|
||||
FieldHeight = height;
|
||||
}
|
||||
public void MakeStep()
|
||||
{
|
||||
if (_state != Status.InProgress)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (IsTargetDestinaion())
|
||||
{
|
||||
_state = Status.Finish;
|
||||
return;
|
||||
}
|
||||
MoveToTarget();
|
||||
}
|
||||
protected bool MoveLeft() => MoveTo(Direction.Left);
|
||||
protected bool MoveRight() => MoveTo(Direction.Right);
|
||||
protected bool MoveUp() => MoveTo(Direction.Up);
|
||||
protected bool MoveDown() => MoveTo(Direction.Down);
|
||||
protected ObjectParameters? GetObjectParameters =>
|
||||
_moveableObject?.GetObjectPosition;
|
||||
protected int? GetStep()
|
||||
{
|
||||
if (_state != Status.InProgress)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return _moveableObject?.GetStep;
|
||||
}
|
||||
protected abstract void MoveToTarget();
|
||||
protected abstract bool IsTargetDestinaion();
|
||||
private bool MoveTo(Direction direction)
|
||||
{
|
||||
if (_state != Status.InProgress)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (_moveableObject?.CheckCanMove(direction) ?? false)
|
||||
{
|
||||
_moveableObject.MoveObject(direction);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
26
Cruiser/Cruiser/Cruiser.csproj
Normal file
26
Cruiser/Cruiser/Cruiser.csproj
Normal file
@ -0,0 +1,26 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<TargetFramework>net6.0-windows</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<UseWindowsForms>true</UseWindowsForms>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Update="Properties\Resources.Designer.cs">
|
||||
<DesignTime>True</DesignTime>
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Resources.resx</DependentUpon>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Update="Properties\Resources.resx">
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
167
Cruiser/Cruiser/CruiserForm.Designer.cs
generated
Normal file
167
Cruiser/Cruiser/CruiserForm.Designer.cs
generated
Normal file
@ -0,0 +1,167 @@
|
||||
namespace Cruiser
|
||||
{
|
||||
partial class CruiserForm
|
||||
{
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
#region Windows Form Designer generated code
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.pictureBoxCruiser = new System.Windows.Forms.PictureBox();
|
||||
this.ButtonDown = new System.Windows.Forms.Button();
|
||||
this.ButtonLeft = new System.Windows.Forms.Button();
|
||||
this.ButtonRight = new System.Windows.Forms.Button();
|
||||
this.ButtonUp = new System.Windows.Forms.Button();
|
||||
this.buttonAdvancedCreate = new System.Windows.Forms.Button();
|
||||
this.buttonCreate = new System.Windows.Forms.Button();
|
||||
this.comboBoxCruiser = new System.Windows.Forms.ComboBox();
|
||||
this.ButtonStep = new System.Windows.Forms.Button();
|
||||
this.ButtonSelected = new System.Windows.Forms.Button();
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBoxCruiser)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// pictureBoxCruiser
|
||||
//
|
||||
this.pictureBoxCruiser.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.pictureBoxCruiser.Location = new System.Drawing.Point(0, 0);
|
||||
this.pictureBoxCruiser.Name = "pictureBoxCruiser";
|
||||
this.pictureBoxCruiser.Size = new System.Drawing.Size(667, 358);
|
||||
this.pictureBoxCruiser.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize;
|
||||
this.pictureBoxCruiser.TabIndex = 0;
|
||||
this.pictureBoxCruiser.TabStop = false;
|
||||
this.pictureBoxCruiser.Click += new System.EventHandler(this.ButtonMove_Click);
|
||||
//
|
||||
// ButtonDown
|
||||
//
|
||||
this.ButtonDown.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.ButtonDown.BackgroundImage = global::Cruiser.Properties.Resources.вниз;
|
||||
this.ButtonDown.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
|
||||
this.ButtonDown.Location = new System.Drawing.Point(543, 306);
|
||||
this.ButtonDown.Name = "ButtonDown";
|
||||
this.ButtonDown.Size = new System.Drawing.Size(30, 30);
|
||||
this.ButtonDown.TabIndex = 1;
|
||||
this.ButtonDown.UseVisualStyleBackColor = true;
|
||||
this.ButtonDown.Click += new System.EventHandler(this.ButtonMove_Click);
|
||||
//
|
||||
// ButtonLeft
|
||||
//
|
||||
this.ButtonLeft.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.ButtonLeft.BackgroundImage = global::Cruiser.Properties.Resources.влево;
|
||||
this.ButtonLeft.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
|
||||
this.ButtonLeft.Location = new System.Drawing.Point(517, 306);
|
||||
this.ButtonLeft.Name = "ButtonLeft";
|
||||
this.ButtonLeft.Size = new System.Drawing.Size(30, 30);
|
||||
this.ButtonLeft.TabIndex = 2;
|
||||
this.ButtonLeft.UseVisualStyleBackColor = true;
|
||||
this.ButtonLeft.Click += new System.EventHandler(this.ButtonMove_Click);
|
||||
//
|
||||
// ButtonRight
|
||||
//
|
||||
this.ButtonRight.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.ButtonRight.BackgroundImage = global::Cruiser.Properties.Resources.вправо;
|
||||
this.ButtonRight.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
|
||||
this.ButtonRight.Location = new System.Drawing.Point(567, 306);
|
||||
this.ButtonRight.Name = "ButtonRight";
|
||||
this.ButtonRight.Size = new System.Drawing.Size(30, 30);
|
||||
this.ButtonRight.TabIndex = 3;
|
||||
this.ButtonRight.UseVisualStyleBackColor = true;
|
||||
this.ButtonRight.Click += new System.EventHandler(this.ButtonMove_Click);
|
||||
//
|
||||
// ButtonUp
|
||||
//
|
||||
this.ButtonUp.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.ButtonUp.BackgroundImage = global::Cruiser.Properties.Resources.вверх;
|
||||
this.ButtonUp.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
|
||||
this.ButtonUp.Location = new System.Drawing.Point(543, 284);
|
||||
this.ButtonUp.Name = "ButtonUp";
|
||||
this.ButtonUp.Size = new System.Drawing.Size(30, 30);
|
||||
this.ButtonUp.TabIndex = 4;
|
||||
this.ButtonUp.UseVisualStyleBackColor = true;
|
||||
this.ButtonUp.Click += new System.EventHandler(this.ButtonMove_Click);
|
||||
//
|
||||
// buttonAdvancedCreate
|
||||
//
|
||||
this.buttonAdvancedCreate.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
|
||||
this.buttonAdvancedCreate.Location = new System.Drawing.Point(12, 267);
|
||||
this.buttonAdvancedCreate.Name = "buttonAdvancedCreate";
|
||||
this.buttonAdvancedCreate.Size = new System.Drawing.Size(210, 69);
|
||||
this.buttonAdvancedCreate.TabIndex = 5;
|
||||
this.buttonAdvancedCreate.Text = "Создать продвинутую версию";
|
||||
this.buttonAdvancedCreate.UseVisualStyleBackColor = true;
|
||||
this.buttonAdvancedCreate.Click += new System.EventHandler(this.ButtonAdvancedCreate_Click);
|
||||
//
|
||||
// buttonCreate
|
||||
//
|
||||
this.buttonCreate.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
|
||||
this.buttonCreate.Location = new System.Drawing.Point(240, 267);
|
||||
this.buttonCreate.Name = "buttonCreate";
|
||||
this.buttonCreate.Size = new System.Drawing.Size(242, 69);
|
||||
this.buttonCreate.TabIndex = 6;
|
||||
this.buttonCreate.Text = "Создать простую версию";
|
||||
this.buttonCreate.UseVisualStyleBackColor = true;
|
||||
this.buttonCreate.Click += new System.EventHandler(this.ButtonCreate_Click);
|
||||
//
|
||||
// comboBoxCruiser
|
||||
//
|
||||
this.comboBoxCruiser.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.comboBoxCruiser.FormattingEnabled = true;
|
||||
this.comboBoxCruiser.Items.AddRange(new object[] {
|
||||
"Центр",
|
||||
"Угол"});
|
||||
this.comboBoxCruiser.Location = new System.Drawing.Point(415, 22);
|
||||
this.comboBoxCruiser.Name = "comboBoxCruiser";
|
||||
this.comboBoxCruiser.Size = new System.Drawing.Size(182, 33);
|
||||
this.comboBoxCruiser.TabIndex = 7;
|
||||
//
|
||||
// ButtonStep
|
||||
//
|
||||
this.ButtonStep.Location = new System.Drawing.Point(485, 70);
|
||||
this.ButtonStep.Name = "ButtonStep";
|
||||
this.ButtonStep.Size = new System.Drawing.Size(112, 34);
|
||||
this.ButtonStep.TabIndex = 8;
|
||||
this.ButtonStep.Text = "Шаг";
|
||||
this.ButtonStep.UseVisualStyleBackColor = true;
|
||||
this.ButtonStep.Click += new System.EventHandler(this.ButtonStep_Click);
|
||||
//
|
||||
// ButtonSelected
|
||||
//
|
||||
this.ButtonSelected.Location = new System.Drawing.Point(180, 215);
|
||||
this.ButtonSelected.Name = "ButtonSelected";
|
||||
this.ButtonSelected.Size = new System.Drawing.Size(105, 34);
|
||||
this.ButtonSelected.TabIndex = 9;
|
||||
this.ButtonSelected.Text = "Выбрать";
|
||||
this.ButtonSelected.UseVisualStyleBackColor = true;
|
||||
this.ButtonSelected.Click += new System.EventHandler(this.ButtonSelectedCruiser_Click);
|
||||
//
|
||||
// CruiserForm
|
||||
//
|
||||
this.ClientSize = new System.Drawing.Size(667, 358);
|
||||
this.Controls.Add(this.ButtonSelected);
|
||||
this.Controls.Add(this.ButtonStep);
|
||||
this.Controls.Add(this.comboBoxCruiser);
|
||||
this.Controls.Add(this.buttonCreate);
|
||||
this.Controls.Add(this.buttonAdvancedCreate);
|
||||
this.Controls.Add(this.ButtonUp);
|
||||
this.Controls.Add(this.ButtonRight);
|
||||
this.Controls.Add(this.ButtonLeft);
|
||||
this.Controls.Add(this.ButtonDown);
|
||||
this.Controls.Add(this.pictureBoxCruiser);
|
||||
this.Name = "CruiserForm";
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBoxCruiser)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
private PictureBox pictureBoxCruiser;
|
||||
private Button ButtonDown;
|
||||
private Button ButtonLeft;
|
||||
private Button ButtonRight;
|
||||
private Button ButtonUp;
|
||||
private Button buttonAdvancedCreate;
|
||||
private Button buttonCreate;
|
||||
private ComboBox comboBoxCruiser;
|
||||
private Button ButtonStep;
|
||||
private Button ButtonSelected;
|
||||
}
|
||||
}
|
135
Cruiser/Cruiser/CruiserForm.cs
Normal file
135
Cruiser/Cruiser/CruiserForm.cs
Normal file
@ -0,0 +1,135 @@
|
||||
using System.Windows.Forms;
|
||||
using Cruiser.DrawningObjects;
|
||||
using Cruiser.MovementStrategy;
|
||||
|
||||
namespace Cruiser
|
||||
{
|
||||
public partial class CruiserForm : Form
|
||||
{
|
||||
private DrawningCruiser? _drawningCruiser;
|
||||
|
||||
private AbstractStrategy? _abstractStrategy;
|
||||
public DrawningCruiser? SelectedCruiser { get; private set; }
|
||||
public CruiserForm()
|
||||
{
|
||||
InitializeComponent();
|
||||
_abstractStrategy = null;
|
||||
SelectedCruiser = null;
|
||||
}
|
||||
private void Draw()
|
||||
{
|
||||
if (_drawningCruiser == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Bitmap bmp = new Bitmap(pictureBoxCruiser.Width, pictureBoxCruiser.Height);
|
||||
Graphics gr = Graphics.FromImage(bmp);
|
||||
_drawningCruiser.DrawTransport(gr);
|
||||
pictureBoxCruiser.Image = bmp;
|
||||
}
|
||||
private void ButtonMove_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (_drawningCruiser == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
string name = ((Button)sender)?.Name ?? string.Empty;
|
||||
switch (name)
|
||||
{
|
||||
case "buttonUp":
|
||||
_drawningCruiser.MoveTransport(Direction.Up);
|
||||
break;
|
||||
case "buttonDown":
|
||||
_drawningCruiser.MoveTransport(Direction.Down);
|
||||
break;
|
||||
case "buttonLeft":
|
||||
_drawningCruiser.MoveTransport(Direction.Left);
|
||||
break;
|
||||
case "buttonRight":
|
||||
_drawningCruiser.MoveTransport(Direction.Right);
|
||||
break;
|
||||
}
|
||||
Draw();
|
||||
}
|
||||
private void ButtonCreate_Click(object sender, EventArgs e)
|
||||
{
|
||||
Random random = new();
|
||||
Color color = Color.FromArgb(random.Next(0, 256),
|
||||
random.Next(0, 256), random.Next(0, 256));
|
||||
ColorDialog dialogColor = new();
|
||||
if (dialogColor.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
color = dialogColor.Color;
|
||||
}
|
||||
_drawningCruiser = new DrawningCruiser(random.Next(100, 300), random.Next(1000, 3000),
|
||||
color, pictureBoxCruiser.Width, pictureBoxCruiser.Height);
|
||||
_drawningCruiser.SetPosition(random.Next(10, 100), random.Next(10, 100));
|
||||
Draw();
|
||||
}
|
||||
private void ButtonStep_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (_drawningCruiser == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (comboBoxCruiser.Enabled)
|
||||
{
|
||||
_abstractStrategy = comboBoxCruiser.SelectedIndex
|
||||
switch
|
||||
{
|
||||
0 => new MoveToCenter(),
|
||||
1 => new MoveToBorder(),
|
||||
_ => null,
|
||||
};
|
||||
if (_abstractStrategy == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_abstractStrategy.SetData(new DrawningObjectCruiser(_drawningCruiser), pictureBoxCruiser.Width,
|
||||
pictureBoxCruiser.Height);
|
||||
}
|
||||
if (_abstractStrategy == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_abstractStrategy.MakeStep();
|
||||
Draw();
|
||||
if (_abstractStrategy.GetStatus() == Status.Finish)
|
||||
{
|
||||
comboBoxCruiser.Enabled = true;
|
||||
_abstractStrategy = null;
|
||||
}
|
||||
}
|
||||
private void ButtonAdvancedCreate_Click(object sender, EventArgs e)
|
||||
{
|
||||
Random random = new();
|
||||
Color color = Color.FromArgb(random.Next(0, 256),
|
||||
random.Next(0, 256), random.Next(0, 256));
|
||||
ColorDialog dialogColor = new();
|
||||
if (dialogColor.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
color = dialogColor.Color;
|
||||
}
|
||||
|
||||
Color dopColor = Color.FromArgb(random.Next(0, 256),
|
||||
random.Next(0, 256), random.Next(0, 256));
|
||||
ColorDialog dialogDopColor = new();
|
||||
if (dialogDopColor.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
dopColor = dialogDopColor.Color;
|
||||
}
|
||||
|
||||
_drawningCruiser = new DrawningAdvancedCruiser(random.Next(100, 300),
|
||||
random.Next(1000, 3000), color, dopColor, Convert.ToBoolean(random.Next(0, 2)),
|
||||
Convert.ToBoolean(random.Next(0, 2)),
|
||||
pictureBoxCruiser.Width, pictureBoxCruiser.Height);
|
||||
_drawningCruiser.SetPosition(random.Next(10, 100), random.Next(10, 100));
|
||||
Draw();
|
||||
}
|
||||
private void ButtonSelectedCruiser_Click(object sender, EventArgs e)
|
||||
{
|
||||
SelectedCruiser = _drawningCruiser;
|
||||
DialogResult = DialogResult.OK;
|
||||
}
|
||||
}
|
||||
}
|
60
Cruiser/Cruiser/CruiserForm.resx
Normal file
60
Cruiser/Cruiser/CruiserForm.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>
|
93
Cruiser/Cruiser/CruiserGenericCollection.cs
Normal file
93
Cruiser/Cruiser/CruiserGenericCollection.cs
Normal file
@ -0,0 +1,93 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Cruiser.Generics;
|
||||
using Cruiser.DrawningObjects;
|
||||
using Cruiser.Entities;
|
||||
using Cruiser.MovementStrategy;
|
||||
|
||||
namespace Cruiser.Generics
|
||||
{
|
||||
internal class CruiserGenericCollection<T, U>
|
||||
where T : DrawningCruiser
|
||||
where U : IMoveableObject
|
||||
{
|
||||
private readonly int _pictureWidth;
|
||||
private readonly int _pictureHeight;
|
||||
private readonly int _placeSizeWidth = 210;
|
||||
private readonly int _placeSizeHeight = 90;
|
||||
private readonly SetGeneric<T> _collection;
|
||||
public CruiserGenericCollection(int picWidth, int picHeight)
|
||||
{
|
||||
int width = picWidth / _placeSizeWidth;
|
||||
int height = picHeight / _placeSizeHeight;
|
||||
_pictureWidth = picWidth;
|
||||
_pictureHeight = picHeight;
|
||||
_collection = new SetGeneric<T>(width * height);
|
||||
}
|
||||
public static bool operator +(CruiserGenericCollection<T, U> collect, T? obj)
|
||||
{
|
||||
if (obj == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return collect?._collection.Insert(obj) ?? false;
|
||||
}
|
||||
public static T? operator -(CruiserGenericCollection<T, U> collect, int pos)
|
||||
{
|
||||
T? obj = collect._collection[pos];
|
||||
if (obj != null)
|
||||
{
|
||||
collect._collection.Remove(pos);
|
||||
}
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
public U? GetU(int pos)
|
||||
{
|
||||
return (U?)_collection[pos]?.GetMoveableObject;
|
||||
}
|
||||
public Bitmap ShowCruisers()
|
||||
{
|
||||
Bitmap bmp = new(_pictureWidth, _pictureHeight);
|
||||
Graphics gr = Graphics.FromImage(bmp);
|
||||
DrawBackground(gr);
|
||||
DrawObjects(gr);
|
||||
return bmp;
|
||||
}
|
||||
private void DrawBackground(Graphics g)
|
||||
{
|
||||
Pen pen = new(Color.Black, 3);
|
||||
for (int i = 0; i < _pictureWidth / _placeSizeWidth; i++)
|
||||
{
|
||||
for (int j = 0; j < _pictureHeight / _placeSizeHeight +
|
||||
1; ++j)
|
||||
{
|
||||
g.DrawLine(pen, i * _placeSizeWidth, j *
|
||||
_placeSizeHeight, i * _placeSizeWidth + _placeSizeWidth / 2, j *
|
||||
_placeSizeHeight);
|
||||
}
|
||||
g.DrawLine(pen, i * _placeSizeWidth, 0, i *
|
||||
_placeSizeWidth, _pictureHeight / _placeSizeHeight * _placeSizeHeight);
|
||||
}
|
||||
}
|
||||
private void DrawObjects(Graphics g)
|
||||
{
|
||||
int i = 0;
|
||||
foreach (var cruiser in _collection.GetCruiser())
|
||||
{
|
||||
if (cruiser != null)
|
||||
{
|
||||
int inRow = _pictureWidth / _placeSizeWidth;
|
||||
cruiser.SetPosition((i % inRow) * _placeSizeWidth + _placeSizeWidth / 20, _placeSizeHeight * (i / inRow) + _placeSizeHeight / 10);
|
||||
cruiser.DrawTransport(g);
|
||||
}
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
50
Cruiser/Cruiser/CruiserGenericStorage.cs
Normal file
50
Cruiser/Cruiser/CruiserGenericStorage.cs
Normal file
@ -0,0 +1,50 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Cruiser.DrawningObjects;
|
||||
using Cruiser.MovementStrategy;
|
||||
|
||||
namespace Cruiser.Generics
|
||||
{
|
||||
internal class CruiserGenericStorage
|
||||
{
|
||||
readonly Dictionary<string, CruiserGenericCollection<DrawningCruiser,
|
||||
DrawningObjectCruiser>> _cruiserStorages;
|
||||
public List<string> Keys => _cruiserStorages.Keys.ToList();
|
||||
private readonly int _pictureWidth;
|
||||
private readonly int _pictureHeight;
|
||||
public CruiserGenericStorage(int pictureWidth, int pictureHeight)
|
||||
{
|
||||
_cruiserStorages = new Dictionary<string, CruiserGenericCollection<DrawningCruiser, DrawningObjectCruiser>>();
|
||||
_pictureWidth = pictureWidth;
|
||||
_pictureHeight = pictureHeight;
|
||||
}
|
||||
public void AddSet(string name)
|
||||
{
|
||||
_cruiserStorages.Add(name, new CruiserGenericCollection<DrawningCruiser, DrawningObjectCruiser>(_pictureWidth, _pictureHeight));
|
||||
}
|
||||
public void DelSet(string name)
|
||||
{
|
||||
if (!_cruiserStorages.ContainsKey(name))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_cruiserStorages.Remove(name);
|
||||
}
|
||||
public CruiserGenericCollection<DrawningCruiser, DrawningObjectCruiser>? this[string ind]
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_cruiserStorages.ContainsKey(ind))
|
||||
{
|
||||
return _cruiserStorages[ind];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
16
Cruiser/Cruiser/Direction.cs
Normal file
16
Cruiser/Cruiser/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 Cruiser
|
||||
{
|
||||
public enum Direction
|
||||
{
|
||||
Up = 1,
|
||||
Down = 2,
|
||||
Left = 3,
|
||||
Right = 4
|
||||
}
|
||||
}
|
47
Cruiser/Cruiser/DrawningAdvancedCruiser.cs
Normal file
47
Cruiser/Cruiser/DrawningAdvancedCruiser.cs
Normal file
@ -0,0 +1,47 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Net.NetworkInformation;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using Cruiser.Entities;
|
||||
|
||||
namespace Cruiser.DrawningObjects
|
||||
{
|
||||
public class DrawningAdvancedCruiser : DrawningCruiser
|
||||
{
|
||||
public DrawningAdvancedCruiser(int speed, double weight, Color bodyColor, Color additionalColor, bool helicopterPad, bool coating, int width, int height) : base(speed, weight, bodyColor, width, height, 110, 60)
|
||||
{
|
||||
if (EntityCruiser != null)
|
||||
{
|
||||
EntityCruiser = new EntityAdvancedCruiser(speed, weight, bodyColor, additionalColor, helicopterPad, coating);
|
||||
}
|
||||
}
|
||||
public override void DrawTransport(Graphics g)
|
||||
{
|
||||
if (EntityCruiser is not EntityAdvancedCruiser cruiser)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Pen pen = new Pen(Color.Black);
|
||||
Brush addBrush = new SolidBrush(cruiser.AdditionalColor);
|
||||
Brush brush = new SolidBrush(cruiser.BodyColor);
|
||||
base.DrawTransport(g);
|
||||
if (cruiser.HelicopterPad)
|
||||
{
|
||||
Brush brYellow = new SolidBrush(Color.Yellow);
|
||||
g.FillEllipse(brYellow, _startPosX + 80, _startPosY + 5, 20,
|
||||
20);
|
||||
g.FillEllipse(brYellow, _startPosX + 80, _startPosY + 35, 20,
|
||||
20);
|
||||
}
|
||||
if (cruiser.Coating)
|
||||
{
|
||||
g.FillEllipse(Brushes.Green, _startPosX + 90, _startPosY + 20, 20, 20);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
129
Cruiser/Cruiser/DrawningCruiser.cs
Normal file
129
Cruiser/Cruiser/DrawningCruiser.cs
Normal file
@ -0,0 +1,129 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Cruiser.Entities;
|
||||
using Cruiser.MovementStrategy;
|
||||
|
||||
namespace Cruiser.DrawningObjects
|
||||
{
|
||||
public class DrawningCruiser
|
||||
{
|
||||
public EntityCruiser? EntityCruiser { get; protected set; }
|
||||
private int _pictureWidth;
|
||||
private int _pictureHeight;
|
||||
protected int _startPosX;
|
||||
protected int _startPosY;
|
||||
private readonly int _cruiserWidth = 110;
|
||||
private readonly int _cruiserHeight = 60;
|
||||
public int GetPosX => _startPosX;
|
||||
public int GetPosY => _startPosY;
|
||||
public int GetWidth => _cruiserWidth;
|
||||
public int GetHeight => _cruiserHeight;
|
||||
public IMoveableObject GetMoveableObject => new DrawningObjectCruiser(this);
|
||||
public DrawningCruiser(int speed, double weight, Color bodyColor, int width, int height)
|
||||
{
|
||||
if (width < _cruiserWidth || height < _cruiserHeight)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_pictureWidth = width;
|
||||
_pictureHeight = height;
|
||||
EntityCruiser = new EntityCruiser(speed, weight, bodyColor);
|
||||
}
|
||||
protected DrawningCruiser(int speed, double weight, Color bodyColor, int
|
||||
width, int height, int cruiserWidth, int cruiserHeight)
|
||||
{
|
||||
if (width <= _cruiserWidth || height <= _cruiserHeight)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_pictureWidth = width;
|
||||
_pictureHeight = height;
|
||||
_cruiserWidth = cruiserWidth;
|
||||
_cruiserHeight = cruiserHeight;
|
||||
EntityCruiser = new EntityCruiser(speed, weight, bodyColor);
|
||||
}
|
||||
public void SetPosition(int x, int y)
|
||||
{
|
||||
if (x < 0 || x + _cruiserWidth > _pictureWidth)
|
||||
{
|
||||
x = Math.Max(0, _pictureWidth - _cruiserWidth);
|
||||
}
|
||||
if (y < 0 || y + _cruiserHeight > _pictureHeight)
|
||||
{
|
||||
y = Math.Max(0, _pictureHeight - _cruiserHeight);
|
||||
}
|
||||
_startPosX = x;
|
||||
_startPosY = y;
|
||||
}
|
||||
public void MoveTransport(Direction direction)
|
||||
{
|
||||
if (!CanMove(direction) || EntityCruiser == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
switch (direction)
|
||||
{
|
||||
case Direction.Left:
|
||||
_startPosX -= (int)EntityCruiser.Step;
|
||||
break;
|
||||
case Direction.Up:
|
||||
_startPosY -= (int)EntityCruiser.Step;
|
||||
break;
|
||||
case Direction.Right:
|
||||
_startPosX += (int)EntityCruiser.Step;
|
||||
break;
|
||||
case Direction.Down:
|
||||
_startPosY += (int)EntityCruiser.Step;
|
||||
break;
|
||||
}
|
||||
}
|
||||
public bool CanMove(Direction direction)
|
||||
{
|
||||
if (EntityCruiser == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return direction switch
|
||||
{
|
||||
Direction.Left => _startPosX - EntityCruiser.Step > 0,
|
||||
Direction.Up => _startPosY - EntityCruiser.Step > 0,
|
||||
Direction.Right => _startPosX + EntityCruiser.Step + _cruiserWidth < _pictureWidth,
|
||||
Direction.Down => _startPosY + EntityCruiser.Step + _cruiserHeight < _pictureHeight,
|
||||
_ => false,
|
||||
};
|
||||
}
|
||||
public virtual void DrawTransport(Graphics g)
|
||||
{
|
||||
if (EntityCruiser == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Pen pen = new Pen(Color.Black);
|
||||
Brush brush = new SolidBrush(EntityCruiser.BodyColor);
|
||||
g.DrawEllipse(pen, _startPosX + 15, _startPosY + 5, 20, 20);
|
||||
g.DrawEllipse(pen, _startPosX + 15, _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 br = new SolidBrush(EntityCruiser.BodyColor);
|
||||
g.FillRectangle(br, _startPosX + 10, _startPosY + 15, 10, 30);
|
||||
g.FillRectangle(br, _startPosX + 90, _startPosY + 15, 10, 30);
|
||||
g.FillRectangle(br, _startPosX + 20, _startPosY + 5, 70, 50);
|
||||
Point[] points = new Point[3];//
|
||||
points[0] = new Point(_startPosX + 100, _startPosY + 5);
|
||||
points[1] = new Point(_startPosX + 100, _startPosY + 55);
|
||||
points[2] = new Point(_startPosX + 100 + 50, _startPosY + 50 / 2);
|
||||
g.FillPolygon(Brushes.Pink, points);
|
||||
g.FillRectangle(Brushes.Black, _startPosX + 5, _startPosY + 15, 10, 10);
|
||||
g.FillRectangle(Brushes.Black, _startPosX + 5, _startPosY + 35, 10, 10);
|
||||
g.DrawRectangle(Pens.Black, _startPosX + 35,
|
||||
_startPosY + 23, 15, 15);
|
||||
g.DrawRectangle(Pens.Black, _startPosX + 50,
|
||||
_startPosY + 19, 30, 25);
|
||||
}
|
||||
}
|
||||
}
|
35
Cruiser/Cruiser/DrawningObjectCruiser.cs
Normal file
35
Cruiser/Cruiser/DrawningObjectCruiser.cs
Normal file
@ -0,0 +1,35 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Cruiser.DrawningObjects;
|
||||
namespace Cruiser.MovementStrategy
|
||||
{
|
||||
internal class DrawningObjectCruiser : IMoveableObject
|
||||
{
|
||||
private readonly DrawningCruiser? _drawningCruiser = null;
|
||||
public DrawningObjectCruiser(DrawningCruiser drawningCruiser)
|
||||
{
|
||||
_drawningCruiser = drawningCruiser;
|
||||
}
|
||||
public ObjectParameters? GetObjectPosition
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_drawningCruiser == null || _drawningCruiser.EntityCruiser ==
|
||||
null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new ObjectParameters(_drawningCruiser.GetPosX,
|
||||
_drawningCruiser.GetPosY, _drawningCruiser.GetWidth, _drawningCruiser.GetHeight);
|
||||
}
|
||||
}
|
||||
public int GetStep => (int)(_drawningCruiser?.EntityCruiser?.Step ?? 0);
|
||||
public bool CheckCanMove(Direction direction) =>
|
||||
_drawningCruiser?.CanMove(direction) ?? false;
|
||||
public void MoveObject(Direction direction) =>
|
||||
_drawningCruiser?.MoveTransport(direction);
|
||||
}
|
||||
}
|
25
Cruiser/Cruiser/EntityAdvancedCruiser.cs
Normal file
25
Cruiser/Cruiser/EntityAdvancedCruiser.cs
Normal file
@ -0,0 +1,25 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Net.NetworkInformation;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Cruiser.Entities
|
||||
{
|
||||
public class EntityAdvancedCruiser : EntityCruiser
|
||||
{
|
||||
public Color AdditionalColor { get; private set; }
|
||||
public bool HelicopterPad { get; private set; }
|
||||
public bool Coating { get; private set; }
|
||||
public EntityAdvancedCruiser(int speed, double weight, Color bodyColor, Color
|
||||
additionalColor, bool helicopterPad, bool coating) : base(speed, weight, bodyColor)
|
||||
{
|
||||
AdditionalColor = additionalColor;
|
||||
HelicopterPad = helicopterPad;
|
||||
Coating = coating;
|
||||
}
|
||||
}
|
||||
}
|
23
Cruiser/Cruiser/EntityCruiser.cs
Normal file
23
Cruiser/Cruiser/EntityCruiser.cs
Normal file
@ -0,0 +1,23 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Cruiser.Entities
|
||||
{
|
||||
public class EntityCruiser
|
||||
{
|
||||
public int Speed { get; private set; }
|
||||
public double Weight { get; private set; }
|
||||
public Color BodyColor { get; private set; }
|
||||
public double Step => (double)Speed * 100 / Weight;
|
||||
public EntityCruiser(int speed, double weight, Color bodyColor)
|
||||
{
|
||||
Speed = speed;
|
||||
Weight = weight;
|
||||
BodyColor = bodyColor;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
173
Cruiser/Cruiser/FormCruiserCollection.Designer.cs
generated
Normal file
173
Cruiser/Cruiser/FormCruiserCollection.Designer.cs
generated
Normal file
@ -0,0 +1,173 @@
|
||||
namespace Cruiser
|
||||
{
|
||||
partial class FormCruiserCollection
|
||||
{
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.pictureBoxCruiser = new System.Windows.Forms.PictureBox();
|
||||
this.panelCruiser = new System.Windows.Forms.Panel();
|
||||
this.panelSet = new System.Windows.Forms.Panel();
|
||||
this.textBoxSet = new System.Windows.Forms.TextBox();
|
||||
this.ButtonAddObject = new System.Windows.Forms.Button();
|
||||
this.listBoxStorages = new System.Windows.Forms.ListBox();
|
||||
this.ButtonDelObject = new System.Windows.Forms.Button();
|
||||
this.ButtonAddCruiser = new System.Windows.Forms.Button();
|
||||
this.textBoxCruiser = new System.Windows.Forms.TextBox();
|
||||
this.ButtonRemoveCruiser = new System.Windows.Forms.Button();
|
||||
this.ButtonRefreshCollection = new System.Windows.Forms.Button();
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBoxCruiser)).BeginInit();
|
||||
this.panelCruiser.SuspendLayout();
|
||||
this.panelSet.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// pictureBoxCruiser
|
||||
//
|
||||
this.pictureBoxCruiser.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.pictureBoxCruiser.Location = new System.Drawing.Point(0, 0);
|
||||
this.pictureBoxCruiser.Name = "pictureBoxCruiser";
|
||||
this.pictureBoxCruiser.Size = new System.Drawing.Size(904, 510);
|
||||
this.pictureBoxCruiser.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize;
|
||||
this.pictureBoxCruiser.TabIndex = 0;
|
||||
this.pictureBoxCruiser.TabStop = false;
|
||||
//
|
||||
// panelCruiser
|
||||
//
|
||||
this.panelCruiser.Controls.Add(this.ButtonRefreshCollection);
|
||||
this.panelCruiser.Controls.Add(this.ButtonRemoveCruiser);
|
||||
this.panelCruiser.Controls.Add(this.textBoxCruiser);
|
||||
this.panelCruiser.Controls.Add(this.ButtonAddCruiser);
|
||||
this.panelCruiser.Controls.Add(this.panelSet);
|
||||
this.panelCruiser.Location = new System.Drawing.Point(655, 12);
|
||||
this.panelCruiser.Name = "panelCruiser";
|
||||
this.panelCruiser.Size = new System.Drawing.Size(221, 486);
|
||||
this.panelCruiser.TabIndex = 1;
|
||||
//
|
||||
// panelSet
|
||||
//
|
||||
this.panelSet.Controls.Add(this.ButtonDelObject);
|
||||
this.panelSet.Controls.Add(this.listBoxStorages);
|
||||
this.panelSet.Controls.Add(this.ButtonAddObject);
|
||||
this.panelSet.Controls.Add(this.textBoxSet);
|
||||
this.panelSet.Location = new System.Drawing.Point(22, 19);
|
||||
this.panelSet.Name = "panelSet";
|
||||
this.panelSet.Size = new System.Drawing.Size(185, 241);
|
||||
this.panelSet.TabIndex = 0;
|
||||
//
|
||||
// textBoxSet
|
||||
//
|
||||
this.textBoxSet.Location = new System.Drawing.Point(38, 21);
|
||||
this.textBoxSet.Name = "textBoxSet";
|
||||
this.textBoxSet.Size = new System.Drawing.Size(118, 31);
|
||||
this.textBoxSet.TabIndex = 0;
|
||||
//
|
||||
// ButtonAddObject
|
||||
//
|
||||
this.ButtonAddObject.Location = new System.Drawing.Point(18, 58);
|
||||
this.ButtonAddObject.Name = "ButtonAddObject";
|
||||
this.ButtonAddObject.Size = new System.Drawing.Size(153, 51);
|
||||
this.ButtonAddObject.TabIndex = 2;
|
||||
this.ButtonAddObject.Text = "Создать набор";
|
||||
this.ButtonAddObject.UseVisualStyleBackColor = true;
|
||||
this.ButtonAddObject.Click += new System.EventHandler(this.ButtonAddObject_Click);
|
||||
//
|
||||
// listBoxStorages
|
||||
//
|
||||
this.listBoxStorages.FormattingEnabled = true;
|
||||
this.listBoxStorages.ItemHeight = 25;
|
||||
this.listBoxStorages.Location = new System.Drawing.Point(49, 115);
|
||||
this.listBoxStorages.Name = "listBoxStorages";
|
||||
this.listBoxStorages.Size = new System.Drawing.Size(97, 54);
|
||||
this.listBoxStorages.TabIndex = 3;
|
||||
this.listBoxStorages.SelectedIndexChanged += new System.EventHandler(this.listBoxObjects_SelectedIndexChanged);
|
||||
//
|
||||
// ButtonDelObject
|
||||
//
|
||||
this.ButtonDelObject.Location = new System.Drawing.Point(18, 175);
|
||||
this.ButtonDelObject.Name = "ButtonDelObject";
|
||||
this.ButtonDelObject.Size = new System.Drawing.Size(153, 47);
|
||||
this.ButtonDelObject.TabIndex = 2;
|
||||
this.ButtonDelObject.Text = "Удалить набор";
|
||||
this.ButtonDelObject.UseVisualStyleBackColor = true;
|
||||
this.ButtonDelObject.Click += new System.EventHandler(this.ButtonDelObject_Click);
|
||||
//
|
||||
// ButtonAddCruiser
|
||||
//
|
||||
this.ButtonAddCruiser.Location = new System.Drawing.Point(45, 266);
|
||||
this.ButtonAddCruiser.Name = "ButtonAddCruiser";
|
||||
this.ButtonAddCruiser.Size = new System.Drawing.Size(133, 38);
|
||||
this.ButtonAddCruiser.TabIndex = 2;
|
||||
this.ButtonAddCruiser.Text = "Добавить";
|
||||
this.ButtonAddCruiser.UseVisualStyleBackColor = true;
|
||||
this.ButtonAddCruiser.Click += new System.EventHandler(this.ButtonAddCruiser_Click);
|
||||
//
|
||||
// textBoxCruiser
|
||||
//
|
||||
this.textBoxCruiser.Location = new System.Drawing.Point(45, 330);
|
||||
this.textBoxCruiser.Name = "textBoxCruiser";
|
||||
this.textBoxCruiser.Size = new System.Drawing.Size(133, 31);
|
||||
this.textBoxCruiser.TabIndex = 3;
|
||||
//
|
||||
// ButtonRemoveCruiser
|
||||
//
|
||||
this.ButtonRemoveCruiser.Location = new System.Drawing.Point(45, 391);
|
||||
this.ButtonRemoveCruiser.Name = "ButtonRemoveCruiser";
|
||||
this.ButtonRemoveCruiser.Size = new System.Drawing.Size(138, 38);
|
||||
this.ButtonRemoveCruiser.TabIndex = 2;
|
||||
this.ButtonRemoveCruiser.Text = "Удалить";
|
||||
this.ButtonRemoveCruiser.UseVisualStyleBackColor = true;
|
||||
this.ButtonRemoveCruiser.Click += new System.EventHandler(this.ButtonRemoveCruiser_Click);
|
||||
//
|
||||
// ButtonRefreshCollection
|
||||
//
|
||||
this.ButtonRefreshCollection.Location = new System.Drawing.Point(45, 435);
|
||||
this.ButtonRefreshCollection.Name = "ButtonRefreshCollection";
|
||||
this.ButtonRefreshCollection.Size = new System.Drawing.Size(138, 41);
|
||||
this.ButtonRefreshCollection.TabIndex = 2;
|
||||
this.ButtonRefreshCollection.Text = "Обновить";
|
||||
this.ButtonRefreshCollection.UseVisualStyleBackColor = true;
|
||||
this.ButtonRefreshCollection.Click += new System.EventHandler(this.ButtonRefreshCollection_Click);
|
||||
//
|
||||
// FormCruiserCollection
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(10F, 25F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(904, 510);
|
||||
this.Controls.Add(this.panelCruiser);
|
||||
this.Controls.Add(this.pictureBoxCruiser);
|
||||
this.Name = "FormCruiserCollection";
|
||||
this.Text = "FormCruiserCollection";
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBoxCruiser)).EndInit();
|
||||
this.panelCruiser.ResumeLayout(false);
|
||||
this.panelCruiser.PerformLayout();
|
||||
this.panelSet.ResumeLayout(false);
|
||||
this.panelSet.PerformLayout();
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
#endregion
|
||||
|
||||
private PictureBox pictureBoxCruiser;
|
||||
private Panel panelCruiser;
|
||||
private Panel panelSet;
|
||||
private TextBox textBoxSet;
|
||||
private ListBox listBoxStorages;
|
||||
private Button ButtonAddObject;
|
||||
private Button ButtonDelObject;
|
||||
private Button ButtonAddCruiser;
|
||||
private Button ButtonRemoveCruiser;
|
||||
private TextBox textBoxCruiser;
|
||||
private Button ButtonRefreshCollection;
|
||||
}
|
||||
}
|
139
Cruiser/Cruiser/FormCruiserCollection.cs
Normal file
139
Cruiser/Cruiser/FormCruiserCollection.cs
Normal file
@ -0,0 +1,139 @@
|
||||
using Cruiser.Generics;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Cruiser
|
||||
{
|
||||
public partial class FormCruiserCollection : Form
|
||||
{
|
||||
private readonly CruiserGenericStorage _storage;
|
||||
|
||||
public FormCruiserCollection()
|
||||
{
|
||||
InitializeComponent();
|
||||
_storage = new CruiserGenericStorage(pictureBoxCruiser.Width, pictureBoxCruiser.Height);
|
||||
}
|
||||
private void ReloadObjects()
|
||||
{
|
||||
int index = listBoxStorages.SelectedIndex;
|
||||
|
||||
listBoxStorages.Items.Clear();
|
||||
for (int i = 0; i < _storage.Keys.Count; i++)
|
||||
{
|
||||
listBoxStorages.Items.Add(_storage.Keys[i]);
|
||||
}
|
||||
|
||||
if (listBoxStorages.Items.Count > 0 && (index == -1 || index >= listBoxStorages.Items.Count))
|
||||
{
|
||||
listBoxStorages.SelectedIndex = 0;
|
||||
}
|
||||
|
||||
else if (listBoxStorages.Items.Count > 0 && index > -1 && index < listBoxStorages.Items.Count)
|
||||
{
|
||||
listBoxStorages.SelectedIndex = index;
|
||||
}
|
||||
}
|
||||
private void ButtonAddObject_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (string.IsNullOrEmpty(textBoxSet.Text))
|
||||
{
|
||||
MessageBox.Show("Не все данные заполнены", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
_storage.AddSet(textBoxSet.Text);
|
||||
ReloadObjects();
|
||||
}
|
||||
private void listBoxObjects_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
pictureBoxCruiser.Image = _storage[listBoxStorages.SelectedItem?.ToString() ?? string.Empty]?.ShowCruisers();
|
||||
}
|
||||
private void ButtonDelObject_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (listBoxStorages.SelectedIndex == -1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (MessageBox.Show($"Удалить объект{listBoxStorages.SelectedItem}?", "Удаление", MessageBoxButtons.YesNo,
|
||||
MessageBoxIcon.Question) == DialogResult.Yes)
|
||||
{
|
||||
_storage.DelSet(listBoxStorages.SelectedItem.ToString()
|
||||
?? string.Empty);
|
||||
ReloadObjects();
|
||||
}
|
||||
}
|
||||
private void ButtonAddCruiser_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (listBoxStorages.SelectedIndex == -1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var obj = _storage[listBoxStorages.SelectedItem.ToString() ?? string.Empty];
|
||||
if (obj == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
CruiserForm form = new();
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
if (obj + form.SelectedCruiser)
|
||||
{
|
||||
MessageBox.Show("Объект добавлен");
|
||||
pictureBoxCruiser.Image = obj.ShowCruisers();
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Не удалось добавить объект");
|
||||
}
|
||||
}
|
||||
}
|
||||
private void ButtonRemoveCruiser_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (listBoxStorages.SelectedIndex == -1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var obj = _storage[listBoxStorages.SelectedItem.ToString() ??
|
||||
string.Empty];
|
||||
if (obj == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (MessageBox.Show("Удалить объект?", "Удаление",
|
||||
MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
|
||||
{
|
||||
return;
|
||||
}
|
||||
int pos = Convert.ToInt32(textBoxCruiser.Text);
|
||||
if (obj - pos != null)
|
||||
{
|
||||
MessageBox.Show("Объект удален");
|
||||
pictureBoxCruiser.Image = obj.ShowCruisers();
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Не удалось удалить объект");
|
||||
}
|
||||
}
|
||||
private void ButtonRefreshCollection_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (listBoxStorages.SelectedIndex == -1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var obj = _storage[listBoxStorages.SelectedItem.ToString() ??
|
||||
string.Empty];
|
||||
if (obj == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
pictureBoxCruiser.Image = obj.ShowCruisers();
|
||||
}
|
||||
}
|
||||
}
|
60
Cruiser/Cruiser/FormCruiserCollection.resx
Normal file
60
Cruiser/Cruiser/FormCruiserCollection.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>
|
17
Cruiser/Cruiser/IMoveableObject.cs
Normal file
17
Cruiser/Cruiser/IMoveableObject.cs
Normal file
@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Cruiser.MovementStrategy;
|
||||
|
||||
namespace Cruiser.MovementStrategy
|
||||
{
|
||||
public interface IMoveableObject
|
||||
{
|
||||
ObjectParameters? GetObjectPosition { get; }
|
||||
int GetStep { get; }
|
||||
bool CheckCanMove(Direction direction);
|
||||
void MoveObject(Direction direction);
|
||||
}
|
||||
}
|
57
Cruiser/Cruiser/MoveToBorder.cs
Normal file
57
Cruiser/Cruiser/MoveToBorder.cs
Normal file
@ -0,0 +1,57 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Cruiser.MovementStrategy
|
||||
{
|
||||
internal class MoveToBorder : AbstractStrategy
|
||||
{
|
||||
protected override bool IsTargetDestinaion()
|
||||
{
|
||||
var objParams = GetObjectParameters;
|
||||
if (objParams == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return objParams.RightBorder <= FieldWidth &&
|
||||
objParams.RightBorder + GetStep() >= FieldWidth &&
|
||||
objParams.DownBorder <= FieldHeight &&
|
||||
objParams.DownBorder + GetStep() >= FieldHeight;
|
||||
}
|
||||
protected override void MoveToTarget()
|
||||
{
|
||||
var objParams = GetObjectParameters;
|
||||
if (objParams == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var diffX = objParams.RightBorder - FieldWidth;
|
||||
if (Math.Abs(diffX) > GetStep())
|
||||
{
|
||||
if (diffX > 0)
|
||||
{
|
||||
MoveLeft();
|
||||
}
|
||||
else
|
||||
{
|
||||
MoveRight();
|
||||
}
|
||||
}
|
||||
var diffY = objParams.DownBorder - FieldHeight;
|
||||
if (Math.Abs(diffY) > GetStep())
|
||||
{
|
||||
if (diffY > 0)
|
||||
{
|
||||
MoveUp();
|
||||
}
|
||||
else
|
||||
{
|
||||
MoveDown();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
57
Cruiser/Cruiser/MoveToCenter.cs
Normal file
57
Cruiser/Cruiser/MoveToCenter.cs
Normal file
@ -0,0 +1,57 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Cruiser.MovementStrategy
|
||||
{
|
||||
internal class MoveToCenter : AbstractStrategy
|
||||
{
|
||||
protected override bool IsTargetDestinaion()
|
||||
{
|
||||
var objParams = GetObjectParameters;
|
||||
if (objParams == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return (objParams.ObjectMiddleHorizontal <= FieldWidth / 2 &&
|
||||
objParams.ObjectMiddleHorizontal + GetStep() >= FieldWidth / 2 &&
|
||||
objParams.ObjectMiddleVertical <= FieldHeight / 2 &&
|
||||
objParams.ObjectMiddleVertical + GetStep() >= FieldHeight / 2);
|
||||
|
||||
}
|
||||
protected override void MoveToTarget()
|
||||
{
|
||||
var objParams = GetObjectParameters;
|
||||
if (objParams == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var diffX = objParams.ObjectMiddleHorizontal - FieldWidth / 2;
|
||||
if (Math.Abs(diffX) > GetStep())
|
||||
{
|
||||
if (diffX > 0)
|
||||
{
|
||||
MoveLeft();
|
||||
}
|
||||
else
|
||||
{
|
||||
MoveRight();
|
||||
}
|
||||
}
|
||||
var diffY = objParams.ObjectMiddleVertical - FieldHeight / 2;
|
||||
if (Math.Abs(diffY) > GetStep())
|
||||
{
|
||||
if (diffY > 0)
|
||||
{
|
||||
MoveUp();
|
||||
}
|
||||
else
|
||||
{
|
||||
MoveDown();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
29
Cruiser/Cruiser/ObjectParameters.cs
Normal file
29
Cruiser/Cruiser/ObjectParameters.cs
Normal file
@ -0,0 +1,29 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Cruiser.MovementStrategy
|
||||
{
|
||||
public class ObjectParameters
|
||||
{
|
||||
private readonly int _x;
|
||||
private readonly int _y;
|
||||
private readonly int _width;
|
||||
private readonly int _height;
|
||||
public int LeftBorder => _x;
|
||||
public int TopBorder => _y;
|
||||
public int RightBorder => _x + _width;
|
||||
public int DownBorder => _y + _height;
|
||||
public int ObjectMiddleHorizontal => _x + _width / 2;
|
||||
public int ObjectMiddleVertical => _y + _height / 2;
|
||||
public ObjectParameters(int x, int y, int width, int height)
|
||||
{
|
||||
_x = x;
|
||||
_y = y;
|
||||
_width = width;
|
||||
_height = height;
|
||||
}
|
||||
}
|
||||
}
|
17
Cruiser/Cruiser/Program.cs
Normal file
17
Cruiser/Cruiser/Program.cs
Normal file
@ -0,0 +1,17 @@
|
||||
namespace Cruiser
|
||||
{
|
||||
internal static class Program
|
||||
{
|
||||
/// <summary>
|
||||
/// The main entry point for the application.
|
||||
/// </summary>
|
||||
[STAThread]
|
||||
static void Main()
|
||||
{
|
||||
// To customize application configuration such as set high DPI settings or default font,
|
||||
// see https://aka.ms/applicationconfiguration.
|
||||
ApplicationConfiguration.Initialize();
|
||||
Application.Run(new FormCruiserCollection());
|
||||
}
|
||||
}
|
||||
}
|
103
Cruiser/Cruiser/Properties/Resources.Designer.cs
generated
Normal file
103
Cruiser/Cruiser/Properties/Resources.Designer.cs
generated
Normal file
@ -0,0 +1,103 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// Этот код создан программой.
|
||||
// Исполняемая версия:4.0.30319.42000
|
||||
//
|
||||
// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае
|
||||
// повторной генерации кода.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace Cruiser.Properties {
|
||||
using System;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Класс ресурса со строгой типизацией для поиска локализованных строк и т.д.
|
||||
/// </summary>
|
||||
// Этот класс создан автоматически классом StronglyTypedResourceBuilder
|
||||
// с помощью такого средства, как ResGen или Visual Studio.
|
||||
// Чтобы добавить или удалить член, измените файл .ResX и снова запустите ResGen
|
||||
// с параметром /str или перестройте свой проект VS.
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
internal class Resources {
|
||||
|
||||
private static global::System.Resources.ResourceManager resourceMan;
|
||||
|
||||
private static global::System.Globalization.CultureInfo resourceCulture;
|
||||
|
||||
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
||||
internal Resources() {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Возвращает кэшированный экземпляр ResourceManager, использованный этим классом.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Resources.ResourceManager ResourceManager {
|
||||
get {
|
||||
if (object.ReferenceEquals(resourceMan, null)) {
|
||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Cruiser.Properties.Resources", typeof(Resources).Assembly);
|
||||
resourceMan = temp;
|
||||
}
|
||||
return resourceMan;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Перезаписывает свойство CurrentUICulture текущего потока для всех
|
||||
/// обращений к ресурсу с помощью этого класса ресурса со строгой типизацией.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Globalization.CultureInfo Culture {
|
||||
get {
|
||||
return resourceCulture;
|
||||
}
|
||||
set {
|
||||
resourceCulture = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap вверх {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("вверх", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap влево {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("влево", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap вниз {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("вниз", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap вправо {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("вправо", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
133
Cruiser/Cruiser/Properties/Resources.resx
Normal file
133
Cruiser/Cruiser/Properties/Resources.resx
Normal file
@ -0,0 +1,133 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<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>
|
||||
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
|
||||
<data name="вниз" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\вниз.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="влево" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\влево.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="вверх" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\вверх.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="вправо" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\вправо.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
</root>
|
BIN
Cruiser/Cruiser/Resources/вверх.jpg
Normal file
BIN
Cruiser/Cruiser/Resources/вверх.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.5 KiB |
BIN
Cruiser/Cruiser/Resources/влево.png
Normal file
BIN
Cruiser/Cruiser/Resources/влево.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.4 KiB |
BIN
Cruiser/Cruiser/Resources/вниз.png
Normal file
BIN
Cruiser/Cruiser/Resources/вниз.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 8.6 KiB |
BIN
Cruiser/Cruiser/Resources/вправо.png
Normal file
BIN
Cruiser/Cruiser/Resources/вправо.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.3 KiB |
81
Cruiser/Cruiser/SetGeneric.cs
Normal file
81
Cruiser/Cruiser/SetGeneric.cs
Normal file
@ -0,0 +1,81 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Cruiser.Generics
|
||||
{
|
||||
internal class SetGeneric<T>
|
||||
where T : class
|
||||
{
|
||||
private readonly List<T?> _places;
|
||||
public int Count => _places.Count;
|
||||
private readonly int _maxCount;
|
||||
public SetGeneric(int count)
|
||||
{
|
||||
_maxCount = count;
|
||||
_places = new List<T?>(count);
|
||||
}
|
||||
public bool Insert(T cruiser)
|
||||
{
|
||||
if (_places.Count == _maxCount)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
Insert(cruiser, 0);
|
||||
return true;
|
||||
}
|
||||
public bool Insert(T cruiser, int position)
|
||||
{
|
||||
if (!(position >= 0 && position <= Count && _places.Count < _maxCount))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
_places.Insert(position, cruiser);
|
||||
return true;
|
||||
}
|
||||
public bool Remove(int position)
|
||||
{
|
||||
if (position < 0 || position >= Count)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
_places.RemoveAt(position);
|
||||
return true;
|
||||
}
|
||||
public T? this[int position]
|
||||
{
|
||||
get
|
||||
{
|
||||
if (position < 0 || position >= _maxCount)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return _places[position];
|
||||
}
|
||||
set
|
||||
{
|
||||
if (!(position >= 0 && position < Count && _places.Count < _maxCount))
|
||||
{
|
||||
return;
|
||||
}
|
||||
_places.Insert(position, value);
|
||||
return;
|
||||
}
|
||||
}
|
||||
public IEnumerable<T?> GetCruiser(int? maxCruisers = null)
|
||||
{
|
||||
for (int i = 0; i < _places.Count; ++i)
|
||||
{
|
||||
yield return _places[i];
|
||||
if (maxCruisers.HasValue && i == maxCruisers.Value)
|
||||
{
|
||||
yield break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
15
Cruiser/Cruiser/Status.cs
Normal file
15
Cruiser/Cruiser/Status.cs
Normal file
@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Cruiser.MovementStrategy
|
||||
{
|
||||
public enum Status
|
||||
{
|
||||
NotInit,
|
||||
InProgress,
|
||||
Finish
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user