Ładowanie mapy z xml'a
@ -25,6 +25,18 @@
|
|||||||
/processorParam:TextureFormat=Color
|
/processorParam:TextureFormat=Color
|
||||||
/build:collector.png
|
/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
|
#begin grass.png
|
||||||
/importer:TextureImporter
|
/importer:TextureImporter
|
||||||
/processor:TextureProcessor
|
/processor:TextureProcessor
|
||||||
@ -49,6 +61,42 @@
|
|||||||
/processorParam:TextureFormat=Color
|
/processorParam:TextureFormat=Color
|
||||||
/build:house.png
|
/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
|
#begin road1.png
|
||||||
/importer:TextureImporter
|
/importer:TextureImporter
|
||||||
/processor:TextureProcessor
|
/processor:TextureProcessor
|
||||||
|
Before Width: | Height: | Size: 83 KiB After Width: | Height: | Size: 83 KiB |
Before Width: | Height: | Size: 100 KiB After Width: | Height: | Size: 100 KiB |
Before Width: | Height: | Size: 85 KiB After Width: | Height: | Size: 85 KiB |
Before Width: | Height: | Size: 52 KiB After Width: | Height: | Size: 52 KiB |
@ -4,8 +4,10 @@ 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.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.Models;
|
using CzokoŚmieciarka.MonoGameView.DataModels.Models;
|
||||||
using MonoGameView.DataModels.Models;
|
using MonoGameView.DataModels.Models;
|
||||||
|
|
||||||
@ -46,9 +48,65 @@ namespace MonoGameView.DataModels
|
|||||||
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);
|
||||||
House house = new House(new Coords(x,y));
|
List<ATrashCan> trashCans = new List<ATrashCan>();
|
||||||
|
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;
|
grid[x, y] = house;
|
||||||
break;
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,13 +1,21 @@
|
|||||||
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 Microsoft.Xna.Framework;
|
||||||
|
using Microsoft.Xna.Framework.Graphics;
|
||||||
|
using MonoGameView.DataModels.Models;
|
||||||
|
|
||||||
namespace CzokoŚmieciarka.MonoGameView.DataModels.GeneralModels.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 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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,27 +1,30 @@
|
|||||||
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 CzokoŚmieciarka.MonoGameView.DataModels.Interfaces;
|
using CzokoŚmieciarka.MonoGameView.DataModels.Interfaces;
|
||||||
using Microsoft.Xna.Framework;
|
using CzokoŚmieciarka.MonoGameView.DataModels.Interfaces.TrashCans;
|
||||||
using Microsoft.Xna.Framework.Content;
|
using Microsoft.Xna.Framework;
|
||||||
using Microsoft.Xna.Framework.Graphics;
|
using Microsoft.Xna.Framework.Content;
|
||||||
|
using Microsoft.Xna.Framework.Graphics;
|
||||||
using MonoGameView.DataModels.Models;
|
using MonoGameView.DataModels.Models;
|
||||||
|
|
||||||
namespace CzokoŚmieciarka.MonoGameView.DataModels.Models
|
namespace CzokoŚmieciarka.MonoGameView.DataModels.Models
|
||||||
{
|
{
|
||||||
public class House : IDrawables
|
public class House : IDrawables, IGarbageLocalization
|
||||||
{
|
{
|
||||||
private Coords Coords;
|
public Coords Coords { get; }
|
||||||
|
|
||||||
public House(Coords coords)
|
public House(Coords coords, IEnumerable<ATrashCan> trashCans)
|
||||||
{
|
{
|
||||||
Coords = coords;
|
Coords = coords;
|
||||||
}
|
}
|
||||||
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 IEnumerable<ATrashCan> TrashCans { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -21,6 +21,11 @@ namespace MonoGameView.DataModels.Models
|
|||||||
_container.Images.Add("road2", content.Load<Texture2D>("road2"));
|
_container.Images.Add("road2", content.Load<Texture2D>("road2"));
|
||||||
_container.Images.Add("grass", content.Load<Texture2D>("grass"));
|
_container.Images.Add("grass", content.Load<Texture2D>("grass"));
|
||||||
_container.Images.Add("collector", content.Load<Texture2D>("collector"));
|
_container.Images.Add("collector", content.Load<Texture2D>("collector"));
|
||||||
|
_container.Images.Add("Glass", content.Load<Texture2D>("glass"));
|
||||||
|
_container.Images.Add("Paper", content.Load<Texture2D>("paper"));
|
||||||
|
_container.Images.Add("PlasticMetal", content.Load<Texture2D>("plasticmetal"));
|
||||||
|
_container.Images.Add("Organic", content.Load<Texture2D>("organic"));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Texture2D GetImage(string s)
|
public static Texture2D GetImage(string s)
|
||||||
|
@ -1,28 +1,28 @@
|
|||||||
using CzokoŚmieciarka.MonoGameView.DataModels.Interfaces;
|
using CzokoŚmieciarka.MonoGameView.DataModels.Interfaces;
|
||||||
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 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 MonoGameView.DataModels.Models;
|
using MonoGameView.DataModels.Models;
|
||||||
|
|
||||||
namespace CzokoŚmieciarka.MonoGameView.DataModels.Models
|
namespace CzokoŚmieciarka.MonoGameView.DataModels.Models
|
||||||
{
|
{
|
||||||
public class Road1 :IRoad1, IDrawables
|
public class Road1 :IRoad1, IDrawables
|
||||||
{
|
{
|
||||||
private Coords Coords;
|
private Coords Coords;
|
||||||
|
|
||||||
public Road1(Coords coords)
|
public Road1(Coords coords)
|
||||||
{
|
{
|
||||||
Coords = coords;
|
Coords = coords;
|
||||||
}
|
}
|
||||||
|
|
||||||
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|