I'm trying to pass an array that comes from the Base class in the constructor of the Child class, however I feel like there might be conflict in terms of constructors getting called as the getFullArray() method of the Base class returns null.
Base class looks like this:
protected Byte[,] _byteTileArray; //is going to be implemented in child class
private Object[,] objectTileArray;
public Level_Manager(ContentManager content)
{
CreateTileArray();
objectTileArray = new Object[_byteTileArray.GetLength(0), _byteTileArray.GetLength(1)];
CreateWorld(content);
}
protected abstract void CreateTileArray();
private void CreateWorld(ContentManager content)
{
for(int row = 0; row < _byteTileArray.GetLength(0); row++)
{
for (int col = 0; col < _byteTileArray.GetLength(1); col++)
{
switch (_byteTileArray[row,col])
{
case 0: objectTileArray[row, col] = null; break;
case 1: objectTileArray[row, col] = new Cube(new Vector2(col * (852/12), row * (480/7)), content, 124, 33, new Vector2(0, 0)); break;
case 2: objectTileArray[row, col] = new Ladder(new Vector2(col * (852 / 12), row * (480 / 7)-33), content, 50, 107, new Vector2(0, 0)); break;
}
}
}
}
public Object[,] getFullArray(){
return objectTileArray;
}
I need the objectTileArray from getFullArray()
This is the Child class constructor:
private Object[,] arrayObjects;
#endregion
public Level1(ContentManager content, GraphicsDevice device) : base(content)
{
this.content = content;
arrayObjects = getFullArray();
hero = new Hero(new Vector2(1, device.Viewport.Height-40), this.content, arrayObjects);
}
arrayObjects is null here.