This commit is contained in:
ryuga4 2019-05-14 17:39:04 +02:00
commit ef2ef838a2
5 changed files with 79 additions and 30 deletions

View File

@ -6,8 +6,29 @@ using System.Threading.Tasks;
namespace MonoGameView.DataModels
{
public class Displayer
public sealed class Displayer
{
public Dictionary<string,string> Content { get; set; }
static Displayer _container = null;
public Dictionary<string, int> barsPercent { get; set; }
public Dictionary<string, string> info { get; set; }
public static int GetPercent(string s)
{
return _container.barsPercent[s];
}
public void SetInfo(Dictionary<string, string> _info)
{
info = _info;
}
public void SetBars(Dictionary<string, int> barsPercent)
{
this.barsPercent = barsPercent;
}
public Displayer()
{
}
}
}

View File

@ -1,4 +1,5 @@
using CzokoŚmieciarka.MonoGameView.DataModels.Interfaces;
using System;
using CzokoŚmieciarka.MonoGameView.DataModels.Interfaces;
using CzokoŚmieciarka.MonoGameView.DataModels.Interfaces.TrashCans;
using CzokoŚmieciarka.MonoGameView.DataModels.Models;
using Microsoft.Xna.Framework;
@ -16,6 +17,7 @@ namespace CzokoŚmieciarka.MonoGameView.DataModels.GeneralModels.Models
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);
batch.Draw(ImageContainer.GetImage(TypeOfGarbage.GarbageType.ToString()+"Bar"), new Rectangle(Coords.X * 500 / size, Coords.Y * 500 / size, (int)Math.Round(FillPercent * 500) / size, 50 / size), Color.White);
}
public override object Clone()

View File

@ -3,6 +3,7 @@ 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;
@ -25,11 +26,24 @@ namespace CzokoŚmieciarka.MonoGameView.DataModels.Models
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("GlassBar"), new Rectangle(Coords.X * 500 / size, Coords.Y * 500 / size, (int)Math.Round(TrashCans.ElementAtOrDefault(0).FillPercent*500) / size, 50 / size), Color.White);
batch.Draw(ImageContainer.GetImage("PaperBar"), new Rectangle(Coords.X * 500 / size, Coords.Y * 500 / size + 5, (int)Math.Round(TrashCans.ElementAtOrDefault(1).FillPercent * 500) / size, 50 / size), Color.White);
batch.Draw(ImageContainer.GetImage("PlasticMetalBar"), new Rectangle(Coords.X * 500 / size, Coords.Y * 500 / size + 10, (int)Math.Round(TrashCans.ElementAtOrDefault(2).FillPercent * 500) / size, 50 / size), Color.White);
batch.Draw(ImageContainer.GetImage("OrganicBar"), new Rectangle(Coords.X * 500 / size, Coords.Y * 500 / size + 15, (int)Math.Round(TrashCans.ElementAtOrDefault(3).FillPercent * 500) / size, 50 / 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;
}
}
}
public object Clone()

View File

