You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
100 lines
2.7 KiB
100 lines
2.7 KiB
using System;
|
|
using System.Collections.Generic;
|
|
|
|
|
|
|
|
|
|
namespace ClassLib000.Walker
|
|
{
|
|
public class Appartment
|
|
{
|
|
public List<CleanSpace> CleanSpaces;
|
|
public VacuumCleaner VC;
|
|
|
|
public Appartment()
|
|
{
|
|
VC = new VacuumCleaner();
|
|
CleanSpaces = new List<CleanSpace>();
|
|
}
|
|
|
|
#region public methods
|
|
|
|
public void InitDoor(int x1, int y1, int x2, int y2)
|
|
{
|
|
foreach (var sp in CleanSpaces)
|
|
{
|
|
if (sp.X > x1 && sp.X > x2 && sp.Y > y1 && sp.Y < y2)
|
|
{
|
|
sp.WallEast = false;
|
|
sp.WallNorth = false;
|
|
sp.WallSouth = false;
|
|
sp.WallWest = false;
|
|
}
|
|
}
|
|
}
|
|
|
|
public void InitRoom(int x1, int y1, int x2, int y2)
|
|
{
|
|
for (int iX = x1; iX <= x2; iX++)
|
|
{
|
|
for (int iY = y1; iY <= y2; iY++)
|
|
{
|
|
CleanSpace cs = new CleanSpace(x1, y1);
|
|
if (iX == x1)
|
|
{
|
|
cs.WallWest = true;
|
|
}
|
|
if (iX == x2)
|
|
{
|
|
cs.WallEast = true;
|
|
}
|
|
if (iY == y1)
|
|
{
|
|
cs.WallNorth = true;
|
|
}
|
|
if (iY == y2)
|
|
{
|
|
cs.WallSouth = true;
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
public void InitVC()
|
|
{
|
|
VC.X = CleanSpaces[0].X;
|
|
VC.Y = CleanSpaces[0].Y;
|
|
}
|
|
|
|
public List<CleanSpace> GetDirtyCleanSpace(int iDayCount)
|
|
{
|
|
List<CleanSpace> result = new List<CleanSpace>();
|
|
DateTime dtFrom = DateTime.Now.AddDays(-iDayCount);
|
|
foreach (var sp in CleanSpaces)
|
|
{
|
|
if (sp.DateClean < dtFrom)
|
|
{
|
|
result.Add(sp);
|
|
}
|
|
}
|
|
return result;
|
|
}
|
|
|
|
public List<CleanSpace> FindRouteForVC(VacuumCleaner vc, int toX, int toY)
|
|
{
|
|
List<CleanSpace> result = new List<CleanSpace>();
|
|
int fromX = vc.X;
|
|
int fromY = vc.Y;
|
|
// ... реализация алгоритма перебора путей (поиск кратчайшего)
|
|
var cleanSpaceFrom = CleanSpaces[0];
|
|
var cleanSpaceTo = CleanSpaces[1];
|
|
if (vc.CanGo(cleanSpaceFrom, cleanSpaceTo))
|
|
{
|
|
//...
|
|
}
|
|
return result;
|
|
}
|
|
#endregion
|
|
}
|
|
}
|
|
|