XDDDD
This commit is contained in:
parent
3167789721
commit
39776ce06a
@ -1,8 +1,8 @@
|
|||||||
<?xml version="1.0" encoding="utf-8" ?>
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
<configuration>
|
<configuration>
|
||||||
<appSettings>
|
<appSettings>
|
||||||
<add key="imageFilePath" value="FOLDERPATH\input.bmp"/>
|
<add key="imageFilePath" value="C:\Users\micjan11\Projekty\Czoko_Smieciarka\Trunk\MonoGameView\map.bmp"/>
|
||||||
<add key="outputFilePath" value="FOLDERPATH\output.xml"/>
|
<add key="outputFilePath" value="C:\Users\micjan11\Projekty\Czoko_Smieciarka\Trunk\MonoGameView\bin\Windows\x86\Debug\map.xml"/>
|
||||||
</appSettings>
|
</appSettings>
|
||||||
<startup>
|
<startup>
|
||||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
|
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
|
||||||
|
@ -22,7 +22,7 @@ namespace MapEditor.Helpers
|
|||||||
return FieldType.House;
|
return FieldType.House;
|
||||||
|
|
||||||
if (color == Color.FromArgb(255,255,0))
|
if (color == Color.FromArgb(255,255,0))
|
||||||
return FieldType.House;
|
return FieldType.Dump;
|
||||||
|
|
||||||
throw new NotImplementedException($"Conversion form {color.ToKnownColor()} has not been implemented.");
|
throw new NotImplementedException($"Conversion form {color.ToKnownColor()} has not been implemented.");
|
||||||
|
|
||||||
|
@ -17,19 +17,36 @@ namespace CzokoŚmieciarka.MonoGameView.Algorithms
|
|||||||
{
|
{
|
||||||
public DFS()
|
public DFS()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
public List<Coords> Houses { get; set; }
|
||||||
|
|
||||||
|
public List<IStep> BestPath(ContentManager content, GarbageCollector collector, ICloneable[,] grid)
|
||||||
public List<IStep> BestPath(ContentManager content, AGarbageCollector collector, object[,] grid)
|
|
||||||
{
|
{
|
||||||
|
Houses = new List<Coords>();
|
||||||
|
for (int x = 0; x < grid.GetLength(0); x++)
|
||||||
|
{
|
||||||
|
for (int y = 0; y < grid.GetLength(1); y++)
|
||||||
|
{
|
||||||
|
if (grid[x, y] is House)
|
||||||
|
{
|
||||||
|
Houses.Add(new Coords(x,y));
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
var r=Search(content, collector, grid, 0).Key;
|
var r=Search(content, collector, grid, 0).Key;
|
||||||
Console.WriteLine(count);
|
|
||||||
if (r == null) return new List<IStep>();
|
if (r == null) return new List<IStep>();
|
||||||
return r;
|
return r;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
List<IStep> PossibleSteps(ContentManager content, AGarbageCollector collector, object[,] grid)
|
List<IStep> PossibleSteps(ContentManager content, AGarbageCollector collector, ICloneable[,] grid)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
@ -44,14 +61,13 @@ namespace CzokoŚmieciarka.MonoGameView.Algorithms
|
|||||||
var filteredMoveSteps = new List<IStep>();
|
var filteredMoveSteps = new List<IStep>();
|
||||||
foreach (var item in moveSteps)
|
foreach (var item in moveSteps)
|
||||||
{
|
{
|
||||||
var copyCollector = (AGarbageCollector)collector.Clone(content);
|
var copyCollector = (AGarbageCollector)collector.Clone();
|
||||||
var copyGrid = (object[,])grid.Clone();
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
item.Invoke(copyCollector, grid);
|
item.Invoke(copyCollector, grid);
|
||||||
var gcx = copyCollector.Coords.X;
|
var gcx = copyCollector.Coords.X;
|
||||||
var gcy = copyCollector.Coords.Y;
|
var gcy = copyCollector.Coords.Y;
|
||||||
if (grid[gcx, gcy] is IRoad1 || grid[gcx, gcy] is IGarbageLocalization || grid[gcx, gcy] is ADump)
|
if (grid[gcx, gcy] is Road1 || grid[gcx, gcy] is House || grid[gcx, gcy] is ADump)
|
||||||
{
|
{
|
||||||
result.Add(item);
|
result.Add(item);
|
||||||
}
|
}
|
||||||
@ -61,21 +77,78 @@ namespace CzokoŚmieciarka.MonoGameView.Algorithms
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (grid[collector.Coords.X, collector.Coords.Y] is IGarbageLocalization)
|
||||||
|
{
|
||||||
|
var collectSteps = new List<IStep>()
|
||||||
|
{
|
||||||
|
new CollectStep(GarbageType.Glass),
|
||||||
|
new CollectStep(GarbageType.Organic),
|
||||||
|
new CollectStep(GarbageType.Paper),
|
||||||
|
new CollectStep(GarbageType.PlasticMetal)
|
||||||
|
};
|
||||||
|
foreach (var item in collectSteps)
|
||||||
|
{
|
||||||
|
var copyCollector = (AGarbageCollector)collector.Clone();
|
||||||
|
var copyGrid = CopyGrid(grid);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
item.Invoke(copyCollector, copyGrid);
|
||||||
|
result.Add(item);
|
||||||
|
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (grid[collector.Coords.X, collector.Coords.Y] is ADump)
|
||||||
|
{
|
||||||
|
var collectSteps = new List<IStep>()
|
||||||
|
{
|
||||||
|
new SpillStep(GarbageType.Glass),
|
||||||
|
new SpillStep(GarbageType.Organic),
|
||||||
|
new SpillStep(GarbageType.Paper),
|
||||||
|
new SpillStep(GarbageType.PlasticMetal)
|
||||||
|
};
|
||||||
|
foreach (var item in collectSteps)
|
||||||
|
{
|
||||||
|
var copyCollector = (AGarbageCollector)collector.Clone();
|
||||||
|
var copyGrid = CopyGrid(grid);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
item.Invoke(copyCollector, copyGrid);
|
||||||
|
result.Add(item);
|
||||||
|
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
KeyValuePair<List<IStep>, int> Search(ContentManager content, AGarbageCollector collector, object[,] grid, int length)
|
KeyValuePair<List<IStep>, int> Search(ContentManager content, GarbageCollector collector, ICloneable[,] grid, int length)
|
||||||
{
|
{
|
||||||
|
if (length > 200) return new KeyValuePair<List<IStep>, int>(null,length);
|
||||||
count++;
|
count++;
|
||||||
if (length > 40) return new KeyValuePair<List<IStep>, int>(new List<IStep>(), length);
|
if (Houses.All(c => (grid[c.X, c.Y] as IGarbageLocalization).TrashCans.All(j => j.FillPercent == 0.0))
|
||||||
var possibleSteps = PossibleSteps(content, collector, grid);
|
&&
|
||||||
|
collector.TrashContainers.All(i => i.FillPercent == 0.0)
|
||||||
|
)
|
||||||
|
|
||||||
|
{
|
||||||
|
return new KeyValuePair<List<IStep>, int>(new List<IStep>(), length);
|
||||||
|
}
|
||||||
|
var possibleSteps = PossibleSteps(content, collector, grid);
|
||||||
|
|
||||||
foreach (var item in possibleSteps)
|
foreach (var item in possibleSteps)
|
||||||
{
|
{
|
||||||
var copyCollector = (AGarbageCollector)collector.Clone(content);
|
var copyCollector = (GarbageCollector)collector.Clone();
|
||||||
var copyGrid = (object[,])grid.Clone();
|
var copyGrid = CopyGrid(grid);
|
||||||
|
|
||||||
|
|
||||||
//if (copyGrid[copyCollector.Coords.X, copyCollector.Coords.Y] is IRoad1) copyGrid[copyCollector.Coords.X, copyCollector.Coords.Y] = new Road2();
|
//if (copyGrid[copyCollector.Coords.X, copyCollector.Coords.Y] is IRoad1) copyGrid[copyCollector.Coords.X, copyCollector.Coords.Y] = new Road2();
|
||||||
item.Invoke(copyCollector, copyGrid);
|
item.Invoke(copyCollector, copyGrid);
|
||||||
@ -102,5 +175,17 @@ namespace CzokoŚmieciarka.MonoGameView.Algorithms
|
|||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
private ICloneable[,] CopyGrid(ICloneable[,] grid)
|
||||||
|
{
|
||||||
|
ICloneable[,] result = new ICloneable[grid.GetLength(0), grid.GetLength(1)];
|
||||||
|
for (int x=0;x< grid.GetLength(0); x++)
|
||||||
|
{
|
||||||
|
for (int y=0;y< grid.GetLength(1); y++)
|
||||||
|
{
|
||||||
|
result[x, y] = (ICloneable) grid[x, y].Clone();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,7 @@ namespace CzokoŚmieciarka.MonoGameView.DataModels.Interfaces.Garbage
|
|||||||
{
|
{
|
||||||
public abstract class AGarbage : IGarbage
|
public abstract class AGarbage : IGarbage
|
||||||
{
|
{
|
||||||
protected AGarbage(ITypeOfGarbage typeOfGarbage, int weight)
|
protected AGarbage(ITypeOfGarbage typeOfGarbage, double weight)
|
||||||
{
|
{
|
||||||
this.TypeOfGarbage = typeOfGarbage;
|
this.TypeOfGarbage = typeOfGarbage;
|
||||||
this.Weight = weight;
|
this.Weight = weight;
|
||||||
@ -16,11 +16,11 @@ namespace CzokoŚmieciarka.MonoGameView.DataModels.Interfaces.Garbage
|
|||||||
|
|
||||||
public ITypeOfGarbage TypeOfGarbage { get; }
|
public ITypeOfGarbage TypeOfGarbage { get; }
|
||||||
|
|
||||||
public virtual int Weight { get; set; }
|
public virtual double Weight { get; set; }
|
||||||
|
|
||||||
public virtual int Volume
|
public virtual double Volume
|
||||||
{
|
{
|
||||||
get { return this.Weight / TypeOfGarbage.Density; }
|
get { return (double) this.Weight / TypeOfGarbage.Density; }
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract AGarbage Add(AGarbage garbageToAdd);
|
protected abstract AGarbage Add(AGarbage garbageToAdd);
|
||||||
@ -40,9 +40,9 @@ namespace CzokoŚmieciarka.MonoGameView.DataModels.Interfaces.Garbage
|
|||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
public object Clone()
|
public virtual object Clone()
|
||||||
{
|
{
|
||||||
return this.MemberwiseClone();
|
return new NotImplementedException("xD");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,8 +10,8 @@ namespace CzokoŚmieciarka.MonoGameView.DataModels.Interfaces.Garbage
|
|||||||
{
|
{
|
||||||
ITypeOfGarbage TypeOfGarbage { get; }
|
ITypeOfGarbage TypeOfGarbage { get; }
|
||||||
|
|
||||||
int Weight { get; }
|
double Weight { get; }
|
||||||
|
|
||||||
int Volume { get; }
|
double Volume { get; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -57,14 +57,10 @@ namespace CzokoŚmieciarka.MonoGameView.DataModels.Interfaces.GarbageCollector
|
|||||||
}
|
}
|
||||||
Coords.X += 1;
|
Coords.X += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual object Clone(ContentManager content)
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
public IEnumerable<AGarbageCollectorContainer> TrashContainers { get; }
|
public IEnumerable<AGarbageCollectorContainer> TrashContainers { get; }
|
||||||
public object Clone()
|
public virtual object Clone()
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
using Microsoft.Xna.Framework.Content;
|
using Microsoft.Xna.Framework.Content;
|
||||||
using Microsoft.Xna.Framework.Graphics;
|
using Microsoft.Xna.Framework.Graphics;
|
||||||
|
using System;
|
||||||
|
|
||||||
namespace CzokoŚmieciarka.MonoGameView.DataModels.Interfaces
|
namespace CzokoŚmieciarka.MonoGameView.DataModels.Interfaces
|
||||||
{
|
{
|
||||||
public interface IDrawables
|
public interface IDrawables : ICloneable
|
||||||
{
|
{
|
||||||
void Draw(SpriteBatch spriteBatch, int size);
|
void Draw(SpriteBatch spriteBatch, int size);
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@ using CzokoŚmieciarka.MonoGameView.DataModels.Enums;
|
|||||||
|
|
||||||
namespace CzokoŚmieciarka.MonoGameView.DataModels.Interfaces
|
namespace CzokoŚmieciarka.MonoGameView.DataModels.Interfaces
|
||||||
{
|
{
|
||||||
public interface ITypeOfGarbage
|
public interface ITypeOfGarbage : ICloneable
|
||||||
{
|
{
|
||||||
GarbageType GarbageType { get; }
|
GarbageType GarbageType { get; }
|
||||||
|
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
namespace CzokoŚmieciarka.MonoGameView.DataModels.Interfaces.TrashCans
|
using CzokoŚmieciarka.MonoGameView.DataModels.Interfaces.Garbage;
|
||||||
|
|
||||||
|
namespace CzokoŚmieciarka.MonoGameView.DataModels.Interfaces.TrashCans
|
||||||
{
|
{
|
||||||
public abstract class AGarbageCollectorContainer : ATrashCan
|
public abstract class AGarbageCollectorContainer : ATrashCan
|
||||||
{
|
{
|
||||||
protected AGarbageCollectorContainer(ITypeOfGarbage typeOfGarbage, int maxVolume) : base(typeOfGarbage, maxVolume)
|
protected AGarbageCollectorContainer(ITypeOfGarbage typeOfGarbage, int maxVolume, AGarbage garbage) : base(typeOfGarbage, maxVolume,garbage)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,14 +1,16 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using CzokoŚmieciarka.MonoGameView.DataModels.GeneralModels.Models;
|
||||||
using CzokoŚmieciarka.MonoGameView.DataModels.Interfaces.Garbage;
|
using CzokoŚmieciarka.MonoGameView.DataModels.Interfaces.Garbage;
|
||||||
|
|
||||||
namespace CzokoŚmieciarka.MonoGameView.DataModels.Interfaces.TrashCans
|
namespace CzokoŚmieciarka.MonoGameView.DataModels.Interfaces.TrashCans
|
||||||
{
|
{
|
||||||
public abstract class ATrashCan
|
public abstract class ATrashCan : ICloneable
|
||||||
{
|
{
|
||||||
protected ATrashCan(ITypeOfGarbage typeOfGarbage, int maxVolume)
|
protected ATrashCan(ITypeOfGarbage typeOfGarbage, int maxVolume)
|
||||||
{
|
{
|
||||||
this.MaxVolume = maxVolume;
|
this.MaxVolume = maxVolume;
|
||||||
this.TypeOfGarbage = typeOfGarbage;
|
this.TypeOfGarbage = typeOfGarbage;
|
||||||
|
Garbage = new BasicGarbage(typeOfGarbage, 0);
|
||||||
}
|
}
|
||||||
protected ATrashCan(ITypeOfGarbage typeOfGarbage, int maxVolume, AGarbage garbage)
|
protected ATrashCan(ITypeOfGarbage typeOfGarbage, int maxVolume, AGarbage garbage)
|
||||||
{
|
{
|
||||||
@ -23,26 +25,34 @@ namespace CzokoŚmieciarka.MonoGameView.DataModels.Interfaces.TrashCans
|
|||||||
|
|
||||||
public AGarbage Garbage { get; private set; }
|
public AGarbage Garbage { get; private set; }
|
||||||
|
|
||||||
public int FillPercent
|
public double FillPercent
|
||||||
{
|
{
|
||||||
get { return Garbage.Volume / this.MaxVolume; }
|
get { return ((double)Garbage.Volume) / this.MaxVolume; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual bool AddGarbage(IGarbage garbage)
|
public virtual void AddGarbage(AGarbage garbage)
|
||||||
{
|
{
|
||||||
if (this.TypeOfGarbage != garbage.TypeOfGarbage)
|
if (this.TypeOfGarbage.GarbageType != garbage.TypeOfGarbage.GarbageType)
|
||||||
throw new Exception("You cannot add up different type garbage!");
|
throw new Exception("You cannot add up different type garbage!");
|
||||||
|
|
||||||
var newGarbage = this.Garbage + Garbage;
|
var newGarbage = this.Garbage + garbage;
|
||||||
if (newGarbage.Volume > this.MaxVolume)
|
if (newGarbage.Volume > this.MaxVolume)
|
||||||
return false;
|
throw new Exception("Trash overload");
|
||||||
|
|
||||||
this.Garbage = newGarbage;
|
this.Garbage = newGarbage;
|
||||||
return true;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual object Clone()
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual AGarbage TakeGarbage()
|
public virtual AGarbage TakeGarbage()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
if (this.Garbage.Weight == 0)
|
||||||
|
throw new Exception("Pusty śmietnik matole");
|
||||||
var result = (AGarbage)this.Garbage.Clone();
|
var result = (AGarbage)this.Garbage.Clone();
|
||||||
this.Garbage.Weight = 0;
|
this.Garbage.Weight = 0;
|
||||||
return result;
|
return result;
|
||||||
|
@ -1,114 +1,115 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Xml;
|
using System.Xml;
|
||||||
using CzokoŚmieciarka.MonoGameView.DataModels.Enums;
|
using CzokoŚmieciarka.MonoGameView.DataModels.Enums;
|
||||||
using CzokoŚmieciarka.MonoGameView.DataModels.GeneralModels.Models;
|
using CzokoŚmieciarka.MonoGameView.DataModels.GeneralModels.Models;
|
||||||
using CzokoŚmieciarka.MonoGameView.DataModels.Interfaces;
|
using CzokoŚmieciarka.MonoGameView.DataModels.Interfaces;
|
||||||
using CzokoŚmieciarka.MonoGameView.DataModels.Interfaces.TrashCans;
|
using CzokoŚmieciarka.MonoGameView.DataModels.Interfaces.TrashCans;
|
||||||
using CzokoŚmieciarka.MonoGameView.DataModels.Models;
|
using CzokoŚmieciarka.MonoGameView.DataModels.Models;
|
||||||
using MonoGameView.DataModels.Models;
|
using MonoGameView.DataModels.Models;
|
||||||
|
|
||||||
namespace MonoGameView.DataModels
|
namespace MonoGameView.DataModels
|
||||||
{
|
{
|
||||||
public class MapLoader
|
public class MapLoader
|
||||||
{
|
{
|
||||||
public void Load(out int size, out IDrawables[,] grid, string filename)
|
public void Load(out int size, out IDrawables[,] grid, string filename)
|
||||||
{
|
{
|
||||||
XmlDocument xml = new XmlDocument();
|
XmlDocument xml = new XmlDocument();
|
||||||
xml.Load(filename);
|
xml.Load(filename);
|
||||||
XmlNode node = xml.GetElementsByTagName("Map").Item(0);
|
XmlNode node = xml.GetElementsByTagName("Map").Item(0);
|
||||||
XmlNode sizeNode = node.SelectSingleNode("/Map/Size");
|
XmlNode sizeNode = node.SelectSingleNode("/Map/Size");
|
||||||
size = Convert.ToInt32(sizeNode.InnerText);
|
size = Convert.ToInt32(sizeNode.InnerText);
|
||||||
grid = new IDrawables[size,size];
|
grid = new IDrawables[size,size];
|
||||||
for (int x = 0; x < size; x++)
|
for (int x = 0; x < size; x++)
|
||||||
{
|
{
|
||||||
for (int y = 0; y < size; y++)
|
for (int y = 0; y < size; y++)
|
||||||
{
|
{
|
||||||
grid[x, y] = new Grass(new Coords(x,y));
|
grid[x, y] = new Grass(new Coords(x,y));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
foreach(XmlNode objectNode in node.SelectNodes("/Map/Objects/Object"))
|
foreach(XmlNode objectNode in node.SelectNodes("/Map/Objects/Object"))
|
||||||
{
|
{
|
||||||
XmlNode positionNode;
|
XmlNode positionNode;
|
||||||
int x;
|
int x;
|
||||||
int y;
|
int y;
|
||||||
switch (objectNode.SelectSingleNode("Type").InnerText)
|
var dupa = objectNode.SelectSingleNode("Type").InnerText.Trim();
|
||||||
{
|
switch (dupa)
|
||||||
case "Road":
|
{
|
||||||
positionNode = objectNode.SelectSingleNode("Position");
|
case "Road":
|
||||||
x = Convert.ToInt32(positionNode.SelectSingleNode("X").InnerText);
|
positionNode = objectNode.SelectSingleNode("Position");
|
||||||
y = Convert.ToInt32(positionNode.SelectSingleNode("Y").InnerText);
|
x = Convert.ToInt32(positionNode.SelectSingleNode("X").InnerText);
|
||||||
Road1 road = new Road1(new Coords(x,y));
|
y = Convert.ToInt32(positionNode.SelectSingleNode("Y").InnerText);
|
||||||
grid[x, y] = road;
|
Road1 road = new Road1(new Coords(x,y));
|
||||||
break;
|
grid[x, y] = road;
|
||||||
case "House":
|
break;
|
||||||
positionNode = objectNode.SelectSingleNode("Position");
|
case "House":
|
||||||
x = Convert.ToInt32(positionNode.SelectSingleNode("X").InnerText);
|
positionNode = objectNode.SelectSingleNode("Position");
|
||||||
y = Convert.ToInt32(positionNode.SelectSingleNode("Y").InnerText);
|
x = Convert.ToInt32(positionNode.SelectSingleNode("X").InnerText);
|
||||||
List<ATrashCan> trashCans = new List<ATrashCan>();
|
y = Convert.ToInt32(positionNode.SelectSingleNode("Y").InnerText);
|
||||||
foreach (XmlNode trashCanNode in objectNode.SelectSingleNode("TrashCans"))
|
List<TrashCan> trashCans = new List<TrashCan>();
|
||||||
{
|
foreach (XmlNode trashCanNode in objectNode.SelectNodes("TrashCans/Can"))
|
||||||
GarbageType type;
|
{
|
||||||
switch (trashCanNode.SelectSingleNode("GarbageType").InnerText)
|
GarbageType type;
|
||||||
{
|
switch (trashCanNode.SelectSingleNode("GarbageType").InnerText.Trim())
|
||||||
case "Glass":
|
{
|
||||||
type = GarbageType.Glass;
|
case "Glass":
|
||||||
break;
|
type = GarbageType.Glass;
|
||||||
case "Organic":
|
break;
|
||||||
type = GarbageType.Organic;
|
case "Organic":
|
||||||
break;
|
type = GarbageType.Organic;
|
||||||
case "Paper":
|
break;
|
||||||
type = GarbageType.Paper;
|
case "Paper":
|
||||||
break;
|
type = GarbageType.Paper;
|
||||||
default:
|
break;
|
||||||
type = GarbageType.PlasticMetal;
|
default:
|
||||||
break;
|
type = GarbageType.PlasticMetal;
|
||||||
}
|
break;
|
||||||
int canDensity = Convert.ToInt32(trashCanNode.SelectSingleNode("Density").InnerText);
|
}
|
||||||
int canProcessingTimePerUnit = Convert.ToInt32(trashCanNode.SelectSingleNode("ProcessingTimePerUnit").InnerText);
|
int canDensity = Convert.ToInt32(trashCanNode.SelectSingleNode("Density").InnerText);
|
||||||
|
int canProcessingTimePerUnit = Convert.ToInt32(trashCanNode.SelectSingleNode("ProcessingTimePerUnit").InnerText);
|
||||||
int volume = Convert.ToInt32(trashCanNode.SelectSingleNode("Volume").InnerText);
|
int volume = Convert.ToInt32(trashCanNode.SelectSingleNode("Volume").InnerText);
|
||||||
TypeOfGarbage canTypeOfGarbage = new TypeOfGarbage(type, canDensity,canProcessingTimePerUnit);
|
TypeOfGarbage canTypeOfGarbage = new TypeOfGarbage(type, canDensity,canProcessingTimePerUnit);
|
||||||
TrashCan trashCan = new TrashCan(canTypeOfGarbage, volume);
|
TrashCan trashCan = new TrashCan(canTypeOfGarbage, volume, new BasicGarbage(canTypeOfGarbage, volume));
|
||||||
trashCans.Add(trashCan);
|
trashCans.Add(trashCan);
|
||||||
}
|
}
|
||||||
House house = new House(new Coords(x,y), trashCans);
|
House house = new House(new Coords(x,y), trashCans);
|
||||||
grid[x, y] = house;
|
grid[x, y] = house;
|
||||||
break;
|
break;
|
||||||
case "Dump":
|
case "Dump":
|
||||||
positionNode = objectNode.SelectSingleNode("Position");
|
positionNode = objectNode.SelectSingleNode("Position");
|
||||||
x = Convert.ToInt32(positionNode.SelectSingleNode("X").InnerText);
|
x = Convert.ToInt32(positionNode.SelectSingleNode("X").InnerText);
|
||||||
y = Convert.ToInt32(positionNode.SelectSingleNode("Y").InnerText);
|
y = Convert.ToInt32(positionNode.SelectSingleNode("Y").InnerText);
|
||||||
XmlNode garbageNode = objectNode.SelectSingleNode("Garbage");
|
XmlNode garbageNode = objectNode.SelectSingleNode("Garbage");
|
||||||
TypeOfGarbage typeOfGarbage;
|
TypeOfGarbage typeOfGarbage;
|
||||||
GarbageType garbageType;
|
GarbageType garbageType;
|
||||||
switch (garbageNode.SelectSingleNode("GarbageType").InnerText)
|
switch (garbageNode.SelectSingleNode("GarbageType").InnerText.Trim())
|
||||||
{
|
{
|
||||||
case "Glass":
|
case "Glass":
|
||||||
garbageType = GarbageType.Glass;
|
garbageType = GarbageType.Glass;
|
||||||
break;
|
break;
|
||||||
case "Organic":
|
case "Organic":
|
||||||
garbageType = GarbageType.Organic;
|
garbageType = GarbageType.Organic;
|
||||||
break;
|
break;
|
||||||
case "Paper":
|
case "Paper":
|
||||||
garbageType = GarbageType.Paper;
|
garbageType = GarbageType.Paper;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
garbageType = GarbageType.PlasticMetal;
|
garbageType = GarbageType.PlasticMetal;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
int density = Convert.ToInt32(garbageNode.SelectSingleNode("Density").InnerText);
|
int density = Convert.ToInt32(garbageNode.SelectSingleNode("Density").InnerText);
|
||||||
int processingTimePerUnit = Convert.ToInt32(garbageNode.SelectSingleNode("ProcessingTimePerUnit").InnerText);
|
int processingTimePerUnit = Convert.ToInt32(garbageNode.SelectSingleNode("ProcessingTimePerUnit").InnerText);
|
||||||
int maxVolume = Convert.ToInt32(objectNode.SelectSingleNode("Volume").InnerText);
|
int maxVolume = Convert.ToInt32(objectNode.SelectSingleNode("Volume").InnerText);
|
||||||
typeOfGarbage = new TypeOfGarbage(garbageType, density, processingTimePerUnit);
|
typeOfGarbage = new TypeOfGarbage(garbageType, density, processingTimePerUnit);
|
||||||
Dump dump = new Dump(typeOfGarbage, maxVolume, new Coords(x, y));
|
Dump dump = new Dump(typeOfGarbage, maxVolume, new Coords(x, y));
|
||||||
grid[x, y] = dump;
|
grid[x, y] = dump;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
31
Trunk/MonoGameView/DataModels/Models/BasicGarbage.cs
Normal file
31
Trunk/MonoGameView/DataModels/Models/BasicGarbage.cs
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
using System;
|
||||||
|
using CzokoŚmieciarka.MonoGameView.DataModels.Interfaces;
|
||||||
|
using CzokoŚmieciarka.MonoGameView.DataModels.Interfaces.Garbage;
|
||||||
|
|
||||||
|
namespace CzokoŚmieciarka.MonoGameView.DataModels.GeneralModels.Models
|
||||||
|
{
|
||||||
|
public class BasicGarbage : AGarbage
|
||||||
|
{
|
||||||
|
public BasicGarbage(ITypeOfGarbage typeOfGarbage, double weight) : base(typeOfGarbage, weight)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override AGarbage Add(AGarbage garbageToAdd)
|
||||||
|
{
|
||||||
|
return new BasicGarbage(TypeOfGarbage, Weight + garbageToAdd.Weight);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override AGarbage Subtract(AGarbage garbageToSubtract)
|
||||||
|
{
|
||||||
|
return new BasicGarbage(TypeOfGarbage, Weight - garbageToSubtract.Weight);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public override object Clone()
|
||||||
|
{
|
||||||
|
return new BasicGarbage((ITypeOfGarbage)TypeOfGarbage.Clone(), Weight);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -6,7 +6,7 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace CzokoŚmieciarka.MonoGameView.DataModels.Models
|
namespace CzokoŚmieciarka.MonoGameView.DataModels.Models
|
||||||
{
|
{
|
||||||
public class Coords
|
public class Coords : ICloneable
|
||||||
{
|
{
|
||||||
public Coords(int x,int y)
|
public Coords(int x,int y)
|
||||||
{
|
{
|
||||||
@ -50,5 +50,10 @@ namespace CzokoŚmieciarka.MonoGameView.DataModels.Models
|
|||||||
{
|
{
|
||||||
return base.GetHashCode();
|
return base.GetHashCode();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public object Clone()
|
||||||
|
{
|
||||||
|
return new Coords(X, Y);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,5 +17,11 @@ namespace CzokoŚmieciarka.MonoGameView.DataModels.GeneralModels.Models
|
|||||||
{
|
{
|
||||||
batch.Draw(ImageContainer.GetImage(TypeOfGarbage.GarbageType.ToString()), new Rectangle(Coords.X * 500 / size, Coords.Y * 500 / size, 500 / size, 500 / size), Color.White);
|
batch.Draw(ImageContainer.GetImage(TypeOfGarbage.GarbageType.ToString()), new Rectangle(Coords.X * 500 / size, Coords.Y * 500 / size, 500 / size, 500 / size), Color.White);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override object Clone()
|
||||||
|
{
|
||||||
|
return new Dump((ITypeOfGarbage)TypeOfGarbage.Clone(), MaxVolume, (Coords)Coords.Clone());
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
37
Trunk/MonoGameView/DataModels/Models/EmptyHouse.cs
Normal file
37
Trunk/MonoGameView/DataModels/Models/EmptyHouse.cs
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
using CzokoŚmieciarka.MonoGameView.DataModels.GeneralModels.Models;
|
||||||
|
using CzokoŚmieciarka.MonoGameView.DataModels.Interfaces;
|
||||||
|
using CzokoŚmieciarka.MonoGameView.DataModels.Interfaces.TrashCans;
|
||||||
|
using CzokoŚmieciarka.MonoGameView.DataModels.Models;
|
||||||
|
using Microsoft.Xna.Framework;
|
||||||
|
using Microsoft.Xna.Framework.Graphics;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace MonoGameView.DataModels.Models
|
||||||
|
{
|
||||||
|
public class EmptyHouse : IDrawables, IGarbageLocalization, ICloneable
|
||||||
|
{
|
||||||
|
public Coords Coords { get; }
|
||||||
|
|
||||||
|
public EmptyHouse(Coords coords)
|
||||||
|
{
|
||||||
|
Coords = coords;
|
||||||
|
TrashCans = new List<ATrashCan>();
|
||||||
|
}
|
||||||
|
public void Draw(SpriteBatch batch, int size)
|
||||||
|
{
|
||||||
|
batch.Draw(ImageContainer.GetImage("road2"), new Rectangle(Coords.X * 500 / size, Coords.Y * 500 / size, 500 / size, 500 / size), Color.White);
|
||||||
|
}
|
||||||
|
|
||||||
|
public object Clone()
|
||||||
|
{
|
||||||
|
return new House((Coords)Coords.Clone(), new List<TrashCan>());
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<ATrashCan> TrashCans { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,24 +0,0 @@
|
|||||||
using System;
|
|
||||||
using CzokoŚmieciarka.MonoGameView.DataModels.Interfaces;
|
|
||||||
using CzokoŚmieciarka.MonoGameView.DataModels.Interfaces.Garbage;
|
|
||||||
|
|
||||||
namespace CzokoŚmieciarka.MonoGameView.DataModels.GeneralModels.Models
|
|
||||||
{
|
|
||||||
public class Garbage : AGarbage
|
|
||||||
{
|
|
||||||
public Garbage(ITypeOfGarbage typeOfGarbage, int weight) : base(typeOfGarbage, weight)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override AGarbage Add(AGarbage garbageToAdd)
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override AGarbage Subtract(AGarbage garbageToSubtract)
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,34 +1,35 @@
|
|||||||
using CzokoŚmieciarka.MonoGameView.DataModels.Interfaces.GarbageCollector;
|
using CzokoŚmieciarka.MonoGameView.DataModels.Interfaces.GarbageCollector;
|
||||||
using CzokoŚmieciarka.MonoGameView.DataModels.Interfaces.TrashCans;
|
using CzokoŚmieciarka.MonoGameView.DataModels.Interfaces.TrashCans;
|
||||||
using CzokoŚmieciarka.MonoGameView.DataModels.Interfaces;
|
using CzokoŚmieciarka.MonoGameView.DataModels.Interfaces;
|
||||||
using Microsoft.Xna.Framework;
|
using Microsoft.Xna.Framework;
|
||||||
using Microsoft.Xna.Framework.Content;
|
using Microsoft.Xna.Framework.Content;
|
||||||
using Microsoft.Xna.Framework.Graphics;
|
using Microsoft.Xna.Framework.Graphics;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using MonoGameView.DataModels.Models;
|
using MonoGameView.DataModels.Models;
|
||||||
|
using CzokoŚmieciarka.MonoGameView.DataModels.GeneralModels.Models;
|
||||||
|
|
||||||
namespace CzokoŚmieciarka.MonoGameView.DataModels.Models
|
namespace CzokoŚmieciarka.MonoGameView.DataModels.Models
|
||||||
{
|
{
|
||||||
public class GarbageCollector : AGarbageCollector, IDrawables
|
public class GarbageCollector : AGarbageCollector, IDrawables
|
||||||
{
|
{
|
||||||
public GarbageCollector(Coords c, List<AGarbageCollectorContainer> l, int rows, int cols) : base(c,l,rows,cols)
|
public GarbageCollector(Coords c, List<GarbageCollectorContainer> l, int rows, int cols) : base(c,l,rows,cols)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Draw(SpriteBatch batch,int size)
|
public void Draw(SpriteBatch batch,int size)
|
||||||
{
|
{
|
||||||
batch.Draw(ImageContainer.GetImage("collector"), new Rectangle(Coords.X*500/size, Coords.Y*500/size, 500/size, 500/size), Color.White);
|
batch.Draw(ImageContainer.GetImage("collector"), new Rectangle(Coords.X*500/size, Coords.Y*500/size, 500/size, 500/size), Color.White);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public override object Clone(ContentManager content)
|
public override object Clone()
|
||||||
{
|
{
|
||||||
var cloneList = new List<AGarbageCollectorContainer>();
|
var cloneList = TrashContainers.Select(x=>(GarbageCollectorContainer)x.Clone()).ToList();
|
||||||
return new GarbageCollector(new Coords(Coords.X,Coords.Y), cloneList, rows,columns);
|
return new GarbageCollector((Coords)Coords.Clone(), cloneList, rows,columns);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,8 +5,13 @@ namespace CzokoŚmieciarka.MonoGameView.DataModels.GeneralModels.Models
|
|||||||
{
|
{
|
||||||
public class GarbageCollectorContainer : AGarbageCollectorContainer
|
public class GarbageCollectorContainer : AGarbageCollectorContainer
|
||||||
{
|
{
|
||||||
public GarbageCollectorContainer(ITypeOfGarbage typeOfGarbage, int maxVolume) : base(typeOfGarbage, maxVolume)
|
public GarbageCollectorContainer(TypeOfGarbage typeOfGarbage, int maxVolume, BasicGarbage garbage) : base(typeOfGarbage, maxVolume,garbage)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override object Clone()
|
||||||
|
{
|
||||||
|
return new GarbageCollectorContainer((TypeOfGarbage)TypeOfGarbage.Clone(), MaxVolume,(BasicGarbage)Garbage.Clone());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,9 +20,16 @@ namespace MonoGameView.DataModels.Models
|
|||||||
Coords = coords;
|
Coords = coords;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public object Clone()
|
||||||
|
{
|
||||||
|
return new Grass((Coords)Coords.Clone());
|
||||||
|
}
|
||||||
|
|
||||||
public void Draw(SpriteBatch batch, int size)
|
public void Draw(SpriteBatch batch, int size)
|
||||||
{
|
{
|
||||||
batch.Draw(ImageContainer.GetImage("grass"), new Rectangle(Coords.X * 500 / size, Coords.Y * 500 / size, 500 / size, 500 / size), Color.White);
|
batch.Draw(ImageContainer.GetImage("grass"), new Rectangle(Coords.X * 500 / size, Coords.Y * 500 / size, 500 / size, 500 / size), Color.White);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@ using System.Collections.Generic;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using CzokoŚmieciarka.MonoGameView.DataModels.GeneralModels.Models;
|
||||||
using CzokoŚmieciarka.MonoGameView.DataModels.Interfaces;
|
using CzokoŚmieciarka.MonoGameView.DataModels.Interfaces;
|
||||||
using CzokoŚmieciarka.MonoGameView.DataModels.Interfaces.TrashCans;
|
using CzokoŚmieciarka.MonoGameView.DataModels.Interfaces.TrashCans;
|
||||||
using Microsoft.Xna.Framework;
|
using Microsoft.Xna.Framework;
|
||||||
@ -12,19 +13,25 @@ using MonoGameView.DataModels.Models;
|
|||||||
|
|
||||||
namespace CzokoŚmieciarka.MonoGameView.DataModels.Models
|
namespace CzokoŚmieciarka.MonoGameView.DataModels.Models
|
||||||
{
|
{
|
||||||
public class House : IDrawables, IGarbageLocalization
|
public class House : IDrawables, IGarbageLocalization, ICloneable
|
||||||
{
|
{
|
||||||
public Coords Coords { get; }
|
public Coords Coords { get; }
|
||||||
|
|
||||||
public House(Coords coords, IEnumerable<ATrashCan> trashCans)
|
public House(Coords coords, IEnumerable<TrashCan> trashCans)
|
||||||
{
|
{
|
||||||
Coords = coords;
|
Coords = coords;
|
||||||
|
TrashCans = trashCans;
|
||||||
}
|
}
|
||||||
public void Draw(SpriteBatch batch, int size)
|
public void Draw(SpriteBatch batch, int size)
|
||||||
{
|
{
|
||||||
batch.Draw(ImageContainer.GetImage("house"), new Rectangle(Coords.X * 500 / size, Coords.Y * 500 / size, 500 / size, 500 / size), Color.White);
|
batch.Draw(ImageContainer.GetImage("house"), new Rectangle(Coords.X * 500 / size, Coords.Y * 500 / size, 500 / size, 500 / size), Color.White);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public object Clone()
|
||||||
|
{
|
||||||
|
return new House((Coords) Coords.Clone(), TrashCans.Select(x => (TrashCan) x.Clone()).ToList());
|
||||||
|
}
|
||||||
|
|
||||||
public IEnumerable<ATrashCan> TrashCans { get; set; }
|
public IEnumerable<ATrashCan> TrashCans { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,6 +20,11 @@ namespace CzokoŚmieciarka.MonoGameView.DataModels.Models
|
|||||||
Coords = coords;
|
Coords = coords;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public object Clone()
|
||||||
|
{
|
||||||
|
return new Road1((Coords)Coords.Clone());
|
||||||
|
}
|
||||||
|
|
||||||
public void Draw(SpriteBatch batch, int size)
|
public void Draw(SpriteBatch batch, int size)
|
||||||
{
|
{
|
||||||
batch.Draw(ImageContainer.GetImage("road1"), new Rectangle(Coords.X * 500 / size, Coords.Y * 500 / size, 500 / size, 500 / size), Color.White);
|
batch.Draw(ImageContainer.GetImage("road1"), new Rectangle(Coords.X * 500 / size, Coords.Y * 500 / size, 500 / size, 500 / size), Color.White);
|
||||||
|
@ -17,8 +17,13 @@ namespace CzokoŚmieciarka.MonoGameView.DataModels.Models
|
|||||||
public Road2(Coords coords)
|
public Road2(Coords coords)
|
||||||
{
|
{
|
||||||
Coords = coords;
|
Coords = coords;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public object Clone()
|
||||||
|
{
|
||||||
|
return new Road2((Coords)Coords.Clone());
|
||||||
|
}
|
||||||
|
|
||||||
public void Draw(SpriteBatch batch, int size)
|
public void Draw(SpriteBatch batch, int size)
|
||||||
{
|
{
|
||||||
batch.Draw(ImageContainer.GetImage("road2"), new Rectangle(Coords.X * 500 / size, Coords.Y * 500 / size, 500 / size, 500 / size), Color.White);
|
batch.Draw(ImageContainer.GetImage("road2"), new Rectangle(Coords.X * 500 / size, Coords.Y * 500 / size, 500 / size, 500 / size), Color.White);
|
||||||
|
@ -3,35 +3,47 @@ using System.Collections.Generic;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using CzokoŚmieciarka.MonoGameView.DataModels.Enums;
|
||||||
|
using CzokoŚmieciarka.MonoGameView.DataModels.Exceptions;
|
||||||
using CzokoŚmieciarka.MonoGameView.DataModels.Interfaces;
|
using CzokoŚmieciarka.MonoGameView.DataModels.Interfaces;
|
||||||
using CzokoŚmieciarka.MonoGameView.DataModels.Interfaces.GarbageCollector;
|
using CzokoŚmieciarka.MonoGameView.DataModels.Interfaces.GarbageCollector;
|
||||||
using CzokoŚmieciarka.MonoGameView.DataModels.Interfaces.TrashCans;
|
using CzokoŚmieciarka.MonoGameView.DataModels.Interfaces.TrashCans;
|
||||||
|
using MonoGameView.DataModels.Models;
|
||||||
|
|
||||||
namespace CzokoŚmieciarka.MonoGameView.DataModels.Models.Steps
|
namespace CzokoŚmieciarka.MonoGameView.DataModels.Models.Steps
|
||||||
{
|
{
|
||||||
public class CollectStep : IStep
|
public class CollectStep : IStep
|
||||||
{
|
{
|
||||||
public CollectStep(ITypeOfGarbage typeOfGarbage)
|
public CollectStep(GarbageType typeOfGarbage)
|
||||||
{
|
{
|
||||||
this._typeOfGarbage = typeOfGarbage;
|
this._typeOfGarbage = typeOfGarbage;
|
||||||
}
|
}
|
||||||
|
|
||||||
private ITypeOfGarbage _typeOfGarbage;
|
private GarbageType _typeOfGarbage;
|
||||||
|
|
||||||
public void Invoke(IGarbageCollector garbageCollector, object [,] grid)
|
public void Invoke(IGarbageCollector _garbageCollector, object [,] grid)
|
||||||
{
|
{
|
||||||
/*
|
|
||||||
|
var _garbageLocalization = (IGarbageLocalization) grid[_garbageCollector.Coords.X, _garbageCollector.Coords.Y];
|
||||||
if(_garbageCollector.Coords != _garbageLocalization.Coords)
|
if(_garbageCollector.Coords != _garbageLocalization.Coords)
|
||||||
throw new WrongPositionException("Śmieciarka nie jest w miejscu oderbania śmieci");
|
throw new WrongPositionException("Śmieciarka nie jest w miejscu oderbania śmieci");
|
||||||
|
|
||||||
var trashCans = _garbageLocalization.TrashCans.Where(t => t.TypeOfGarbage == _typeOfGarbage);
|
var trashCans = _garbageLocalization.TrashCans.Where(t => t.TypeOfGarbage.GarbageType == _typeOfGarbage);
|
||||||
var garbage = trashCans.Select(t => t.TakeGarbage()).Aggregate((a,b)=>a+b);
|
var garbage = trashCans.Select(t => t.TakeGarbage()).Aggregate((a,b)=>a+b);
|
||||||
|
|
||||||
if (_garbageCollector.TrashContainers.All(c => c.TypeOfGarbage != _typeOfGarbage))
|
if (_garbageCollector.TrashContainers.All(c => c.TypeOfGarbage.GarbageType != _typeOfGarbage))
|
||||||
throw new TrashContainerNotFound($"Nie znaleziono kontenera na {_typeOfGarbage.GarbageType}.");
|
throw new TrashContainerNotFound($"Nie znaleziono kontenera na {_typeOfGarbage}.");
|
||||||
|
|
||||||
_garbageCollector.TrashContainers.First(t => t.TypeOfGarbage == _typeOfGarbage).AddGarbage(garbage);
|
_garbageCollector.TrashContainers.First(t => t.TypeOfGarbage.GarbageType == _typeOfGarbage).AddGarbage(garbage);
|
||||||
*/
|
|
||||||
|
for (int x= 0;x < grid.GetLength(0); x++){
|
||||||
|
for (int y = 0; y < grid.GetLength(1); y++)
|
||||||
|
{
|
||||||
|
if (grid[x, y] is Road2) grid[x, y] = new Road1(new Coords(x,y));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (_garbageLocalization.TrashCans.All(x => x.FillPercent == 0.0))
|
||||||
|
grid[_garbageCollector.Coords.X, _garbageCollector.Coords.Y] = new EmptyHouse(new Coords(_garbageCollector.Coords.X, _garbageCollector.Coords.Y));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,8 @@ using System.Collections.Generic;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using CzokoŚmieciarka.MonoGameView.DataModels.Enums;
|
||||||
|
using CzokoŚmieciarka.MonoGameView.DataModels.Exceptions;
|
||||||
using CzokoŚmieciarka.MonoGameView.DataModels.Interfaces;
|
using CzokoŚmieciarka.MonoGameView.DataModels.Interfaces;
|
||||||
using CzokoŚmieciarka.MonoGameView.DataModels.Interfaces.GarbageCollector;
|
using CzokoŚmieciarka.MonoGameView.DataModels.Interfaces.GarbageCollector;
|
||||||
using CzokoŚmieciarka.MonoGameView.DataModels.Interfaces.TrashCans;
|
using CzokoŚmieciarka.MonoGameView.DataModels.Interfaces.TrashCans;
|
||||||
@ -11,29 +13,37 @@ namespace CzokoŚmieciarka.MonoGameView.DataModels.Models.Steps
|
|||||||
{
|
{
|
||||||
public class SpillStep : IStep
|
public class SpillStep : IStep
|
||||||
{
|
{
|
||||||
public SpillStep(ITypeOfGarbage typeOfGarbage)
|
public SpillStep(GarbageType typeOfGarbage)
|
||||||
{
|
{
|
||||||
this._typeOfGarbage = typeOfGarbage;
|
this._typeOfGarbage = typeOfGarbage;
|
||||||
}
|
}
|
||||||
|
|
||||||
private ITypeOfGarbage _typeOfGarbage;
|
private GarbageType _typeOfGarbage;
|
||||||
|
|
||||||
public void Invoke(IGarbageCollector garbageCollector, object [,] grid)
|
public void Invoke(IGarbageCollector _garbageCollector, object [,] grid)
|
||||||
{/*
|
{
|
||||||
|
var _dump = (ADump)grid[_garbageCollector.Coords.X, _garbageCollector.Coords.Y];
|
||||||
if(_garbageCollector.Coords != _dump.Coords)
|
if(_garbageCollector.Coords != _dump.Coords)
|
||||||
throw new WrongPositionException("Śmieciarka nie na terenie podanego wyspiska");
|
throw new WrongPositionException("Śmieciarka nie na terenie podanego wyspiska");
|
||||||
|
|
||||||
if(_dump.TypeOfGarbage != _typeOfGarbage)
|
if(_dump.TypeOfGarbage.GarbageType != _typeOfGarbage)
|
||||||
throw new TrashContainerNotFound($"Wysypisko nie przyjmuje smieci typu {_typeOfGarbage.GarbageType}");
|
throw new TrashContainerNotFound($"Wysypisko nie przyjmuje smieci typu {_typeOfGarbage}");
|
||||||
|
|
||||||
if(_garbageCollector.TrashContainers.All(c => c.TypeOfGarbage != _typeOfGarbage))
|
if(_garbageCollector.TrashContainers.All(c => c.TypeOfGarbage.GarbageType != _typeOfGarbage))
|
||||||
throw new TrashContainerNotFound($"Smieciarka nie ma pojemnika na {_typeOfGarbage.GarbageType}!");
|
throw new TrashContainerNotFound($"Smieciarka nie ma pojemnika na {_typeOfGarbage}!");
|
||||||
|
|
||||||
var garbage = _garbageCollector.TrashContainers.Where(t => t.TypeOfGarbage == _typeOfGarbage)
|
var garbage = _garbageCollector.TrashContainers.Where(t => t.TypeOfGarbage.GarbageType == _typeOfGarbage)
|
||||||
.Select(t => t.TakeGarbage())
|
.Select(t => t.TakeGarbage())
|
||||||
.Aggregate((a, b) => a + b);
|
.Aggregate((a, b) => a + b);
|
||||||
|
|
||||||
_dump.AddGarbage(garbage);*/
|
_dump.AddGarbage(garbage);
|
||||||
|
for (int x = 0; x < grid.GetLength(0); x++)
|
||||||
|
{
|
||||||
|
for (int y = 0; y < grid.GetLength(1); y++)
|
||||||
|
{
|
||||||
|
if (grid[x, y] is Road2) grid[x, y] = new Road1(new Coords(x, y));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using CzokoŚmieciarka.MonoGameView.DataModels.Interfaces;
|
using CzokoŚmieciarka.MonoGameView.DataModels.Interfaces;
|
||||||
|
using CzokoŚmieciarka.MonoGameView.DataModels.Interfaces.Garbage;
|
||||||
using CzokoŚmieciarka.MonoGameView.DataModels.Interfaces.TrashCans;
|
using CzokoŚmieciarka.MonoGameView.DataModels.Interfaces.TrashCans;
|
||||||
|
|
||||||
namespace CzokoŚmieciarka.MonoGameView.DataModels.GeneralModels.Models
|
namespace CzokoŚmieciarka.MonoGameView.DataModels.GeneralModels.Models
|
||||||
@ -8,8 +9,13 @@ namespace CzokoŚmieciarka.MonoGameView.DataModels.GeneralModels.Models
|
|||||||
public TrashCan(ITypeOfGarbage typeOfGarbage, int maxVolume) : base(typeOfGarbage, maxVolume)
|
public TrashCan(ITypeOfGarbage typeOfGarbage, int maxVolume) : base(typeOfGarbage, maxVolume)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
public TrashCan(ITypeOfGarbage typeOfGarbage, int maxVolume, Garbage garbage) : base(typeOfGarbage, maxVolume, garbage)
|
public TrashCan(ITypeOfGarbage typeOfGarbage, int maxVolume, BasicGarbage garbage) : base(typeOfGarbage, maxVolume, garbage)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override object Clone()
|
||||||
|
{
|
||||||
|
return new TrashCan((TypeOfGarbage) TypeOfGarbage.Clone(), MaxVolume, (BasicGarbage) Garbage.Clone());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,5 +15,10 @@ namespace CzokoŚmieciarka.MonoGameView.DataModels.GeneralModels.Models
|
|||||||
public GarbageType GarbageType { get; }
|
public GarbageType GarbageType { get; }
|
||||||
public int ProcessingTimePerUnit { get; }
|
public int ProcessingTimePerUnit { get; }
|
||||||
public int Density { get; }
|
public int Density { get; }
|
||||||
|
|
||||||
|
public object Clone()
|
||||||
|
{
|
||||||
|
return new TypeOfGarbage(GarbageType, Density, ProcessingTimePerUnit);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,8 @@ using System.Linq;
|
|||||||
using CzokoŚmieciarka.MonoGameView.Algorithms;
|
using CzokoŚmieciarka.MonoGameView.Algorithms;
|
||||||
using MonoGameView.DataModels;
|
using MonoGameView.DataModels;
|
||||||
using MonoGameView.DataModels.Models;
|
using MonoGameView.DataModels.Models;
|
||||||
|
using CzokoŚmieciarka.MonoGameView.DataModels.GeneralModels.Models;
|
||||||
|
using CzokoŚmieciarka.MonoGameView.DataModels.Enums;
|
||||||
|
|
||||||
namespace CzokoŚmieciarka.MonoGameView
|
namespace CzokoŚmieciarka.MonoGameView
|
||||||
{
|
{
|
||||||
@ -22,14 +24,10 @@ namespace CzokoŚmieciarka.MonoGameView
|
|||||||
private static int size;
|
private static int size;
|
||||||
GraphicsDeviceManager graphics;
|
GraphicsDeviceManager graphics;
|
||||||
SpriteBatch spriteBatch;
|
SpriteBatch spriteBatch;
|
||||||
Texture2D road1;
|
|
||||||
Texture2D road2;
|
|
||||||
Texture2D grass;
|
|
||||||
Texture2D house;
|
|
||||||
MapLoader mapLoader = new MapLoader();
|
MapLoader mapLoader = new MapLoader();
|
||||||
Vector2 roadPos;
|
Vector2 roadPos;
|
||||||
float timer;
|
float timer;
|
||||||
const float TIMER = 0.2f;
|
const float TIMER = 0.02f;
|
||||||
int stepN;
|
int stepN;
|
||||||
List<IStep> steps;
|
List<IStep> steps;
|
||||||
GarbageCollector collector;
|
GarbageCollector collector;
|
||||||
@ -55,11 +53,18 @@ namespace CzokoŚmieciarka.MonoGameView
|
|||||||
|
|
||||||
ImageContainer.InitContainer(Content);
|
ImageContainer.InitContainer(Content);
|
||||||
// TODO: Add your initialization logic here
|
// TODO: Add your initialization logic here
|
||||||
roadPos = new Vector2(0, 0);
|
timer = 5f;
|
||||||
timer = 0.2f;
|
|
||||||
|
|
||||||
mapLoader.Load(out size,out grid,"map.xml");
|
mapLoader.Load(out size,out grid,"map.xml");
|
||||||
collector = new GarbageCollector(new Coords(0, 0), new List<AGarbageCollectorContainer>(), size, size);
|
var containers = new List<GarbageCollectorContainer>()
|
||||||
|
{
|
||||||
|
new GarbageCollectorContainer(
|
||||||
|
new TypeOfGarbage(GarbageType.Glass,50,1),
|
||||||
|
100,
|
||||||
|
new BasicGarbage(new TypeOfGarbage(GarbageType.Glass,50,1),1)
|
||||||
|
),
|
||||||
|
};
|
||||||
|
collector = new GarbageCollector(new Coords(0,0), containers, size, size);
|
||||||
|
|
||||||
|
|
||||||
stepN = 0;
|
stepN = 0;
|
||||||
@ -77,10 +82,6 @@ namespace CzokoŚmieciarka.MonoGameView
|
|||||||
{
|
{
|
||||||
// Create a new SpriteBatch, which can be used to draw textures.
|
// Create a new SpriteBatch, which can be used to draw textures.
|
||||||
spriteBatch = new SpriteBatch(GraphicsDevice);
|
spriteBatch = new SpriteBatch(GraphicsDevice);
|
||||||
road1 = Content.Load<Texture2D>("road1");
|
|
||||||
road2 = Content.Load<Texture2D>("road2");
|
|
||||||
grass = Content.Load<Texture2D>("grass");
|
|
||||||
house = Content.Load<Texture2D>("house");
|
|
||||||
// TODO: use this.Content to load your game content here
|
// TODO: use this.Content to load your game content here
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,7 +65,8 @@
|
|||||||
<Compile Include="DataModels\MapLoader.cs" />
|
<Compile Include="DataModels\MapLoader.cs" />
|
||||||
<Compile Include="DataModels\Models\Coords.cs" />
|
<Compile Include="DataModels\Models\Coords.cs" />
|
||||||
<Compile Include="DataModels\Models\Dump.cs" />
|
<Compile Include="DataModels\Models\Dump.cs" />
|
||||||
<Compile Include="DataModels\Models\Garbage.cs" />
|
<Compile Include="DataModels\Models\BasicGarbage.cs" />
|
||||||
|
<Compile Include="DataModels\Models\EmptyHouse.cs" />
|
||||||
<Compile Include="DataModels\Models\GarbageCollectorContainer.cs" />
|
<Compile Include="DataModels\Models\GarbageCollectorContainer.cs" />
|
||||||
<Compile Include="DataModels\Models\GarbageLocalization.cs" />
|
<Compile Include="DataModels\Models\GarbageLocalization.cs" />
|
||||||
<Compile Include="DataModels\Models\Grass.cs" />
|
<Compile Include="DataModels\Models\Grass.cs" />
|
||||||
|
BIN
Trunk/MonoGameView/map.bmp
Normal file
BIN
Trunk/MonoGameView/map.bmp
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.3 KiB |
Loading…
Reference in New Issue
Block a user