namespace RichStrat
{
public abstract class Hex
{
public List<long> unitIds;
}
}
namespace RichStrat
{
public class HexC: Hex
{
public Terr terr;
public HexC()
{
terr = Terr.Plain;
unitIds = new List<long> { };
}
}
}
namespace RichStrat
{
public abstract class Scenario
{
public long xDim;
public long yDim;
public DateTime currGameTime;
public Hex[,] hexs;
public List<Unit> units;
}
}
namespace RichStrat
{
public class ScenarioC: Scenario //The Core Database for the game scenario. Theoretically multiple secenarios can be loaded into memory at the same time
{
public HexC[,] hexs; /But when I comment this line out it still compiles
public ScenarioU[] userView; // A database for every user and AI entity
public ScenarioC(TestScenario t)
{
xDim = 4;
yDim = 5;
hexs = new HexC[xDim, yDim];
for (long x = 0; x < xDim; x++)
{
for (long y = 0; y < yDim; y++)
hexs[x, y] = new HexC();
}
units = new List<Unit> () {};
units.Add(new Unit(this, units.Count, 3,3));
}
public void InitUserData()
{
}
}
}
But when I comment out the line:
public: HexC[,] hexs; // It still compiles.
Haven't I just instantiated an abstract class?
Edit: Ah silly me! I've just realised that I'm not instantiating any Hex only an array of Hex.Should I be using an interface instead here to force the derived Classes of scenario to implement a Hex derived Class?