Komlev_S.I. Lab2 #4

Closed
SemkaKMLV wants to merge 7 commits from Lab2 into Lab1
4 changed files with 1 additions and 114 deletions
Showing only changes of commit c85363a749 - Show all commits

View File

@ -1,53 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace GasolineTanker
{
internal class FormLawn : AbstractMap
{
private readonly Brush tankColor = new SolidBrush(Color.Yellow);
private readonly Pen logoPen = new Pen(Color.DarkGreen, 5);
private readonly Brush roadColor = new SolidBrush(Color.Green);
protected override void DrawBarrierPart(Graphics g, int i, int j)
{
g.FillRectangle(roadColor, i * _size_x, j * _size_y, _size_x, _size_y);
g.FillEllipse(tankColor, i * _size_x, j * _size_y, _size_x, _size_y);
g.DrawEllipse(logoPen, i * _size_x, j * _size_y, _size_x, _size_y);
}
protected override void DrawRoadPart(Graphics g, int i, int j)
{
g.FillRectangle(roadColor, i * _size_x, j * _size_y, _size_x, _size_y);
}
protected override void GenerateMap()
{
_map = new int[39, 26];
_size_x = (float)_width / _map.GetLength(0);
_size_y = (float)_height / _map.GetLength(1);
int counter = 0;
for (int i = 0; i < _map.GetLength(0); ++i)
{
for (int j = 0; j < _map.GetLength(1); ++j)
{
_map[i, j] = _freeRoad;
}
}
while (counter < 20)
{
int x = _random.Next(0, 39);
int y = _random.Next(0, 26);
if (_map[x, y] == _freeRoad)
{
_map[x, y] = _barrier;
counter++;
}
}
}
}
}

View File

@ -159,9 +159,7 @@
this.comboBoxSelectorMap.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.comboBoxSelectorMap.FormattingEnabled = true;
this.comboBoxSelectorMap.Items.AddRange(new object[] {
"Простая карта",
"Минное поле",
"Лужайка"});
"Простая карта"});
this.comboBoxSelectorMap.Location = new System.Drawing.Point(12, 12);
this.comboBoxSelectorMap.Name = "comboBoxSelectorMap";
this.comboBoxSelectorMap.Size = new System.Drawing.Size(121, 23);

View File

@ -96,12 +96,6 @@ namespace GasolineTanker
case "Простая карта":
_abstractMap = new SimpleMap();
break;
case "Минное поле":
_abstractMap = new MineField();
break;
case "Лужайка":
_abstractMap = new FormLawn();
break;
}
}
}

View File

@ -1,52 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace GasolineTanker
{
internal class MineField : AbstractMap
{
private readonly Brush tankColor = new SolidBrush(Color.WhiteSmoke);
private readonly Pen logoPen = new Pen(Color.Yellow, 1);
private readonly Brush roadColor = new SolidBrush(Color.DarkGray);
protected override void DrawBarrierPart(Graphics g, int i, int j)
{
g.FillRectangle(roadColor, i * _size_x, j * _size_y, _size_x, _size_y);
g.FillEllipse(tankColor, i * _size_x, j * _size_y, _size_x, _size_y);
g.DrawEllipse(logoPen, i * _size_x, j * _size_y, _size_x, _size_y);
}
protected override void DrawRoadPart(Graphics g, int i, int j)
{
g.FillRectangle(roadColor, i * _size_x, j * _size_y, _size_x, _size_y);
}
protected override void GenerateMap()
{
_map = new int[39, 26];
_size_x = (float)_width / _map.GetLength(0);
_size_y = (float)_height / _map.GetLength(1);
int counter = 0;
for (int i = 0; i < _map.GetLength(0); ++i)
{
for (int j = 0; j < _map.GetLength(1); ++j)
{
_map[i, j] = _freeRoad;
}
}
while (counter < 20)
{
int x = _random.Next(0, 39);
int y = _random.Next(0, 26);
if (_map[x, y] == _freeRoad)
{
_map[x, y] = _barrier;
counter++;
}
}
}
}
}