Czoko_Smieciarka/Trunk/MonoGameView/DataModels/Models/House.cs
2019-05-14 23:05:37 +02:00

57 lines
2.8 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
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.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, IGarbageLocalization, ICloneable
{
public Coords Coords { get; }
public House(Coords coords, List<TrashCan> trashCans)
{
Coords = coords;
TrashCans = trashCans.Select(x=>(x as ATrashCan)).ToList();
}
public void Draw(SpriteBatch batch, int size,int width)
{
batch.Draw(ImageContainer.GetImage("house"), new Rectangle(Coords.X * width / size, Coords.Y * width / size, width / size, width / size), Color.White);
foreach (TrashCan can in TrashCans)
{
switch (can.Garbage.TypeOfGarbage.GarbageType)
{
case GarbageType.Glass:
batch.Draw(ImageContainer.GetImage("GlassBar"), new Rectangle(Coords.X * width / size, Coords.Y * width / size + width/200, (int)Math.Round(can.FillPercent * width) / size, width/5 / size), Color.White);
break;
case GarbageType.Paper:
batch.Draw(ImageContainer.GetImage("PaperBar"), new Rectangle(Coords.X * width / size, Coords.Y * width / size + 2*width / 200, (int)Math.Round(can.FillPercent * width) / size, width/5 / size), Color.White);
break;
case GarbageType.PlasticMetal:
batch.Draw(ImageContainer.GetImage("PlasticMetalBar"), new Rectangle(Coords.X * width / size, Coords.Y * width / size + 3*width / 200, (int)Math.Round(can.FillPercent * width) / size, width/5 / size), Color.White);
break;
case GarbageType.Organic:
batch.Draw(ImageContainer.GetImage("OrganicBar"), new Rectangle(Coords.X * width / size, Coords.Y * width / size + 4*width / 200, (int)Math.Round(can.FillPercent * width) / size, width/5 / size), Color.White);
break;
}
}
}
public object Clone()
{
return new House((Coords) Coords.Clone(), TrashCans.Select(x => (TrashCan) x.Clone()).ToList());
}
public List<ATrashCan> TrashCans { get; }
}
}