Dodany obiekt Road2 i odświeżanie Boardu z obiektami
This commit is contained in:
parent
e105382084
commit
6071eb60b9
@ -43,7 +43,7 @@ namespace Czoko_Smieciarka.AI_Naive
|
||||
switch (CurrentState)
|
||||
{
|
||||
case State.TravelToDump:
|
||||
if (Destination == Collector.Position)
|
||||
if (Destination == Collector.Coords)
|
||||
{
|
||||
var dump = (DestinationObject as ADump);
|
||||
var step = new SpillStep(Collector, dump, dump.TypeOfGarbage);
|
||||
@ -52,7 +52,7 @@ namespace Czoko_Smieciarka.AI_Naive
|
||||
}
|
||||
else
|
||||
{
|
||||
var dif = Destination - Collector.Position;
|
||||
var dif = Destination - Collector.Coords;
|
||||
Direction nextDirection = (dif.X == 0) ?
|
||||
((dif.Y > 0) ? Direction.Up : Direction.Down) :
|
||||
((dif.X > 0) ? Direction.Right : Direction.Left);
|
||||
@ -62,7 +62,7 @@ namespace Czoko_Smieciarka.AI_Naive
|
||||
}
|
||||
break;
|
||||
case State.TravelToCan:
|
||||
if (Destination == Collector.Position)
|
||||
if (Destination == Collector.Coords)
|
||||
{
|
||||
var garbage = (DestinationObject as IGarbageLocalization);
|
||||
foreach (var item in garbage.TrashCans)
|
||||
@ -75,7 +75,7 @@ namespace Czoko_Smieciarka.AI_Naive
|
||||
}
|
||||
else
|
||||
{
|
||||
var dif = Destination - Collector.Position;
|
||||
var dif = Destination - Collector.Coords;
|
||||
Direction nextDirection = (dif.X == 0) ?
|
||||
((dif.Y > 0) ? Direction.Up : Direction.Down) :
|
||||
((dif.X > 0) ? Direction.Right : Direction.Left);
|
||||
@ -89,7 +89,7 @@ namespace Czoko_Smieciarka.AI_Naive
|
||||
if (notEmpty.Any())
|
||||
{
|
||||
var destDump = Dumps.First(i => i.TypeOfGarbage == notEmpty.First().TypeOfGarbage);
|
||||
this.Destination = destDump.Localization;
|
||||
this.Destination = destDump.Coords;
|
||||
this.CurrentState = State.TravelToDump;
|
||||
}
|
||||
else
|
||||
|
@ -12,29 +12,29 @@ namespace CzokoŚmieciarka.DataModels.Interfaces.GarbageCollector
|
||||
{
|
||||
public AGarbageCollector(Coords startPosition, IEnumerable<AGarbageCollectorContainer> trashContainers)
|
||||
{
|
||||
this.Position = startPosition;
|
||||
this.Coords = startPosition;
|
||||
this.TrashContainers = trashContainers;
|
||||
}
|
||||
public Coords Position { get; set; }
|
||||
public Coords Coords { get; set; }
|
||||
|
||||
public Coords MoveUp()
|
||||
{
|
||||
return new Coords(Position.X,Position.Y+1);
|
||||
return new Coords(Coords.X,Coords.Y+1);
|
||||
}
|
||||
|
||||
public Coords MoveDown()
|
||||
{
|
||||
return new Coords(Position.X, Position.Y - 1);
|
||||
return new Coords(Coords.X, Coords.Y - 1);
|
||||
}
|
||||
|
||||
public Coords MoveLeft()
|
||||
{
|
||||
return new Coords(Position.X-1, Position.Y);
|
||||
return new Coords(Coords.X-1, Coords.Y);
|
||||
}
|
||||
|
||||
public Coords MoveRight()
|
||||
{
|
||||
return new Coords(Position.X+1, Position.Y);
|
||||
return new Coords(Coords.X+1, Coords.Y);
|
||||
}
|
||||
|
||||
public object Clone()
|
||||
|
@ -10,7 +10,7 @@ namespace CzokoŚmieciarka.DataModels.Interfaces
|
||||
{
|
||||
public interface IGarbageCollector : ICloneable
|
||||
{
|
||||
Coords Position { get; }
|
||||
Coords Coords { get; }
|
||||
Coords MoveUp();
|
||||
Coords MoveDown();
|
||||
Coords MoveLeft();
|
||||
|
@ -6,9 +6,9 @@ namespace CzokoŚmieciarka.DataModels.Interfaces.TrashCans
|
||||
{
|
||||
protected ADump(ITypeOfGarbage typeOfGarbage, int maxVolume, Coords localization) : base(typeOfGarbage, maxVolume)
|
||||
{
|
||||
this.Localization = localization;
|
||||
this.Coords = localization;
|
||||
}
|
||||
|
||||
public Coords Localization { get; set; }
|
||||
public Coords Coords { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ namespace CzokoŚmieciarka.DataModels.Models.Steps
|
||||
|
||||
public void Invoke()
|
||||
{
|
||||
if(_garbageCollector.Position != _garbageLocalization.Coords)
|
||||
if(_garbageCollector.Coords != _garbageLocalization.Coords)
|
||||
throw new WrongPositionException("Śmieciarka nie jest w miejscu oderbania śmieci");
|
||||
|
||||
var trashCans = _garbageLocalization.TrashCans.Where(t => t.TypeOfGarbage == _typeOfGarbage);
|
||||
|
@ -23,7 +23,7 @@ namespace CzokoŚmieciarka.DataModels.Models.Steps
|
||||
|
||||
public void Invoke()
|
||||
{
|
||||
if(_garbageCollector.Position != _dump.Localization)
|
||||
if(_garbageCollector.Coords != _dump.Coords)
|
||||
throw new WrongPositionException("Śmieciarka nie na terenie podanego wyspiska");
|
||||
|
||||
if(_dump.TypeOfGarbage != _typeOfGarbage)
|
||||
|
@ -74,6 +74,7 @@
|
||||
<Compile Include="Models\GarbageCollector.cs" />
|
||||
<Compile Include="Models\House.cs" />
|
||||
<Compile Include="Models\Road.cs" />
|
||||
<Compile Include="Models\Road2.cs" />
|
||||
<Compile Include="Properties\Annotations.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs">
|
||||
<SubType>Code</SubType>
|
||||
|
BIN
Trunk/Interface/CzokoŚmieciarka.WPFv2/Images/intersectionRED.png
Normal file
BIN
Trunk/Interface/CzokoŚmieciarka.WPFv2/Images/intersectionRED.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.0 KiB |
@ -5,6 +5,7 @@ using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Media;
|
||||
using CzokoŚmieciarka.DataModels.Models;
|
||||
|
||||
namespace CzokoŚmieciarka.WPFv2.Interfaces
|
||||
{
|
||||
@ -12,5 +13,7 @@ namespace CzokoŚmieciarka.WPFv2.Interfaces
|
||||
{
|
||||
string ImagePath { get; set; }
|
||||
Image Image { get; set; }
|
||||
Coords Coords { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -51,9 +51,16 @@ namespace CzokoŚmieciarka.WPFv2
|
||||
}
|
||||
|
||||
CollectorBoard.Children.Clear();
|
||||
Grid.SetRow(garbageCollector.Image, garbageCollector.Position.Y);
|
||||
Grid.SetColumn(garbageCollector.Image, garbageCollector.Position.X);
|
||||
Grid.SetColumn(garbageCollector.Image, garbageCollector.Coords.X);
|
||||
Grid.SetRow(garbageCollector.Image, garbageCollector.Coords.Y);
|
||||
CollectorBoard.Children.Add(garbageCollector.Image);
|
||||
Board.Children.Clear();
|
||||
foreach (var item in Objects)
|
||||
{
|
||||
Grid.SetColumn(item.Image, item.Coords.X);
|
||||
Grid.SetRow(item.Image, item.Coords.Y);
|
||||
Board.Children.Add(item.Image);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -108,14 +115,14 @@ namespace CzokoŚmieciarka.WPFv2
|
||||
new GarbageCollectorContainer(new TypeOfGarbage(GarbageType.Paper, 1,1), 500)
|
||||
};
|
||||
garbageCollector = new WPFGarbageCollector(new Coords(2, 1), GarbageCollectorContainers);
|
||||
Grid.SetRow(garbageCollector.Image, garbageCollector.Position.Y);
|
||||
Grid.SetColumn(garbageCollector.Image, garbageCollector.Position.X);
|
||||
Grid.SetRow(garbageCollector.Image, garbageCollector.Coords.Y);
|
||||
Grid.SetColumn(garbageCollector.Image, garbageCollector.Coords.X);
|
||||
CollectorBoard.Children.Add(garbageCollector.Image);
|
||||
CollectorBoard.ShowGridLines = true;
|
||||
//CollectorInfo.ItemsSource = garbageCollector.TrashContainers;
|
||||
//CollectorInfo.Items.Add(garbageCollector);
|
||||
//CollectorInfo.Columns.Add(new DataGridTextColumn {Header="X", Binding = new Binding("Position.X")});
|
||||
//CollectorInfo.Columns.Add(new DataGridTextColumn { Header = "Y", Binding = new Binding("Position.Y") });
|
||||
//CollectorInfo.Columns.Add(new DataGridTextColumn {Header="X", Binding = new Binding("Coords.X")});
|
||||
//CollectorInfo.Columns.Add(new DataGridTextColumn { Header = "Y", Binding = new Binding("Coords.Y") });
|
||||
IEnumerable<TrashCan> trashCans = new List<TrashCan>()
|
||||
{
|
||||
new TrashCan(new TypeOfGarbage(GarbageType.Glass,1,1), 500, new Garbage(new TypeOfGarbage(GarbageType.Glass,1,1), 100)),
|
||||
|
@ -15,7 +15,7 @@ namespace CzokoŚmieciarka.WPFv2.Models
|
||||
{
|
||||
class WPFHouse : IGarbageLocalization, IWPFObject
|
||||
{
|
||||
public Coords Coords { get; }
|
||||
public Coords Coords { get; set; }
|
||||
public IEnumerable<ATrashCan> TrashCans { get; set; }
|
||||
public string ImagePath { get; set; }
|
||||
public Image Image { get; set; }
|
||||
|
@ -15,6 +15,7 @@ namespace CzokoŚmieciarka.WPFv2.Models
|
||||
{
|
||||
public string ImagePath { get; set; }
|
||||
public Image Image { get; set; }
|
||||
public Coords Coords { get; set; }
|
||||
|
||||
public Road()
|
||||
{
|
||||
|
28
Trunk/Interface/CzokoŚmieciarka.WPFv2/Models/Road2.cs
Normal file
28
Trunk/Interface/CzokoŚmieciarka.WPFv2/Models/Road2.cs
Normal file
@ -0,0 +1,28 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Media.Imaging;
|
||||
using CzokoŚmieciarka.DataModels.Models;
|
||||
using CzokoŚmieciarka.WPFv2.Interfaces;
|
||||
|
||||
namespace CzokoŚmieciarka.WPFv2.Models
|
||||
{
|
||||
class Road2 : IWPFObject
|
||||
{
|
||||
public string ImagePath { get; set; }
|
||||
public Image Image { get; set; }
|
||||
public Coords Coords { get; set; }
|
||||
|
||||
public Road2()
|
||||
{
|
||||
ImagePath = AppDomain.CurrentDomain.BaseDirectory + @"..\..\Images\intersectionRED.png";
|
||||
Image = new Image
|
||||
{
|
||||
Source = new BitmapImage(new Uri(ImagePath))
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user