2022-09-26 22:02:22 +04:00
|
|
|
|
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 Artilleries
|
|
|
|
|
{
|
|
|
|
|
public partial class FormMap : Form
|
|
|
|
|
{
|
|
|
|
|
private AbstractMap _abstractMap;
|
|
|
|
|
|
|
|
|
|
public FormMap()
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
_abstractMap = new SimpleMap();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void SetData(DrawingArtillery artillery)
|
|
|
|
|
{
|
|
|
|
|
Random rnd = new();
|
|
|
|
|
artillery.SetPosition(rnd.Next(10, 100), rnd.Next(10, 100), pictureBoxArtilleries.Width, pictureBoxArtilleries.Height);
|
|
|
|
|
SpeedStatusLabel.Text = $"Скорость: {artillery.Artillery.Speed}";
|
|
|
|
|
WeightStatusLabel.Text = $"Вес: {artillery.Artillery.Weight}";
|
|
|
|
|
ColorStatusLabel.Text = $"Цвет: {artillery.Artillery.BodyColor.Name}";
|
|
|
|
|
pictureBoxArtilleries.Image = _abstractMap.CreateMap(pictureBoxArtilleries.Width, pictureBoxArtilleries.Height, new DrawingObjectArtillery(artillery));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void createAdvancedButton_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
Random rnd = new();
|
|
|
|
|
var artillery = new DrawingAdvancedArtillery(
|
|
|
|
|
rnd.Next(100, 300),
|
|
|
|
|
rnd.Next(1000, 2000),
|
|
|
|
|
Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)),
|
|
|
|
|
Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)),
|
|
|
|
|
rnd.Next(0, 2) == 1, rnd.Next(0, 2) == 1
|
|
|
|
|
);
|
|
|
|
|
SetData(artillery);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void buttonCreate_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
Random rnd = new();
|
|
|
|
|
var artillery = new DrawingArtillery(rnd.Next(100, 300), rnd.Next(1000, 2000), Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)));
|
|
|
|
|
SetData(artillery);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void buttonMove_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
string name = ((Button)sender)?.Name ?? string.Empty;
|
|
|
|
|
Direction dir = Direction.None;
|
|
|
|
|
switch (name)
|
|
|
|
|
{
|
|
|
|
|
case "buttonUp":
|
|
|
|
|
dir = Direction.Up;
|
|
|
|
|
break;
|
|
|
|
|
case "buttonDown":
|
|
|
|
|
dir = Direction.Down;
|
|
|
|
|
break;
|
|
|
|
|
case "buttonLeft":
|
|
|
|
|
dir = Direction.Left;
|
|
|
|
|
break;
|
|
|
|
|
case "buttonRight":
|
|
|
|
|
dir = Direction.Right;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
pictureBoxArtilleries.Image = _abstractMap?.MoveObject(dir);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void comboBoxSelectorMap_SelectedIndexChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
switch (comboBoxSelectorMap.Text)
|
|
|
|
|
{
|
|
|
|
|
case "Простая карта":
|
|
|
|
|
_abstractMap = new SimpleMap();
|
|
|
|
|
break;
|
2022-09-26 23:12:22 +04:00
|
|
|
|
case "Лесная карта":
|
|
|
|
|
_abstractMap = new ForestMap();
|
|
|
|
|
break;
|
2022-09-26 22:02:22 +04:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|