Czoko_Smieciarka/Trunk/MonoGameView/DataModels/Models/House.cs

57 lines
2.6 KiB
C#
Raw Normal View History

2019-04-22 16:50:40 +02:00
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using CzokoŚmieciarka.MonoGameView.DataModels.Enums;
2019-04-23 06:32:35 +02:00
using CzokoŚmieciarka.MonoGameView.DataModels.GeneralModels.Models;
2019-04-22 16:50:40 +02:00
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;
2019-04-22 14:55:47 +02:00
using MonoGameView.DataModels.Models;
2019-04-22 16:50:40 +02:00
namespace CzokoŚmieciarka.MonoGameView.DataModels.Models
{
2019-04-23 06:32:35 +02:00
public class House : IDrawables, IGarbageLocalization, ICloneable
2019-04-22 16:50:40 +02:00
{
public Coords Coords { get; }
2019-05-13 17:57:32 +02:00
public House(Coords coords, List<TrashCan> trashCans)
2019-04-22 16:50:40 +02:00
{
Coords = coords;
2019-05-13 17:57:32 +02:00
TrashCans = trashCans.Select(x=>(x as ATrashCan)).ToList();
2019-04-22 16:50:40 +02:00
}
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);
foreach (TrashCan can in TrashCans)
{
switch (can.Garbage.TypeOfGarbage.GarbageType)
{
case GarbageType.Glass:
batch.Draw(ImageContainer.GetImage("GlassBar"), new Rectangle(Coords.X * 500 / size, Coords.Y * 500 / size, (int)Math.Round(can.FillPercent * 500) / size, 50 / size), Color.White);
break;
case GarbageType.Paper:
batch.Draw(ImageContainer.GetImage("PaperBar"), new Rectangle(Coords.X * 500 / size, Coords.Y * 500 / size + 5, (int)Math.Round(can.FillPercent * 500) / size, 50 / size), Color.White);
break;
case GarbageType.PlasticMetal:
batch.Draw(ImageContainer.GetImage("PlasticMetalBar"), new Rectangle(Coords.X * 500 / size, Coords.Y * 500 / size + 10, (int)Math.Round(can.FillPercent * 500) / size, 50 / size), Color.White);
break;
case GarbageType.Organic:
batch.Draw(ImageContainer.GetImage("OrganicBar"), new Rectangle(Coords.X * 500 / size, Coords.Y * 500 / size + 15, (int)Math.Round(can.FillPercent * 500) / size, 50 / size), Color.White);
break;
}
}
2019-04-22 16:50:40 +02:00
}
2019-04-23 06:32:35 +02:00
public object Clone()
{
return new House((Coords) Coords.Clone(), TrashCans.Select(x => (TrashCan) x.Clone()).ToList());
}
2019-05-13 17:57:32 +02:00
public List<ATrashCan> TrashCans { get; }
2019-04-22 16:50:40 +02:00
}
}