public BuildingFactory(Tile[,] tiledata) { Buildings = new Building[tiledata.GetUpperBound(0), tiledata.GetUpperBound(1), Assets.BUILDINGHEIGHT]; //Colors Colors.Add(Color.Beige); Colors.Add(Color.Bisque); Colors.Add(Color.BlanchedAlmond); Colors.Add(Color.Khaki); Colors.Add(Color.Moccasin); Colors.Add(Color.NavajoWhite); Colors.Add(Color.Sienna); Colors.Add(Color.Tan); Colors.Add(Color.Gray); Colors.Add(Color.DarkGray); AddBuildings(tiledata); AddFeatures(tiledata); AddPlants(tiledata); AddRoofs(); AddStructures(tiledata); }
private void AddFeatures(Tile[,] tiledata) { for (int y = 0; y <= Buildings.GetUpperBound(1); y++) { for (int x = 0; x <= Buildings.GetUpperBound(0); x++) { //Generate Doors if (Buildings[x, y, 0].Texture == Assets.BOTTOMBLANKBLOCK) { if (Assets.RandomBool()) Buildings[x, y, 0].FeatureTexture = Assets.EMPTY; else { Buildings[x, y, 0].FeatureTexture = Assets.DOOR; //Checks to see if there is an adjacent road it can flip the door to. If not, then delete the door, if (x != 0 && tiledata[x - 1, y].Texture == Assets.ROAD) Buildings[x, y, 0].FeatureFlip = true; else if (y >= tiledata.GetUpperBound(1) && tiledata[x, y + 1].Texture == Assets.ROAD) Buildings[x, y, 0].FeatureFlip = false; else //If there isn't a road to align to, try making windows instead. { if (Assets.RandomBool()) Buildings[x, y, 0].FeatureTexture = Assets.Windows[Assets.Random.Next(0, Assets.Windows.Count)]; else Buildings[x, y, 0].FeatureTexture = Assets.EMPTY; } } } for (int z = 0; z < Assets.BUILDINGHEIGHT; z++ ) { if (Buildings[x, y, z].Texture == Assets.BLANKBLOCK && Buildings[x, y, z].FeatureTexture == Assets.EMPTY) { //Generate Windows if (Assets.RandomBool()) Buildings[x, y, z].FeatureTexture = Assets.EMPTY; else { Buildings[x, y, z].FeatureTexture = Assets.Windows[Assets.Random.Next(0, Assets.Windows.Count)]; } } } } } }