zmiana pozycji obiektu smieciarki z interfejsu dla logiki

This commit is contained in:
Michał Dulski 2019-03-27 02:00:58 +01:00
parent 56d2a4ff75
commit 70b821ce36
5 changed files with 29 additions and 16 deletions

View File

@ -15,7 +15,7 @@ namespace CzokoŚmieciarka.DataModels.Interfaces.GarbageCollector
this.Position = startPosition;
this.TrashContainers = trashContainers;
}
public Coords Position { get; }
public Coords Position { get; set; }
public Coords MoveUp()
{

View File

@ -10,7 +10,6 @@ namespace CzokoŚmieciarka.WPF.Models
{
public interface IObject
{
Coords Location { get; set; }
string ImagePath { get; set; }
string Data { get; set; }
ImageBrush Image { get; set; }

View File

@ -32,7 +32,7 @@ namespace CzokoŚmieciarka.WPF
//public Board board;
private static int rows = 9;
private static int columns = 9;
private GarbageCollectorWPF garbageCollector = new GarbageCollectorWPF(columns, new Coords(0, 0), AppDomain.CurrentDomain.BaseDirectory + @"..\..\Images\garbageCollector.png");
private GarbageCollectorWPF garbageCollector = new GarbageCollectorWPF(columns, new Coords(0, 0), AppDomain.CurrentDomain.BaseDirectory + @"..\..\Images\garbageCollector.png", new List<AGarbageCollectorContainer>());
private List<AObject> Objects = new List<AObject>();
public MainWindow()
{

View File

@ -9,35 +9,46 @@ using System.Windows.Media;
using System.Windows.Media.Imaging;
using CzokoŚmieciarka.DataModels.Enums;
using CzokoŚmieciarka.DataModels.GeneralModels.Models;
using CzokoŚmieciarka.DataModels.Interfaces.GarbageCollector;
using CzokoŚmieciarka.DataModels.Interfaces.TrashCans;
using CzokoŚmieciarka.DataModels.Models;
using CzokoŚmieciarka.WPF.Annotations;
using CzokoŚmieciarka.WPF.Interfaces;
namespace CzokoŚmieciarka.WPF.Models
{
public class GarbageCollectorWPF : AObject, INotifyPropertyChanged
public class GarbageCollectorWPF : AGarbageCollector, IObject, INotifyPropertyChanged
{
public Coords Location { get; set; }
public string ImagePath { get; set; }
public string Data { get; set; }
public ImageBrush Image { get; set; }
public void Move(int columns, Direction direction)
{
switch (direction)
{
case (Direction.Up):
Location.Y = Location.Y + (-1 * columns);
Position = this.MoveUp();
break;
case (Direction.Down):
Location.Y = Location.Y + (1 * columns);
Position = this.MoveDown();
break;
case (Direction.Left):
Location.X = Location.X + (-1);
Position = this.MoveLeft();
break;
case (Direction.Right):
Location.X = Location.X + (1);
Position = this.MoveRight();
break;
}
}
public GarbageCollectorWPF(int columns,Coords location, string imagePath)
public GarbageCollectorWPF(int columns, Coords location, string imagePath, IEnumerable<AGarbageCollectorContainer> trashContainers) : base(location, trashContainers)
{
Location = new Coords(location.X, location.Y * columns);
ImagePath = imagePath;
@ -51,5 +62,8 @@ namespace CzokoŚmieciarka.WPF.Models
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
}
}