diff --git a/Trunk/MonoGameView/Content/Content.mgcb b/Trunk/MonoGameView/Content/Content.mgcb index 60deb1d..131b7bf 100644 --- a/Trunk/MonoGameView/Content/Content.mgcb +++ b/Trunk/MonoGameView/Content/Content.mgcb @@ -25,6 +25,18 @@ /processorParam:TextureFormat=Color /build:collector.png +#begin glass.png +/importer:TextureImporter +/processor:TextureProcessor +/processorParam:ColorKeyColor=255,0,255,255 +/processorParam:ColorKeyEnabled=True +/processorParam:GenerateMipmaps=False +/processorParam:PremultiplyAlpha=True +/processorParam:ResizeToPowerOfTwo=False +/processorParam:MakeSquare=False +/processorParam:TextureFormat=Color +/build:glass.png + #begin grass.png /importer:TextureImporter /processor:TextureProcessor @@ -49,6 +61,42 @@ /processorParam:TextureFormat=Color /build:house.png +#begin organic.png +/importer:TextureImporter +/processor:TextureProcessor +/processorParam:ColorKeyColor=255,0,255,255 +/processorParam:ColorKeyEnabled=True +/processorParam:GenerateMipmaps=False +/processorParam:PremultiplyAlpha=True +/processorParam:ResizeToPowerOfTwo=False +/processorParam:MakeSquare=False +/processorParam:TextureFormat=Color +/build:organic.png + +#begin paper.png +/importer:TextureImporter +/processor:TextureProcessor +/processorParam:ColorKeyColor=255,0,255,255 +/processorParam:ColorKeyEnabled=True +/processorParam:GenerateMipmaps=False +/processorParam:PremultiplyAlpha=True +/processorParam:ResizeToPowerOfTwo=False +/processorParam:MakeSquare=False +/processorParam:TextureFormat=Color +/build:paper.png + +#begin plasticmetal.png +/importer:TextureImporter +/processor:TextureProcessor +/processorParam:ColorKeyColor=255,0,255,255 +/processorParam:ColorKeyEnabled=True +/processorParam:GenerateMipmaps=False +/processorParam:PremultiplyAlpha=True +/processorParam:ResizeToPowerOfTwo=False +/processorParam:MakeSquare=False +/processorParam:TextureFormat=Color +/build:plasticmetal.png + #begin road1.png /importer:TextureImporter /processor:TextureProcessor diff --git a/Trunk/MonoGameView/Content/Dumps/glass.png b/Trunk/MonoGameView/Content/glass.png similarity index 100% rename from Trunk/MonoGameView/Content/Dumps/glass.png rename to Trunk/MonoGameView/Content/glass.png diff --git a/Trunk/MonoGameView/Content/Dumps/organic.png b/Trunk/MonoGameView/Content/organic.png similarity index 100% rename from Trunk/MonoGameView/Content/Dumps/organic.png rename to Trunk/MonoGameView/Content/organic.png diff --git a/Trunk/MonoGameView/Content/Dumps/paper.png b/Trunk/MonoGameView/Content/paper.png similarity index 100% rename from Trunk/MonoGameView/Content/Dumps/paper.png rename to Trunk/MonoGameView/Content/paper.png diff --git a/Trunk/MonoGameView/Content/Dumps/plasticmetal.png b/Trunk/MonoGameView/Content/plasticmetal.png similarity index 100% rename from Trunk/MonoGameView/Content/Dumps/plasticmetal.png rename to Trunk/MonoGameView/Content/plasticmetal.png diff --git a/Trunk/MonoGameView/DataModels/MapLoader.cs b/Trunk/MonoGameView/DataModels/MapLoader.cs index f3fe9b0..29f5fd2 100644 --- a/Trunk/MonoGameView/DataModels/MapLoader.cs +++ b/Trunk/MonoGameView/DataModels/MapLoader.cs @@ -4,8 +4,10 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using System.Xml; +using CzokoŚmieciarka.MonoGameView.DataModels.Enums; 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.Models; using MonoGameView.DataModels.Models; @@ -46,9 +48,65 @@ namespace MonoGameView.DataModels positionNode = objectNode.SelectSingleNode("Position"); x = Convert.ToInt32(positionNode.SelectSingleNode("X").InnerText); y = Convert.ToInt32(positionNode.SelectSingleNode("Y").InnerText); - House house = new House(new Coords(x,y)); + List trashCans = new List(); + foreach (XmlNode trashCanNode in objectNode.SelectSingleNode("TrashCans")) + { + GarbageType type; + switch (trashCanNode.SelectSingleNode("GarbageType").InnerText) + { + case "Glass": + type = GarbageType.Glass; + break; + case "Organic": + type = GarbageType.Organic; + break; + case "Paper": + type = GarbageType.Paper; + break; + default: + type = GarbageType.PlasticMetal; + break; + } + int canDensity = Convert.ToInt32(trashCanNode.SelectSingleNode("Density").InnerText); + int canProcessingTimePerUnit = Convert.ToInt32(trashCanNode.SelectSingleNode("ProcessingTimePerUnit").InnerText); + int volume = Convert.ToInt32(trashCanNode.SelectSingleNode("Volume").InnerText); + TypeOfGarbage canTypeOfGarbage = new TypeOfGarbage(type, canDensity,canProcessingTimePerUnit); + TrashCan trashCan = new TrashCan(canTypeOfGarbage, volume); + trashCans.Add(trashCan); + } + House house = new House(new Coords(x,y), trashCans); grid[x, y] = house; break; + case "Dump": + positionNode = objectNode.SelectSingleNode("Position"); + x = Convert.ToInt32(positionNode.SelectSingleNode("X").InnerText); + y = Convert.ToInt32(positionNode.SelectSingleNode("Y").InnerText); + XmlNode garbageNode = objectNode.SelectSingleNode("Garbage"); + TypeOfGarbage typeOfGarbage; + GarbageType garbageType; + switch (garbageNode.SelectSingleNode("GarbageType").InnerText) + { + case "Glass": + garbageType = GarbageType.Glass; + break; + case "Organic": + garbageType = GarbageType.Organic; + break; + case "Paper": + garbageType = GarbageType.Paper; + break; + default: + garbageType = GarbageType.PlasticMetal; + break; + } + + int density = Convert.ToInt32(garbageNode.SelectSingleNode("Density").InnerText); + int processingTimePerUnit = Convert.ToInt32(garbageNode.SelectSingleNode("ProcessingTimePerUnit").InnerText); + int maxVolume = Convert.ToInt32(objectNode.SelectSingleNode("Volume").InnerText); + typeOfGarbage = new TypeOfGarbage(garbageType, density, processingTimePerUnit); + Dump dump = new Dump(typeOfGarbage, maxVolume, new Coords(x, y)); + grid[x, y] = dump; + break; } } } diff --git a/Trunk/MonoGameView/DataModels/Models/Dump.cs b/Trunk/MonoGameView/DataModels/Models/Dump.cs index 2de111e..585134a 100644 --- a/Trunk/MonoGameView/DataModels/Models/Dump.cs +++ b/Trunk/MonoGameView/DataModels/Models/Dump.cs @@ -1,13 +1,21 @@ 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 MonoGameView.DataModels.Models; namespace CzokoŚmieciarka.MonoGameView.DataModels.GeneralModels.Models { - public class Dump : ADump + public class Dump : ADump, IDrawables { public Dump(ITypeOfGarbage typeOfGarbage, int maxVolume, Coords localization) : base(typeOfGarbage, maxVolume, localization) { } + + public void Draw(SpriteBatch batch, int size) + { + batch.Draw(ImageContainer.GetImage(TypeOfGarbage.GarbageType.ToString()), new Rectangle(Coords.X * 500 / size, Coords.Y * 500 / size, 500 / size, 500 / size), Color.White); + } } } diff --git a/Trunk/MonoGameView/DataModels/Models/House.cs b/Trunk/MonoGameView/DataModels/Models/House.cs index c8be10d..a7a38d6 100644 --- a/Trunk/MonoGameView/DataModels/Models/House.cs +++ b/Trunk/MonoGameView/DataModels/Models/House.cs @@ -1,27 +1,30 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using CzokoŚmieciarka.MonoGameView.DataModels.Interfaces; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Content; -using Microsoft.Xna.Framework.Graphics; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using CzokoŚmieciarka.MonoGameView.DataModels.Interfaces; +using CzokoŚmieciarka.MonoGameView.DataModels.Interfaces.TrashCans; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Content; +using Microsoft.Xna.Framework.Graphics; using MonoGameView.DataModels.Models; -namespace CzokoŚmieciarka.MonoGameView.DataModels.Models -{ - public class House : IDrawables - { - private Coords Coords; - - public House(Coords coords) - { - Coords = coords; - } - 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); - } - } -} +namespace CzokoŚmieciarka.MonoGameView.DataModels.Models +{ + public class House : IDrawables, IGarbageLocalization + { + public Coords Coords { get; } + + public House(Coords coords, IEnumerable trashCans) + { + Coords = coords; + } + 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); + } + + public IEnumerable TrashCans { get; set; } + } +} diff --git a/Trunk/MonoGameView/DataModels/Models/ImageContainer.cs b/Trunk/MonoGameView/DataModels/Models/ImageContainer.cs index be08600..7382ae8 100644 --- a/Trunk/MonoGameView/DataModels/Models/ImageContainer.cs +++ b/Trunk/MonoGameView/DataModels/Models/ImageContainer.cs @@ -21,6 +21,11 @@ namespace MonoGameView.DataModels.Models _container.Images.Add("road2", content.Load("road2")); _container.Images.Add("grass", content.Load("grass")); _container.Images.Add("collector", content.Load("collector")); + _container.Images.Add("Glass", content.Load("glass")); + _container.Images.Add("Paper", content.Load("paper")); + _container.Images.Add("PlasticMetal", content.Load("plasticmetal")); + _container.Images.Add("Organic", content.Load("organic")); + } public static Texture2D GetImage(string s) diff --git a/Trunk/MonoGameView/DataModels/Models/Road1.cs b/Trunk/MonoGameView/DataModels/Models/Road1.cs index b3d2c1f..8996763 100644 --- a/Trunk/MonoGameView/DataModels/Models/Road1.cs +++ b/Trunk/MonoGameView/DataModels/Models/Road1.cs @@ -1,28 +1,28 @@ -using CzokoŚmieciarka.MonoGameView.DataModels.Interfaces; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Content; -using Microsoft.Xna.Framework.Graphics; +using CzokoŚmieciarka.MonoGameView.DataModels.Interfaces; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Content; +using Microsoft.Xna.Framework.Graphics; using MonoGameView.DataModels.Models; -namespace CzokoŚmieciarka.MonoGameView.DataModels.Models -{ - public class Road1 :IRoad1, IDrawables - { - private Coords Coords; - - public Road1(Coords coords) - { - Coords = coords; - } - - 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); - } - } -} +namespace CzokoŚmieciarka.MonoGameView.DataModels.Models +{ + public class Road1 :IRoad1, IDrawables + { + private Coords Coords; + + public Road1(Coords coords) + { + Coords = coords; + } + + 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); + } + } +}