public MegaTile(Level containingLevel, Vector2 topLeftLocation, MegaTileType mTileType, int width, int height)
{
//Set the containing level
level = containingLevel;
//Create victims list
victims = new List<Victim>();
//Set location of tile
location = topLeftLocation;
//Set the type of this tile
megaTileType = mTileType;
//Calculate the bounds of this tile
bounds.X = (int)location.X;
bounds.Y = (int)location.Y;
bounds.Width = width;
bounds.Height = height;
//Calculate the bounds for the roads (whether there will be any or not)
westRoadBounds = new Rectangle((int)location.X, (int)location.Y, megaTileType.RoadWidth, bounds.Height);
northRoadBounds = new Rectangle((int)location.X, (int)location.Y, bounds.Width, megaTileType.RoadWidth);
intersectionBounds = new Rectangle((int)location.X, (int)location.Y, megaTileType.RoadWidth, megaTileType.RoadWidth);
//Set whether roads are enabled or not
if (megaTileType.CanHaveRoads)
{
westRoad = true;
northRoad = true;
intersection = true;
}
int maxTries = 1;
int tryCount = 0;
//Look for required victims and add them in first
foreach(MegaTileVictimConfig mtvConfig in megaTileType.PossibleVictims)
{
int genSize = rand.Next(mtvConfig.RequiredPopulation, mtvConfig.MaxPopulation);
//Add in the required number of victims
for (int i = 0; i < genSize; i++)
{
tryCount = 0;
//Try to add the victim a certain number of times
while (!tryAddingVictim(mtvConfig.VictimConfig) && tryCount < maxTries)
{
tryCount++;
}
}
}
}