@ -38,7 +38,7 @@ namespace CzokoŚmieciarka.MonoGameView
List<IStep> steps;
GarbageCollector collector;
IDrawables[,] grid;
Displayer displayer = new Displayer(){Content = new Dictionary<string, string>()};
Displayer displayer = new Displayer();
public Game1()
@ -64,28 +64,28 @@ namespace CzokoŚmieciarka.MonoGameView
// TODO: Add your initialization logic here
timer = 0f;
mapLoader.Load(out size,out grid,"map2.xml");
mapLoader.Load(out size,out grid,"map3.xml");
var containers = new List<GarbageCollectorContainer>()
{
new GarbageCollectorContainer(
new TypeOfGarbage(GarbageType.Glass,1),
1000,
10000,
new BasicGarbage(new TypeOfGarbage(GarbageType.Glass,1),0)
),
new GarbageCollectorContainer(
new TypeOfGarbage(GarbageType.Paper,1),
1000,
new BasicGarbage(new TypeOfGarbage(GarbageType.Glass,1),0)
10000,
new BasicGarbage(new TypeOfGarbage(GarbageType.Paper,1),0)
),
new GarbageCollectorContainer(
new TypeOfGarbage(GarbageType.Organic,1),
1000,
new BasicGarbage(new TypeOfGarbage(GarbageType.Glass,1),0)
10000,
new BasicGarbage(new TypeOfGarbage(GarbageType.Organic,1),0)
),
new GarbageCollectorContainer(
new TypeOfGarbage(GarbageType.PlasticMetal,1),
1000,
new BasicGarbage(new TypeOfGarbage(GarbageType.Glass,1),0)
10000,
new BasicGarbage(new TypeOfGarbage(GarbageType.PlasticMetal,1),0)
),
};
@ -148,15 +148,19 @@ namespace CzokoŚmieciarka.MonoGameView
}
*/
// TODO: Add your update logic here
var barsDictionary = new Dictionary<string, int>();
var collectorDictionary = new Dictionary<string, string>
{
{"Garbage Collector Info", ""},
{collector.TrashContainers.ElementAtOrDefault(0).TypeOfGarbage.GarbageType.ToString(), collector.TrashContainers.ElementAtOrDefault(0).Garbage.Weight.ToString()},
{collector.TrashContainers.ElementAtOrDefault(1).TypeOfGarbage.GarbageType.ToString(), collector.TrashContainers.ElementAtOrDefault(1).Garbage.Weight.ToString()},
{collector.TrashContainers.ElementAtOrDefault(2).TypeOfGarbage.GarbageType.ToString(), collector.TrashContainers.ElementAtOrDefault(2).Garbage.Weight.ToString()},
{collector.TrashContainers.ElementAtOrDefault(3).TypeOfGarbage.GarbageType.ToString(), collector.TrashContainers.ElementAtOrDefault(3).Garbage.Weight.ToString()}
{"Garbage Collector Info", ""}
};
displayer.Content = collectorDictionary;
foreach (GarbageCollectorContainer container in collector.TrashContainers)
{
collectorDictionary.Add(container.TypeOfGarbage.GarbageType.ToString(), container.Garbage.Weight.ToString());
barsDictionary.Add(container.TypeOfGarbage.GarbageType.ToString(), (int) Math.Round(container.FillPercent * 100));
}
displayer.info = collectorDictionary;
displayer.barsPercent = barsDictionary;
base.Update(gameTime);
}
@ -177,7 +181,7 @@ namespace CzokoŚmieciarka.MonoGameView
}
}
collector.Draw(spriteBatch, size);
Display(displayer.Content);
Display(displayer.info, displayer.barsPercent);
spriteBatch.End();
// TODO: Add your drawing code here
@ -188,7 +192,7 @@ namespace CzokoŚmieciarka.MonoGameView
///
/// </summary>
/// <param name="info"></param>
public void Display(Dictionary<string, string> info)
public void Display(Dictionary<string, string> info, Dictionary<string,int> barInfo)
{
int x = 510;
int y = 10;
@ -198,7 +202,15 @@ namespace CzokoŚmieciarka.MonoGameView
y += 15;
spriteBatch.DrawString(font, item.Value, new Vector2(x, y), Color.White);
y += 30;
try
{
var bar = barInfo[item.Key];
spriteBatch.Draw(ImageContainer.GetImage(item.Key+"Bar"), new Rectangle(x, y, bar * 40, 10), Color.White);
y += 50;
}
catch
{
}
}
}
}

View File

@ -716,7 +716,7 @@
</ProcessingTimePerUnit>
</Garbage>
<Volume>
100
100000
</Volume>
</Object>
<Object>
@ -743,7 +743,7 @@
</ProcessingTimePerUnit>
</Garbage>
<Volume>
100
100000
</Volume>
</Object>
<Object>
@ -874,7 +874,7 @@
</ProcessingTimePerUnit>
</Garbage>
<Volume>
100
100000
</Volume>
</Object>
<Object>
@ -901,7 +901,7 @@
</ProcessingTimePerUnit>
</Garbage>
<Volume>
100
100000
</Volume>
</Object>
<Object>