zmiana pozycji obiektu smieciarki z interfejsu dla logiki
This commit is contained in:
parent
56d2a4ff75
commit
70b821ce36
@ -15,7 +15,7 @@ namespace CzokoŚmieciarka.DataModels.Interfaces.GarbageCollector
|
|||||||
this.Position = startPosition;
|
this.Position = startPosition;
|
||||||
this.TrashContainers = trashContainers;
|
this.TrashContainers = trashContainers;
|
||||||
}
|
}
|
||||||
public Coords Position { get; }
|
public Coords Position { get; set; }
|
||||||
|
|
||||||
public Coords MoveUp()
|
public Coords MoveUp()
|
||||||
{
|
{
|
||||||
|
@ -10,7 +10,6 @@ namespace CzokoŚmieciarka.WPF.Models
|
|||||||
{
|
{
|
||||||
public interface IObject
|
public interface IObject
|
||||||
{
|
{
|
||||||
Coords Location { get; set; }
|
|
||||||
string ImagePath { get; set; }
|
string ImagePath { get; set; }
|
||||||
string Data { get; set; }
|
string Data { get; set; }
|
||||||
ImageBrush Image { get; set; }
|
ImageBrush Image { get; set; }
|
||||||
|
@ -32,7 +32,7 @@ namespace CzokoŚmieciarka.WPF
|
|||||||
//public Board board;
|
//public Board board;
|
||||||
private static int rows = 9;
|
private static int rows = 9;
|
||||||
private static int columns = 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>();
|
private List<AObject> Objects = new List<AObject>();
|
||||||
public MainWindow()
|
public MainWindow()
|
||||||
{
|
{
|
||||||
|
@ -9,35 +9,46 @@ using System.Windows.Media;
|
|||||||
using System.Windows.Media.Imaging;
|
using System.Windows.Media.Imaging;
|
||||||
using CzokoŚmieciarka.DataModels.Enums;
|
using CzokoŚmieciarka.DataModels.Enums;
|
||||||
using CzokoŚmieciarka.DataModels.GeneralModels.Models;
|
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.DataModels.Models;
|
||||||
using CzokoŚmieciarka.WPF.Annotations;
|
using CzokoŚmieciarka.WPF.Annotations;
|
||||||
using CzokoŚmieciarka.WPF.Interfaces;
|
using CzokoŚmieciarka.WPF.Interfaces;
|
||||||
|
|
||||||
namespace CzokoŚmieciarka.WPF.Models
|
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)
|
public void Move(int columns, Direction direction)
|
||||||
{
|
{
|
||||||
switch (direction)
|
switch (direction)
|
||||||
{
|
{
|
||||||
case (Direction.Up):
|
case (Direction.Up):
|
||||||
Location.Y = Location.Y + (-1 * columns);
|
Location.Y = Location.Y + (-1 * columns);
|
||||||
|
Position = this.MoveUp();
|
||||||
break;
|
break;
|
||||||
case (Direction.Down):
|
case (Direction.Down):
|
||||||
Location.Y = Location.Y + (1 * columns);
|
Location.Y = Location.Y + (1 * columns);
|
||||||
|
Position = this.MoveDown();
|
||||||
break;
|
break;
|
||||||
case (Direction.Left):
|
case (Direction.Left):
|
||||||
Location.X = Location.X + (-1);
|
Location.X = Location.X + (-1);
|
||||||
|
Position = this.MoveLeft();
|
||||||
break;
|
break;
|
||||||
case (Direction.Right):
|
case (Direction.Right):
|
||||||
Location.X = Location.X + (1);
|
Location.X = Location.X + (1);
|
||||||
|
Position = this.MoveRight();
|
||||||
|
|
||||||
break;
|
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);
|
Location = new Coords(location.X, location.Y * columns);
|
||||||
ImagePath = imagePath;
|
ImagePath = imagePath;
|
||||||
@ -51,5 +62,8 @@ namespace CzokoŚmieciarka.WPF.Models
|
|||||||
{
|
{
|
||||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user