coś tam
This commit is contained in:
parent
5e132690da
commit
653e7cc3b7
@ -17,10 +17,9 @@ namespace CzokoŚmieciarka.WPF.Interfaces
|
|||||||
public string Data { get; set; }
|
public string Data { get; set; }
|
||||||
public ImageBrush Image { get; set; }
|
public ImageBrush Image { get; set; }
|
||||||
|
|
||||||
public ImageBrush RefreshImage()
|
public void RefreshImage()
|
||||||
{
|
{
|
||||||
ImageBrush image = new ImageBrush(new BitmapImage(new Uri(ImagePath)));
|
Image = new ImageBrush(new BitmapImage(new Uri(ImagePath)));
|
||||||
return image;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -28,8 +28,8 @@ namespace CzokoŚmieciarka.WPF
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public partial class MainWindow : Window
|
public partial class MainWindow : Window
|
||||||
{
|
{
|
||||||
public GarbageCollector garbageCollector = new GarbageCollector(new Coords(0,0), new List<AGarbageCollectorContainer>());
|
public GarbageCollector garbageCollector = new GarbageCollector(new Coords(1,1), new List<AGarbageCollectorContainer>());
|
||||||
public Board board;
|
//public Board board;
|
||||||
private int rows = 9;
|
private int rows = 9;
|
||||||
private int columns = 9;
|
private int columns = 9;
|
||||||
private List<AObject> Objects = new List<AObject>();
|
private List<AObject> Objects = new List<AObject>();
|
||||||
@ -37,6 +37,8 @@ namespace CzokoŚmieciarka.WPF
|
|||||||
{
|
{
|
||||||
|
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
List<AObject> Objects = new List<AObject>();
|
||||||
|
|
||||||
for (int y = 0; y < rows; y++)
|
for (int y = 0; y < rows; y++)
|
||||||
{
|
{
|
||||||
for(int x = 0; x < columns; x++)
|
for(int x = 0; x < columns; x++)
|
||||||
@ -62,12 +64,36 @@ namespace CzokoŚmieciarka.WPF
|
|||||||
Objects[dump.Location.X + dump.Location.Y] = dump;
|
Objects[dump.Location.X + dump.Location.Y] = dump;
|
||||||
|
|
||||||
|
|
||||||
board = new Board(Objects, garbageCollector);
|
Board board = new Board(Objects, garbageCollector);
|
||||||
this.DataContext = board;
|
this.DataContext = board;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void MainWindow_OnKeyDown(object sender, KeyEventArgs e)
|
private void MainWindow_OnKeyDown(object sender, KeyEventArgs e)
|
||||||
{
|
{
|
||||||
|
List<AObject> Objects = new List<AObject>();
|
||||||
|
for (int y = 0; y < rows; y++)
|
||||||
|
{
|
||||||
|
for (int x = 0; x < columns; x++)
|
||||||
|
{
|
||||||
|
Road road = new Road(columns, new Coords(x, y), AppDomain.CurrentDomain.BaseDirectory + @"..\..\Images\intersection.png");
|
||||||
|
Objects.Add(road);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
House house = new House(columns, new Coords(0, 0));
|
||||||
|
Objects[house.Location.X + house.Location.Y] = house;
|
||||||
|
house = new House(columns, new Coords(1, 0));
|
||||||
|
Objects[house.Location.X + house.Location.Y] = house;
|
||||||
|
house = new House(columns, new Coords(2, 0));
|
||||||
|
Objects[house.Location.X + house.Location.Y] = house;
|
||||||
|
DumpWPF dump = new DumpWPF(columns, new Coords(2, 4), new TypeOfGarbage("glass", 0, 0));
|
||||||
|
Objects[dump.Location.X + dump.Location.Y] = dump;
|
||||||
|
dump = new DumpWPF(columns, new Coords(2, 5), new TypeOfGarbage("plasticmetal", 0, 0));
|
||||||
|
Objects[dump.Location.X + dump.Location.Y] = dump;
|
||||||
|
dump = new DumpWPF(columns, new Coords(3, 4), new TypeOfGarbage("organic", 0, 0));
|
||||||
|
Objects[dump.Location.X + dump.Location.Y] = dump;
|
||||||
|
dump = new DumpWPF(columns, new Coords(3, 5), new TypeOfGarbage("paper", 0, 0));
|
||||||
|
Objects[dump.Location.X + dump.Location.Y] = dump;
|
||||||
if (e.Key == Key.Up)
|
if (e.Key == Key.Up)
|
||||||
{
|
{
|
||||||
garbageCollector.Position.Y -= 1;
|
garbageCollector.Position.Y -= 1;
|
||||||
@ -86,8 +112,9 @@ namespace CzokoŚmieciarka.WPF
|
|||||||
{
|
{
|
||||||
garbageCollector.Position.X += 1;
|
garbageCollector.Position.X += 1;
|
||||||
}
|
}
|
||||||
|
Board board = new Board(Objects, garbageCollector);
|
||||||
this.DataContext = new Board(Objects, garbageCollector);
|
board.BoardRefresh(Objects, garbageCollector);
|
||||||
|
this.DataContext = board;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,7 @@ namespace CzokoŚmieciarka.WPF.Models
|
|||||||
static int _rows = 9;
|
static int _rows = 9;
|
||||||
static int _columns = 9;
|
static int _columns = 9;
|
||||||
List<Tile> _tiles = new List<Tile>();
|
List<Tile> _tiles = new List<Tile>();
|
||||||
private GarbageCollectorWPF garbageCollectorWPF = new GarbageCollectorWPF(_columns, new Coords(0,0), AppDomain.CurrentDomain.BaseDirectory + @"..\..\Images\garbageCollector.png");
|
private GarbageCollectorWPF garbageCollectorWPF = new GarbageCollectorWPF(_columns, new Coords(1,1), AppDomain.CurrentDomain.BaseDirectory + @"..\..\Images\garbageCollector.png");
|
||||||
|
|
||||||
public Board(List<AObject> objects, GarbageCollector garbageCollector)
|
public Board(List<AObject> objects, GarbageCollector garbageCollector)
|
||||||
{
|
{
|
||||||
@ -38,17 +38,23 @@ namespace CzokoŚmieciarka.WPF.Models
|
|||||||
|
|
||||||
public void BoardRefresh(List<AObject> objects, GarbageCollector garbageCollector)
|
public void BoardRefresh(List<AObject> objects, GarbageCollector garbageCollector)
|
||||||
{
|
{
|
||||||
|
List<Tile> tiles = new List<Tile>();
|
||||||
|
|
||||||
foreach (var item in objects)
|
foreach (var item in objects)
|
||||||
{
|
{
|
||||||
_tiles[item.Location.X + item.Location.Y].Object = item;
|
Tile tile = new Tile()
|
||||||
_tiles[item.Location.X + item.Location.Y].Object.Image = _tiles[item.Location.X + item.Location.Y].Object.RefreshImage();
|
{
|
||||||
|
Data = item.Data,
|
||||||
|
Object = item
|
||||||
|
};
|
||||||
|
tiles.Add(tile);
|
||||||
}
|
}
|
||||||
|
|
||||||
garbageCollectorWPF.Move(_columns, garbageCollector);
|
garbageCollectorWPF.Move(_columns, garbageCollector);
|
||||||
_tiles[garbageCollectorWPF.Location.X + garbageCollectorWPF.Location.Y].Object.Image = MergedBitmaps(
|
tiles[garbageCollectorWPF.Location.X + garbageCollectorWPF.Location.Y].Object.Image = MergedBitmaps(
|
||||||
new Bitmap(_tiles[garbageCollectorWPF.Location.X + garbageCollectorWPF.Location.Y].Object.ImagePath),
|
new Bitmap(tiles[garbageCollectorWPF.Location.X + garbageCollectorWPF.Location.Y].Object.ImagePath),
|
||||||
new Bitmap(garbageCollectorWPF.ImagePath));
|
new Bitmap(garbageCollectorWPF.ImagePath));
|
||||||
|
_tiles = tiles;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int Rows
|
public int Rows
|
||||||
|
Loading…
Reference in New Issue
Block a user