Wyświetlanie pasków zapełnienia śmieciarki i wysypisk
This commit is contained in:
parent
c3b0d5f609
commit
d2ccf63523
@ -6,8 +6,29 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace MonoGameView.DataModels
|
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()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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.Interfaces.TrashCans;
|
||||||
using CzokoŚmieciarka.MonoGameView.DataModels.Models;
|
using CzokoŚmieciarka.MonoGameView.DataModels.Models;
|
||||||
using Microsoft.Xna.Framework;
|
using Microsoft.Xna.Framework;
|
||||||
@ -16,6 +17,7 @@ namespace CzokoŚmieciarka.MonoGameView.DataModels.GeneralModels.Models
|
|||||||
public void Draw(SpriteBatch batch, int size)
|
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()), 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()
|
public override object Clone()
|
||||||
|
@ -3,6 +3,7 @@ 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.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.Interfaces.TrashCans;
|
||||||
@ -25,11 +26,24 @@ namespace CzokoŚmieciarka.MonoGameView.DataModels.Models
|
|||||||
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);
|
||||||
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);
|
foreach (TrashCan can in TrashCans)
|
||||||
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);
|
switch (can.Garbage.TypeOfGarbage.GarbageType)
|
||||||
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);
|
{
|
||||||
|
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()
|
public object Clone()
|
||||||
|
@ -38,7 +38,7 @@ namespace CzokoŚmieciarka.MonoGameView
|
|||||||
List<IStep> steps;
|
List<IStep> steps;
|
||||||
GarbageCollector collector;
|
GarbageCollector collector;
|
||||||
IDrawables[,] grid;
|
IDrawables[,] grid;
|
||||||
Displayer displayer = new Displayer(){Content = new Dictionary<string, string>()};
|
Displayer displayer = new Displayer();
|
||||||
|
|
||||||
|
|
||||||
public Game1()
|
public Game1()
|
||||||
@ -64,28 +64,28 @@ namespace CzokoŚmieciarka.MonoGameView
|
|||||||
// TODO: Add your initialization logic here
|
// TODO: Add your initialization logic here
|
||||||
timer = 0f;
|
timer = 0f;
|
||||||
|
|
||||||
mapLoader.Load(out size,out grid,"map2.xml");
|
mapLoader.Load(out size,out grid,"map3.xml");
|
||||||
var containers = new List<GarbageCollectorContainer>()
|
var containers = new List<GarbageCollectorContainer>()
|
||||||
{
|
{
|
||||||
new GarbageCollectorContainer(
|
new GarbageCollectorContainer(
|
||||||
new TypeOfGarbage(GarbageType.Glass,1),
|
new TypeOfGarbage(GarbageType.Glass,1),
|
||||||
1000,
|
10000,
|
||||||
new BasicGarbage(new TypeOfGarbage(GarbageType.Glass,1),0)
|
new BasicGarbage(new TypeOfGarbage(GarbageType.Glass,1),0)
|
||||||
),
|
),
|
||||||
new GarbageCollectorContainer(
|
new GarbageCollectorContainer(
|
||||||
new TypeOfGarbage(GarbageType.Paper,1),
|
new TypeOfGarbage(GarbageType.Paper,1),
|
||||||
1000,
|
10000,
|
||||||
new BasicGarbage(new TypeOfGarbage(GarbageType.Glass,1),0)
|
new BasicGarbage(new TypeOfGarbage(GarbageType.Paper,1),0)
|
||||||
),
|
),
|
||||||
new GarbageCollectorContainer(
|
new GarbageCollectorContainer(
|
||||||
new TypeOfGarbage(GarbageType.Organic,1),
|
new TypeOfGarbage(GarbageType.Organic,1),
|
||||||
1000,
|
10000,
|
||||||
new BasicGarbage(new TypeOfGarbage(GarbageType.Glass,1),0)
|
new BasicGarbage(new TypeOfGarbage(GarbageType.Organic,1),0)
|
||||||
),
|
),
|
||||||
new GarbageCollectorContainer(
|
new GarbageCollectorContainer(
|
||||||
new TypeOfGarbage(GarbageType.PlasticMetal,1),
|
new TypeOfGarbage(GarbageType.PlasticMetal,1),
|
||||||
1000,
|
10000,
|
||||||
new BasicGarbage(new TypeOfGarbage(GarbageType.Glass,1),0)
|
new BasicGarbage(new TypeOfGarbage(GarbageType.PlasticMetal,1),0)
|
||||||
),
|
),
|
||||||
|
|
||||||
};
|
};
|
||||||
@ -93,7 +93,7 @@ namespace CzokoŚmieciarka.MonoGameView
|
|||||||
|
|
||||||
|
|
||||||
stepN = 0;
|
stepN = 0;
|
||||||
var dfs = new BFS(collector,grid);
|
var dfs = new DFS(collector,grid);
|
||||||
//steps = dfs.BestPath(Content, collector, grid);
|
//steps = dfs.BestPath(Content, collector, grid);
|
||||||
new Thread(delegate() {
|
new Thread(delegate() {
|
||||||
var x = dfs.BestPath(Content, collector, grid);
|
var x = dfs.BestPath(Content, collector, grid);
|
||||||
@ -148,15 +148,19 @@ namespace CzokoŚmieciarka.MonoGameView
|
|||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
// TODO: Add your update logic here
|
// TODO: Add your update logic here
|
||||||
|
var barsDictionary = new Dictionary<string, int>();
|
||||||
var collectorDictionary = new Dictionary<string, string>
|
var collectorDictionary = new Dictionary<string, string>
|
||||||
{
|
{
|
||||||
{"Garbage Collector Info", ""},
|
{"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()}
|
|
||||||
};
|
};
|
||||||
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);
|
base.Update(gameTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -177,7 +181,7 @@ namespace CzokoŚmieciarka.MonoGameView
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
collector.Draw(spriteBatch, size);
|
collector.Draw(spriteBatch, size);
|
||||||
Display(displayer.Content);
|
Display(displayer.info, displayer.barsPercent);
|
||||||
|
|
||||||
spriteBatch.End();
|
spriteBatch.End();
|
||||||
// TODO: Add your drawing code here
|
// TODO: Add your drawing code here
|
||||||
@ -188,7 +192,7 @@ namespace CzokoŚmieciarka.MonoGameView
|
|||||||
///
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="info"></param>
|
/// <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 x = 510;
|
||||||
int y = 10;
|
int y = 10;
|
||||||
@ -198,7 +202,15 @@ namespace CzokoŚmieciarka.MonoGameView
|
|||||||
y += 15;
|
y += 15;
|
||||||
spriteBatch.DrawString(font, item.Value, new Vector2(x, y), Color.White);
|
spriteBatch.DrawString(font, item.Value, new Vector2(x, y), Color.White);
|
||||||
y += 30;
|
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
|
||||||
|
{
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -716,7 +716,7 @@
|
|||||||
</ProcessingTimePerUnit>
|
</ProcessingTimePerUnit>
|
||||||
</Garbage>
|
</Garbage>
|
||||||
<Volume>
|
<Volume>
|
||||||
100
|
100000
|
||||||
</Volume>
|
</Volume>
|
||||||
</Object>
|
</Object>
|
||||||
<Object>
|
<Object>
|
||||||
@ -743,7 +743,7 @@
|
|||||||
</ProcessingTimePerUnit>
|
</ProcessingTimePerUnit>
|
||||||
</Garbage>
|
</Garbage>
|
||||||
<Volume>
|
<Volume>
|
||||||
100
|
100000
|
||||||
</Volume>
|
</Volume>
|
||||||
</Object>
|
</Object>
|
||||||
<Object>
|
<Object>
|
||||||
@ -874,7 +874,7 @@
|
|||||||
</ProcessingTimePerUnit>
|
</ProcessingTimePerUnit>
|
||||||
</Garbage>
|
</Garbage>
|
||||||
<Volume>
|
<Volume>
|
||||||
100
|
100000
|
||||||
</Volume>
|
</Volume>
|
||||||
</Object>
|
</Object>
|
||||||
<Object>
|
<Object>
|
||||||
@ -901,7 +901,7 @@
|
|||||||
</ProcessingTimePerUnit>
|
</ProcessingTimePerUnit>
|
||||||
</Garbage>
|
</Garbage>
|
||||||
<Volume>
|
<Volume>
|
||||||
100
|
100000
|
||||||
</Volume>
|
</Volume>
|
||||||
</Object>
|
</Object>
|
||||||
<Object>
|
<Object>
|
||||||
|
Loading…
Reference in New Issue
Block a user