Dzień dobry,
#EDITED
Mam pewien problem, pokażę od razu na kodzie:
public partial class GameWindow : Window
{
private Player _player;
private Maze _maze;
private Point _dim;
private int _count = 0;
static protected Random rand = new Random();
protected const int lineLengh = 20;
protected const int bound = 25;
protected Point start, exit;
public GameWindow(int w, int h)
{
InitializeComponent();
InitializeObjects(w, h);
this.Width = bound * 3 + (lineLengh * w) - lineLengh;
this.Height = bound * 4 + (lineLengh * h);
// Setting position of objects on grid
SettingPositions();
// Render maze
_maze.RenderMaze(gameGrid);
// Render player at start position
_player.Render(gameGrid);
}
private void InitializeObjects(int w, int h)
{
start = new Point(0, RandomInt(0, h));
exit = new Point(w, RandomInt(0, h));
_dim = new Point(w, h);
_maze = new Maze(w, h);
_player = new Player(start);
}
}
public class Maze : GameWindow
{
private bool[,] _v = new bool[5, 5];
public Maze(int w, int h)
{
_v[start.X, start.Y] = false;
}
public class Point : GameWindow
{
private int _x, _y;
public Point(int a, int b)
{
_x = a;
_y = b;
}
public Point(Point p)
{
_x = p.X;
_y = p.Y;
}
public Point() { }
public int X
{
get { return _x; }
set { _x = value; }
}
public int Y
{
get { return _y; }
set { _y = value; }
}
}
Chodzi o to, że w miejscu: (_v[start.X, start.Y] = false;) - linia 21 dostaję błąd: Additional information: Odwołanie do obiektu nie zostało ustawione na wystąpienie obiektu.
Moje pytanie: w klasie GameWindow wartość start dobrze się inicjuje ale za to w klasie Maze, która dziedziczy po klasie GameWindow tak jakby tej wartości "nie widzi", chociaż jest ona protected. Dlaczego? Jak przekazać tę wartość to klasy Maze?