private void DrawBuildingsToAnimals(SpriteBatch spriteBatch) { // loop through each building purchased foreach (var building in buildingPos) { Animalhouse currentAnimalHouse = park.selectAnimalHouse(building.Value); int currentAnimalHouseAnimals = currentAnimalHouse.getCurrentAnimals(); // Loop through textures in texturelist foreach (var item in texturesLevel1) { // Compare values for the right texture if (building.Value == item.Key) { spriteBatch.Draw(item.Value, new Rectangle((int)building.Key.X, (int)building.Key.Y, item.Value.Width / 4, item.Value.Height / 4), Color.White); //clickableItems.Add(item.Key, new Rectangle((int)building.Key.X, (int)building.Key.Y, item.Value.Width / 4, item.Value.Height / 4)); clickable = new Rectangle((int)building.Key.X, (int)building.Key.Y, item.Value.Width / 4, item.Value.Height / 4); } } } }
public override void Draw(GameTime gameTime, SpriteBatch spriteBatch) { // Local variables for map generation int TileWidth = 0; int TileHeight = 0; int TileX = 0; int TileY = 0; int offsetX = 200; int offsetY = -500; int difference = TileHeight - TileWidth; int newOffset = TileWidth / 3; // Draw the background #region Background spriteBatch.Begin(transformMatrix: camera.GetViewMatrix()); // y axis for (int i = 0; i < 300; i++) { // x axis for (int j = 300; j > 0; j--) { TileWidth = grass.Width; TileHeight = grass.Height; TileX = (j * TileWidth / 3) + (i * TileWidth / 2) / 2 + newOffset; TileY = (i * TileHeight / 2) - (j * TileHeight / 4); spriteBatch.Draw(grass, new Rectangle((TileX - TileY) + offsetX, (TileY + TileX) + offsetY, TileWidth, TileHeight), Color.White); } newOffset = 0 - (TileWidth * i) / 3; } spriteBatch.End(); #endregion // Draw the main elements #region Main spriteBatch.Begin(transformMatrix: camera.GetViewMatrix()); ms = Mouse.GetState(); kbs = Keyboard.GetState(); Matrix inverseTransform = Matrix.Invert(camera.GetViewMatrix()); Vector2 mouseInWorld = Vector2.Transform(new Vector2(ms.X, ms.Y), inverseTransform); if (itemName != null) { DrawBuildings(spriteBatch); } spriteBatch.End(); #endregion // Draw the UI #region UI spriteBatch.Begin(); var boxWidth = 650; // width of pop-up screen var boxHeight = 600; // height of pop-up screen float stringX = screenCenter; // X starting point of the strings float stringY = 240; // Y starting point of the strings spriteBatch.Draw(rand, new Rectangle(0, 0, screenWidth, screenHeight), Color.White); if (animal == true || animalHouse == true || facility == true) { var textX = 315; var textY = 210; //animal and animalHouse menu spriteBatch.Draw(box, new Rectangle(70, 100, 450, 700), Color.White); if (animal == true || animalHouse == true) { foreach (var component in _components2) { component.Draw(gameTime, spriteBatch); } if (animal == true) { spriteBatch.DrawString(font, "$300", new Vector2(textX, textY), browncolour); spriteBatch.DrawString(font, "$200", new Vector2(textX, textY + 70), browncolour); spriteBatch.DrawString(font, "$250", new Vector2(textX, textY + 140), browncolour); spriteBatch.DrawString(font, "$150", new Vector2(textX, textY + 210), browncolour); spriteBatch.DrawString(font, "$75", new Vector2(textX, textY + 280), browncolour); spriteBatch.DrawString(font, "$1000", new Vector2(textX, textY + 350), browncolour); spriteBatch.DrawString(font, "$200", new Vector2(textX, textY + 420), browncolour); } if (animalHouse == true) { spriteBatch.DrawString(font, "$1000", new Vector2(textX, textY), browncolour); spriteBatch.DrawString(font, "$1200", new Vector2(textX, textY + 70), browncolour); spriteBatch.DrawString(font, "$1500", new Vector2(textX, textY + 140), browncolour); spriteBatch.DrawString(font, "$1200", new Vector2(textX, textY + 210), browncolour); spriteBatch.DrawString(font, "$1000", new Vector2(textX, textY + 280), browncolour); spriteBatch.DrawString(font, "$3000", new Vector2(textX, textY + 350), browncolour); spriteBatch.DrawString(font, "$1000", new Vector2(textX, textY + 420), browncolour); } } //facility menu if (facility == true) { foreach (var component in _components3) { component.Draw(gameTime, spriteBatch); } spriteBatch.DrawString(font, "$750", new Vector2(textX, textY), browncolour); spriteBatch.DrawString(font, "$2000", new Vector2(textX, textY + 140), browncolour); spriteBatch.DrawString(font, "$1500", new Vector2(textX, textY + 70), browncolour); } } if (animalHouseClicked) { // draw the pop-up screen spriteBatch.Draw(box2, new Rectangle(screenCenter - (boxWidth / 2), (768 / 2) - (boxHeight / 2), boxWidth, boxHeight), Color.White); // draw the buttons foreach (var component in _components4) { component.Draw(gameTime, spriteBatch); } Animalhouse currentAnimalHouse = park.selectAnimalHouse(itemName); currentAnimalHouse.setPriceUpgrade(); // specify the text in the pop-up screen string a = "This animal house contains "; string b = currentAnimalHouse.getCurrentAnimals() + " animal(s) and is level " + currentAnimalHouse.getLevel(); string c = "Do you want to upgrade"; string d = "this building for " + currentAnimalHouse.getPrice() + " coins?"; // draw the text spriteBatch.DrawString(font, a, new Vector2(stringX - (font.MeasureString(a).X / 2), stringY), new Color(102, 71, 54)); spriteBatch.DrawString(font, b, new Vector2(stringX - (font.MeasureString(b).X / 2), stringY + 25), new Color(102, 71, 54)); spriteBatch.DrawString(font, c, new Vector2(stringX - (font.MeasureString(c).X / 2), stringY + 75), new Color(102, 71, 54)); spriteBatch.DrawString(font, d, new Vector2(stringX - (font.MeasureString(d).X / 2), stringY + 100), new Color(102, 71, 54)); } if (moneyMenu == true) { //draw the pop-up screen spriteBatch.Draw(box2, new Rectangle(screenCenter - (boxWidth / 2), (768 / 2) - (boxHeight / 2), boxWidth, boxHeight), Color.White); string a = "Set the entrance fee."; string b = entrenceFeeTemp.ToString(); // draw the text spriteBatch.DrawString(font, a, new Vector2(stringX - (font.MeasureString(a).X / 2), stringY), new Color(102, 71, 54)); spriteBatch.DrawString(font, b, new Vector2(stringX - (font.MeasureString(b).X / 2), stringY + 75), new Color(102, 71, 54)); //draw the buttons foreach (var component in _components5) { component.Draw(gameTime, spriteBatch); } } //draw left buttons foreach (var component in _components) { component.Draw(gameTime, spriteBatch); } //draw top text Vector2 textcoord3 = new Vector2(300, 18); spriteBatch.DrawString(font, park.getDate(), textcoord3, Color.White); Vector2 textcoord1 = new Vector2(575, 18); spriteBatch.DrawString(font, "$ " + park.getCoins(), textcoord1, Color.White); Vector2 textcoord2 = new Vector2(840, 18); spriteBatch.DrawString(font, "Visitors: " + park.getVisitorCount(), textcoord2, Color.White); spriteBatch.End(); #endregion }